コード例 #1
0
ファイル: _rss_item.php プロジェクト: snouhaud/camptocamp.org
<?php

$feedItem = new sfGeoFeedItem();
$i18n = $item['ArticleI18n'][0];
$feedItem->setTitle($i18n['name']);
$id = $item['id'];
$lang = $i18n['culture'];
$feedItem->setLink("@document_by_id_lang_slug?module=articles&id={$id}&lang={$lang}&slug=" . make_slug($i18n['name']));
$feedItem->setUniqueId(sfRouting::getInstance()->getCurrentInternalUri() . '_' . $id);
$feedItem->setAuthorName($item['creator']);
$feedItem->setPubdate(strtotime($item['creation_date']));
$data = array();
$data[] = get_paginated_value_from_list($item['categories'], 'mod_articles_categories_list');
if (isset($item['activities']) && is_string($item['activities'])) {
    $data[] = get_paginated_activities($item['activities'], true);
}
$data[] = get_paginated_value($item['article_type'], 'mod_articles_article_types_list');
$feedItem->setDescription(implode(' - ', $data));
$feed->addItem($feedItem);
コード例 #2
0
 public function executeQuicksearch()
 {
     $query_string = $this->getRequestParameter('q');
     if (($module = $this->getRequestParameter('type')) && in_array($module, sfConfig::get('app_modules_list'))) {
         $model = c2cTools::module2model($module);
     } else {
         if ($module == 'forums') {
             return $this->renderText('<ul></ul>');
         } else {
             $model = 'Document';
             $module = 'documents';
         }
     }
     // search
     $items = Document::quickSearchByName($query_string, $model);
     $nb_results = count($items);
     if ($nb_results == 0 || $nb_results > sfConfig::get('app_autocomplete_max_results')) {
         return $this->renderText('<ul></ul>');
     }
     $items = Language::getTheBest($items, $model);
     // FIXME this part is a bit dirty..
     // + can't we do it in only one request?
     if ($model == 'Route') {
         $routes = array();
         foreach ($items as $item) {
             $routes[] = array('id' => $item['id'], 'name' => $item[$model . 'I18n'][0]['name'], 'activities' => $item['activities']);
         }
         $items = Route::addBestSummitName($routes, $this->__(' :') . ' ');
     }
     // if module = summit, site, parking or hut, check for similarities and if any, append regions for disambiguation
     if (in_array($model, array('Summit', 'Site', 'Parking', 'Hut'))) {
         sfLoader::loadHelpers(array('General'));
         $items_copy = $items;
         for ($i = 1; $i < count($items); $i++) {
             $item_cmp = array_shift($items_copy);
             foreach ($items_copy as $item) {
                 if (levenshtein(remove_accents($item_cmp[$model . 'I18n'][0]['name']), remove_accents($item[$model . 'I18n'][0]['name'])) <= 3) {
                     $add_region = true;
                     break 2;
                 }
             }
         }
     }
     if (isset($add_region)) {
         $tmp = array();
         foreach ($items as $item) {
             $tmp[$item['id']] = $item;
         }
         $items = $tmp;
         // retrieve attached regions best names
         $q = Doctrine_Query::create()->select('m.id, g0.main_id, a.area_type, ai.name, ai.culture')->from("{$model} m")->leftJoin("m.geoassociations g0")->leftJoin('g0.AreaI18n ai')->leftJoin('ai.Area a')->addWhere('g0.main_id IN (' . implode(',', array_keys($items)) . ')')->addWhere("g0.type != 'dm'")->execute(array(), Doctrine::FETCH_ARRAY);
         $areas_array = Language::getTheBestForAssociatedAreas($q);
         // choose the best area description (like in homepage)
         foreach ($areas_array as $item) {
             $area_name = Area::getBestRegionDescription($item['geoassociations']);
             if (!empty($area_name)) {
                 $items[$item['id']]['area_name'] = $area_name;
             }
         }
     }
     $html = '<ul>';
     foreach ($items as $item) {
         $name = isset($item[$model . 'I18n']) ? $item[$model . 'I18n'][0]['name'] : '';
         $suffix = '';
         switch ($model) {
             case 'Route':
                 sfLoader::loadHelpers(array('I18N', 'Pagination'));
                 $name = $item['name'];
                 $suffix = get_paginated_activities($item['activities']);
                 break;
             case 'User':
                 $suffix = '<em>(' . $item['private_data']['username'] . ')</em>';
                 break;
             case 'Summit':
             case 'Site':
             case 'Parking':
             case 'Hut':
                 if (isset($item['area_name'])) {
                     $suffix = '<em>(' . $item['area_name'] . ')</em>';
                 }
                 break;
             case 'Document':
                 $suffix = '<em>(' . $this->__(substr($item['module'], 0, -1)) . ')</em>';
                 break;
         }
         $html .= '<li id="' . $item['id'] . '">' . $name . (empty($suffix) ? '' : ' ' . $suffix) . '</li>';
     }
     $html .= '</ul>';
     return $this->renderText($html);
 }
コード例 #3
0
<?php

use_helper('Date', 'General', 'Field', 'Link');
if (strlen($item['geom_wkt'])) {
    $has_gps_track = picto_tag('action_gps', __('has GPS track'));
} else {
    $has_gps_track = '';
}
$item_i18n = $item['OutingI18n'][0];
$activities = $item['activities'];
?>
<div class="right"><?php 
echo get_paginated_activities($activities);
?>
</div>
<div><?php 
echo list_link($item_i18n, 'outings') . ' ' . $has_gps_track;
?>
</div>
<div>
<?php 
echo _implode(' - ', array(format_date($item['date'], 'D'), link_to($item['creator'], '@document_by_id?module=users&id=' . $item['creator_id'])));
?>
</div>
<div>
<?php 
echo _implode(' - ', array(displayWithSuffix($item['max_elevation'], 'meters'), displayWithSuffix($item['height_diff_up'], 'meters'), isset($item['linked_routes']) ? field_route_ratings_data($item, false, false, false, 'html', $activities) : '', get_paginated_value($item['conditions_status'], 'mod_outings_conditions_statuses_list'), field_frequentation_picto_if_set($item, true)));
?>
</div>
<div><?php 
include_partial('documents/regions4list', array('geoassociations' => $item['geoassociations']));
コード例 #4
0
?>
</td>
<td><?php 
echo $item['author'];
?>
</td>
<td><?php 
echo $item['editor'];
?>
</td>
<td><?php 
echo $item['publication_date'];
?>
</td>
<td><?php 
echo get_paginated_activities($item['activities']);
?>
</td>
<td><?php 
echo get_paginated_value_from_list($item['book_types'], 'mod_books_book_types_list');
?>
</td>
<td><?php 
echo get_paginated_value_from_list($item['langs'], 'app_languages_book');
?>
</td>
<td><?php 
echo isset($item['nb_images']) ? $item['nb_images'] : '';
?>
</td>
<td><?php 
コード例 #5
0
 $culture = $sf_user->getCulture();
 $date = 0;
 foreach ($items as $item) {
     echo '<tr><td>';
     $timedate = $item['date'];
     if ($is_mobile_version) {
         $text_date = $timedate;
     } else {
         $text_date = format_date($timedate, 'D');
     }
     if ($timedate != $date || $is_mobile_version) {
         echo '<time datetime="' . $timedate . '">' . $text_date . '</time>';
         $date = $timedate;
     }
     echo '</td><td>';
     echo get_paginated_activities($item['activities'], false, '&nbsp;');
     echo '</td><td>';
     echo list_link($item['OutingI18n'][0], 'outings');
     $max_elevation = displayWithSuffix($item['max_elevation'], 'meters');
     if (!$is_mobile_version) {
         echo '</td><td>';
     }
     if (!empty($max_elevation)) {
         if ($is_mobile_version) {
             echo ' - ';
         }
         echo $max_elevation;
     }
     if (!$is_mobile_version) {
         echo '</td><td>';
     }
コード例 #6
0
<?php

use_helper('Language', 'Viewer', 'sfBBCode', 'SmartFormat', 'Field', 'SmartDate');
// lang-independent content starts here
$i18n = $item['OutingI18n'][0];
echo '<span class="item_title">' . format_date($item['date'], 'dd/MM/yyyy') . ' - ' . get_paginated_activities($item['activities']) . ' - ' . link_to($i18n['name'], '@document_by_id_lang_slug?module=outings&id=' . $i18n['id'] . '&lang=' . $i18n['culture'] . '&slug=' . make_slug($i18n['name'])) . ' - ' . displayWithSuffix($item['max_elevation'], 'meters') . ' - ' . field_route_ratings_data($item, false, true);
if (isset($item['nb_images'])) {
    echo ' - ' . picto_tag('picto_images', __('nb_linked_images')) . '&nbsp;' . $item['nb_images'];
}
if (isset($item['nb_comments'])) {
    echo ' - ' . picto_tag('action_comment', __('nb_comments')) . '&nbsp;' . link_to($item['nb_comments'], '@document_comment?module=outings&id=' . $item['OutingI18n'][0]['id'] . '&lang=' . $item['OutingI18n'][0]['culture']);
}
echo '</span>';
$participants = _format_text_data('participants', $i18n['participants'], null, array('needs_translation' => false, 'show_label' => false, 'show_images' => false));
$documents_versions_id = null;
foreach ($item['versions'] as $version) {
    if (!$documents_versions_id || $version['documents_versions_id'] < $documents_versions_id) {
        $documents_versions_id = $version['documents_versions_id'];
        $author_info_name = $version['history_metadata']['user_private_data']['topo_name'];
        $author_info_id = $version['history_metadata']['user_private_data']['id'];
    }
}
$author = _format_data('author', link_to($author_info_name, '@document_by_id?module=users&id=' . $author_info_id));
echo '<div class="all_associations col_left col_66">';
include_partial('documents/association', array('associated_docs' => array(), 'extra_docs' => array($author, $participants), 'module' => 'users', 'inline' => true));
echo '</div>';
$geoassociations = $item['geoassociations'];
echo '<div class="all_associations col_right col_33">';
include_partial('areas/association', array('associated_docs' => $geoassociations, 'module' => 'areas'));
echo '</div>';
?>