public static function data_table_build($params = array()) { $tds = array(); $trs = array(); $ths = array(); $thead = \GCore\Helpers\Html::container('thead', implode("\n", $ths), array()); $tbody = $tbody = \GCore\Helpers\Html::container('tbody', implode("\n", $trs), array()); if (!empty(\GCore\Helpers\DataPresenter::$columns)) { \GCore\Helpers\DataPresenter::set_cells_data(); $trs = self::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' => !empty($params['class']) ? $params['class'] : 'gcore_table_list', 'id' => !empty($params['id']) ? $params['id'] : 'gcore_table_list__#')); $table = \GCore\Helpers\DataLoader::load($table, \GCore\Helpers\DataPresenter::$data); \GCore\Helpers\DataPresenter::_flush(); return $table; }
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>'; }