1
0

Roll the administration controller and view into an event listener in

three_nids_event so that we piggyback on the form generated in Admin >
Appearance > Theme Options.  This makes a cleaner user interface for
the user since there's not an extra config page for the theme and
greatly reduces the amount of code in the theme.
This commit is contained in:
Bharat Mediratta 2009-11-29 12:40:03 -08:00
parent 649b7ba7bc
commit 1b12d8467e
4 changed files with 20 additions and 121 deletions

View File

@ -1,77 +0,0 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 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_Three_Nids_Controller extends Admin_Controller {
public function index() {
// Generate a new admin page.
$view = new Admin_View("admin.html");
$view->content = new View("admin_three_nids.html");
// Generate a form for Google Maps Settings.
$view->content->theme_form = $this->_get_three_nids_form();
// Display the page.
print $view;
}
private function _get_three_nids_form() {
// Make a new form for inputing information associated with google maps.
$form = new Forge("admin/three_nids/savethree_nidsprefs", "", "post",
array("id" => "gTagsMapAdminForm"));
// Input box for the Maps API Key
$form->input("title")
->label(t("item title : parent or item."))
->value(module::get_var("three_nids", "title"));
$form->input("description")
->label(t("item description : tags or item or parent or nothing. If item description chosen and not available, then parent description is used."))
->value(module::get_var("three_nids", "description"));
$form->input("photo_size")
->label(t("Photo size: resize or full."))
->value(module::get_var("three_nids", "photo_size"));
// Add a save button to the form.
$form->submit("SaveSettings")->value(t("Save"));
// Return the newly generated form.
return $form;
}
public function savethree_nidsprefs() {
// Save information associated with Google Maps to the database.
// Prevent Cross Site Request Forgery
access::verify_csrf();
// Figure out the values of the text boxes
$description = Input::instance()->post("description");
$title = Input::instance()->post("title");
$photo_size = Input::instance()->post("photo_size");
// Save Settings.
module::set_var("three_nids", "description", $description);
module::set_var("three_nids", "title", $title);
module::set_var("three_nids", "photo_size", $photo_size);
// Display a success message and redirect back to the TagsMap admin page.
message::success(t("Your Settings Have Been Saved."));
url::redirect("admin/three_nids");
}
}

View File

@ -18,12 +18,25 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class three_nids_event_Core {
static function admin_menu($menu, $theme) {
// Add a link to the three_nids admin page to the Content menu.
$menu->get("appearance_menu")
->append(Menu::factory("link")
->id("three_nids")
->label(t("3nids settings"))
->url(url::site("admin/three_nids")));
static function theme_edit_form($form) {
$group = $form->group("three_nids")->label(t("3nids Theme Settings"));
$group->input("title")
->rules("required")
->label(t("item title : parent or item."))
->value(module::get_var("three_nids", "title"));
$group->input("description")
->rules("required")
->label(t("item description : tags or item or parent or nothing. If item description chosen and not available, then parent description is used."))
->value(module::get_var("three_nids", "description"));
$group->input("photo_size")
->rules("required")
->label(t("Photo size: resize or full."))
->value(module::get_var("three_nids", "photo_size"));
}
static function theme_edit_form_completed($form) {
module::set_var("three_nids", "description", $form->three_nids->description->value);
module::set_var("three_nids", "title", $form->three_nids->title->value);
module::set_var("three_nids", "photo_size", $form->three_nids->photo_size->value);
}
}

View File

@ -1,8 +0,0 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<h2>
<?= t("3nids Theme Settings") ?>
</h2>
<div class="g-block">
<?= $theme_form ?>
</div>

View File

@ -1,29 +0,0 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 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 three_nids_event_Core {
static function admin_menu($menu, $theme) {
// Add a link to the three_nids admin page to the Content menu.
$menu->get("appearance_menu")
->append(Menu::factory("link")
->id("three_nids")
->label(t("3nids settings"))
->url(url::site("admin/three_nids")));
}
}