1
0

Code cleanups, etc.

This commit is contained in:
rWatcher 2009-07-25 01:17:24 -04:00
parent bf66e8403a
commit 582b9648f0
6 changed files with 33 additions and 31 deletions

View File

@ -36,22 +36,19 @@ class Admin_TagsMap_Controller extends Admin_Controller {
}
public function edit_gps($tag_id) {
// Generate a new admin page to edit the tag specified by $tag_id.
// Generate a new admin page to edit gps data for the tag specified by $tag_id.
$view = new Admin_View("admin.html");
$view->content = new View("admin_tagsmap_edit.html");
$view->content->tagsmapedit_form = $this->_get_tagsgpsedit_form($tag_id);
print $view;
}
public function confirm_delete_gps($tag_id) {
// Make sure the user meant to hit the delete button.
// Make a new Form.
$view = new Admin_View("admin.html");
$view->content = new View("admin_tagsmap_delete.html");
$view->content->tag_id = $tag_id;
print $view;
}
public function delete_gps($tag_id) {
@ -68,14 +65,16 @@ class Admin_TagsMap_Controller extends Admin_Controller {
}
private function _get_tagsgpsedit_form($tag_id) {
// Make a new Form.
// Make a new form for editing GPS data associated with a tag ($tag_id).
$form = new Forge("admin/tagsmap/savegps", "", "post",
array("id" => "gTagsMapAdminForm"));
// Add a few input boxes for GPS and Description
$tagsgps_group = $form->group("TagsMapGPS");
$tagsgps_group->hidden("tag_id")->value($tag_id);
// Check and see if this ID already has GPS data.
// Check and see if this ID already has GPS data, then create
// input boxes to either update it or enter in new information.
$existingGPS = ORM::factory("tags_gps")
->where("tag_id", $tag_id)
->find_all();
@ -109,7 +108,8 @@ class Admin_TagsMap_Controller extends Admin_Controller {
$str_description = Input::instance()->post("gps_description");
// Save to database.
// Check and see if this ID already has GPS data.
// Check and see if this ID already has GPS data,
// Update it if it does, create a new record if it doesn't.
$existingGPS = ORM::factory("tags_gps")
->where("tag_id", $str_tagid)
->find_all();
@ -135,7 +135,7 @@ class Admin_TagsMap_Controller extends Admin_Controller {
}
private function _get_googlemaps_form() {
// Make a new Form.
// Make a new form for inputing information associated with google maps.
$form = new Forge("admin/tagsmap/savemapprefs", "", "post",
array("id" => "gTagsMapAdminForm"));
@ -145,7 +145,7 @@ class Admin_TagsMap_Controller extends Admin_Controller {
->label(t("Google Maps API Key"))
->value(module::get_var("tagsmap", "googlemap_api_key"));
// Input boxes for the Maps starting location and zoom.
// Input boxes for the Maps starting location map type and zoom.
$startingmap_group = $form->group("GoogleMapsPos");
$startingmap_group->input("google_starting_latitude")
->label(t("Starting Latitude"))
@ -165,10 +165,11 @@ class Admin_TagsMap_Controller extends Admin_Controller {
// Return the newly generated form.
return $form;
}
public function savemapprefs() {
// Save information associated with Google Maps to the database.
// Prevent Cross Site Request Forgery
access::verify_csrf();
@ -185,9 +186,9 @@ class Admin_TagsMap_Controller extends Admin_Controller {
module::set_var("tagsmap", "googlemap_longitude", $str_googlelongitude);
module::set_var("tagsmap", "googlemap_zoom", $str_googlezoom);
module::set_var("tagsmap", "googlemap_type", $str_googlemaptype);
message::success(t("Your Settings Have Been Saved."));
// Redirect back to the TagsMap admin page.
// Display a success message and redirect back to the TagsMap admin page.
message::success(t("Your Settings Have Been Saved."));
url::redirect("admin/tagsmap");
}
}

View File

@ -19,6 +19,8 @@
*/
class tagsmap_event_Core {
static function module_change($changes) {
// See if the Tags module is installed,
// tell the user to install it if it isn't.
if (!module::is_active("tag") || in_array("tag", $changes->deactivate)) {
site_status::warning(
t("The TagsMap module requires the Tags module. " .

View File

@ -19,8 +19,8 @@
*/
class tagsmap_installer {
static function install() {
// Create a table to store GPS data in.
$db = Database::instance();
$db->query("CREATE TABLE IF NOT EXISTS {tags_gpses} (
`id` int(9) NOT NULL auto_increment,
`tag_id` int(9) NOT NULL,
@ -31,6 +31,7 @@ class tagsmap_installer {
KEY(`tag_id`, `id`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
// Set the module's version number.
module::set_version("tagsmap", 1);
}
@ -39,6 +40,7 @@ class tagsmap_installer {
}
static function uninstall() {
// Delete the GPS table before uninstalling.
$db = Database::instance();
$db->query("DROP TABLE IF EXISTS {tags_gpses};");
module::delete("tagsmap");

View File

@ -19,6 +19,7 @@
*/
class tagsmap_menu_Core {
static function admin($menu, $theme) {
// Add a link to the TagsMap admin page to the Content menu.
$menu->get("content_menu")
->append(Menu::factory("link")
->id("tagsmap")

View File

@ -46,19 +46,18 @@
<span class="understate">(<?= $tag->count ?>)</span>
<a href="<?= url::site("admin/tagsmap/edit_gps/$tag->id") ?>"><?= t("Edit GPS") ?></a>
<?
// Check and see if this ID already has GPS data.
$existingGPS = ORM::factory("tags_gps")
->where("tag_id", $tag->id)
->find_all();
if (count($existingGPS) > 0) {
?>
| <a href="<?= url::site("admin/tagsmap/confirm_delete_gps/$tag->id") ?>"><?= t("Delete GPS") ?></a>
<?
}
?>
<?
// Check and see if this ID already has GPS data, display a delete button if it does.
$existingGPS = ORM::factory("tags_gps")
->where("tag_id", $tag->id)
->find_all();
if (count($existingGPS) > 0) {
?>
| <a href="<?= url::site("admin/tagsmap/confirm_delete_gps/$tag->id") ?>"><?= t("Delete GPS") ?></a>
<?
}
?>
</li>
<? $column_tag_count++ ?>

View File

@ -3,7 +3,7 @@
<script src="http://www.google.com/jsapi?key=<?=$google_map_key ?>" type="text/javascript"></script>
<script type="text/javascript">
google.load("maps", "2");
google.load("maps", "2");
function initialize() {
if (GBrowserIsCompatible()) {
@ -45,12 +45,9 @@ google.load("maps", "2");
}
}
}
google.setOnLoadCallback(initialize);
</script>
<div id="map_canvas" style="width: 600px; height: 480px"></div>
<div id="map_canvas" style="width: 600px; height: 480px"></div>
<br/>