/** * Universal SamsonCMS table render * @return string HTML SamsonCMS table */ public function render(array $db_rows = null, $module = null) { // Rows HTML $rows = ''; // if no rows data is passed - perform db request if (!isset($db_rows)) { $db_rows = $this->query->exec(); } // If we have table rows data if (is_array($db_rows) && sizeof($db_rows)) { // Save quantity of rendering rows $this->last_render_count = sizeof($db_rows); // Debug info $rn = 0; $rc = sizeof($db_rows); // Iterate db data and perform rendering foreach ($db_rows as &$db_row) { if ($this->debug) { elapsed('Rendering row ' . $rn++ . ' of ' . $rc . '(#' . $db_row->id . ')'); } $rows .= $this->row($db_row, $this->pager, $module); //catch(\Exception $e){ return e('Error rendering row#'.$rn.' of '.$rc.'(#'.$db_row->id.')'); } } } else { $rows .= $this->emptyrow($this->query, $this->pager, $module); } //elapsed('render pages: '.$this->pager->total); // Render table view return m($module)->view($this->table_tmpl)->set($this->pager)->rows($rows)->output(); }