diff --git a/modules/exif_gps/controllers/admin_exif_gps.php b/modules/exif_gps/controllers/admin_exif_gps.php new file mode 100644 index 00000000..a140b753 --- /dev/null +++ b/modules/exif_gps/controllers/admin_exif_gps.php @@ -0,0 +1,90 @@ +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; + } +} \ No newline at end of file diff --git a/modules/exif_gps/helpers/exif_gps_event.php b/modules/exif_gps/helpers/exif_gps_event.php index e19f2a17..5a61483e 100644 --- a/modules/exif_gps/helpers/exif_gps_event.php +++ b/modules/exif_gps/helpers/exif_gps_event.php @@ -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"))); + } } diff --git a/modules/exif_gps/views/admin_exif_gps.html.php b/modules/exif_gps/views/admin_exif_gps.html.php new file mode 100644 index 00000000..6a977c1c --- /dev/null +++ b/modules/exif_gps/views/admin_exif_gps.html.php @@ -0,0 +1,5 @@ + +