Пример #1
0
<?php

use_helper('sfBBCode', 'SmartFormat');
echo $needs_translation ? '<div class="translatable">' : '';
echo '<div class="field_value">';
echo '<p class="abstract">', parse_links(parse_bbcode_abstract($document->get('abstract'))), '</p>';
if ($document->get('description')) {
    echo parse_links(parse_bbcode($document->get('description'), $images, $filter_image_type));
}
echo '</div>';
echo $needs_translation ? '</div>' : '';
Пример #2
0
 /**
  * Executes view action.
  */
 public function executeView()
 {
     parent::executeView();
     $mobile_version = c2cTools::mobileVersion();
     if (!$this->document->isArchive() && $this->document['redirects_to'] == NULL) {
         sfLoader::loadHelpers(array('Pagination'));
         $user = $this->getUser();
         $prefered_cultures = $user->getCulturesForDocuments();
         $document = $this->document;
         $id = $this->document->get('id');
         $topo_filter = $this->document->get('topo_filter');
         $url_params = array();
         $main_params = unpackUrlParameters($topo_filter, $main_url_params);
         // map filter
         $has_map = $this->document->get('has_map');
         $has_map = !$mobile_version && !empty($has_map);
         $this->has_map = $has_map;
         if ($has_map) {
             $map_filter_temp = $this->document->get('map_filter');
             $map_filter_temp = str_replace(' ', '', $map_filter_temp);
             $map_filter_temp = explode('|', $map_filter_temp);
             $map_filter = array();
             foreach ($map_filter_temp as $filter) {
                 $filter = explode(':', $filter);
                 if (isset($filter[1])) {
                     $map_filter[$filter[0]] = $filter[1];
                 }
             }
             if (empty($map_filter['objects'])) {
                 $map_filter['objects'] = null;
             }
             if (!empty($map_filter['lon']) || !empty($map_filter['lat']) || !empty($map_filter['zoom'])) {
                 if (empty($map_filter['lon'])) {
                     $lon = $this->document->get('lon');
                     if (is_null($lon)) {
                         $lon = 7;
                     }
                 } else {
                     $lon = $map_filter['lon'];
                 }
                 if (empty($map_filter['lat'])) {
                     $lat = $this->document->get('lat');
                     if (is_null($lat)) {
                         $lat = 45.5;
                     }
                 } else {
                     $lat = $map_filter['lat'];
                 }
                 if (empty($map_filter['zoom'])) {
                     $zoom = 6;
                 } else {
                     $zoom = $map_filter['zoom'];
                 }
                 $map_filter['center'] = array($lon, $lat, $zoom);
             } else {
                 $map_filter['center'] = null;
             }
             if (empty($map_filter['height'])) {
                 $map_filter['height'] = null;
             }
             $this->map_filter = $map_filter;
             $this->has_geom = false;
         }
         // user filters:
         $perso = c2cPersonalization::getInstance();
         $langs = $ranges = $activities = array();
         if ($perso->isMainFilterSwitchOn()) {
             $langs = $perso->getLanguagesFilter();
             $names = array_keys($main_params);
             if (!array_intersect($names, array('areas', 'summits', 'sites', 'huts', 'parkings', 'routes', 'books'))) {
                 $ranges = $perso->getPlacesFilter();
             }
             if (!in_array('act', $names)) {
                 $activities = $perso->getActivitiesFilter();
             }
         }
         // latest outings
         $nb_outings = $this->document->get('nb_outings');
         $has_outings = !empty($nb_outings);
         $this->has_outings = $has_outings;
         if ($has_outings) {
             $outing_url_params = array();
             $outing_params = $this->document->get('outing_filter');
             $outing_params = unpackUrlParameters($outing_params, $outing_url_params);
             $outing_langs = $langs;
             $outing_ranges = $ranges;
             $outing_activities = $activities;
             if (isset($outing_params['perso'])) {
                 $perso_params = explode('-', $outing_params['perso']);
                 if (array_intersect(array('areas', 'act', 'cult', 'no'), $perso_params)) {
                     if (!in_array('cult', $perso_params)) {
                         $outing_langs = array();
                     }
                     if (!in_array('areas', $perso_params)) {
                         $outing_ranges = array();
                     }
                     if (!in_array('act', $perso_params)) {
                         $outing_activities = array();
                     }
                 }
             }
             $latest_outings = Outing::listLatest($nb_outings, $outing_langs, $outing_ranges, $outing_activities, $outing_params);
             // choose best language for outings and regions names
             $latest_outings = Language::getTheBest($latest_outings, 'Outing');
             $this->latest_outings = Language::getTheBestForAssociatedAreas($latest_outings);
             $this->outing_url_params = $outing_url_params;
         }
         // latest articles
         $nb_articles = $this->document->get('nb_articles');
         $has_articles = !empty($nb_articles);
         $this->has_articles = $has_articles;
         if ($has_articles) {
             $article_url_params = array();
             $article_params = $this->document->get('article_filter');
             $article_params = unpackUrlParameters($article_params, $article_url_params);
             $this->latest_articles = Article::listLatest($nb_articles, $langs, $activities, $article_params);
             $this->article_url_params = $article_url_params;
         }
         // latest images
         if ($mobile_version) {
             $nb_images = sfConfig::get('app_recent_documents_images_mobile_limit');
         } else {
             $nb_images = $this->document->get('nb_images');
         }
         $has_images = !empty($nb_images);
         $this->has_images = $has_images;
         if ($has_images) {
             $image_url_params = array();
             $image_params = $this->document->get('image_filter');
             $image_params = unpackUrlParameters($image_params, $image_url_params);
             $latest_images = Image::listLatest($nb_images, $langs, $ranges, $activities, $image_params);
             $this->latest_images = Language::getTheBest($latest_images, 'Image');
             $this->image_url_params = $image_url_params;
         }
         // latest videos
         $nb_videos = $this->document->get('nb_videos');
         $has_videos = !$mobile_version && !empty($nb_videos);
         if ($has_videos) {
             $video_url_params = array();
             $video_params = $this->document->get('video_filter');
             $video_params = explode('|', $video_params, 3);
             if (count($video_params) == 3) {
                 $video_item = array('url' => trim($video_params[0]), 'thumbnail' => trim($video_params[1]), 'title' => trim($video_params[2]));
                 $latest_videos = array($video_item);
                 $this->latest_videos = $latest_videos;
             } else {
                 $has_videos = false;
             }
         }
         $this->has_videos = $has_videos;
         // forum 'mountain news' latest active threads
         $nb_news = $this->document->get('nb_news');
         $has_news = !empty($nb_news);
         $this->has_news = $has_news;
         $news_filter_ids = array();
         if ($has_news) {
             $news_filter_temp = $this->document->get('news_filter');
             $news_filter_temp = explode('|', $news_filter_temp);
             $news_filter = array();
             foreach ($news_filter_temp as $filter) {
                 $filter = explode(':', $filter);
                 if (isset($filter[1])) {
                     $news_filter[$filter[0]] = explode(',', $filter[1]);
                 }
             }
             $news_filter_ids = PunbbTopics::getForumIds('app_forum_mountain_news', $langs, $activities, $news_filter);
             $this->latest_mountain_news = PunbbTopics::listLatestById($nb_news, $news_filter_ids);
             $this->news_filter_ids = implode('-', $news_filter_ids);
         }
         // forum latest active threads
         $nb_topics = $this->document->get('nb_topics');
         $has_topics = !empty($nb_topics);
         $this->has_topics = $has_topics;
         if ($has_topics) {
             $forum_filter_temp = $this->document->get('forum_filter');
             $forum_filter_temp = explode('|', $forum_filter_temp);
             $forum_filter = array();
             foreach ($forum_filter_temp as $filter) {
                 $filter = explode(':', $filter);
                 if (isset($filter[1])) {
                     $forum_filter[$filter[0]] = explode(',', $filter[1]);
                 }
             }
             $forum_filter_ids = PunbbTopics::getForumIds('app_forum_public_ids', $langs, $activities, $forum_filter);
             $this->latest_threads = PunbbTopics::listLatestById($nb_topics, $forum_filter_ids);
             $this->forum_filter_ids = implode('-', array_merge($news_filter_ids, $forum_filter_ids));
         }
         $cda_config = sfConfig::get('app_portals_cda');
         if ($id == $cda_config['id']) {
             $description = $this->document->get('description');
             $has_description = !empty($description);
             $this->has_description = $has_description;
             $this->setTemplate('changerdapproche');
         }
         sfLoader::loadHelpers(array('sfBBCode', 'SmartFormat'));
         $abstract = strip_tags(parse_links(parse_bbcode_abstract($this->document->get('abstract'))));
         $this->getResponse()->addMeta('description', $abstract);
     }
 }
$design_files = explode(',', $design_files);
if (count($design_files)) {
    foreach ($design_files as $file) {
        $file = trim($file);
        if (!empty($file)) {
            use_stylesheet('/static/css/' . $file . '.css', 'custom');
        }
    }
}
echo init_js_var(true, 'home_nav', $connected);
echo '<div id="cda_context" class="home article portals_content">';
if (!$mobile_version) {
    echo '<div id="cda_background_left">';
    $lang = $document->getCulture();
    $abstract = $document->get('abstract');
    $abstract = parse_links(parse_bbcode_abstract($abstract));
    $title = __('changerdapproche');
    $know_more_link = getMetaArticleRoute('cda_know_more', false);
    include_partial('portals/welcome', array('sf_cache_key' => $id . '_' . $culture . '_' . $lang, 'title' => $title, 'description' => $abstract, 'know_more_link' => $know_more_link, 'default_open' => true));
    include_partial('portals/wizard_button', array('sf_cache_key' => ($connected ? 'connected' : 'not_connected') . '_' . $culture));
    if ($has_videos) {
        include_partial('portals/latest_videos', array('items' => $latest_videos, 'culture' => $culture, 'default_open' => true));
    }
    if ($has_images && $has_map) {
        echo '<div id="last_images">';
        $image_url_params = $sf_data->getRaw('image_url_params');
        $image_url_params = implode('&', $image_url_params);
        $custom_title_link = 'images/list';
        $custom_rss_link = 'images/rss';
        if (!empty($image_url_params)) {
            $custom_title_link .= '?' . $image_url_params;
Пример #4
0
        } else {
            ?>
                <li class="even">
            <?php 
        }
        $list_item++;
        $id = $item['id'];
        $lang = $item['ArticleI18n'][0]['culture'];
        ?>
            <span class="home_article_title">
            <?php 
        echo link_to($item['ArticleI18n'][0]['name'], "@document_by_id_lang_slug?module=articles&id={$id}&lang={$lang}&slug=" . make_slug($item['ArticleI18n'][0]['name']), array('hreflang' => $lang));
        ?>
            </span>
            <?php 
        echo truncate_article_abstract(parse_links(parse_bbcode_abstract($item['ArticleI18n'][0]['abstract'])), sfConfig::get('app_recent_documents_articles_abstract_characters_limit'));
        ?>
            </li>
    <?php 
    }
    ?>
    </ul>
<?php 
}
?>
<div class="home_link_list">
<?php 
echo link_to($custom_footer_text, $custom_title_link) . ' - ' . link_to(__('Summary'), getMetaArticleRoute('home_articles'));
?>
</div>
</div>
Пример #5
0
 /**
  * Executes view action.
  */
 public function executeView()
 {
     sfLoader::loadHelpers(array('General'));
     parent::executeView();
     if (!$this->document->isArchive() && $this->document['redirects_to'] == NULL) {
         // Add the summit name to route
         $associated_routes = array_filter($this->associated_docs, array('c2cTools', 'is_route'));
         $associated_routes = Route::addBestSummitName($associated_routes, $this->__(' :') . ' ');
         // Include outings additional data
         $associated_outings = array_filter($this->associated_docs, array('c2cTools', 'is_outing'));
         $associated_outings = Outing::fetchAdditionalFields($associated_outings);
         // group all linked docs except images in a single list
         $associated_docs = array_filter($this->associated_docs, array('c2cTools', 'is_not_route'));
         $associated_docs = array_filter($associated_docs, array('c2cTools', 'is_not_outing'));
         $associated_docs = array_filter($associated_docs, array('c2cTools', 'is_not_image'));
         $associated_docs = array_merge($associated_docs, $associated_routes, $associated_outings);
         // sort by document type, name
         if (count($associated_docs)) {
             foreach ($associated_docs as $key => $row) {
                 $module[$key] = $row['module'];
                 $name[$key] = remove_accents($row['name']);
             }
             array_multisort($module, SORT_STRING, $name, SORT_STRING, $associated_docs);
         }
         $this->associated_users = array_filter($associated_docs, array('c2cTools', 'is_user'));
         $this->associated_documents = $associated_docs;
         // Retrieve linked docs areas (except users)
         $parent_ids = array();
         $associated_areas = array();
         foreach ($this->associated_docs as $doc) {
             if ($doc['module'] != 'users') {
                 $parent_ids[] = $doc['id'];
             }
         }
         if (count($parent_ids)) {
             $prefered_cultures = $this->getUser()->getCulturesForDocuments();
             $associated_areas = GeoAssociation::findAreasWithBestName($parent_ids, $prefered_cultures);
         }
         $this->associated_areas = $associated_areas;
         // retrieve related portals, depending on article category
         // Soft mobility articles => changedapproche
         // ice activity + gear, stories or expeditions => ice portal
         $related_portals = array();
         $activities = $this->document->get('activities');
         $categories = $this->document->get('categories');
         if (in_array(7, $categories)) {
             $related_portals[] = 'cda';
         }
         if (array_intersect(array(2, 3, 8), $categories) && in_array(5, $activities)) {
             $related_portals[] = 'ice';
         }
         Portal::getLocalPortals($related_portals, $associated_areas);
         $this->related_portals = $related_portals;
         sfLoader::loadHelpers(array('sfBBCode', 'SmartFormat'));
         $abstract = strip_tags(parse_links(parse_bbcode_abstract($this->document->get('abstract'))));
         $this->getResponse()->addMeta('description', $abstract);
         if (in_array(100, $categories)) {
             $this->getResponse()->addMeta('robots', 'noindex, follow');
         }
     }
 }