public static function render($module, $container = false) { $site = $module['site'] == 'admin' ? '\\Admin' : ''; $mod_class = '\\GCore' . $site . '\\Modules\\' . \GCore\Libs\Str::camilize($module['type']) . '\\' . \GCore\Libs\Str::camilize($module['type']); $mod_params = new \GCore\Libs\Parameter($module['params']); ob_start(); $class = new $mod_class(); $class->display($module); //initialize and render view $view = new \GCore\Libs\View(); $view->initialize($class); $view->renderModule($module['type']); $output = ob_get_clean(); //check the returned output settings if ($container === false) { //do nothing, we are returning plain output } elseif ($container === true) { $output = \GCore\Helpers\Html::container('div', $output, array('class' => 'module-body')); if ((bool) $mod_params->get('show_title') === true) { $output = \GCore\Helpers\Html::container('h3', $module['title'], array('class' => 'module-title')) . "\n" . $output; } $output = \GCore\Helpers\Html::container('div', $output, array('class' => 'module' . (strlen($mod_params->get('class_sfx', '')) > 0 ? ' ' . $mod_params->get('class_sfx', '') : ''))); } elseif (is_callable($container)) { //some function provided: callback/lambada/anonymous $output = $container($output, $module); } return $output; }
public static function message_wrap($ul, $type) { $type_container = \GCore\Helpers\Html::container('dd', $ul, array('class' => $type . ' message')); $header = ''; //\GCore\Helpers\Html::container('dt', \GCore\Libs\Lang::_(strtoupper($type)), array('class' => $type)); return \GCore\Helpers\Html::container('dl', $header . $type_container, array('class' => 'system-message')); }
public function display($connection, $area = 'front', $rows = array()) { $doc = \GCore\Libs\Document::getInstance(); //display header $custom_headers = array(); if (!empty(\GCore\Helpers\DataPresenter::$headers)) { foreach (\GCore\Helpers\DataPresenter::$headers as $k => $header) { $custom_headers[$k] = \GCore\Helpers\Html::container($header['tag'], $header['text'], $header['atts']); } } ob_start(); eval('?>' . $connection['Connection']['extras'][$area]['blocks']['custom']['header']); $header = ob_get_clean(); $header = $this->view->Lister->prepare($connection, $header); $header = \GCore\Libs\Str::replacer($header, $custom_headers, array('exploder' => '*')); echo $this->view->Lister->translate($connection, \GCore\Libs\Str::replacer($header, $rows)); //display rows foreach ($rows as $c_r_k => $row) { ob_start(); eval('?>' . $connection['Connection']['extras'][$area]['blocks']['custom']['body']); $body = ob_get_clean(); if (isset(\GCore\Helpers\DataPresenter::$cells_data[$c_r_k])) { $body = \GCore\Libs\Str::replacer($body, \GCore\Helpers\DataPresenter::$cells_data[$c_r_k], array('exploder' => '*')); } echo $this->view->Lister->translate($connection, \GCore\Libs\Str::replacer($body, $row)); } //display footer ob_start(); eval('?>' . $connection['Connection']['extras'][$area]['blocks']['custom']['footer']); $footer = ob_get_clean(); $footer = $this->view->Lister->prepare($connection, $footer); $footer = \GCore\Libs\Str::replacer($footer, $custom_headers, array('exploder' => '*')); echo $this->view->Lister->translate($connection, \GCore\Libs\Str::replacer($footer, $rows)); }
function execute(&$form, $action_id) { $config = $form->actions_config[$action_id]; $config = new \GCore\Libs\Parameter($config); $field = $config->get('field', ''); $data_path = $config->get('data_path', ''); $value = $config->get('value_key', 'value'); $prepend = $config->get('prepend_value', true); $text = $config->get('text_key', 'text'); $level = $config->get('level_key', ''); $labels = $config->get('labels', 'L1,L2,L3,L4'); $limit = $config->get('limit', 999); $placeholder = $config->get('placeholder', 'Procurar...'); $res = array(); if (!empty($field) && !empty($data_path) && !empty($text) && !empty($value)) { $treeList = self::mount_tree($form->data[$data_path], $value, $prepend, $text, $level); self::mount_list($treeList, explode(',', $labels), $value, $text, $res); $list = implode("\n", $res); $clean_attrbs = array('type' => 'button', 'value' => 'Limpar', 'id' => 'limpar'); $search_attrbs = array('type' => 'text', 'name' => 'busca', 'id' => 'busca', 'placeholder' => $placeholder, 'size' => '20'); $clean = \GCore\Helpers\Html::_concat($clean_attrbs, array_keys($clean_attrbs), '<input ', ' />'); $search = \GCore\Helpers\Html::_concat($search_attrbs, array_keys($search_attrbs), '<input ', ' />'); $arvore = '<div id="arvore">' . $list . '</div>'; $c_busca = \GCore\Helpers\Html::container('div', $search . $clean, array('id' => 'c_busca')); $modal_div = \GCore\Helpers\Html::container('div', $c_busca . $arvore, array('id' => 'modal_arvore', 'style' => array('display' => 'none'))); $doc = \GCore\Libs\Document::getInstance(); $doc->addCssFile('vendors/vakata-jstree/themes/default/style.min.css'); $doc->addCssFile('vendors/jquery-ui-1.11.4/jquery-ui.min.css'); $doc->addJsFile('vendors/vakata-jstree/jstree.min.js'); $doc->addJsFile('vendors/jquery-ui-1.11.4/jquery-ui.min.js'); $fieldKey = $this->getFieldKey($form->form['Form']['extras']['fields'], $field); $campo = $form->form['Form']['extras']['fields'][$fieldKey]; $condicoes = $config->get('conditions', ""); if (!empty($condicoes)) { $condicoes = explode("\n", $condicoes); foreach ($condicoes as $condicao) { $condicao = explode("::", $condicao); // $condicao[0]: Condição; $condicao[1]: Mensagem $elseifs = ' else if (' . $condicao[0] . ')' . '{ alert("' . $condicao[1] . '"); event.preventDefault(); return false; }'; } } else { $elseifs = ''; } $opcoes = array('{field}' => $field, '{fieldID}' => $campo['id'], '{label}' => $campo['label']['text'], '{limit}' => empty($limit) || is_null($limit) ? 999 : $limit, '{condicoes}' => $elseifs); $doc->addJsCode($this->get_script($opcoes)); $doc->addCssCode($this->get_style($campo['id'])); $form->form['Form']['content'] = str_replace('<div id="modal_tree" style="display: none;"></div>', $modal_div, $form->form['Form']['content']); } // echo 'Field name: ' . $field . '<br/>'; // echo 'Chave: ' . array_search($field, array_column($form->form['Form']['extras']['fields'], 'name')); }
public function display($connection, $area = 'front', $rows = array()) { $doc = \GCore\Libs\Document::getInstance(); $tds = array(); $trs = array(); $ths = array(); //display header ob_start(); eval('?>' . $connection['Connection']['extras'][$area]['blocks']['table']['header']); $header = ob_get_clean(); $header = $this->view->Lister->translate($connection, $this->view->Lister->prepare($connection, $header)); echo \GCore\Libs\Str::replacer($header, $rows); $thead = \GCore\Helpers\Html::container('thead', implode("\n", $ths), array()); $tbody = \GCore\Helpers\Html::container('tbody', implode("\n", $trs), array()); if (!empty(\GCore\Helpers\DataPresenter::$columns)) { //\GCore\Helpers\DataPresenter::set_cells_data(); $trs = \GCore\Helpers\DataTable::trs(); $tbody = \GCore\Helpers\Html::container('tbody', implode("\n", $trs), array()); foreach (\GCore\Helpers\DataPresenter::$headers as $k => $header) { $th_tag = \GCore\Helpers\Html::container($header['tag'], $header['text'], $header['atts']); $ths[] = \GCore\Helpers\Html::container('th', $th_tag, array('class' => 'th-' . $k)); } $thead = \GCore\Helpers\Html::container('thead', \GCore\Helpers\Html::container('tr', implode("\n", $ths)), array()); } $table = \GCore\Helpers\Html::container('table', $thead . $tbody, array('class' => 'table table-hover table-censored', 'id' => 'gcore_table_list__#')); $table = \GCore\Helpers\DataLoader::load($table, \GCore\Helpers\DataPresenter::$cells_data); \GCore\Helpers\DataPresenter::_flush(); //show table echo $this->view->Lister->translate($connection, $table); //display footer ob_start(); eval('?>' . $connection['Connection']['extras'][$area]['blocks']['table']['footer']); $footer = ob_get_clean(); $footer = $this->view->Lister->translate($connection, $this->view->Lister->prepare($connection, $footer)); echo \GCore\Libs\Str::replacer($footer, $rows); //echo '</div>'; }
function _renderHeader() { $chunks = array($this->doc->getBase(), $this->doc->getMeta(), $this->doc->getTitle(), $this->doc->getFavicon()); //add css files list foreach ($this->doc->cssfiles as $cssfile) { $chunks[] = \GCore\Helpers\Html::_concat($cssfile, array_keys($cssfile), '<link ', ' />'); } //add css code list foreach ($this->doc->csscodes as $media => $codes) { $chunks[] = \GCore\Helpers\Html::container('style', implode("\n", $codes), array('type' => 'text/css', 'media' => $media)); } //add js files list foreach ($this->doc->jsfiles as $jsfile) { $chunks[] = \GCore\Helpers\Html::_concat($jsfile, array_keys($jsfile), '<script ', '></script>'); } //add js code list foreach ($this->doc->jscodes as $type => $codes) { $chunks[] = \GCore\Helpers\Html::container('script', implode("\n", $codes), array('type' => $type)); } foreach ($this->doc->headertags as $k => $code) { $chunks[] = $code; } return implode("\n", array_filter($chunks)); }
function build_action_display($action, $events, $root, $configs) { $actions_output = array(); $pcs = explode('_', $action); $id = $pcs[count($pcs) - 1]; unset($pcs[count($pcs) - 1]); $name = implode('_', $pcs); $action_class = '\\GCore\\Admin\\Extensions\\Chronoforms\\Actions\\' . \GCore\Libs\Str::camilize($name) . '\\' . \GCore\Libs\Str::camilize($name); if (class_exists($action_class) and isset($action_class::$title)) { $action_class = new $action_class(); /* $actions_output[] = $action_label = \GCore\Helpers\Html::container('label', $action_class::$title.'<font style="color:#f00"> ('.$id.')</font>', array( 'class' => 'action_label' )); if(!empty($configs[$id]['action_label'])){ $actions_output[] = \GCore\Helpers\Html::container('label', '<font style="color:#888"> - '.$configs[$id]['action_label'].'</font>', array( 'class' => 'action_label' )); } */ $icons_code = '<span class="edit_icon action_icon label label-primary" title="Edit">Edit</span><span class="drag_icon action_icon label label-warning" title="Drag">Drag</span><span class="delete_icon action_icon label label-danger" title="Delete">Delete</span>'; $action_icons = \GCore\Helpers\Html::container('div', $icons_code, array('id' => 'action_icons_' . $id, 'class' => 'action_icons pull-right')); $action_title = '<div class="pull-left action-title-labels"><span class="form_action_label label label-primary">' . $action_class::$title . '</span><span style="" class="label label-info action_icon_number">' . $id . '</span>' . (!empty($configs[$id]['action_label']) ? '<span style="" class="label action_label_label">' . $configs[$id]['action_label'] . '</span>' : '') . '</div>'; $actions_output[] = \GCore\Helpers\Html::container('div', $action_title . $action_icons . '<div class="clearfix"></div>', array('class' => 'panel-heading')); //add footer with some diagnostics if ($this->view->vars['chronoforms_settings']->get('wizard.display_diagnostics', 1)) { if (method_exists($action_class, 'config_check')) { $footer_contents = '<span class="label label-default label_diagnostics"><i class="fa fa-puzzle-piece fa-lg"></i></span>'; $check_result = $action_class::config_check(isset($configs[$id]) ? $configs[$id] : array()); foreach ($check_result as $text => $bool) { if ($bool === true) { $class = 'label-success'; $icon_class = 'fa-check'; $footer_contents .= '<span class="label ' . $class . '">' . $text . ' <i class="fa ' . $icon_class . ' fa-lg"></i></span>'; } else { if ($bool === false) { $class = 'label-danger'; $icon_class = 'fa-times'; $footer_contents .= '<span class="label ' . $class . '">' . $text . ' <i class="fa ' . $icon_class . ' fa-lg"></i></span>'; } else { if ($bool === -1) { $class = 'label-warning'; $icon_class = 'fa-exclamation'; $footer_contents .= '<span class="label ' . $class . '">' . $text . ' <i class="fa ' . $icon_class . ' fa-lg"></i></span>'; } else { $class = 'label-info'; $icon_class = 'fa-gear'; $footer_contents .= '<span class="label ' . $class . '"><i class="fa ' . $icon_class . ' fa-lg"></i> ' . $text . ' ' . $bool . '</span>'; } } } } $actions_output[] = \GCore\Helpers\Html::container('div', $footer_contents, array('class' => 'panel-heading action_diagnostics_area')); } } $action_dna = '<input type="hidden" name="' . $root . '[' . $action . ']" alt="ghost" class="events_dna" value="">'; $action_events = array(); if (!empty($events)) { foreach ($events as $event => $info) { $event_dna = '<input type="hidden" name="' . $root . '[' . $action . '][' . $event . ']" alt="ghost" class="events_dna" value="">'; if ($event == 'success' or isset($action_class->events_status[$event]) and $action_class->events_status[$event] == 'success') { $e_cl = 'good_event alert alert-success'; $label_class = 'form_event_label label label-success'; } else { if ($event == 'fail' or isset($action_class->events_status[$event]) and $action_class->events_status[$event] == 'fail') { $e_cl = 'bad_event alert alert-danger'; $label_class = 'form_event_label label label-danger'; } else { $e_cl = 'normal_event alert alert-info'; $label_class = 'form_event_label label label-info'; } } $event_label = \GCore\Helpers\Html::container('label', 'On ' . trim($event), array('class' => $label_class)); $event_container = \GCore\Helpers\Html::container('div', $event_label . $event_dna . $this->build($info, $root . '[' . $action . '][' . $event . ']', $configs), array('id' => 'cfactionevent_' . $name . '_' . $id . '_' . $event, 'class' => 'form_event ' . $e_cl)); $action_events[] = $event_container; } } ob_start(); $action_class::config(isset($configs[$id]) ? $configs[$id] : array()); $action_config = ob_get_clean(); $action_config = str_replace('{N}', $id, $action_config); $body_contents = $action_dna . implode("\n", $action_events) . $action_config; if (empty($this->config)) { $body_contents = $action_dna . implode("\n", $action_events); } $actions_output[] = \GCore\Helpers\Html::container('div', $body_contents, array('class' => 'panel-body')); //$actions_output[] = $action_clear = '<div class="clear"> </div>'; $container = \GCore\Helpers\Html::container('div', implode("\n", $actions_output), array('id' => 'cfaction_' . $name . '_element_' . $id, 'class' => 'cfaction_' . $name . '_element_view wizard_element form_action panel panel-default', 'item_id' => $name)); return $container; } return ''; }
function paginator_full_nav($first, $prev, $numbers, $next, $last) { $full = \GCore\Helpers\Html::container('ul', $first . $prev . $numbers . $next . $last, array('class' => 'pagination pagination-sm gcore-pagination', 'style' => 'margin:0px; padding:0px; height:auto;')); return $full; }
public static function getHeader() { $doc = \GCore\Libs\Document::getInstance(); static $used; if (!isset($used)) { $used = array(); } $chunks = array(); $chunks[] = ' <script type="text/javascript"> if("undefined"==typeof window.jQuery){}else{ var gcore_jQuery_bak = window.jQuery; var gcore_$_bak = window.$; } if("undefined"==typeof gcore_jQuery){}else{ window.jQuery = gcore_jQuery; window.$ = gcore_$; } </script> '; //add css files list foreach ($doc->cssfiles as $k => $cssfile) { //if(empty($used['cssfiles'][$k])){ $used['cssfiles'][$k] = true; $chunks[] = \GCore\Helpers\Html::_concat($cssfile, array_keys($cssfile), '<link ', '>'); //} } //add css code list foreach ($doc->csscodes as $media => $codes) { $chunks[] = \GCore\Helpers\Html::container('style', implode("\n", $codes), array('type' => 'text/css', 'media' => $media)); foreach ($doc->csscodes[$media] as $k => $code) { unset($doc->csscodes[$media][$k]); } } //add js files list foreach ($doc->jsfiles as $k => $jsfile) { /*if(strpos($jsfile['src'], 'jquery.js') !== false){ $document = \JFactory::getDocument(); $document->addScript($jsfile['src']); continue; }*/ //if(empty($used['jsfiles'][$k])){ $used['jsfiles'][$k] = true; $chunks[] = \GCore\Helpers\Html::_concat($jsfile, array_keys($jsfile), '<script ', '></script>'); //} } //add js code list foreach ($doc->jscodes as $type => $codes) { $chunks[] = \GCore\Helpers\Html::container('script', implode("\n", $codes), array('type' => $type)); foreach ($doc->jscodes[$type] as $k => $code) { unset($doc->jscodes[$type][$k]); } } foreach ($doc->headertags as $k => $code) { $chunks[] = $code; unset($doc->headertags[$k]); } $chunks[] = ' <script type="text/javascript"> if("undefined"==typeof gcore_jQuery){ var gcore_jQuery = window.jQuery; var gcore_$ = window.$; } if("undefined"==typeof gcore_jQuery_bak){}else{ window.jQuery = gcore_jQuery_bak; window.$ = gcore_$_bak; } </script> '; return implode("\n", array_filter($chunks)); }
function paginator_full_nav($first, $prev, $numbers, $next, $last) { $full = \GCore\Helpers\Html::container('div', $first . $prev . $numbers . $next . $last, array('class' => 'ui pagination menu small')); return $full; }
public function getList($lang = array()) { $dropdown = \GCore\Helpers\Html::input('limit', array('type' => 'dropdown', 'values' => $this->limit, 'class' => 'SS', 'onchange' => "jQuery(this).closest('form').submit();", 'options' => array(5 => 5, 10 => 10, 15 => 15, 20 => 20, 30 => 30, 50 => 50, 100 => 100, \GCore\Libs\Base::getConfig('max_list_limit', 1000) => self::l_('PAGINATOR_ALL', $lang)))); //$text = sprintf(self::l_('PAGINATOR_SHOW_X_ENTRIES', $lang), $dropdown); $full = \GCore\Helpers\Html::container('div', $dropdown, array('class' => 'gcore-datatable-list')); return $full; }
public static function data_table__r($content = '') { return \GCore\Helpers\Html::container('div', $content, array('class' => 'gcore-datatable-box-right')); }
function build_action_display($action, $events, $root, $configs) { $actions_output = array(); $pcs = explode('_', $action); $id = $pcs[count($pcs) - 1]; unset($pcs[count($pcs) - 1]); $name = implode('_', $pcs); $action_class = '\\GCore\\Admin\\Extensions\\Chronoforms\\Actions\\' . \GCore\Libs\Str::camilize($name) . '\\' . \GCore\Libs\Str::camilize($name); if (class_exists($action_class) and isset($action_class::$title)) { $action_class = new $action_class(); /* $actions_output[] = $action_label = \GCore\Helpers\Html::container('label', $action_class::$title.'<font style="color:#f00"> ('.$id.')</font>', array( 'class' => 'action_label' )); if(!empty($configs[$id]['action_label'])){ $actions_output[] = \GCore\Helpers\Html::container('label', '<font style="color:#888"> - '.$configs[$id]['action_label'].'</font>', array( 'class' => 'action_label' )); } */ $icons_code = '<span class="edit_icon action_icon label label-primary" title="Edit">Edit</span><span class="drag_icon action_icon label label-warning" title="Drag">Drag</span><span class="delete_icon action_icon label label-danger" title="Delete">Delete</span>'; $action_icons = \GCore\Helpers\Html::container('div', $icons_code, array('id' => 'action_icons_' . $id, 'class' => 'action_icons pull-right')); $action_title = '<div class="pull-left"><span class="form_action_label label label-primary">' . $action_class::$title . '</span><span style="" class="label label-info action_icon_number">' . $id . '</span></div>'; $actions_output[] = \GCore\Helpers\Html::container('div', $action_title . $action_icons . '<div class="clearfix"></div>', array('class' => 'panel-heading')); $action_dna = '<input type="hidden" name="' . $root . '[' . $action . ']" alt="ghost" class="events_dna" value="">'; $action_events = array(); if (!empty($events)) { foreach ($events as $event => $info) { $event_dna = '<input type="hidden" name="' . $root . '[' . $action . '][' . $event . ']" alt="ghost" class="events_dna" value="">'; if ($event == 'success' or isset($action_class->events_status[$event]) and $action_class->events_status[$event] == 'success') { $e_cl = 'good_event alert alert-success'; $label_class = 'form_event_label label label-success'; } else { if ($event == 'fail' or isset($action_class->events_status[$event]) and $action_class->events_status[$event] == 'fail') { $e_cl = 'bad_event alert alert-danger'; $label_class = 'form_event_label label label-danger'; } else { $e_cl = 'normal_event alert alert-info'; $label_class = 'form_event_label label label-info'; } } $event_label = \GCore\Helpers\Html::container('label', 'On ' . trim($event), array('class' => $label_class)); $event_container = \GCore\Helpers\Html::container('div', $event_label . $event_dna . $this->build($info, $root . '[' . $action . '][' . $event . ']'), array('id' => 'cfactionevent_' . $name . '_' . $id . '_' . $event, 'class' => 'form_event ' . $e_cl)); $action_events[] = $event_container; } } ob_start(); $action_class::config(); $action_config = ob_get_clean(); $action_config = str_replace('{N}', $id, $action_config); $body_contents = $action_dna . implode("\n", $action_events) . $action_config; if (empty($this->config)) { $body_contents = $action_dna . implode("\n", $action_events); } $actions_output[] = \GCore\Helpers\Html::container('div', $body_contents, array('class' => 'panel-body')); //$actions_output[] = $action_clear = '<div class="clear"> </div>'; $container = \GCore\Helpers\Html::container('div', implode("\n", $actions_output), array('id' => 'cfaction_' . $name . '_element_' . $id, 'class' => 'cfaction_' . $name . '_element_view wizard_element form_action panel panel-default', 'item_id' => $name)); return $container; } return ''; }