Example #1
0
 public function execute()
 {
     $alphabetize = new alphabetize($this->output, "demo");
     $words = $this->model->get_words($alphabetize->char);
     $this->output->open_tag("words");
     foreach ($words as $word) {
         $this->output->add_tag("word", $word);
     }
     $this->output->close_tag();
     $alphabetize->show_browse_links();
 }
 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();
 }