Added an admin screen.
This commit is contained in:
parent
b55a52c5b0
commit
c46dee67e5
90
modules/exif_gps/controllers/admin_exif_gps.php
Normal file
90
modules/exif_gps/controllers/admin_exif_gps.php
Normal file
@ -0,0 +1,90 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.");
|
||||
/**
|
||||
* Gallery - a web based photo album viewer and editor
|
||||
* Copyright (C) 2000-2010 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_EXIF_GPS_Controller extends Admin_Controller {
|
||||
public function index() {
|
||||
// Generate a new admin page.
|
||||
$view = new Admin_View("admin.html");
|
||||
$view->content = new View("admin_exif_gps.html");
|
||||
$view->content->exifgps_form = $this->_get_admin_form();
|
||||
print $view;
|
||||
}
|
||||
|
||||
public function saveprefs() {
|
||||
// Save user preferences to the database.
|
||||
|
||||
// Prevent Cross Site Request Forgery
|
||||
access::verify_csrf();
|
||||
|
||||
$form = $this->_get_admin_form();
|
||||
if ($form->validate()) {
|
||||
Kohana_Log::add("error",print_r($form,1));
|
||||
module::set_var("exif_gps", "googlemap_api_key", $form->google_api_key->value);
|
||||
module::set_var("exif_gps", "sidebar_zoom", $form->Sidebar->sidebar_default_zoom->value);
|
||||
module::set_var("exif_gps", "sidebar_mapformat", $form->Sidebar->sidebar_mapformat->value);
|
||||
module::set_var("exif_gps", "sidebar_maptype", $form->Sidebar->sidebar_maptype->value);
|
||||
|
||||
// Display a success message and redirect back to the TagsMap admin page.
|
||||
message::success(t("Your settings have been saved."));
|
||||
url::redirect("admin/exif_gps");
|
||||
}
|
||||
|
||||
// Else show the page with errors
|
||||
$view = new Admin_View("admin.html");
|
||||
$view->content = new View("admin_exif_gps.html");
|
||||
$view->content->exifgps_form = $form;
|
||||
print $view;
|
||||
}
|
||||
|
||||
private function _get_admin_form() {
|
||||
// Make a new Form.
|
||||
$form = new Forge("admin/exif_gps/saveprefs", "", "post",
|
||||
array("id" => "g-exif-gps-adminForm"));
|
||||
|
||||
// Input box for the Maps API Key
|
||||
$form->input("google_api_key")
|
||||
->label(t("Google Maps API Key"))
|
||||
->value(module::get_var("exif_gps", "googlemap_api_key"))
|
||||
->rules("required");
|
||||
|
||||
// Create a group for sidebar settings
|
||||
$gps_sidebar = $form->group("Sidebar")
|
||||
->label(t("Sidebar Settings"));
|
||||
$gps_sidebar->input("sidebar_default_zoom")
|
||||
->label(t("Default Zoom Level"))
|
||||
->value(module::get_var("exif_gps", "sidebar_zoom"))
|
||||
->rules("required");
|
||||
$gps_sidebar->dropdown("sidebar_mapformat")
|
||||
->label(t("Default Map Format"))
|
||||
->options(array(t("Static"), t("Interactive")))
|
||||
->selected(module::get_var("exif_gps", "sidebar_mapformat"));
|
||||
$gps_sidebar->dropdown("sidebar_maptype")
|
||||
->label(t("Default Map Type"))
|
||||
->options(array(t("Road Map"), t("Satellite Map"),
|
||||
t("Hybrid Map"), t("Physical Map")))
|
||||
->selected(module::get_var("exif_gps", "sidebar_maptype"));
|
||||
|
||||
// Add a save button to the form.
|
||||
$form->submit("SaveLinks")->value(t("Save"));
|
||||
|
||||
// Return the newly generated form.
|
||||
return $form;
|
||||
}
|
||||
}
|
@ -87,4 +87,13 @@ class exif_gps_event_Core {
|
||||
$record->save();
|
||||
}
|
||||
}
|
||||
|
||||
static function admin_menu($menu, $theme) {
|
||||
// Add a link to the EXIF_GPS admin page to the Settings menu.
|
||||
$menu->get("settings_menu")
|
||||
->append(Menu::factory("link")
|
||||
->id("exif_gps")
|
||||
->label(t("EXIF_GPS Settings"))
|
||||
->url(url::site("admin/exif_gps")));
|
||||
}
|
||||
}
|
||||
|
5
modules/exif_gps/views/admin_exif_gps.html.php
Normal file
5
modules/exif_gps/views/admin_exif_gps.html.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<div id="g-exif-gps-admin">
|
||||
<h2> <?= t("EXIF GPS Settings") ?> </h2>
|
||||
<?= $exifgps_form ?>
|
||||
</div>
|
Reference in New Issue
Block a user