public function execute() { if (isset($_SERVER["hide_ss"]) == false) { $_SERVER["hide_ss"] = true; } if ($_SERVER["REQUEST_METHOD"] == "POST" && $_POST["submit_button"] == "hidess") { $_SERVER["hide_ss"] = is_true($_POST["hide_ss"]); } $this->output->add_css("banshee/filter.css"); $filter = new filter($this->db, $this->output, $this->user); $filter->to_output($this->model->table, false); if (($count = $this->model->count_events($filter->webserver, $_SERVER["hide_ss"])) === false) { $this->output->add_tag("result", "Database error."); return; } $paging = new pagination($this->output, "events", $this->settings->event_page_size, $count); if ($_SERVER["REQUEST_METHOD"] == "POST") { $paging->reset(); } if (($events = $this->model->get_events($paging->offset, $paging->size, $filter->webserver, $_SERVER["hide_ss"])) === false) { $this->output->add_tag("result", "Database error."); return; } $this->output->open_tag("events", array("hide_ss" => show_boolean($_SERVER["hide_ss"]))); foreach ($events as $event) { $event["timestamp"] = date("j F Y, H:i:s", $event["timestamp"]); $event["event"] = $this->output->secure_string($event["event"], "_"); $this->output->record($event, "event"); } $paging->show_browse_links(); $this->output->close_tag(); }
protected function show_overview() { switch ($this->browsing) { case "alphabetize": $alphabet = new alphabetize($this->output, "tableadmin_" . $this->model->table); if ($_POST["submit_button"] == "Search") { $alphabet->reset(); } if (($items = $this->model->get_items($alphabet->char)) === false) { $this->output->add_tag("result", "Error while creating overview."); return; } break; case "pagination": if (($item_count = $this->model->count_items()) === false) { $this->output->add_tag("result", "Error while counting items."); return; } $paging = new pagination($this->output, "tableadmin_" . $this->model->table, $this->page_size, $item_count); if ($_POST["submit_button"] == "Search") { $paging->reset(); } if (($items = $this->model->get_items($paging->offset, $paging->size)) === false) { $this->output->add_tag("result", "Error while creating overview."); return; } break; case "datatables": $this->output->add_javascript("jquery/jquery.js"); $this->output->add_javascript("banshee/jquery.datatables.js"); $this->output->run_javascript("\$(document).ready(function(){ \$('table.datatable').dataTable(); });"); $this->output->add_css("banshee/datatables.css"); $this->_table_class = "datatable"; $this->enable_search = false; default: if (($items = $this->model->get_items()) === false) { $this->output->add_tag("result", "Error while creating overview."); return; } } if ($this->table_class != null) { $this->_table_class .= " " . $this->table_class; } $params = array("class" => $this->_table_class, "allow_create" => show_boolean($this->model->allow_create)); $this->output->open_tag("overview", $params); /* Labels */ $this->output->open_tag("labels", array("name" => strtolower($this->name))); foreach ($this->model->elements as $name => $element) { $args = array("name" => $name, "overview" => show_boolean($element["overview"])); if ($element["overview"]) { $this->output->add_tag("label", $element["label"], $args); } } $this->output->close_tag(); /* Values */ $this->output->open_tag("items"); foreach ($items as $item) { $this->output->open_tag("item", array("id" => $item["id"])); foreach ($item as $name => $value) { $element = $this->model->elements[$name]; if ($element["overview"]) { switch ($element["type"]) { case "boolean": $value = show_boolean($value); break; case "date": $value = date("j F Y", strtotime($value)); break; case "timestamp": $value = date("j F Y H:i", strtotime($value)); break; case "foreignkey": if ($value === null) { $value = $this->foreign_null; } else { if (($result = $this->db->entry($element["table"], $value)) != false) { if (is_array($element["column"]) == false) { $value = $result[$element["column"]]; } else { $values = array(); foreach ($element["column"] as $column) { array_push($values, $result[$column]); } $value = implode(" ", $values); } } } break; } $this->output->add_tag("value", $value, array("name" => $name)); } } $this->output->close_tag(); } $this->output->close_tag(); switch ($this->browsing) { case "alphabetize": $alphabet->show_browse_links(); break; case "pagination": $paging->show_browse_links($this->pagination_links, $this->pagination_step); break; } if ($this->enable_search) { $this->output->add_tag("search", $_SESSION["tablemanager_search_" . $this->model->table]); } $this->output->close_tag(); }