diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-01-04 01:55:59 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-01-04 01:55:59 +0000 |
commit | 2c274694127f5127fef311c13d265a9099dd629d (patch) | |
tree | f2c855e5306822a14ffaef9a4f6ec3734a4890db | |
parent | 08c9745086a51accf6e561d6e8ac2a9ab7582ef7 (diff) |
Simple admin tags interface.
-rw-r--r-- | modules/tag/controllers/admin_tags.php | 50 | ||||
-rw-r--r-- | modules/tag/helpers/tag_menu.php | 2 | ||||
-rw-r--r-- | modules/tag/views/admin_tags.html.php | 31 |
3 files changed, 82 insertions, 1 deletions
diff --git a/modules/tag/controllers/admin_tags.php b/modules/tag/controllers/admin_tags.php new file mode 100644 index 00000000..42bb9985 --- /dev/null +++ b/modules/tag/controllers/admin_tags.php @@ -0,0 +1,50 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2008 Bharat Mediratta + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ +class Admin_Tags_Controller extends Admin_Controller { + public function index() { + $filter = $this->input->get("filter"); + + $view = new Admin_View("admin.html"); + $view->content = new View("admin_tags.html"); + $view->content->filter = $filter; + + $query = ORM::factory("tag"); + if ($filter) { + $query->like("name", $filter); + } + $view->content->tags = $query->orderby("name", "ASC")->find_all(); + print $view; + } + + public function delete($id) { + access::verify_csrf(); + $tag = ORM::factory("tag", $id); + if ($tag->loaded) { + $name = $tag->name; + Database::instance()->query("DELETE from `items_tags` where `tag_id` = $tag->id"); + $tag->delete(); + message::success(sprintf(_("Deleted tag %s"), $name)); + log::success("tags", sprintf(_("Deleted tag %s"), $name)); + } + + url::redirect("admin/tags"); + } +} + diff --git a/modules/tag/helpers/tag_menu.php b/modules/tag/helpers/tag_menu.php index 965e66c4..b13453f8 100644 --- a/modules/tag/helpers/tag_menu.php +++ b/modules/tag/helpers/tag_menu.php @@ -23,6 +23,6 @@ class tag_menu_Core { ->append(Menu::factory("link") ->id("tags") ->label(_("Tags")) - ->url("#")); + ->url(url::site("admin/tags"))); } } diff --git a/modules/tag/views/admin_tags.html.php b/modules/tag/views/admin_tags.html.php new file mode 100644 index 00000000..9f2aa099 --- /dev/null +++ b/modules/tag/views/admin_tags.html.php @@ -0,0 +1,31 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<h1> <?= _("Tags") ?> </h1> + +<div id="gTagSearch"> + <form method="get" action="<?= url::site("admin/tags") ?>"> + <fieldset> + <legend> <?= _("Search Tags") ?> </legend> + <input name="filter" value="<?= $filter ?>"/> + <input type="submit" value="<?= _("Search Tags") ?>"/> + </fieldset> + </form> +</div> + +<table> + <tr> + <th> <?= _("Tag") ?> </th> + <th> <?= _("Photos") ?> </th> + <th> <?= _("Actions") ?> </th> + </tr> + <? foreach ($tags as $tag): ?> + <tr> + <td> <?= $tag->name ?> </td> + <td> <?= $tag->count ?> </td> + <td> + <a href="<?= url::site("admin/tags/delete/$tag->id?csrf=" . access::csrf_token()) ?>"> + <?= _("delete") ?> + </a> + </td> + </tr> + <? endforeach ?> +</table> |