function loadRessources()
{
    $response = sfContext::getInstance()->getResponse();
    if (!c2cTools::mobileVersion()) {
        $response->addJavascript('/static/js/modal.js', 'last');
        $response->addStylesheet('/static/css/modal.css', 'last');
    }
}
function phone_link($phone = '')
{
    if (!empty($phone) && c2cTools::mobileVersion()) {
        $simple_phone = preg_replace('/\\(0\\)/', '', str_replace(array(' ', '.'), '', $phone));
        // if number is not only digits,+,- do not try to present it as a link
        if (!ereg('[0-9\\+-]+', $simple_phone)) {
            return $phone;
        }
        $link = content_tag('a', $phone, array('href' => 'tel:' . $simple_phone));
        return $link;
    } else {
        return $phone;
    }
}
/**
* Display flash message if needed
*/
function display_flash_message($type)
{
    $flash = sfContext::getInstance()->getUser()->getAttribute($type, null, 'symfony/flash');
    if ($flash) {
        $message = '<div class="' . $type . '" id="' . $type . '"><div>' . $flash . '</div></div>';
        if (!c2cTools::mobileVersion()) {
            // show feedback div, highlight it, and then fade it out and remove it
            $js = javascript_queue("\$('#{$type}').delay(3000).animate({opacity:0}, {duration:1500, complete: function() { \$(this).hide(); }});");
        } else {
            $js = javascript_queue("\$('#{$type}').click(function() { \$(this).hide(); });");
        }
        return $message . $js;
    }
}
function geocode_auto_complete($name, $service)
{
    $mobile_version = c2cTools::mobileVersion();
    $service_class = $service === 'nominatim' ? ' nominatim' : ' geonames';
    $out = input_tag($name, '', array('class' => 'geocode_auto_complete' . $service_class, 'placeholder' => __('enter place name'), 'data-noresult' => __('no results')));
    if ($mobile_version) {
        $out .= content_tag('span', '<br />' . __('autocomplete_help'), array('class' => 'mobile_auto_complete_background'));
        $out .= content_tag('span', 'X', array('class' => 'mobile_auto_complete_escape'));
    }
    // following script will automatically intanciate geocode autocompleter
    $out .= javascript_queue('$.ajax({
      url: "' . minify_get_combined_files_url('/static/js/geocode_autocompleter.js') . '",
      dataType: "script",
      cache: true});');
    return $out;
}
function language_select_list($module, $id, $current_language, $translated_languages)
{
    $mobile_version = c2cTools::mobileVersion();
    $items = array();
    foreach (Language::getAll() as $language => $value) {
        $lang = format_language_c2c($language);
        if ($current_language == $language) {
            $items[] = '<div class="current_lang">' . ($mobile_version ? $language : $lang) . '</div>';
        } else {
            $existing_lang = in_array($language, $translated_languages);
            $options = $existing_lang ? array('class' => 'translated') : array('class' => 'not_translated', 'rel' => 'nofollow');
            if (!$mobile_version) {
                $items[] = link_to($lang, "@document_by_id_lang?module={$module}&id={$id}&lang={$language}", $options);
            } else {
                $items[] = $existing_lang ? link_to($language, "@document_by_id_lang?module={$module}&id={$id}&lang={$language}", $options) : '<span class="not_translated">' . $language . '</span>';
            }
        }
    }
    return implode(' |&nbsp;', $items);
}
 public function executeGetmultipleselect()
 {
     $mobile_version = c2cTools::mobileVersion();
     $separate_prefs = $this->hasRequestParameter('sep_prefs') ? $this->getRequestParameter('sep_prefs') : 'true';
     $separate_prefs = $separate_prefs == 'false' ? false : true;
     $area_type = $this->getRequestParameter('area_type');
     if (!$mobile_version) {
         $default_width = 'auto';
         $default_height = '350px';
     } else {
         $default_width = '216px';
         $default_height = '3.8em';
     }
     $height = $this->hasRequestParameter('height') ? $this->getRequestParameter('height') . 'px' : $default_height;
     $width = $this->hasRequestParameter('width') ? $this->getRequestParameter('width') . 'px' : $default_width;
     $select_id = $this->hasRequestParameter('select_id') ? $this->getRequestParameter('select_id') : 'places';
     $select_name = $this->hasRequestParameter('select_id') ? $this->getRequestParameter('select_name') : 'areas';
     $areas = $this->getAreas($area_type, $separate_prefs);
     sfLoader::loadHelpers(array('Tag', 'Form'));
     return $this->renderText(select_tag($select_name, options_for_select($areas, $separate_prefs ? null : c2cPersonalization::getInstance()->getPlacesFilter()), array('id' => $select_id, 'multiple' => true, 'style' => 'width:' . $width . '; height:' . $height . ';')) . input_hidden_tag($select_id . '_type', $area_type));
 }
function start_section_tag($label, $container_id, $state = 'opened', $map = false, $first = false, $hide = false, $show_tip = true)
{
    $class = 'article_titre_bg';
    if ($first) {
        $class .= ' hfirst';
    }
    $picto_class = $state == 'opened' ? 'picto_close' : 'picto_open';
    $status = __($state == 'opened' ? 'section close' : 'section open');
    $label = picto_tag($picto_class, '', array('id' => $container_id . '_toggle')) . __($label);
    if ($show_tip && !c2cTools::mobileVersion()) {
        $label .= '<span id="tip_' . $container_id . '" class="tips">[' . $status . ']</span>';
        $up = '<a href="#header">' . picto_tag('action_up', __('menu'), array('class' => 'go_up')) . '</a>';
    } else {
        $up = '';
    }
    $style = $hide ? '" style="display:none' : '';
    $html = '<div class="' . $class . '" id="' . $container_id . '_tbg' . $style . '">' . '<div class="title" id="' . $container_id . '_section_title" title="' . $status . '">' . '<a href="#" id="' . $container_id . '" data-toggle-view="' . $container_id . '">' . $label . '</a>' . $up . '</div>' . '</div>';
    if (!$map) {
        $display = $state == 'opened' && !$hide ? '' : ' style="display:none;"';
        $html .= '<section id="' . $container_id . '_section_container" class="section"' . $display . '>';
    }
    return $html;
}
<?php

use_helper('Pagination', 'MyImage', 'Lightbox', 'JavascriptQueue', 'Link', 'Viewer', 'General');
$mobile_version = c2cTools::mobileVersion();
$id = $sf_params->get('id');
$lang = $sf_params->get('lang');
if (!$mobile_version) {
    // add lightbox ressources
    addLbMinimalRessources();
} else {
    echo javascript_queue('C2C.swipe_i18n = {"Big size": "' . __('Big size') . '",' . '"Original image": "' . __('Original image') . '",' . '"Informations": "' . __('Informations') . '"};');
    use_javascript('/static/js/swipe.js', 'last');
    use_javascript('/static/js/swipe.wrapper.js', 'last');
}
echo display_title(__('images list'), $sf_params->get('module'), false, 'list_nav');
if (!c2cTools::mobileVersion()) {
    echo '<div id="nav_space">&nbsp;</div>';
    include_partial('nav4list');
    //include_partial('documents/nav_news');
}
echo display_content_top('list_content');
echo start_content_tag('images_content');
if (!$mobile_version) {
    echo javascript_tag('lightbox_msgs = Array("' . __('View image details') . '","' . __('View original image') . '");');
}
echo '<p class="list_header">' . __('images presentation');
if ($nb_results == 0) {
    echo '<br /><br />' . __('there is no %1% to show', array('%1%' => __('images'))) . '</p>';
} else {
    echo '</p>';
    $pager_navigation = pager_navigation($pager);
if ($has_associated_docs || $has_extra_docs) {
    ?>
<div class="one_kind_association">
<div class="association_content">
<?php 
    echo '<div class="assoc_img picto_' . $module . '" title="' . ucfirst(__($module)) . '"><span>' . ucfirst(__($module)) . __('&nbsp;:') . '</span></div>';
    if ($has_associated_docs) {
        $is_inline = isset($inline);
        //case for users list in outings
        $has_merge_inline = isset($merge_inline) && trim($merge_inline) != '';
        if ($is_inline) {
            echo '<div class="linked_elt">';
        }
        $is_first = true;
        $reduce_name = isset($reduce_name) && $reduce_name;
        $has_route_list_link = isset($route_list_module) && !empty($route_list_ids) && !c2cTools::mobileVersion();
        if ($has_route_list_link) {
            $base_url = 'routes/list?';
            $param2 = "{$route_list_module}={$route_list_ids}";
            $link_text = substr(__('routes'), 0, 1);
            $title = "routes linked to {$module} and {$route_list_module}";
        }
        foreach ($associated_docs as $doc) {
            $is_doc = isset($doc['is_doc']) && $doc['is_doc'];
            $doc_id = $doc['id'];
            $idstring = isset($type) ? ' id="' . $type . '_' . ($revert_ids ? $id : $doc_id) . '"' : '';
            $class = 'linked_elt';
            $level = isset($doc['level']) ? $doc['level'] : 0;
            if ($level > 1) {
                $class .= ' level' . $level;
            }
 /**
  * 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);
     }
 }
Exemple #11
0
$license_url .= $sf_user->getCulture();
$license_name = 'Creative Commons ' . __($license);
$license_title = __("{$license} title");
$class = 'license_box';
if (isset($large) && $large) {
    $class .= ' large';
}
?>
<footer class="<?php 
echo $class;
?>
">
<?php 
echo '<div class="cc">' . link_to(picto_tag(($iscopyright ? '' : 'cc-') . $license), getMetaArticleRoute('licenses', false, ($iscopyright ? '' : 'cc-') . $license), array('title' => $license != 'copyright' ? 'Creative Commons' : 'Copyright')) . '</div>';
echo ' ';
if ($iscopyright) {
    echo __('Image under copyright license');
} else {
    echo __('Page under %1% license', array('%1%' => "<a rel=\"license\" href=\"{$license_url}\" title=\"{$license_title}\">{$license_name}</a>"));
}
echo '<br />' . __('Images are under license specified in the original document of each image');
if (isset($version) && !c2cTools::mobileVersion()) {
    echo '<br /><span class="doc_infos">', __('Version #%1%, date %2%', array('%1%' => $version, '%2%' => format_date($created_at, 'D')));
    if ($sf_user->hasCredential(sfConfig::get('app_credentials_moderator'))) {
        echo '<span class="no_print"> - ', __('Document generated %1% in %2%', array('%1%' => format_datetime(time()), '%2%' => round(1000 * $timer->getElapsedTime()))), '</span>';
    }
    echo '</span>';
}
?>
</footer>
Exemple #12
0
            echo ' <span class="meta">(' . implode(' - ', $outing_data) . ')</span>';
        }
        if (isset($item['nb_images'])) {
            $images = picto_tag('picto_images_light', format_number_choice('[1]1 image|(1,+Inf]%1% images', array('%1%' => $item['nb_images']), $item['nb_images'])) . ' ';
            echo $images;
        }
        ?>
            </li>
    <?php 
    }
    ?>
    </ul>
<?php 
}
?>
<div class="home_link_list">
<?php 
echo link_to($custom_footer_text, $custom_footer_link) . ' - ' . link_to(__('recent conditions'), $conditions_link) . ' - ' . link_to(__('Prepare outing'), getMetaArticleRoute('prepare_outings'));
if ($sf_user->isConnected() && !c2cTools::mobileVersion()) {
    echo ' - ' . button_wizard();
}
echo ' - ' . customize_link_to();
?>
</div>
</div>
<?php 
$cookie_position = array_search('last_outings', sfConfig::get('app_personalization_cookie_fold_positions'));
echo javascript_tag('C2C.setSectionStatus(\'last_outings\', ' . $cookie_position . ', ' . (!$default_open ? 'false' : 'true') . ");");
?>
</div>
<?php

use_helper('MyForm');
echo form_tag('documents/search', array('method' => 'get', 'class' => 'search'));
echo '<div class="sbox">';
$prefix = isset($prefix) ? $prefix : '';
$autocomplete = c2cTools::mobileVersion() ? false : (isset($autocomplete) ? $autocomplete : false);
echo search_box_tag($prefix, $autocomplete);
echo '</div></form>';
<?php

use_helper('Language', 'Sections', 'Viewer', 'AutoComplete', 'General', 'MyForm');
$is_connected = $sf_user->isConnected();
$is_moderator = $sf_user->hasCredential(sfConfig::get('app_credentials_moderator'));
$id = $sf_params->get('id');
$lang = $document->getCulture();
$is_not_archive = !$document->isArchive();
$is_not_merged = !$document->get('redirects_to');
$mobile_version = c2cTools::mobileVersion();
$show_link_tool = $is_not_archive && $is_not_merged && $is_connected && !$mobile_version;
display_page_header('articles', $document, $id, $metadata, $current_version, array('item_type' => 'http://schema.org/Article', 'nb_comments' => $nb_comments));
// lang-dependent content
echo start_section_tag('Article', 'description');
include_partial('documents/i18n_section', array('document' => $document, 'languages' => $sf_data->getRaw('languages'), 'needs_translation' => $needs_translation, 'images' => $associated_images, 'filter_image_type' => $document->get('article_type') == 1));
echo end_section_tag();
// lang-independent content starts here
echo start_section_tag('Information', 'data');
include_partial('data', array('document' => $document, 'nb_comments' => $nb_comments));
if ($is_not_archive) {
    echo '<div class="all_associations">';
    include_partial('areas/association', array('associated_docs' => $associated_areas, 'module' => 'areas'));
    echo '</div>';
}
echo end_section_tag();
if ($is_not_archive && $is_not_merged) {
    $is_personal_article = $document->get('article_type') == 2;
    // if the user is not a moderator, and personal article, use javascript to distinguish
    // between document author(s) and others
    $author_specific = !$is_moderator && $is_connected && $is_personal_article;
    if ($author_specific) {
 /**
  * Parses REQUEST sent by filter form and keeps only relevant sort parameters.
  * @return array
  */
 protected function filterSortParameters($result_type = null)
 {
     $sort = array();
     if (($npp = $this->getRequestParameter('npp')) && $npp != (c2cTools::mobileVersion() ? sfConfig::get('app_list_mobile_maxline_number') : sfConfig::get('app_list_maxline_number'))) {
         $sort[] = "npp={$npp}";
     }
     $module = $this->getModuleName();
     if ($module != $result_type && $result_type == 'outings') {
         $sort[] = "orderby=date";
         $sort[] = "order=desc";
     } elseif (is_null($result_type) || $module == $result_type) {
         $default_order = sfConfig::get('app_list_default_order', 'asc');
         $has_orderby = $this->addParam($sort, 'orderby');
         if ($has_orderby) {
             $this->addParam($sort, 'order', $default_order);
         }
         $has_orderby = $this->addParam($sort, 'orderby2');
         if ($has_orderby) {
             $this->addParam($sort, 'order2', $default_order);
         }
         $has_orderby = $this->addParam($sort, 'orderby3');
         if ($has_orderby) {
             $this->addParam($sort, 'order3', $default_order);
         }
     }
     return $sort;
 }
 /**  
  * Executes list action.
  * Overrides documentsActions::executeList()
  */
 public function executeList()
 {
     // params in order to add images of linked summits, parkings, etc...
     $request_array = array();
     if ($this->hasRequestParameter('rsummits') && ($summit_ids = $this->getRequestParameter('rsummits'))) {
         if (!in_array($summit_ids, array('-', ' '))) {
             $request_array = array(explode('-', $summit_ids), 'sr', 'ri', 'si');
         }
     } elseif ($this->hasRequestParameter('rparkings') && ($parking_ids = $this->getRequestParameter('rparkings'))) {
         if (!in_array($parking_ids, array('-', ' '))) {
             $request_array = array(explode('-', $parking_ids), 'pr', 'ri', 'pi');
         }
     } elseif ($this->hasRequestParameter('rhuts') && ($hut_ids = $this->getRequestParameter('rhuts'))) {
         if (!in_array($hut_ids, array('-', ' '))) {
             $request_array = array(explode('-', $hut_ids), 'hr', 'ri', 'hi');
         }
     } elseif ($this->hasRequestParameter('oroutes') && ($route_ids = $this->getRequestParameter('oroutes'))) {
         if (!in_array($route_ids, array('-', ' '))) {
             $request_array = array(explode('-', $route_ids), 'ro', 'oi', 'ri');
         }
     } elseif ($this->hasRequestParameter('osites') && ($site_ids = $this->getRequestParameter('osites'))) {
         if (!in_array($site_ids, array('-', ' '))) {
             $request_array = array(explode('-', $site_ids), 'to', 'oi', 'ti');
         }
     }
     if (!empty($request_array)) {
         $ids = array_shift($request_array);
         $pager = new c2cDoctrinePager('Image', c2cTools::mobileVersion() ? sfConfig::get('app_list_mobile_maxline_number') : sfConfig::get('app_list_maxline_number'));
         $this->pager = $pager;
         $q = $pager->getQuery();
         $q->select('DISTINCT i.id, i.image_type, i.geom_wkt, i.filename, ii.name, ii.culture, ii.search_name')->from('Image i')->leftJoin('i.associations a ON i.id = a.linked_id')->leftJoin('i.ImageI18n ii')->where('(a.main_id IN (SELECT a2.linked_id FROM Association a2 WHERE a2.main_id IN (' . implode(',', $ids) . ') AND a2.type = ?) AND a.type = ?)' . ' OR (a.main_id IN (' . implode(',', $ids) . ') AND a.type = ?)', $request_array);
         $pager->setPage($this->getRequestParameter('page', 1));
         $pager->init();
         $nb_results = $pager->getNbResults();
         $this->nb_results = $nb_results;
         // deal with format
         if (isset($this->format)) {
             $format = $this->format;
         } else {
             $format = $this->getRequestParameter('format', 'list');
             $format = explode('-', $format);
             $this->format = $format;
         }
         if ($nb_results == 0 && !in_array('json', $format)) {
             $params_list = array_keys(c2cTools::getCriteriaRequestParameters());
             if (count($params_list) == 1) {
                 $param = reset($params_list);
                 if (strpos($param, 'nam') !== false) {
                     $this->query_string = $this->getRequestParameter($param);
                     $this->setTemplate('../../documents/templates/simplenoresult');
                 }
             }
         } else {
             $this->items = $pager->getResults('array');
         }
         $this->setPageTitle($this->__($this->getModuleName() . ' list'));
         $this->setTemplate('list');
     } else {
         parent::executeList();
         $nb_results = $this->nb_results;
         if ($nb_results == 0) {
             return;
         }
         $items = $this->query->execute(array(), Doctrine::FETCH_ARRAY);
         $this->items = Language::parseListItems($items, 'Image');
         $this->setTemplate('list');
     }
     if (in_array('json', $this->format)) {
         $this->setJsonResponse();
         $this->setTemplate('../../documents/templates/jsonlist');
     }
 }
/* In this section we put code for immediately hiding some sections according
 * to preferences stored in fold cookie
 *
 * The sections are hidden (or not) right after they are created in the DOM in
 * order to prevent visual glitches. Thus, the javascript has to be ready from
 * the beginning. As the file is kept very small (less than 1kb) it is ok to inline
 * it, avoiding an extra request.
 *
 * Following js code is the minified version of the web/static/fold_init*.js files
 * We have different vesions depending on the different use cases. Basically, the
 * following sections can be concerned:
 * - left navigation on standard version (every page)
 * - sections on home and portals
 * - map section (n that cases, some additional code is added by the map partials)
 */
$mobile = c2cTools::mobileVersion();
$module = $sf_context->getModuleName();
$action = $sf_context->getActionName();
if ($mobile) {
    if ($action == 'home' || $module == 'portals' && $action == 'view') {
        // fold_init_home_mobile.js ~ 510b
        ?>
(function(e,t){e.shouldHide=function(e,n){var o=/(?:^|;)\s?fold=([tfx]{20})(?:;|$)/.exec(t.cookie)
if(o)switch(o[1].charAt(e)){case"t":return!1
case"f":return!0}return!n},e.setSectionStatus=function(n,o,a){if(e.shouldHide(o,a)){if("map_container"==n)return!0
var s=e.section_open
t.getElementById(n+"_section_container").style.display="none",t.getElementById(n+"_toggle").title=s
for(var l=t.querySelectorAll("#"+n+" .nav_box_top"),i=0;i<l.length;i++)l[i].className+=" small"}}})(window.C2C=window.C2C||{},document)
<?php 
    } else {
        // fold init_default_mobile.js ~280b
function field_value_selector($name, $conf, $options)
{
    $blank = _option($options, 'blank', false);
    $keepfirst = _option($options, 'keepfirst', true);
    $multiple = _option($options, 'multiple', false);
    $size = c2cTools::mobileVersion() ? _option($options, 'msize', 1) : _option($options, 'size', 0);
    $filled_options = _option($options, 'filled_options', true);
    $exclude = _option($options, 'exclude', null);
    $values = array_map('__', sfConfig::get($conf));
    if ($exclude) {
        $exclude = is_array($exclude) ? $exclude : array($exclude);
        foreach ($exclude as $value) {
            unset($values[$value]);
        }
    }
    if (!$keepfirst) {
        unset($values[0]);
    }
    if ($filled_options) {
        $values[' '] = __('filled in');
        $values['_'] = __('nonwell informed');
    }
    $option_tags = options_for_select($values, '', array('include_blank' => $blank));
    if ($multiple) {
        $select_param = array('multiple' => true);
        if ($size == 0) {
            $size = count($values);
            if ($filled_options) {
                $size -= 2;
            }
        }
        $select_param['size'] = $size;
    } else {
        $select_param = array();
    }
    return select_tag($name, $option_tags, $select_param);
}
function start_content_tag($content_class = '', $home = false)
{
    $mobile_version = c2cTools::mobileVersion();
    if (!empty($content_class)) {
        $content_class = ' ' . $content_class;
    }
    $js_tag = javascript_tag("C2C.setSectionStatus('nav', C2C.nav_status_cookie_position, C2C.default_nav_status)");
    // TODO move smwhr else?
    return '<div class="content_article">' . (!$mobile_version ? '<div id="splitter" data-title-reduce="' . __('Reduce the bar') . '" data-title-enlarge="' . __('Enlarge the bar') . '"></div>' . $js_tag : '') . '<article class="article' . $content_class . '">';
}
Exemple #20
0
<?php

echo '(' . f_link_to($UnreadMsg, 'message_list.php') . ')';
if ($UnreadMsg && !c2cTools::mobileVersion()) {
    use_helper('JavascriptQueue');
    echo javascript_queue("\$.ajax({ url: '" . minify_get_combined_files_url('/static/js/tinycon.min.js') . "', dataType: 'script', cache: true })\n      .done(function() { Tinycon.setBubble({$UnreadMsg}); });");
}
<?php

use_helper('JavascriptQueue', 'Form', 'MyMinify');
if (!empty($message) || $sf_user->hasCredential('moderator') && !c2cTools::mobileVersion()) {
    $output_message = empty($message) ? __('No message defined. Click to edit') : $sf_data->getRaw('message');
    // unescaped data : we trust moderators !
    ?>
    <div id="edit_me" class="front_message"><?php 
    echo $output_message;
    ?>
</div>
    <?php 
    if ($sf_user->hasCredential('moderator') && !$mobile_version) {
        echo javascript_queue("\n          \$.ajax({\n            url: '" . minify_get_combined_files_url('/static/js/jquery.jeditable.js') . "',\n            dataType: 'script',\n            cache: true})\n          .done(function() {\n            \$('#edit_me')\n              .addClass('editable')\n              .editable('" . url_for('@default?module=common&action=edit&lang=' . $sf_user->getCulture()) . "', {\n                type: 'textarea',\n                submit: '<input type=\"submit\" value=\"" . __('Update') . "\" />',\n                cancel: '<input type=\"submit\" value=\"" . __('Cancel') . "\" />',\n                indicator: '" . __('saving...') . "',\n                tooltip: '" . __('Click to edit') . "',\n                onblur: 'ignore',\n                rows: 4\n              });\n          });");
    }
}
 /**
  * Detects list sort parameters: what field to order on, direction and 
  * number of items per page (npp).
  * @return array
  */
 public static function getListSortCriteria($model = 'Document', $default_npp = null, $max_npp = 100, $mi = 'mi')
 {
     $orderby_list = c2cTools::getRequestParameterArray(array('orderby', 'orderby2', 'orderby3'));
     $order_list = c2cTools::getRequestParameterArray(array('order', 'order2', 'order3'), sfConfig::get('app_list_default_order'));
     if (empty($default_npp)) {
         $default_npp = c2cTools::mobileVersion() ? sfConfig::get('app_list_mobile_maxline_number') : sfConfig::get('app_list_maxline_number');
     }
     $npp = c2cTools::getRequestParameter('npp', $default_npp);
     if (!empty($max_npp)) {
         $npp = min($npp, $max_npp);
     }
     return self::buildSortCriteria($model, $orderby_list, $order_list, $npp, $mi);
 }
function format_book_data($books, $type, $main_id, $is_moderator = false)
{
    $type_list = $type . '_list';
    $module = 'books';
    $main_module = c2cTools::Letter2Module(substr($type, 1, 1));
    $strict = 1;
    $html = '<div class="association_content_inside_field">';
    foreach ($books as $book) {
        $doc_id = $book['id'];
        $idstring = $type . '_' . $doc_id;
        $class = 'linked_elt';
        $html .= '<div class="' . $class . '" id="' . $idstring . '">' . '<div class="assoc_img picto_' . $module . '" title="' . ucfirst(__($module)) . '"></div>';
        $name = ucfirst($book['name']);
        $url = "@document_by_id_lang_slug?module={$module}&id={$doc_id}" . '&lang=' . $book['culture'] . '&slug=' . make_slug($book['name']);
        $html .= link_to($name, $url);
        if (isset($book['author']) && trim($book['author']) != '') {
            $html .= ' - ' . $book['author'];
        }
        if (isset($book['publication_date']) && trim($book['publication_date']) != '') {
            $html .= ' - ' . $book['publication_date'];
        }
        if ($is_moderator && $main_id && !c2cTools::mobileVersion()) {
            $html .= c2c_link_to_delete_element($type, $doc_id, $main_id, false, $strict);
        }
        $html .= '</div>';
    }
    $html .= '</div>';
    return $html;
}
<?php

$document = isset($document) ? $document : null;
if ($sf_user->isConnected() && $document && !$document->get('geom_wkt') && !c2cTools::mobileVersion()) {
    if (!isset($message)) {
        $message = 'No geom info, please edit this document to add some';
    }
    ?>
    <p class="default_text"><?php 
    echo __($message);
    ?>
</p>
    <?php 
}
 public function executeManageimages()
 {
     if (!$this->getUser()->isConnected()) {
         $referer = $this->getRequest()->getReferer();
         $this->setErrorAndRedirect('You need to login to access this page', $referer);
     }
     $user_id = $this->getUser()->getId();
     // logged user id
     $this->pager = new c2cDoctrinePager('Image', c2cTools::mobileVersion() ? sfConfig::get('app_list_mobile_maxline_number') : sfConfig::get('app_list_maxline_number'));
     $q = $this->pager->getQuery();
     $q->select('i.id, i.filename, i.image_type, ii.name, ii.culture')->from('Image i')->leftJoin('i.associations a ON i.id = a.linked_id')->leftJoin('i.ImageI18n ii')->leftJoin('i.versions v')->leftJoin('v.history_metadata hm');
     $where = 'i.image_type = 2 AND v.version = 1 AND hm.user_id = ?';
     $document_type = $this->getRequestParameter('dtyp');
     if (!empty($document_type)) {
         if ($document_type <= 1) {
             $types = array('ai', 'mi', 'bi', 'hi', 'pi', 'ri', 'ti', 'si');
         } else {
             $types = array('oi', 'ui');
         }
         $where .= " AND a.type IN ( '" . implode("', '", $types) . "' )";
     } else {
         $document_type = $this->getRequestParameter('ctyp');
         if (!empty($document_type)) {
             $q->leftJoin('a.Article c');
             if ($document_type <= 1) {
                 $document_type = 1;
             } else {
                 $document_type = 2;
             }
             $where .= " AND a.type = 'ci' AND c.article_type = {$document_type}";
         }
     }
     $q->where($where, array($user_id));
     $q->orderBy('i.id DESC');
     $page = $this->getRequestParameter('page', 1);
     $this->pager->setPage($page);
     $this->pager->init();
     $this->page = $page;
     if ($this->getRequest()->getMethod() == sfRequest::POST) {
         // images management
         $switch = $this->getRequestParameter('switch');
         $lang = $this->getUser()->getCulture();
         if (empty($switch)) {
             return $this->setNoticeAndRedirect('No image has been edited', "/users/manageimages?module=users&page={$page}");
         }
         $conn = sfDoctrine::Connection();
         $conn->beginTransaction();
         $history_metadata = new HistoryMetadata();
         $history_metadata->setComment('Switch to collaborative license');
         $history_metadata->set('is_minor', true);
         $history_metadata->set('user_id', $user_id);
         $history_metadata->save();
         foreach ($switch as $image_id) {
             // verify id corresponds to an image created by the user
             $img = Doctrine_Query::create()->select('i.id')->from('Image i')->leftJoin('i.versions v')->leftJoin('v.history_metadata hm')->where('v.version = 1 AND hm.user_id = ? AND i.id = ?', array($user_id, $image_id))->execute();
             if (empty($img)) {
                 $conn->rollback();
                 return $this->setNoticeAndRedirect('You do not have the right to change the license of theses images', "/users/manageimages?module=users&page={$page}");
             }
             $db_doc = Document::find('Image', $image_id);
             $db_doc->set('image_type', 1);
             $db_doc->save();
             // clear cache
             $this->clearCache('images', $image_id, false, 'view');
             $associated_docs = Association::findAllAssociatedDocs($image_id, array('id', 'module'));
             foreach ($associated_docs as $doc) {
                 // clear their view cache
                 $this->clearCache($doc['module'], $doc['id'], false, 'view');
             }
         }
         // apply modifications if everything went fine
         $conn->commit();
         return $this->setNoticeAndRedirect('Your images have been successfully updated', "/users/manageimages?module=users&page={$page}");
     } else {
         // display form
         $this->setPageTitle($this->__('User image management'));
     }
 }
<br />
<?php 
echo '<div class="orderform">' . __('Display');
$npp_options = options_for_select(array('10' => 10, '20' => 20, '30' => 30, '40' => 40, '50' => 50, '100' => 100), c2cTools::mobileVersion() ? 20 : 30);
echo select_tag('npp', $npp_options);
echo __('items per page');
$conf = 'mod_' . $sf_context->getModuleName() . '_sort_criteria';
$sort_fields = array_map('translate_sort_param', sfConfig::get($conf));
// First criteria of order
if (!isset($orderby_default)) {
    $orderby_default = '';
}
$orderby_options = options_for_select($sort_fields, $orderby_default, array('include_blank' => true));
echo select_tag('orderby', $orderby_options);
if (!isset($order_default)) {
    $order_default = '';
}
$order_options = options_for_select(array('asc' => __('ascending'), 'desc' => __('descending')), $order_default, array('include_blank' => true));
echo select_tag('order', $order_options);
// Second criteria of order
echo '<br />' . __('then by');
if (!empty($orderby_default)) {
    $orderby2_options = options_for_select($sort_fields, '', array('include_blank' => true));
} else {
    $orderby2_options = $orderby_options;
}
echo select_tag('orderby2', $orderby2_options);
if (!empty($order_default)) {
    $order2_options = options_for_select(array('asc' => __('ascending'), 'desc' => __('descending')), '', array('include_blank' => true));
} else {
    $order2_options = $order_options;
<?php

use_helper('Language');
$module = $sf_context->getModuleName();
if (!$document->isArchive()) {
    ?>
    <div class="switch_lang">
        <div class="article_infos_titre">
        <?php 
    echo (c2cTools::mobileVersion() ? __('Switch lang short:') : __('Switch lang:')) . '</div>';
    echo language_select_list($module, $document->get('id'), $document->getCulture(), $sf_data->getRaw('languages'));
    // instead of $languages: XSS protection deactivation
    ?>
    </div>
<?php 
}
?>

<?php 
if ($document->isAvailable()) {
    ?>
    <div class="article_contenu">
        <?php 
    $i18n_args = array('document' => $document, 'needs_translation' => isset($needs_translation) ? $needs_translation : false, 'images' => isset($images) ? $images : null);
    if (isset($filter_image_type)) {
        $i18n_args['filter_image_type'] = $filter_image_type;
    }
    if (isset($associated_books)) {
        $i18n_args['associated_books'] = $associated_books;
        $i18n_args['main_id'] = $document->get('id');
    }
 /**
  * Constructor of CaptchaBox. 
  * Initializes foreground and background colors.
  * Initializes X & Y coordinates for image and box.	 
  * @access public
  */
 function CaptchaBox()
 {
     $mobile_version = c2cTools::mobileVersion();
     $this->boxX = $mobile_version ? 40 : 20;
     $this->boxY = $mobile_version ? 40 : 20;
     $this->background = array(255, 255, 255);
     $this->foreground = array(0, 0, 128);
     $this->boxPosX = $_SESSION["x"] ? $_SESSION["x"] : null;
     $this->boxPosY = $_SESSION["y"] ? $_SESSION["y"] : null;
     $this->imageX = $mobile_version ? 292 : 200;
     $this->imageY = 150;
 }
} catch (Exception $e) {
    $items = array();
}
if (count($items) == 0) {
    ?>
    <p><?php 
    echo __('No recent changes available');
    ?>
</p>
<?php 
} else {
    ?>
    <ul class="docs_changes">
    <?php 
    $list_item = 0;
    $max_items = c2cTools::mobileVersion() ? sfConfig::get('app_recent_documents_latest_docs_mobile_limit') : 100;
    foreach ($items as $item) {
        ?>
        <?php 
        if ($list_item > $max_items) {
            break;
        }
        // Add class to know if li is odd or even
        if ($list_item % 2 == 1) {
            ?>
                <li class="odd">
            <?php 
        } else {
            ?>
                <li class="even">
            <?php 
 public static function do_videos($text, $show_videos = true)
 {
     if (stripos($text, '[/video]') !== false) {
         $mobile_version = c2cTools::mobileVersion();
         $width = $mobile_version ? 310 : 400;
         $height = $mobile_version ? 232 : 300;
         $alternatif = '<strong>Flash plugin needed</strong>';
         // first replace all [video] by [video $width,$height]
         // for mobile version, we force the dimensions
         $text = $mobile_version ? preg_replace('#\\[video( ([0-9]{2,4}),([0-9]{2,4}))?\\]#i', "[video {$width},{$height}]", $text) : preg_replace('#\\[video\\]#i', "[video {$width},{$height}]", $text);
         if ($show_videos) {
             $patterns = array('#\\[video( ([0-9]{2,4}),([0-9]{2,4}))?\\]https?:\\/\\/(www\\.)?youtube\\.com/watch\\?([=&\\w]+&)?v=([-\\w]+)(&.+)?(\\#.*)?\\[/video\\]#isU', '#\\[video( ([0-9]{2,4}),([0-9]{2,4}))?\\]https?:\\/\\/(www\\.)?youtu\\.be/([-\\w]+)(\\#.*)?\\[/video\\]#isU', '#\\[video( ([0-9]{2,4}),([0-9]{2,4}))?\\]https?://www\\.dailymotion\\.com/video/([\\da-zA-Z]+)_[-&;\\w]+(\\#.*)?\\[/video\\]#isU', '#\\[video( ([0-9]{2,4}),([0-9]{2,4}))?\\]https?://video\\.google\\.com/videoplay\\?docid=(\\d+)(\\#.*)?\\[/video\\]#isU', '#\\[video( ([0-9]{2,4}),([0-9]{2,4}))?\\]https?://(www\\.)?vimeo\\.com/(\\d+)(\\#.*)?\\[/video\\]#isU', '#\\[video( ([0-9]{2,4}),([0-9]{2,4}))?\\]https?://www\\.metacafe\\.com/watch/(\\d+/[_a-z]+)(/|\\.swf)(\\#.*)?\\[/video\\]#isU');
             $replacements = array('<iframe class="video youtube-player" width="$2" height="$3" src="//www.youtube.com/embed/$6"></iframe>', '<iframe class="video youtube-player" width="$2" height="$3" src="//www.youtube.com/embed/$5"></iframe>', '<iframe class="video" width="$2" height="$3" src="//www.dailymotion.com/embed/video/$4?theme=none&amp;wmode=transparent"></iframe>', '<object class="video" width="$2" height="$3" data="http://video.google.com/googleplayer.swf?docId=$4"><param name="movie" value="http://video.google.com/googleplayer.swf?docId=$4" /><embed src="http://video.google.com/googleplayer.swf?docId=$4" type="application/x-shockwave-flash" width="$2" height="$3" /></object>', '<iframe class="video" src="//player.vimeo.com/video/$5?title=0&amp;byline=0&amp;portrait=0&amp;color=ff9933" width="$2" height="$3"></iframe>', '<iframe class="video" src="http://www.metacafe.com/embed/$4/" width="$2" height="$3" allowFullScreen frameborder=0></iframe>');
         } else {
             $patterns = array('#\\[video(.*?)\\](.*)\\[/video\\]\\n?#s');
             $replacements = array('');
         }
         $text = preg_replace($patterns, $replacements, $text);
     }
     return $text;
 }