public function linkForItem(KurogoObject $placemark, $options = null) { $addBreadcrumb = $options && isset($options['addBreadcrumb']) && $options['addBreadcrumb']; $urlArgs = shortArrayFromMapFeature($placemark); if (isset($options['external']) && $options['external']) { $urlArgs['external'] = true; } $result = array('title' => $placemark->getTitle(), 'subtitle' => $placemark->getSubtitle(), 'url' => $this->buildBreadcrumbURL('detail', $urlArgs, $addBreadcrumb)); if (($distance = $placemark->getField('distance')) && $this->getOptionalModuleVar('SHOW_DISTANCES', true)) { $result['subtitle'] = $this->displayTextFromMeters($distance); } return $result; }
protected function initializeForPage() { switch ($this->page) { case 'help': break; case 'index': $redirectedWithLocation = $this->getArg('redirected'); if ($action = $this->getArg('action', false)) { if ($this->feedGroup && $action == 'add') { // TODO have config for different types of cookie expiration times $expireTime = time() + 897298; setcookie(MAP_GROUP_COOKIE, $this->feedGroup, $expireTime, COOKIE_PATH); } else if ($action == 'remove') { $expireTime = time() - 4096; setcookie(MAP_GROUP_COOKIE, '', $expireTime, COOKIE_PATH); } } if ($this->feedGroup === null && $this->numGroups > 1) { // show the list of groups foreach ($this->feedGroups as $id => $groupData) { $categories[] = array( 'title' => $groupData['title'], 'url' => $this->groupURL($id), 'loc' => explode("," ,$groupData['center']) ); } // only display categories in a list if the current location attempt has been made // and a redirection has occured. if ($redirectedWithLocation) { $groupAlias = $this->getOptionalModuleVar('GROUP_ALIAS', 'Campus'); $this->assign('browseHint', "Select a $groupAlias"); $this->assign('categories', $categories); $this->assign('searchTip', NULL); $latitude = $this->getArg('lat'); $longitude = $this->getArg('lon'); // if current lat/lon were found and valid, sort the categories based on that. if (is_numeric($latitude) && is_numeric($longitude)) { $sorted_categories = $this->sortCategoriesForCurrentLocation($categories, $latitude, $longitude); $this->assign('categories', $sorted_categories); $this->assign('browseHint', "Select a $groupAlias (Closest first)"); } $this->generateBookmarkLink(); } else{ $js = $this->getJavascriptStringForLocationRedirection(); $this->addInlineJavascript($js); } } else { $groupData = $this->getDataForGroup($this->feedGroup); $browseBy = $groupData['title']; if ($this->numGroups > 1) { $cookieID = http_build_query(array('group' => $this->feedGroup)); $this->generateBookmarkOptions($cookieID); $groupAlias = $this->getOptionalModuleVar('GROUP_ALIAS_PLURAL', 'Campuses'); $clearLink = array(array( 'title' => "All $groupAlias", 'url' => $this->groupURL(''), )); $this->assign('clearLink', $clearLink); } $categories = $this->assignCategories(); if (count($categories)==1) { $category = current($categories); $this->redirectTo('category', array('category'=>$category['id'])); } $this->assign('browseHint', "Browse {$browseBy} by:"); $this->assign('searchTip', "You can search by any category shown in the 'Browse by' list below."); $this->generateBookmarkLink(); } break; case 'bookmarks': $feedGroups = array(); $places = array(); foreach ($this->getBookmarks() as $aBookmark) { if ($aBookmark) { // prevent counting empty string $titles = $this->getTitleForBookmark($aBookmark); $subtitle = count($titles) > 1 ? $titles[1] : null; if ($this->bookmarkType($aBookmark) == 'group') { $feedGroups[] = array( 'title' => $titles[0], 'subtitle' => $subtitle, 'url' => $this->detailURLForBookmark($aBookmark), ); } else { $places[] = array( 'title' => $titles[0], 'subtitle' => $subtitle, 'url' => $this->detailURLForBookmark($aBookmark), ); } } } $this->assign('groupAlias', $this->getOptionalModuleVar('GROUP_ALIAS_PLURAL', 'Campuses')); $this->assign('groups', $feedGroups); $this->assign('places', $places); break; case 'search': if (isset($this->args['filter'])) { $searchTerms = $this->args['filter']; $mapSearch = $this->getSearchClass(); $searchResults = $mapSearch->searchCampusMap($searchTerms); if (count($searchResults) == 1) { $this->redirectTo('detail', shortArrayFromMapFeature($searchResults[0])); } else { $places = array(); foreach ($searchResults as $result) { $title = $result->getTitle(); $subtitle = $result->getSubtitle(); $place = array( 'title' => $title, 'subtitle' => $subtitle, 'url' => $this->detailURLForResult(shortArrayFromMapFeature($result)), ); $places[] = $place; } } $this->assign('searchTerms', $searchTerms); $this->assign('places', $places); } else { $this->redirectTo('index'); } break; case 'category': $categoryPath = $this->getCategoriesAsArray(); if ($categoryPath) { // populate drop-down list at the bottom $this->assignCategories(); // build the drill-down list $dataController = $this->getDataController($categoryPath, $listItemPath); $listItems = $dataController->getListItems($listItemPath); if (count($listItems) == 1 && $listItems[0] instanceof MapFeature) { $args = $this->args; $args['featureindex'] = $listItems[0]->getIndex(); $this->redirectTo('detail', $args, true); } $places = array(); foreach ($listItems as $listItem) { if ($listItem instanceof MapFeature) { $url = $this->detailURL($listItem->getIndex(), $categoryPath); } else { // for folder objects, getIndex returns the subcategory ID $drilldownPath = array_merge($categoryPath, array($listItem->getIndex())); $url = $this->categoryURL($drilldownPath, false); // don't add breadcrumb } $places[] = array( 'title' => $listItem->getTitle(), 'subtitle' => $listItem->getSubtitle(), 'url' => $url, ); } $this->assign('title', $dataController->getTitle()); $this->assign('places', $places); } else { $this->redirectTo('index'); } break; case 'detail': $detailConfig = $this->loadPageConfigFile('detail', 'detailConfig'); $tabKeys = array(); $tabJavascripts = array(); $dataController = $this->getDataControllerForMap($listItemPath); $feature = $this->getFeatureForMap($dataController, $listItemPath); if (isset($this->args['featureindex'])) { // this is a regular place $cookieParams = array( 'category' => $this->args['category'], 'featureindex' => $this->args['featureindex'], ); $cookieID = http_build_query($cookieParams); $this->generateBookmarkOptions($cookieID); } elseif (isset($this->args['group'])) { $cookieID = http_build_query(array('group' => $this->args['group'])); $this->generateBookmarkOptions($cookieID); } $this->assign('name', $this->getArg('title', $feature->getTitle())); // prevent infinite loop in smarty_modifier_replace // TODO figure out why smarty gets in an infinite loop $address = str_replace("\n", " ", $feature->getSubtitle()); $this->assign('address', $this->getArg('address', $address)); $possibleTabs = $detailConfig['tabs']['tabkeys']; foreach ($possibleTabs as $tabKey) { if ($this->generateTabForKey($tabKey, $feature, $dataController, $tabJavascripts)) { $tabKeys[] = $tabKey; } } $this->assign('tabKeys', $tabKeys); $this->enableTabs($tabKeys, null, $tabJavascripts); break; case 'fullscreen': $dataController = $this->getDataControllerForMap(); $feature = $this->getFeatureForMap($dataController); $this->initializeMap($dataController, $feature, true); break; } }
protected function initializeForPage() { switch ($this->page) { case 'help': break; case 'index': case 'campus': $campus = $this->getArg('campus', NULL); $numCampuses = $GLOBALS['siteConfig']->getVar('CAMPUS_COUNT'); if ($campus === NULL && $numCampuses > 1) { $campusLinks = array(); for ($i = 0; $i < $numCampuses; $i++) { $campusData = $GLOBALS['siteConfig']->getSection('campus-'.$i); $campusLinks[] = array( 'title' => $campusData['title'], 'url' => $this->campusURL($campusData['id']), ); } $this->assign('browseHint', 'Select a Location'); $this->assign('categories', $campusLinks); $this->assign('searchTip', NULL); } else { $browseBy = 'map'; if ($campus !== null) { $campusData = $this->getDataForCampus($campus); if ($campusData) { $browseBy = $campusData['title']; } $cookieID = http_build_query(array('campus' => $campus)); $this->generateBookmarkOptions($cookieID); } $this->assignCategoriesForCampus($campus); $this->assign('browseHint', "Browse {$browseBy} by:"); $this->assign('searchTip', "You can search by any category shown in the 'Browse by' list below."); } $this->generateBookmarkLink(); break; case 'bookmarks': $campuses = array(); $places = array(); foreach ($this->getBookmarks() as $aBookmark) { if ($aBookmark) { // prevent counting empty string $titles = $this->getTitleForBookmark($aBookmark); $subtitle = count($titles) > 1 ? $titles[1] : null; if ($this->bookmarkType($aBookmark) == 'campus') { $campuses[] = array( 'title' => $titles[0], 'subtitle' => $subtitle, 'url' => $this->detailURLForBookmark($aBookmark), ); } else { $places[] = array( 'title' => $titles[0], 'subtitle' => $subtitle, 'url' => $this->detailURLForBookmark($aBookmark), ); } } } $this->assign('campuses', $campuses); $this->assign('places', $places); break; case 'search': if (isset($this->args['filter'])) { $searchTerms = $this->args['filter']; $mapSearchClass = $GLOBALS['siteConfig']->getVar('MAP_SEARCH_CLASS'); $mapSearch = new $mapSearchClass(); if (!$this->feeds) $this->feeds = $this->loadFeedData(); $mapSearch->setFeedData($this->feeds); $searchResults = $mapSearch->searchCampusMap($searchTerms); if (count($searchResults) == 1) { $this->redirectTo('detail', shortArrayFromMapFeature($searchResults[0])); } else { $places = array(); foreach ($searchResults as $result) { $title = $result->getTitle(); $subtitle = $result->getSubtitle(); $place = array( 'title' => $title, 'subtitle' => $subtitle, 'url' => $this->detailURLForResult(shortArrayFromMapFeature($result)), ); $places[] = $place; } } $this->assign('searchTerms', $searchTerms); $this->assign('places', $places); } else { $this->redirectTo('index'); } break; case 'category': if (isset($this->args['category'])) { // populate drop-down list at the bottom $this->assignCategoriesForCampus($this->getArg('campus', NULL)); // build the drill-down list $categoryPath = $this->args['category']; if (is_array($categoryPath)) { $topCategory = array_shift($categoryPath); } else { $topCategory = $categoryPath; $categoryPath = array(); } $dataController = $this->getDataController($topCategory); $listItems = $dataController->getListItems($categoryPath); array_unshift($categoryPath, $topCategory); // restore the path since we still need it if (count($listItems) == 1 && $listItems[0] instanceof MapFeature) { $args = $this->args; $args['featureindex'] = $listItems[0]->getIndex(); $this->redirectTo('detail', $args, true); } $places = array(); foreach ($listItems as $listItem) { if ($listItem instanceof MapFeature) { $url = $this->detailURL($listItem->getIndex(), $categoryPath); } else { // for folder objects, getIndex returns the subcategory ID $drilldownPath = array_merge($categoryPath, array($listItem->getIndex())); $url = $this->categoryURL($drilldownPath, false); // don't add breadcrumb } $places[] = array( 'title' => $listItem->getTitle(), 'subtitle' => $listItem->getSubtitle(), 'url' => $url, ); } $this->assign('title', $dataController->getTitle()); $this->assign('places', $places); } else { $this->redirectTo('index'); } break; case 'detail': $detailConfig = $this->loadPageConfigFile('detail', 'detailConfig'); $tabKeys = array(); $tabJavascripts = array(); $dataController = $this->getDataControllerForMap(); $feature = $this->getFeatureForMap($dataController); if (isset($this->args['featureindex'])) { // this is a regular place $cookieParams = array( 'category' => $this->args['category'], 'featureindex' => $this->args['featureindex'], ); $cookieID = http_build_query($cookieParams); $this->generateBookmarkOptions($cookieID); } elseif (isset($this->args['campus'])) { $cookieID = http_build_query(array('campus' => $this->args['campus'])); $this->generateBookmarkOptions($cookieID); } $this->assign('name', $this->getArg('title', $feature->getTitle())); // prevent infinite loop in smarty_modifier_replace // TODO figure out why smarty gets in an infinite loop $address = str_replace("\n", " ", $feature->getSubtitle()); $this->assign('address', $this->getArg('address', $address)); $possibleTabs = $detailConfig['tabs']['tabkeys']; foreach ($possibleTabs as $tabKey) { if ($this->generateTabForKey($tabKey, $feature, $dataController, $tabJavascripts)) { $tabKeys[] = $tabKey; } } $this->assign('tabKeys', $tabKeys); $this->enableTabs($tabKeys, null, $tabJavascripts); break; case 'fullscreen': $dataController = $this->getDataControllerForMap(); $feature = $this->getFeatureForMap($dataController); $this->initializeMap($dataController, $feature, true); break; } }