-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathshow_map.controller.php
More file actions
82 lines (59 loc) · 3.5 KB
/
show_map.controller.php
File metadata and controls
82 lines (59 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
include_once(dirname(__FILE__) ."/include/main.php");
include_once(dirname(__FILE__) ."/include/quickroute_jpeg_extension_data.php");
class ShowMapController
{
public function Execute()
{
$viewData = array();
// no user specified - redirect to user list page
if(!getCurrentUser()) Helper::Redirect("users.php");
// user is hidden - redirect to user list page
if(!getCurrentUser()->Visible) Helper::Redirect("users.php");
// the requested map
$map = new Map();
$map->Load($_GET["map"]);
if(!$map->ID) die("The map has been removed.");
DataAccess::UnprotectMapIfNeeded($map);
if(Helper::MapIsProtected($map)) die("The map is protected until ". date("Y-m-d H:i:s", Helper::StringToTime($map->ProtectedUntil, true)) .".");
if($map->UserID != getCurrentUser()->ID) die();
$viewData["Comments"] = DataAccess::GetCommentsByMapId($map->ID);
$viewData["Name"] = $map->Name .' ('. date(__("DATE_FORMAT"), Helper::StringToTime($map->Date, true)) .')';
// previous map in archive
$previous = DataAccess::GetPreviousMap(getCurrentUser()->ID, $map->ID, Helper::GetLoggedInUserID());
$viewData["PreviousName"] = $previous == null ? null :$previous->Name .' ('. date(__("DATE_FORMAT"), Helper::StringToTime($previous->Date, true)) .')';
// next map in archive
$next = DataAccess::GetNextMap(getCurrentUser()->ID, $map->ID, Helper::GetLoggedInUserID());
$viewData["NextName"] = $next == null ? null : $next->Name .' ('. date(__("DATE_FORMAT"), Helper::StringToTime($next->Date, true)) .')';
$size = $map->GetMapImageSize();
$viewData["ImageWidth"] = $size["Width"];
$viewData["ImageHeight"] = $size["Height"];
DataAccess::IncreaseMapViews($map);
$viewData["Map"] = $map;
$viewData["BackUrl"] = isset($_SERVER["HTTP_REFERER"]) && basename($_SERVER["HTTP_REFERER"]) == "users.php"
? "users.php"
: "index.php?". Helper::CreateQuerystring(getCurrentUser());
$viewData["Previous"] = $previous;
$viewData["Next"] = $next;
$viewData["ShowComments"] = (isset($_GET["showComments"]) && $_GET["showComments"] = true) || !__("COLLAPSE_VISITOR_COMMENTS");
$viewData["FirstMapImageName"] = Helper::GetMapImage($map);
if($map->BlankMapImage) $viewData["SecondMapImageName"] = Helper::GetBlankMapImage($map);
$viewData["QuickRouteJpegExtensionData"] = $map->GetQuickRouteJpegExtensionData();
if(isset($viewData["QuickRouteJpegExtensionData"]) && $viewData["QuickRouteJpegExtensionData"]->IsValid)
{
$categories = DataAccess::GetCategoriesByUserID(getCurrentUser()->ID);
$viewData["OverviewMapData"][] = Helper::GetOverviewMapData($map, true, false, false, $categories);
$viewData["GoogleMapsUrl"] = "https://maps.google.com/maps".
"?q=". urlencode(Helper::GlobalPath("export_kml.php?id=". $map->ID ."&format=kml")).
"&language=". Session::GetLanguageCode();
}
if(USE_3DRERUN=='1' && DataAccess::GetSetting("LAST_WORLDOFO_CHECK_DOMA_TIME", "0")+RERUN_FREQUENCY*3600<time())
{
$viewData["RerunMaps"] = Helper::GetMapsForRerunRequest();
$viewData["TotalRerunMaps"] = count(explode(",",$viewData["RerunMaps"]));
$viewData["ProcessRerun"] = true;
}
return $viewData;
}
}
?>