示例#1
0
 /**
  * overrides function from parent in order to correctly display slug
  * with summit name
  */
 protected function redirectToView()
 {
     sfLoader::loadHelpers(array('General'));
     $prefered_cultures = $this->getUser()->getCulturesForDocuments();
     $summits = Association::findAllWithBestName($this->document->get('id'), $prefered_cultures, 'sr');
     $summit_name = c2cTools::extractHighestName($summits);
     $this->redirect('@document_by_id_lang_slug?module=' . $this->getModuleName() . '&id=' . $this->document->get('id') . '&lang=' . $this->document->getCulture() . '&slug=' . make_slug($summit_name) . '-' . get_slug($this->document));
 }
示例#2
0
 /**
  * populates custom fields (for instance if we are creating a new outing, already associated with a route)
  * overrides the one in documentsActions class.
  */
 protected function populateCustomFields()
 {
     $document = $this->document;
     if ($this->getRequestParameter('link') && ($linked_doc = Document::find('Document', $this->getRequestParameter('link'), array('module')))) {
         $prefered_cultures = $this->getUser()->getCulturesForDocuments();
         switch ($linked_doc->get('module')) {
             case 'routes':
                 $linked_doc = Document::find('Route', $this->getRequestParameter('link'), array('activities', 'max_elevation', 'min_elevation', 'height_diff_up', 'height_diff_down'));
                 $linked_doc->setBestCulture($prefered_cultures);
                 $this->linked_doc = $linked_doc;
                 // FIXME: this "field getting" triggers an additional request to the db (yet already hydrated),
                 // probably because activities field has been hydrated into object as a string and not as an array
                 // cf filterGetActivities and filterSetActivities in Route.class.php ...
                 $activities = $linked_doc->get('activities');
                 $document->set('activities', $activities);
                 if ($max_elevation = $linked_doc->get('max_elevation')) {
                     $document->set('max_elevation', $max_elevation);
                 }
                 if ($min_elevation = $linked_doc->get('min_elevation')) {
                     $document->set('access_elevation', $min_elevation);
                     if (in_array(1, $activities)) {
                         $document->set('up_snow_elevation', $min_elevation);
                         $document->set('down_snow_elevation', $min_elevation);
                     }
                 }
                 if ($height_diff_up = $linked_doc->get('height_diff_up')) {
                     $document->set('height_diff_up', $height_diff_up);
                 }
                 if ($height_diff_down = $linked_doc->get('height_diff_down')) {
                     $document->set('height_diff_down', $height_diff_down);
                 }
                 // find associated summits to this route, extract the highest and create document with this name.
                 $associated_summits = array_filter(Association::findAllWithBestName($linked_doc->get('id'), $prefered_cultures), array('c2cTools', 'is_summit'));
                 $this->highest_summit_name = c2cTools::extractHighestName($associated_summits);
                 $document->set('name', $this->highest_summit_name . $this->__(' :') . ' ' . $linked_doc->get('name'));
                 break;
             case 'sites':
                 $linked_doc = Document::find('Site', $this->getRequestParameter('link'), array('mean_rating'));
                 $linked_doc->setBestCulture($prefered_cultures);
                 $document->set('name', $linked_doc->get('name'));
                 $document->set('activities', array(4));
                 $this->linked_doc = $linked_doc;
                 break;
             default:
                 $this->setErrorAndRedirect('You cannot create an outing without linking it to an existing route or site', '@default_index?module=outings');
         }
     }
     $this->document = $document;
 }