/** * Executes view action. */ public function executeView() { parent::executeView(); if (!$this->document->isArchive() && $this->document['redirects_to'] == NULL) { $user = $this->getUser(); $prefered_cultures = $user->getCulturesForDocuments(); $this->associated_summits = Summit::getAssociatedSummitsData($this->associated_docs); $this->associated_routes = Route::getAssociatedRoutesData($this->associated_docs, $this->__(' :') . ' '); $this->associated_huts = Hut::getAssociatedHutsData($this->associated_docs); $this->associated_sites = Site::getAssociatedSitesData($this->associated_docs); // add linked docs areas $parent_ids = array(); $associated_areas = array(); if (count($this->associated_docs)) { foreach ($this->associated_docs as $doc) { $parent_ids[] = $doc['id']; } $associated_areas = GeoAssociation::findAreasWithBestName($parent_ids, $prefered_cultures); } $this->associated_areas = $associated_areas; $cas = count($this->associated_summits); $car = count($this->associated_routes); $cah = count($this->associated_huts); $cab = count($this->associated_sites); $this->section_list = array('summits' => $cas != 0, 'routes' => $car != 0, 'huts' => $cah != 0, 'sites' => $cab != 0, 'docs' => $cas + $car + $cah + $cab == 0); $related_portals = array(); $activities = $this->document->get('activities'); $book_types = $this->document->get('book_types'); Portal::getRelatedPortals($related_portals, $this->associated_areas, $this->associated_routes, $activities); if (array_intersect(array(1, 4, 10, 14, 18), $book_types) && in_array(5, $activities) && !in_array('ice', $related_portals)) { $related_portals[] = 'ice'; } $this->related_portals = $related_portals; $description = array($this->__('book') . ' :: ' . $this->document->get('name'), $this->getActivitiesList()); $this->getResponse()->addMeta('description', implode(' - ', $description)); } }
public static function buildPagerConditions(&$q, $criteria) { $conditions = $criteria[0]; $values = $criteria[1]; $joins = $criteria[2]; self::buildAreaIdPagerConditions($q, $joins); // join with site / book / article tables only if needed if (isset($joins['join_site'])) { Site::buildSitePagerConditions($q, $joins, true); } // join with summit tables only if needed if (isset($joins['join_summit'])) { Summit::buildSummitPagerConditions($q, $joins, false, false, 'm.associations', 'st'); } // join with hut tables only if needed if (isset($joins['join_hut'])) { Hut::buildHutPagerConditions($q, $joins, false, false, 'm.associations', 'ht'); } // join with parking tables only if needed if (isset($joins['join_parking'])) { Parking::buildParkingPagerConditions($q, $joins, false, false, 'm.associations', 'pt'); } // join with outing tables only if needed if (isset($joins['join_user'])) { $joins['join_outing'] = true; $joins['post_outing'] = true; } if (isset($joins['join_outing'])) { Outing::buildOutingPagerConditions($q, $joins, false, true, 'm.LinkedAssociation', 'to'); if (isset($joins['join_user'])) { User::buildUserPagerConditions($q, $joins, false, false, 'lo.MainMainAssociation', 'uo'); } } // join with image tables only if needed if (isset($joins['join_image_id']) || isset($joins['join_image']) || isset($joins['join_image_i18n']) || isset($joins['join_itag_id'])) { Image::buildImagePagerConditions($q, $joins, false, 'pi'); } if (!empty($conditions)) { $q->addWhere(implode(' AND ', $conditions), $values); } }
public static function buildPagerConditions(&$q, $criteria) { $conditions = $criteria[0]; $values = $criteria[1]; $joins = $criteria[2]; $route_join = 'm.associations'; $route_ltype = 'ri'; $summit_join = 'm.associations'; $summit_ltype = 'si'; $hut_join = 'm.associations'; $hut_ltype = 'hi'; $parking_join = 'm.associations'; $parking_ltype = 'pi'; $site_join = 'm.associations'; $site_ltype = 'ti'; self::joinOnLinkedDocMultiRegions($q, $joins); if (isset($joins['doc']) || isset($joins['dtag'])) { $q->leftJoin('m.associations lid'); if (isset($joins['dtag'])) { $q->leftJoin('lid.LinkedLinkedAssociation ldc'); } } // join with image tables only if needed if (isset($joins['join_image'])) { Image::buildImagePagerConditions($q, $joins, true); } // join with outing tables only if needed if (isset($joins['join_outing'])) { Outing::buildOutingPagerConditions($q, $joins, false, false, 'm.associations', 'oi'); $route_join = 'lo.MainAssociation'; $route_ltype = 'ro'; $summit_join = 'lr.MainAssociation'; $summit_ltype = 'sr'; $hut_join = 'lr.MainAssociation'; $hut_ltype = 'hr'; $parking_join = 'lr.MainAssociation'; $parking_ltype = 'pr'; $site_join = 'lo.MainAssociation'; $site_ltype = 'to'; if (isset($joins['ouser_id'])) { $q->leftJoin($route_join . ' lou'); } if (isset($joins['join_summit']) || isset($joins['join_hut']) || isset($joins['join_parking'])) { $joins['join_route'] = true; $joins['post_route'] = true; } } // join with route tables only if needed if (isset($joins['join_route'])) { Route::buildRoutePagerConditions($q, $joins, false, false, $route_join, $route_ltype); $summit_join = 'lr.MainAssociation'; $summit_ltype = 'sr'; $hut_join = 'lr.MainAssociation'; $hut_ltype = 'hr'; $parking_join = 'lr.MainAssociation'; $parking_ltype = 'pr'; } // join with summit tables only if needed if (isset($joins['join_summit'])) { Summit::buildSummitPagerConditions($q, $joins, false, false, $summit_join, $summit_ltype); } // join with hut tables only if needed if (isset($joins['join_hut'])) { Hut::buildHutPagerConditions($q, $joins, false, false, $hut_join, $hut_ltype); } // join with parking tables only if needed if (isset($joins['join_parking'])) { Parking::buildParkingPagerConditions($q, $joins, false, false, $parking_join, $parking_ltype); } // join with site tables only if needed if (isset($joins['join_site'])) { Site::buildSitePagerConditions($q, $joins, false, false, $site_join, $site_ltype); } // join with user tables only if needed if (isset($joins['user_id'])) { $q->leftJoin('m.versions v')->leftJoin('v.history_metadata hm')->addWhere('v.version = 1'); } if (!empty($conditions)) { $q->addWhere(implode(' AND ', $conditions), $values); } }
public static function buildPagerConditions(&$q, $criteria) { $conditions = $criteria[0]; $values = $criteria[1]; $joins = $criteria[2]; $route_join = 'm.MainGeoassociations'; $route_ltype = ''; $summit_join = 'm.MainGeoassociations'; $summit_ltype = ''; $hut_join = 'm.MainGeoassociations'; $hut_ltype = ''; $parking_join = 'm.MainGeoassociations'; $parking_ltype = ''; $site_join = 'm.MainGeoassociations'; $site_ltype = ''; $user_join = 'm.MainGeoassociations'; $user_ltype = ''; // join with area tables only if needed if (isset($joins['join_area'])) { Area::buildAreaPagerConditions($q, $joins, true); } // join with outing tables only if needed if (isset($joins['join_outing'])) { Outing::buildOutingPagerConditions($q, $joins, false, false, 'm.MainGeoassociations', ''); $route_join = 'lo.MainAssociation'; $route_ltype = 'ro'; $summit_join = 'lr.MainAssociation'; $summit_ltype = 'sr'; $hut_join = 'lr.MainAssociation'; $hut_ltype = 'hr'; $parking_join = 'lr.MainAssociation'; $parking_ltype = 'pr'; $site_join = 'lo.MainAssociation'; $site_ltype = 'to'; $user_join = 'lu.MainAssociations'; $user_ltype = 'uo'; } // join with route tables only if needed if (isset($joins['join_route'])) { Route::buildRoutePagerConditions($q, $joins, false, false, $route_join, $route_ltype); $summit_join = 'lr.MainAssociation'; $summit_ltype = 'sr'; $hut_join = 'lr.MainAssociation'; $hut_ltype = 'hr'; $parking_join = 'lr.MainAssociation'; $parking_ltype = 'pr'; } // join with summit tables only if needed if (isset($joins['join_summit'])) { Summit::buildSummitPagerConditions($q, $joins, false, false, $summit_join, $summit_ltype); } // join with hut tables only if needed if (isset($joins['join_hut'])) { Hut::buildHutPagerConditions($q, $joins, false, false, $hut_join, $hut_ltype); } // join with parking tables only if needed if (isset($joins['join_parking'])) { Parking::buildParkingPagerConditions($q, $joins, false, false, $parking_join, $parking_ltype); } // join with site tables only if needed if (isset($joins['join_site'])) { Site::buildSitePagerConditions($q, $joins, false, false, $site_join, $site_ltype); } // join with product tables only if needed if (isset($joins['join_product'])) { Product::buildProductPagerConditions($q, $joins, false, false, 'm.MainGeoassociations', ''); } // join with user tables only if needed if (isset($joins['join_user'])) { User::buildUserPagerConditions($q, $joins, false, false, $user_join, $user_ltype); } // join with image tables only if needed if (isset($joins['join_image'])) { Image::buildImagePagerConditions($q, $joins, false, ''); } if (!empty($conditions)) { $q->addWhere(implode(' AND ', $conditions), $values); } }
public static function buildPagerConditions(&$q, $criteria) { $conditions = $criteria[0]; $values = $criteria[1]; $joins = $criteria[2]; self::buildAreaIdPagerConditions($q, $joins); // join with parking / book / article tables only if needed if (isset($joins['join_parking'])) { Parking::buildParkingPagerConditions($q, $joins, true); } // join with huts tables only if needed if (isset($joins['join_hut'])) { Hut::buildHutPagerConditions($q, $joins, false, true, 'm.LinkedAssociation', 'ph'); } // join with routes tables only if needed if (isset($joins['join_summit']) || isset($joins['join_outing'])) { $joins['join_route'] = true; $joins['post_route'] = true; } if (isset($joins['join_route'])) { Route::buildRoutePagerConditions($q, $joins, false, true, 'm.LinkedAssociation', 'pr'); if (isset($joins['join_summit'])) { Summit::buildSummitPagerConditions($q, $joins, false, false, 'lr.MainAssociation', 'sr'); } if (isset($joins['join_outing'])) { Outing::buildOutingPagerConditions($q, $joins, false, true, 'lr.LinkedAssociation', 'ro'); } } // join with site tables only if needed if (isset($joins['join_site'])) { Site::buildSitePagerConditions($q, $joins, false, true, 'm.LinkedAssociation', 'pt'); } // join with image tables only if needed if (isset($joins['join_image'])) { Image::buildImagePagerConditions($q, $joins, false, 'pi'); } if (!empty($conditions)) { $q->addWhere(implode(' AND ', $conditions), $values); } }
public static function buildPagerConditions(&$q, $criteria) { $conditions = $criteria[0]; $values = $criteria[1]; $joins = $criteria[2]; $route_join = 'm.associations'; $route_ltype = 'rc'; $summit_join = 'm.associations'; $summit_ltype = 'sc'; $hut_join = 'm.associations'; $hut_ltype = 'hc'; $parking_join = 'm.associations'; $parking_ltype = 'pc'; $site_join = 'm.associations'; $site_ltype = 'tc'; self::joinOnLinkedDocMultiRegions($q, $joins); self::joinOnMulti($q, $joins, 'user_id', 'm.associations u', 4); if (isset($joins['cdoc'])) { $q->leftJoin('m.associations lcd'); } // join with article tables only if needed if (isset($joins['join_article'])) { Article::buildArticlePagerConditions($q, $joins, true); } // join with book tables only if needed if (isset($joins['join_cbook'])) { Book::buildBookPagerConditions($q, $joins, false, 'c', false, $main_join, 'bc'); } // join with outing tables only if needed if (isset($joins['join_outing'])) { Outing::buildOutingPagerConditions($q, $joins, false, false, 'm.associations', 'oc'); $route_join = 'lo.MainAssociation'; $route_ltype = 'ro'; $summit_join = 'lr.MainAssociation'; $summit_ltype = 'sr'; $hut_join = 'lr.MainAssociation'; $hut_ltype = 'hr'; $parking_join = 'lr.MainAssociation'; $parking_ltype = 'pr'; $site_join = 'lo.MainAssociation'; $site_ltype = 'to'; if (isset($joins['join_summit']) || isset($joins['join_hut']) || isset($joins['join_parking'])) { $joins['join_route'] = true; $joins['post_route'] = true; } } // join with route tables only if needed if (isset($joins['join_route'])) { Route::buildRoutePagerConditions($q, $joins, false, false, $route_join, $route_ltype); $summit_join = 'lr.MainAssociation'; $summit_ltype = 'sr'; $hut_join = 'lr.MainAssociation'; $hut_ltype = 'hr'; $parking_join = 'lr.MainAssociation'; $parking_ltype = 'pr'; } // join with summit tables only if needed if (isset($joins['join_summit'])) { Summit::buildSummitPagerConditions($q, $joins, false, false, $summit_join, $summit_ltype); } // join with hut tables only if needed if (isset($joins['join_hut'])) { Hut::buildHutPagerConditions($q, $joins, false, false, $hut_join, $hut_ltype); } // join with parking tables only if needed if (isset($joins['join_parking'])) { Parking::buildParkingPagerConditions($q, $joins, false, false, $parking_join, $parking_ltype); } // join with site tables only if needed if (isset($joins['join_site'])) { Site::buildSitePagerConditions($q, $joins, false, false, $site_join, $site_ltype); } // join with image tables only if needed if (isset($joins['join_image'])) { Image::buildImagePagerConditions($q, $joins, false, 'ci'); } if (!empty($conditions)) { $q->addWhere(implode(' AND ', $conditions), $values); } }
public static function buildPagerConditions(&$q, $criteria) { $conditions = $criteria[0]; $values = $criteria[1]; $joins = $criteria[2]; self::buildAreaIdPagerConditions($q, $joins); // join with product tables only if needed if (isset($joins['join_product'])) { Product::buildProductPagerConditions($q, $joins, true); } // join with parkings tables only if needed if (isset($joins['join_hut'])) { $joins['join_parking'] = true; $joins['post_parking'] = true; } if (isset($joins['join_parking'])) { Parking::buildParkingPagerConditions($q, $joins, false, false, 'm.associations', 'pf', 'q'); // join with huts tables only if needed if (isset($joins['join_hut'])) { Hut::buildHutPagerConditions($q, $joins, false, true, 'lp.LinkedLinkedAssociation', 'ph'); } } // join with image tables only if needed if (isset($joins['join_image'])) { Image::buildImagePagerConditions($q, $joins, false, 'fi'); } if (!empty($conditions)) { $q->addWhere(implode(' AND ', $conditions), $values); } }
require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php'; // needed for doctrine connection to work $context = sfContext::getInstance(); $region_id = 1234; $buffer = 10; // summits $summits = Summit::listFromRegion($region_id, $buffer, 'summits', 'AND summit_type != 5'); $csv = ''; foreach ($summits as $summit) { $csv .= sprintf('"%s";"%s";"%s";"http://www.camptocamp.org/summits/popup/%d/fr";"%d"' . "\n", $summit['name'], $summit['lon'], $summit['lat'], $summit['id'], $summit['elevation']); } file_put_contents(GP_DIR . 'sommets_c2c.csv', $csv); $nb_summits = count($summits); echo "Summits exported: {$nb_summits}\n"; // huts $huts = Hut::listFromRegion($region_id, $buffer); $csv = ''; foreach ($huts as $hut) { $csv .= sprintf('"%s";"%s";"%s";"http://www.camptocamp.org/huts/popup/%d/fr";"%d"' . "\n", $hut['name'], $hut['lon'], $hut['lat'], $hut['id'], $hut['elevation']); } file_put_contents(GP_DIR . 'refuges_c2c.csv', $csv); $nb_huts = count($huts); echo "Huts exported: {$nb_huts}\n"; // climbing sites $sites = Site::listFromRegion($region_id, $buffer); $csv = ''; foreach ($sites as $site) { $csv .= sprintf('"%s";"%s";"%s";"http://www.camptocamp.org/sites/popup/%d/fr";"%d"' . "\n", $site['name'], $site['lon'], $site['lat'], $site['id'], $site['elevation']); } file_put_contents(GP_DIR . 'sites_c2c.csv', $csv); $nb_sites = count($sites);