Skip to content

Commit

Permalink
Display location block on tag pages.
Browse files Browse the repository at this point in the history
  • Loading branch information
rWatcher authored and Tim Almdal committed Jun 18, 2010
1 parent c24003f commit 8f8b787
Showing 1 changed file with 75 additions and 43 deletions.
118 changes: 75 additions & 43 deletions modules/exif_gps/helpers/exif_gps_block.php
Expand Up @@ -25,54 +25,86 @@ static function get_site_list() {
static function get($block_id, $theme) { static function get($block_id, $theme) {
$block = ""; $block = "";


// Make sure the current page belongs to an item.
if (!$theme->item()) {
return;
}

switch ($block_id) { switch ($block_id) {
case "exif_gps_map": case "exif_gps_map":
// Check and see if the item has exif coordinates associated with it. if ($theme->item()) {
$record = ORM::factory("exif_coordinate")->where("item_id", "=", $theme->item->id)->find(); // Check and see if the item has exif coordinates associated with it.
if ($record->loaded()) { $record = ORM::factory("exif_coordinate")->where("item_id", "=", $theme->item->id)->find();
$block = new Block(); if ($record->loaded()) {
$block->css_id = "g-exif-gps-sidebar"; $block = new Block();
$block->title = t("Location"); $block->css_id = "g-exif-gps-sidebar";
if (module::get_var("exif_gps", "sidebar_mapformat") == 1) { $block->title = t("Location");
$block->content = new View("exif_gps_dynamic_sidebar.html"); if (module::get_var("exif_gps", "sidebar_mapformat") == 1) {
if (module::get_var("exif_gps", "sidebar_maptype") == 0) $block->content->sidebar_map_type = "ROADMAP"; $block->content = new View("exif_gps_dynamic_sidebar.html");
if (module::get_var("exif_gps", "sidebar_maptype") == 1) $block->content->sidebar_map_type = "SATELLITE"; if (module::get_var("exif_gps", "sidebar_maptype") == 0) $block->content->sidebar_map_type = "ROADMAP";
if (module::get_var("exif_gps", "sidebar_maptype") == 2) $block->content->sidebar_map_type = "HYBRID"; if (module::get_var("exif_gps", "sidebar_maptype") == 1) $block->content->sidebar_map_type = "SATELLITE";
if (module::get_var("exif_gps", "sidebar_maptype") == 3) $block->content->sidebar_map_type = "TERRAIN"; if (module::get_var("exif_gps", "sidebar_maptype") == 2) $block->content->sidebar_map_type = "HYBRID";
} else { if (module::get_var("exif_gps", "sidebar_maptype") == 3) $block->content->sidebar_map_type = "TERRAIN";
$block->content = new View("exif_gps_static_sidebar.html"); } else {
if (module::get_var("exif_gps", "sidebar_maptype") == 0) $block->content->sidebar_map_type = "roadmap"; $block->content = new View("exif_gps_static_sidebar.html");
if (module::get_var("exif_gps", "sidebar_maptype") == 1) $block->content->sidebar_map_type = "satellite"; if (module::get_var("exif_gps", "sidebar_maptype") == 0) $block->content->sidebar_map_type = "roadmap";
if (module::get_var("exif_gps", "sidebar_maptype") == 2) $block->content->sidebar_map_type = "hybrid"; if (module::get_var("exif_gps", "sidebar_maptype") == 1) $block->content->sidebar_map_type = "satellite";
if (module::get_var("exif_gps", "sidebar_maptype") == 3) $block->content->sidebar_map_type = "terrain"; if (module::get_var("exif_gps", "sidebar_maptype") == 2) $block->content->sidebar_map_type = "hybrid";
} if (module::get_var("exif_gps", "sidebar_maptype") == 3) $block->content->sidebar_map_type = "terrain";
$block->content->latitude = $record->latitude; }
$block->content->longitude = $record->longitude; $block->content->latitude = $record->latitude;
} elseif (module::is_active("tagsmap") && module::is_active("tag")) { $block->content->longitude = $record->longitude;
// If there are no exif coordinates, check for tagsmap coordinates instead. } elseif (module::is_active("tagsmap") && module::is_active("tag")) {
$tagsItem = ORM::factory("tag") // If there are no exif coordinates, check for tagsmap coordinates instead.
->join("items_tags", "tags.id", "items_tags.tag_id") $tagsItem = ORM::factory("tag")
->where("items_tags.item_id", "=", $theme->item->id) ->join("items_tags", "tags.id", "items_tags.tag_id")
->find_all(); ->where("items_tags.item_id", "=", $theme->item->id)
if (count($tagsItem) > 0) { ->find_all();
foreach ($tagsItem as $oneTag) { if (count($tagsItem) > 0) {
$tagsGPS = ORM::factory("tags_gps")->where("tag_id", "=", $oneTag->id)->find(); foreach ($tagsItem as $oneTag) {
if ($tagsGPS->loaded()) { $tagsGPS = ORM::factory("tags_gps")->where("tag_id", "=", $oneTag->id)->find();
$block = new Block(); if ($tagsGPS->loaded()) {
$block->css_id = "g-exif-gps-sidebar"; $block = new Block();
$block->title = t("Location"); $block->css_id = "g-exif-gps-sidebar";
$block->content = new View("exif_gps_sidebar.html"); $block->title = t("Location");
$block->content->latitude = $tagsGPS->latitude; if (module::get_var("exif_gps", "sidebar_mapformat") == 1) {
$block->content->longitude = $tagsGPS->longitude; $block->content = new View("exif_gps_dynamic_sidebar.html");
break; if (module::get_var("exif_gps", "sidebar_maptype") == 0) $block->content->sidebar_map_type = "ROADMAP";
if (module::get_var("exif_gps", "sidebar_maptype") == 1) $block->content->sidebar_map_type = "SATELLITE";
if (module::get_var("exif_gps", "sidebar_maptype") == 2) $block->content->sidebar_map_type = "HYBRID";
if (module::get_var("exif_gps", "sidebar_maptype") == 3) $block->content->sidebar_map_type = "TERRAIN";
} else {
$block->content = new View("exif_gps_static_sidebar.html");
if (module::get_var("exif_gps", "sidebar_maptype") == 0) $block->content->sidebar_map_type = "roadmap";
if (module::get_var("exif_gps", "sidebar_maptype") == 1) $block->content->sidebar_map_type = "satellite";
if (module::get_var("exif_gps", "sidebar_maptype") == 2) $block->content->sidebar_map_type = "hybrid";
if (module::get_var("exif_gps", "sidebar_maptype") == 3) $block->content->sidebar_map_type = "terrain";
}
$block->content->latitude = $tagsGPS->latitude;
$block->content->longitude = $tagsGPS->longitude;
break;
}
} }
} }
} }
} elseif ( ($theme->tag()) && (module::is_active("tagsmap") && module::is_active("tag")) ) {
// If the current page belongs to a tag, check and see if the tag has GPS coordinates.
$tagsGPS = ORM::factory("tags_gps")->where("tag_id", "=", $theme->tag()->id)->find();
if ($tagsGPS->loaded()) {
$block = new Block();
$block->css_id = "g-exif-gps-sidebar";
$block->title = t("Location");
if (module::get_var("exif_gps", "sidebar_mapformat") == 1) {
$block->content = new View("exif_gps_dynamic_sidebar.html");
if (module::get_var("exif_gps", "sidebar_maptype") == 0) $block->content->sidebar_map_type = "ROADMAP";
if (module::get_var("exif_gps", "sidebar_maptype") == 1) $block->content->sidebar_map_type = "SATELLITE";
if (module::get_var("exif_gps", "sidebar_maptype") == 2) $block->content->sidebar_map_type = "HYBRID";
if (module::get_var("exif_gps", "sidebar_maptype") == 3) $block->content->sidebar_map_type = "TERRAIN";
} else {
$block->content = new View("exif_gps_static_sidebar.html");
if (module::get_var("exif_gps", "sidebar_maptype") == 0) $block->content->sidebar_map_type = "roadmap";
if (module::get_var("exif_gps", "sidebar_maptype") == 1) $block->content->sidebar_map_type = "satellite";
if (module::get_var("exif_gps", "sidebar_maptype") == 2) $block->content->sidebar_map_type = "hybrid";
if (module::get_var("exif_gps", "sidebar_maptype") == 3) $block->content->sidebar_map_type = "terrain";
}
$block->content->latitude = $tagsGPS->latitude;
$block->content->longitude = $tagsGPS->longitude;
}
} }
break; break;
} }
Expand Down

0 comments on commit 8f8b787

Please sign in to comment.