public function executePreview() { parent::executePreview(); $id = $this->getRequestParameter('id'); if (empty($id)) { $summit_id = $this->getRequestParameter('summit_id'); if (!empty($summit_id) && ($lang = DocumentI18n::findBestCulture($summit_id, $this->getUser()->getCulturesForDocuments(), 'Summit'))) { $this->title_prefix = DocumentI18n::findName($summit_id, $lang, 'Summit'); } $this->associated_books = null; } else { $this->title_prefix = $this->getHighestSummitName(); // retrieve associated books if any $prefered_cultures = $this->getUser()->getCulturesForDocuments(); $this->associated_books = Book::getAssociatedBooksData(Association::findAllWithBestName($id, $prefered_cultures, 'br')); } }
public function executeGetdirections() { sfLoader::loadHelpers(array('GetDirections')); $referer = $this->getRequest()->getReferer(); $dest_id = $this->getRequestParameter('id'); $service = $this->getRequestParameter('service'); $user_id = $this->getUser()->getId(); $lang = $this->getUser()->getCulture(); // parking coords $dest_coords = Document::fetchAdditionalFieldsFor(array(array('id' => $dest_id)), 'Document', array('lat', 'lon')); if (empty($dest_coords) || $dest_coords[0]['lat'] instanceof Doctrine_Null || $dest_coords[0]['lon'] instanceof Doctrine_Null) { return $this->setWarningAndRedirect('Document does not exists or has no attached geometry', $referer); } // retrieve best parking name if ($service == 'gmaps' || $service == 'livesearch') { $name = urlencode(DocumentI18n::findBestName($dest_id, $this->getUser()->getCulturesForDocuments(), 'Document')); } // user coords - they can be either given as parameters, retrieved from user profile or inexistent $user_lon = floatval($this->getRequestParameter('lon')); $user_lat = floatval($this->getRequestParameter('lat')); if (!$user_lon || !$user_lat) { $user_coords = empty($user_id) ? null : Document::fetchAdditionalFieldsFor(array(array('id' => $user_id)), 'User', array('lat', 'lon')); if (empty($user_coords) || $user_coords[0]['lat'] instanceof Doctrine_Null || $user_coords[0]['lon'] instanceof Doctrine_Null) { $user_lat = $user_lon = null; } else { $user_lat = $user_coords[0]['lat']; $user_lon = $user_coords[0]['lon']; } } switch ($service) { case 'yahoo': $url = yahoo_maps_direction_link($user_lat, $user_lon, $dest_coords[0]['lat'], $dest_coords[0]['lon'], $lang); break; case 'livesearch': $url = live_search_maps_direction_link($user_lat, $user_lon, $dest_coords[0]['lat'], $dest_coords[0]['lon'], $name); break; case 'openmapquest': $url = openmapquest_direction_link($user_lat, $user_lon, $dest_coords[0]['lat'], $dest_coords[0]['lon'], $lang); break; case 'osrm': $url = osrm_direction_link($user_lat, $user_lon, $dest_coords[0]['lat'], $dest_coords[0]['lon'], $lang); break; case 'gmaps': default: $url = gmaps_direction_link($user_lat, $user_lon, $dest_coords[0]['lat'], $dest_coords[0]['lon'], $lang); break; } $this->redirect($url); }