array("GalleryID" => "Countries/England", "SubsetID" => "London"), "Budapest" => array("GalleryID" => "Countries/Hungary", "SubsetID" => "Budapest"), "Cairo" => array("GalleryID" => "Countries/Egypt", "SubsetID" => "Cairo"), "Paris" => array("GalleryID" => "Countries/France", "SubsetID" => "Paris"), "Vienna" => array("GalleryID" => "Countries/Austria", "SubsetID" => "Vienna"), "Prague" => array("GalleryID" => "Countries/CzechRepublic", "SubsetID" => "Prague"), "Istanbul" => array("GalleryID" => "Countries/Turkey", "SubsetID" => "Istanbul"), "New-York-City" => array("GalleryID" => "Countries/USA", "SubsetID" => "New-York-City"), "Melbourne" => array("GalleryID" => "Countries/Australia", "SubsetID" => "Melbourne"), "Malta" => array("GalleryID" => "Countries/Malta", "SubsetID" => "") ); class MapHandler { var $GMap; var $MapConfig; var $MapMarkers; var $WrapperHTML = ""; var $MappableGalleries; var $MapPageID; // Indexes the $MappableGalleries array var $GalleryHandler; var $LinkGenerator; var $GalleryID; var $SubsetID; var $MarkerCounter = 0; function MapHandler(& $GalleryHandler) { global $MappableGalleries; // Should be passed as a parameter $this->GalleryHandler = & $GalleryHandler; $this->LinkGenerator = $this->GalleryHandler->LinkGenerator; $this->MappableGalleries = $MappableGalleries; $this->GalleryID = $this->GalleryHandler->Directory; $this->SubsetID = $this->GalleryHandler->SubsetID; $this->MapPageID = $this->GetMapPageID(); $this->LoadConfig(); } function InitMap() { $this->GMap = new GMap(); $this->GMap->width = '100%'; $this->GMap->addLargeMapControl(); if ($this->MapConfig['map_type_control']) { $this->GMap->addMapTypeControl(); } $this->GMap->setMapType('G_SATELLITE_MAP'); $this->GMap->zoom = $this->MapConfig['zoom']; $this->GMap->center = new GPoint($this->MapConfig['center_x'], $this->MapConfig['center_y']); } function IsMapEnabled() { $IsMapEnabled = GetAssocElement($this->MapConfig, 'map_enabled'); $IsMapEnabled = $IsMapEnabled && (boolean)$this->MapPageID; return $IsMapEnabled; } function LoadConfig() { $MapMarkerFile = $this->LinkGenerator->GetRelativePath($this->GalleryHandler->GalleryInfoSubdir . "map.txt", RELATIVE_TO_FILEROOT); $MapConfigFile = $this->LinkGenerator->GetRelativePath($this->GalleryHandler->GalleryInfoSubdir . "mapconfig.txt", RELATIVE_TO_FILEROOT); $MapConfigFile = LocalizeFile($MapConfigFile); $this->MapConfig = $this->GalleryHandler->GalleryHelper->LoadDescriptions($MapConfigFile); $this->MapMarkers = $this->GalleryHandler->GalleryHelper->LoadDescriptions($MapMarkerFile); } function GenerateMap() { $this->LoadHTML(); $this->AddMarkers(); $this->ReplaceTags(); return $this->WrapperHTML; } function ReplaceTags() { $GalleryTitle = $this->GalleryHandler->GalleryTitle; $MapCode = $this->GMap->getHeader('', false); $MapInfo = $this->MapConfig['info']; $MapCode .= " "; $this->WrapperHTML = str_replace("<-%MapCode%->", $MapCode, $this->WrapperHTML); $this->WrapperHTML = str_replace("<-%MapInfo%->", $MapInfo, $this->WrapperHTML); $this->WrapperHTML = str_replace("<-%GalleryTitle%->", $GalleryTitle, $this->WrapperHTML); $this->WrapperHTML = str_replace("<-%LowercaseGalleryTitle%->", mb_strtolower($GalleryTitle, DEFAULT_ENCODING), $this->WrapperHTML); $Crumbtrail = array(); $Crumbtrail[LocalizeString("Home", "Főoldal")] = "/"; $Crumbtrail[LocalizeString("Photos", "Fotók")] = "/"; $Crumbtrail[$this->GalleryHandler->NonSubsetGalleryTitle] = $this->LinkGenerator->GetGalleryLink($this->GalleryHandler->Directory); $Crumbtrail[$this->GalleryHandler->GalleryTitle] = $this->LinkGenerator->GetGalleryLink($this->GalleryHandler->Directory, false, true, $this->GalleryHandler->SubsetID); $Crumbtrail[LocalizeString("Photo Map", "Fotótérkép")] = ""; $this->WrapperHTML = str_replace("<-%SiteHeader%->", FetchSiteHeader($Crumbtrail, false, false), $this->WrapperHTML); } function LoadHTML() { $MapFilename = LocalizeFile("Maps/Map.html"); $fp = fopen($MapFilename, "r"); while (!feof($fp)) { $this->WrapperHTML .= fgets($fp, 4096); } fclose($fp); } function AddMarkers() { //echo $_SERVER['HTTP_HOST']; $UsedCoordinates = array(); foreach ($this->MapMarkers as $Picture => $Coordinates) { if ($Coordinates) { list ($X, $Y) = $this->GetURLCoordinates($Coordinates); if ($X === false || $Y === false) { if ($_SERVER['HTTP_HOST'] == 'localhost') { echo 'Invalid coordinate URL for ' . $Picture . '
'; } continue; } $this->AddMarker($X, $Y, $this->GalleryHandler->Descriptions[$Picture], $Picture); $CombinedCoordinates = $Y . "," . $X; if (isset($UsedCoordinates[$CombinedCoordinates]) && $_SERVER['HTTP_HOST'] == 'localhost') { echo "Coordinate clash at $CombinedCoordinates: $UsedCoordinates[$CombinedCoordinates] and $Picture
"; } else { $UsedCoordinates[$CombinedCoordinates] = $Picture; } if ($this->MarkerCounter >= 20) { //break; } $this->MarkerCounter++; } } } function CenterAndZoom($X, $Y, $Zoom) { return "CenterAndZoom($X, $Y, $Zoom);"; //return "maphandler.zoomTo(2);"; //return "maphandler.recenterOrPanToLatLng(new GPoint($X, $Y));"; } function AddMarker($X, $Y, $Caption, $Picture) { $HighlightedPicture = HTTPGETParam("photo") . ".jpg"; $CurrentHighlighted = $HighlightedPicture == $Picture; $Link = "/" . $this->GalleryID . "/" . basename($Picture, ".jpg") . ".html"; $ThumbnailPath = $this->GalleryID . "/thumbnails/" . $Picture; $ThumbnailWeb = $this->LinkGenerator->GetRelativePath($ThumbnailPath, RELATIVE_TO_WEBROOT, true);; //"/photos/" . $ThumbnailPath; $ThumbnailFilesystem = $this->LinkGenerator->GetRelativePath($ThumbnailPath, RELATIVE_TO_FILEROOT, true); $ImageSizeTags = GetImageSizeTags($ThumbnailFilesystem); $ZoomInCommand = $this->CenterAndZoom($X, $Y + 0.0006, $this->MapConfig['street_level_zoom']); $ZoomOutCommand = $this->CenterAndZoom($X, $Y + 0.0048, "maphandler.getZoomLevel() + 3"); $ZoomInLabel = LocalizeString("zoom in", "térképet nagyít"); $ZoomOutLabel = LocalizeString("zoom out", "térképet kicsinyít"); $HTML = '
' . '' . '' . '
' . $Caption . '
' . '
' . '
' . '' . $ZoomInLabel . '   ' . '' . $ZoomOutLabel . '' . '
' . '
'; //$HTML = 'zoom in   '; $HTML = str_replace("'", "\'", $HTML); $Marker = new GMarker(new GPoint($X, $Y), $HTML, "click", $CurrentHighlighted); $this->GMap->addOverlay($Marker); } function GetURLCoordinates($Coordinates) { if (StartsWith($Coordinates, "http://") || StartsWith($Coordinates, "https://")) { if (strpos($Coordinates, '&ll=') === false) { return array(false, false); } else { list ($tmp, $Coordinates) = explode("&ll=", $Coordinates); list ($Coordinates, $tmp) = explode("&", $Coordinates); } } list ($Y, $X) = preg_split("/,/", $Coordinates); if (!((float) $X) || (!(float) $Y)) { $X = false; $Y = false; } return array($X, $Y); } function LogMap() { LogElement("Maps/maps.log", $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); LogReferrer(); } function GetMapLink($Picture = false) { if ($PageID = $this->MapPageID) { $Link = "/Maps/" . $PageID . ".html"; if ($Picture && !IsRequestBySearchEngine()) { $Link .= "&photo=" . basename($Picture, ".jpg"); } return $Link; } else { return false; } } function IsPictureMapped($Picture) { return (isset($this->MapMarkers[$Picture]) && $this->MapMarkers[$Picture]); } /* AUXILIARY */ function GetMapPageID() { reset($this->MappableGalleries); foreach ($this->MappableGalleries as $PageID => $GalleryDetails) { if ($GalleryDetails['GalleryID'] == $this->GalleryID && ($GalleryDetails['SubsetID'] == $this->SubsetID || $this->SubsetID == false)) { return $PageID; } } } } ?> link] pairs function DisplaySiteHeader($Crumbtrail = false, $BuyPictureLink = false, $PictureToBuy = false) { echo FetchSiteHeader($Crumbtrail, $BuyPictureLink, $PictureToBuy); } function FetchSiteHeader($Crumbtrail = false, $BuyPictureLink = false, $PictureToBuy = false, $Root = "") { $TemplateManager = new Smarty; if ($Crumbtrail) { $FilteredCrumbtrail = array(); foreach ($Crumbtrail as $CrumbtrailEntryName => $CrumbtrailEntryLink) { // CSS font-variant: small-caps doesn't seem to work on this $FilteredCrumbtrail[mb_strtolower($CrumbtrailEntryName, DEFAULT_ENCODING)] = $CrumbtrailEntryLink; } $TemplateManager->assign("Crumbtrail", $FilteredCrumbtrail); } else { $TemplateManager->assign("Crumbtrail", array()); } $TemplateManager->assign("PictureToBuy", $PictureToBuy); $TemplateManager->assign("BuyPictureLink", $BuyPictureLink); $TemplateManager->assign("Language", GetLanguage()); $TemplateManager->assign("VisitorSource", GetVisitorSource()); if (GetLanguage() == LANG_HUN) { $BlogLinkProvider = new BlogLinkProvider(); list ($BlogPostLink, $BlogPostTitle) = $BlogLinkProvider->getRandomLink(LANG_HUN); $TemplateManager->assign("BlogPostLink", $BlogPostLink); $TemplateManager->assign("BlogPostTitle", strtolower($BlogPostTitle)); } return $TemplateManager->fetch($Root . TEMPLATE_ROOT . "SiteHeader.html"); } ?>= sizeof($filelist) - 1) return false; $nextfile = $filelist[$index + 1]; if ($this->MatchesPrefix($nextfile, $prefix)) return $nextfile; $index++; } } function PrivateGallery($Gallery) { if (StartsWith($Gallery, "Duhongo") || StartsWith($Gallery, "Private") || StartsWith($Gallery, "NonPublic") || StartsWith($Gallery, "Others") || StartsWith($Gallery, "tmp")) { return true; } else { return false; } } // Megadja a galeriaban az elozo file nevet, vagy false-t, ha az elso file-nal vagyunk function GetPrevFile($filelist, $curfile, $prefix) { $index = array_search($curfile, $filelist); if ($index === false) return false; while (1) { if ($index == 0) return false; $prevfile = $filelist[$index - 1]; if ($this->MatchesPrefix($prevfile, $prefix)) return $prevfile; $index--; } } function DisplayText($text, $CSS, $Extra = "") { if ($Extra) $Extra = " " . $Extra; echo ("" . $text . ""); } function StartCell($CellWidth, $VAlign) { echo ("\n

\n"); } function EndCell() { echo ("

\n\n\n"); } function SmallSpacerTable($Size, $Return = false) { $Table = "\n
\n"; if ($Return) { return $Table; } else echo $Table; } function MatchesPrefix($CurPic, $Prefix) { return (!$Prefix || $Prefix && substr($CurPic, 0, strlen($Prefix)) == $Prefix); } function InsertEmptyCell($Extra = "") { echo (" {$Extra}"); } function FilterLanguageParam($Gallery, $Picture) { $Language = false; list ($Language_tmp, $Gallery) = $this->LanguageRegexp($Gallery); if ($Language_tmp) $Language = $Language_tmp; list ($Language_tmp, $Picture) = $this->LanguageRegexp($Picture); if ($Language_tmp) $Language = $Language_tmp; return array($Language, $Gallery, $Picture); } function LanguageRegexp($String) { $LanguageRegexp = "-(..)"; if (ereg($LanguageRegexp, $String, $Regs)) { $Language = $Regs[1]; $String = ereg_replace($LanguageRegexp, "", $String); } else $Language = false; return array($Language, $String); } } ?>  Útifotó | earth-photography.com