Added code to remove orphaned data, added fullsize map option.
This commit is contained in:
parent
117ab47e10
commit
ef05ee0a1f
@ -37,17 +37,61 @@ class Admin_TagsMap_Controller extends Admin_Controller {
|
||||
|
||||
public function edit_gps($tag_id) {
|
||||
// Generate a new admin page to edit gps data for the tag specified by $tag_id.
|
||||
|
||||
// Determine the name of the tag.
|
||||
$tagName = ORM::factory("tag")
|
||||
->where("id", $tag_id)
|
||||
->find_all();
|
||||
|
||||
// Set up the admin page.
|
||||
$view = new Admin_View("admin.html");
|
||||
$view->content = new View("admin_tagsmap_edit.html");
|
||||
$view->content->tagsmapedit_form = $this->_get_tagsgpsedit_form($tag_id);
|
||||
$view->content->tag_name = $tagName[0]->name;
|
||||
print $view;
|
||||
}
|
||||
|
||||
public function orphaned_tags() {
|
||||
// Locate and delete any orphaned GPS data.
|
||||
$int_deleted_records = 0;
|
||||
|
||||
// Generate a list of all tags with GPS data.
|
||||
$existingGPS = ORM::factory("tags_gps")
|
||||
->find_all();
|
||||
|
||||
// Loop through each record and see if a corresponding tag exists.
|
||||
foreach ($existingGPS as $oneGPS) {
|
||||
$oneTag = ORM::factory("tag")
|
||||
->where("id", $oneGPS->tag_id)
|
||||
->find_all();
|
||||
|
||||
// If the tag no longer exists then delete the record.
|
||||
if (count($oneTag) == 0) {
|
||||
// Delete the record.
|
||||
ORM::factory("tags_gps")
|
||||
->where("tag_id", $oneGPS->tag_id)
|
||||
->delete_all();
|
||||
$int_deleted_records++;
|
||||
}
|
||||
}
|
||||
|
||||
// Redirect back to the main screen and display a "success" message.
|
||||
message::success($int_deleted_records . t(" Orphaned Record(s) have been deleted."));
|
||||
url::redirect("admin/tagsmap");
|
||||
}
|
||||
|
||||
public function confirm_delete_gps($tag_id) {
|
||||
// Make sure the user meant to hit the delete button.
|
||||
$view = new Admin_View("admin.html");
|
||||
$view->content = new View("admin_tagsmap_delete.html");
|
||||
$view->content->tag_id = $tag_id;
|
||||
|
||||
// Determine the name of the tag.
|
||||
$tagName = ORM::factory("tag")
|
||||
->where("id", $tag_id)
|
||||
->find_all();
|
||||
$view->content->tag_name = $tagName[0]->name;
|
||||
|
||||
print $view;
|
||||
}
|
||||
|
||||
|
@ -18,24 +18,41 @@
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
class TagsMap_Controller extends Controller {
|
||||
public function googlemap() {
|
||||
public function googlemap($fullsize) {
|
||||
// Display all tags with GPS coordinates on a google map.
|
||||
|
||||
// Set up and display the actual page.
|
||||
$template = new Theme_View("page.html", "Contact");
|
||||
$template->content = new View("tagsmap_googlemap.html");
|
||||
|
||||
// Generate a list of GPS coordinates.
|
||||
$tagsGPS = ORM::factory("tags_gps")->find_all();
|
||||
$template->content->tags_gps = $tagsGPS;
|
||||
|
||||
// Set up and display the actual page.
|
||||
// If fullsize is true, allow the map to take up the entire browser window,
|
||||
// if not, then display the map in the gallery theme.
|
||||
if ($fullsize == true) {
|
||||
$view = new View("tagsmap_googlemap.html");
|
||||
$view->map_fullsize = true;
|
||||
|
||||
// Load in module preferences.
|
||||
$view->tags_gps = $tagsGPS;
|
||||
$view->google_map_key = module::get_var("tagsmap", "googlemap_api_key");
|
||||
$view->google_map_latitude = module::get_var("tagsmap", "googlemap_latitude");
|
||||
$view->google_map_longitude = module::get_var("tagsmap", "googlemap_longitude");
|
||||
$view->google_map_zoom = module::get_var("tagsmap", "googlemap_zoom");
|
||||
$view->google_map_type = module::get_var("tagsmap", "googlemap_type");
|
||||
|
||||
// Load in module preferences.
|
||||
$template->content->google_map_key = module::get_var("tagsmap", "googlemap_api_key");
|
||||
$template->content->google_map_latitude = module::get_var("tagsmap", "googlemap_latitude");
|
||||
$template->content->google_map_longitude = module::get_var("tagsmap", "googlemap_longitude");
|
||||
$template->content->google_map_zoom = module::get_var("tagsmap", "googlemap_zoom");
|
||||
$template->content->google_map_type = module::get_var("tagsmap", "googlemap_type");
|
||||
print $view;
|
||||
} else {
|
||||
$template = new Theme_View("page.html", "Contact");
|
||||
$template->content = new View("tagsmap_googlemap.html");
|
||||
|
||||
// Load in module preferences.
|
||||
$template->content->tags_gps = $tagsGPS;
|
||||
$template->content->google_map_key = module::get_var("tagsmap", "googlemap_api_key");
|
||||
$template->content->google_map_latitude = module::get_var("tagsmap", "googlemap_latitude");
|
||||
$template->content->google_map_longitude = module::get_var("tagsmap", "googlemap_longitude");
|
||||
$template->content->google_map_zoom = module::get_var("tagsmap", "googlemap_zoom");
|
||||
$template->content->google_map_type = module::get_var("tagsmap", "googlemap_type");
|
||||
|
||||
print $template;
|
||||
print $template;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
<? $tags_per_column = $tags->count()/5 ?>
|
||||
<? $column_tag_count = 0 ?>
|
||||
|
||||
<table id="gTagAdmin" class="gBlockContent">
|
||||
<table id="gGPSTagAdmin" class="gBlockContent">
|
||||
<caption class="understate">
|
||||
<?= t2("There is one tag", "There are %count tags", $tags->count()) ?>
|
||||
</caption>
|
||||
@ -68,3 +68,16 @@
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="gBlock">
|
||||
<h3>
|
||||
<?= t("Remove Orphaned GPS Data") ?>
|
||||
</h3>
|
||||
<table id="gOrphanedTagAdmin" class="gBlockContent">
|
||||
<tr><td>
|
||||
<a href="<?= url::site("admin/tagsmap/orphaned_tags") ?>">
|
||||
<?= t("Search For and Delete Orphaned Data") ?>
|
||||
</a>
|
||||
</td></tr>
|
||||
</table>
|
||||
</div>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<div id="gTagsMapDeleteAdmin">
|
||||
<h2> <?= t("Delete GPS Data?") ?> </h2>
|
||||
<?= t("Are you sure you wish to delete all GPS data associated with this tag?") ?> <br/>
|
||||
<h2> <?= t("Delete GPS Data For Tag ") . $tag_name . "?" ?> </h2>
|
||||
<?= t("Are you sure you wish to delete all GPS data associated with this tag?") ?> <br/><br/>
|
||||
<a href="<?= url::site("admin/tagsmap/delete_gps/" . $tag_id) ?>">Delete</a>
|
||||
<a href="<?= url::site("admin/tagsmap") ?>">Cancel</a>
|
||||
<?= $tagsmapdelete_form ?>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<div id="gTagsMapEditAdmin">
|
||||
<h2> <?= t("Edit Tag GPS") ?> </h2>
|
||||
<h2> <?= t("Edit GPS Data for Tag ") . $tag_name ?> </h2>
|
||||
<?= $tagsmapedit_form ?>
|
||||
</div>
|
||||
|
||||
|
@ -1,7 +1,14 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<? if ($map_fullsize == true) { ?>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
||||
<title>Gallery: Map</title>
|
||||
</head>
|
||||
<body>
|
||||
<? } ?>
|
||||
|
||||
<script src="http://www.google.com/jsapi?key=<?=$google_map_key ?>" type="text/javascript"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
google.load("maps", "2.160");
|
||||
|
||||
@ -49,5 +56,12 @@
|
||||
google.setOnLoadCallback(initialize);
|
||||
</script>
|
||||
|
||||
<div id="map_canvas" style="width: 600px; height: 480px"></div>
|
||||
<br/>
|
||||
<? if ($map_fullsize == true) { ?>
|
||||
<div id="map_canvas" style="width: 100%; height: 100%"></div>
|
||||
</body></html>
|
||||
<? } else { ?>
|
||||
<div id="map_canvas" style="width: 600px; height: 480px"></div> <br/>
|
||||
<a href="<?= url::site("tagsmap/googlemap/fullsize/1")?>">
|
||||
<?= t("View Fullsize")?>
|
||||
</a><br/><br/>
|
||||
<? } ?>
|
||||
|
Reference in New Issue
Block a user