/application/classes/Controller/Admin/Administration/Logs.php
https://bitbucket.org/chrispiechowicz/zepto · PHP · 102 lines · 77 code · 18 blank · 7 comment · 9 complexity · e33cbc3bfb1e1554d4f11559d09b3e6c MD5 · raw file
- <?php
- class Controller_Admin_Administration_Logs extends Controller_Admin_App
- {
- public function before()
- {
- parent::before();
-
- // check access
- $this->admin->access("administration/logs");
-
- // create unit
- $this->unit = new Admin_Unit(Config::get("admin#logs")->as_array());
-
- // add to breadcrumb
- Breadcrumb::add(Language::get("admin/units/unit.".$this->unit->name), Url::base().$this->unit->url);
- }
-
- public function action_index()
- {
- // create actionbar
- if ($this->admin->checkPermissions($this->unit->key, "deleteall"))
- $this->actionbar->add(array("link" => Url::base().$this->unit->url."deleteall", "title" => Language::get($this->unit->url."/label.deleteall"), "image" => "delete"));
-
- // create filter form
- $filterform = new Form(Url::base().$this->unit->url, "get");
- if ($this->unit->filterbar)
- {
- foreach ($this->unit->filterbar as $item)
- $filterform->add($item);
- }
- $this->filterbar->setForm($filterform->render("inline"));
- $this->filterbar->setClearLink(URL::base().$this->unit->url);
-
- // create pagination
- $pagination = Paginator::factory(array("items_per_page" => $this->unit->items_per_page, "show_sum" => TRUE, "show_label" => TRUE))->total($this->db->getSum($this->unit->table, $filterform->getFilter()));
-
- // create grid
- $rows = $this->db->getRows($this->unit->table, $filterform->getFilter(), Admin_Sort::get($this->unit->sort_fields, $this->unit->default_sort), $pagination->offset(), $this->unit->items_per_page);
- if ($rows)
- {
- $grid = new Admin_Grid($rows, array_merge(Config::get("lib#grid")->as_array(), array("grid_change" => $this->unit->grid_change, "grid_change_url" => $this->unit->grid_change_url)));
-
- foreach ($this->unit->grid as $item)
- {
- if($item["sort"])
- $item["title"] = Admin_Sort::link($item["key"], $this->unit->url, $item["title"], $this->unit->default_sort);
- $grid->add(array_merge(Config::get("lib#grid/row"), $item));
- }
-
- $grid = $grid->render();
- }
- else
- $grid = Language::get($this->unit->url."label.norows");
-
- $this->template->content = $this->actionbar->render().$this->filterbar->render().Notice::render().$grid.$pagination->render();
- }
-
- public function action_change()
- {
- if (Input::isPost($this->request))
- {
- if (Input::post("rows") && is_array(Input::post("rows")))
- {
- $rows = Input::post("rows");
-
- if (Input::post("delete_x"))
- {
- $this->admin->access($this->unit->key, "delete");
- foreach ($rows as $item)
- $this->db->delete($this->unit->table, array("id", "=", $item));
- Notice::add(Dlog::SUCCESS, Language::get($this->unit->url."/label.change_success"));
- }
- }
- }
- $this->redirect($this->unit->url);
- }
-
- public function action_deleteall()
- {
- $this->admin->access($this->unit->key, "deleteall");
-
- $this->db->delete($this->unit->table);
- Notice::add(Dlog::SUCCESS, Language::get($this->unit->url."/label.deleteall_success"));
- $this->redirect($this->unit->url);
-
- }
-
- public function action_info()
- {
- $this->admin->access($this->unit->key, "info");
- $id = $this->request->param("id");
- $row = $this->db->getRow($this->unit->table, array("id", "=", $id));
- if (!$row)
- $this->redirect($this->unit->url);
-
- Breadcrumb::add(Language::get($this->unit->url."/label.info"), Url::base().$this->unit->url."/info/".$id);
- $this->actionbar->add(array("link" => Url::base().$this->unit->url, "title" => Language::get($this->unit->url."/label.return"), "image" => "return"));
-
- $this->template->content = $this->actionbar->render().View::factory("admin/units/log", $row);
- }
- }
- ?>