breadcrum = $str; } /** * Getter for breadcrum * * @return array Breadcrum. */ public function getBreadcrum() { return $this->breadcrum; } /** * Add an element to breadcrum array. * * @param string $breads Elements to add to breadcrum. * * @return void */ protected function addBreadcrum($breads) { if (empty($breads)) { return; } $this->breadcrum = array_merge($this->breadcrum, $breads); } /** * Breadcrum builder. * * @param array $urls Array of urls to be transformed into a breadcrum. * * @return array Breadcrum prepared. */ public function prepareBreadcrum( array $urls ) { $bc = []; $i = 0; foreach ($urls as $url) { if ($url['selected'] == 1) { $class = 'selected'; } else { $class = ''; } $bc[$i] = ''; $bc[$i] .= ''; $bc[$i] .= $url['label']; $bc[$i] .= ''; $bc[$i] .= ''; $i++; } return $bc; } /** * Print breadcrum to follow flow. * * @return string Breadcrum HTML code. */ public function printBreadcrum() { return implode( ' ', $this->breadcrum ); } /** * Prints a go back button redirecting to main page. * * @param string $url Optional target url. * * @return void */ public function printGoBackButton($url=null) { if (isset($url) === false) { $url = ui_get_full_url('index.php'); } $form = [ 'form' => [ 'method' => 'POST', 'action' => $url, ], 'inputs' => [ [ 'class' => 'w100p', 'arguments' => [ 'name' => 'submit', 'label' => __('Go back'), 'type' => 'submit', 'attributes' => 'class="sub cancel"', 'return' => true, ], ], ], ]; $this->printForm($form); } /** * Print input using functions html lib. * * @param array $data Input definition. * * @return string HTML code for desired input. */ public function printInput(array $data) { global $config; include_once $config['homedir'].'/include/functions_html.php'; if (is_array($data) === false) { return ''; } $input = html_print_input(($data + ['return' => true]), 'div', true); if ($input === false) { return ''; } return $input; } /** * Print a block of inputs. * * @param array $input Definition of target block to be printed. * @param boolean $return Return as string or direct output. * * @return string HTML content. */ public function printBlock( array $input, bool $return=false ) { $output = ''; if ($input['hidden'] == 1) { $class = ' hidden'; } else { $class = ''; } if (isset($input['class']) === true) { $class = $input['class'].$class; } if (is_array($input['block_content']) === true) { // Print independent block of inputs. if (isset($input['wrapper']) === true) { $output .= '