$outing_with_public_transportation = empty($outing_with_public_transportation) ? false : true; $properties = array_merge($properties, array('minElevation' => doctrine_value($item['min_elevation']), 'heightDiffDown' => doctrine_value($item['height_diff_down']), 'outingLength' => doctrine_value($item['outing_length']), 'partialTrip' => $partial_trip, 'usePublicTransportation' => $outing_with_public_transportation, 'trackStatus' => $use_keys ? $track_status : @$track_statuses[$track_status], 'hutStatus' => $use_keys ? $hut_status : @$hut_statuses[$hut_status], 'liftStatus' => $use_keys ? $lift_status : @$lift_statuses[$lift_status])); if ($add_text) { $access_comments = $item_i18n['access_comments']; if (check_not_empty($access_comments) && !$access_comments instanceof sfOutputEscaperObjectDecorator) { if ($text_html) { $access_comments = parse_links(parse_bbcode($description, null, false, false)); } } else { $access_comments = null; } $hut_comments = $item_i18n['hut_comments']; if (check_not_empty($hut_comments) && !$hut_comments instanceof sfOutputEscaperObjectDecorator) { if ($text_html) { $hut_comments = parse_links(parse_bbcode($hut_comments, null, false, false)); } } else { $hut_comments = null; } $description = $item_i18n['description']; if (check_not_empty($description) && !$description instanceof sfOutputEscaperObjectDecorator) { if ($text_html) { $description = parse_links(parse_bbcode($description, null, false, false)); } } else { $description = null; } $properties = array_merge($properties, array('accessComments' => $access_comments, 'hutComments' => $hut_comments, 'outingComments' => $description)); } } echo json_encode(array('type' => 'Feature', 'id' => $item['id'], 'properties' => $properties, 'geometry' => $add_gpx_track ? geojson_geometry($item) : null));
function simple_data($name, $value, $suffix = '') { if (!check_not_empty($value)) { return ''; } if (!empty($suffix)) { $suffix = __($suffix); } return '<em>' . __($name) . '</em> ' . $value . $suffix; }
/** * Executes autocomplete action. * returns formated list of best matching names and their ids */ public function executeAutocomplete() { sfLoader::loadHelpers(array('General')); $model = $this->model_class; $module = c2cTools::model2module($model); $string = $this->getRequestParameter($module . '_name'); // useful protection: if (strlen($string) < sfConfig::get('app_autocomplete_min_chars')) { return $this->renderText('<ul></ul>'); } // return all documents matching $string in given module/model // NB: autocomplete on outings only returns those for which the current user is linked to // autocomplete on articles and images only returns collaborative and proper personal ones (all for moderators) $user = $this->getUser(); $filter_personal_content = !$user->hasCredential('moderator') && ($module == 'articles' || $module == 'images'); $results = Document::searchByName($string, $model, $user->getId(), $filter_personal_content); $nb_results = count($results); if ($nb_results == 0) { return $this->ajax_feedback_autocomplete('no results'); } if ($nb_results > sfConfig::get('app_autocomplete_max_results') && $nb_results < sfConfig::get('app_list_maxline_number')) { // if there are too many results to display, but if there is at least one exact match, it is in the results returned by the db query // we display the exact matches, if any. We translate some special chars and capital letters sfLoader::loadHelpers(array('General')); $simple_string = remove_accents($string); $exact_matches = array(); foreach ($results as $result) { if (remove_accents($result[$this->model_class . 'I18n'][0]['name']) == $simple_string || $module == 'users' && remove_accents($result['private_data']['username']) == $simple_string) { $exact_matches[] = $result; } } if (count($exact_matches)) { $results = $exact_matches; } else { return $this->ajax_feedback_autocomplete('Too many results. Please go on typing...'); } } elseif ($nb_results == sfConfig::get('app_list_maxline_number')) { // we have the maximum number of results returned by the db query, so we assume there are more // before giving up and returning "too many results", we can try some extra things // if we have lat lon info, we try to limit results to those in the neighboorhood if ($this->hasRequestParameter('lat') && $this->hasRequestParameter('lon') && in_array($module, array('sites', 'huts', 'parkings', 'summits'))) { $near_results = Document::searchByName($string, $model, $user->getId(), $filter_personal_content, false, array('lon' => floatval($this->getRequestParameter('lon')), 'lat' => floatval($this->getRequestParameter('lat')))); $nb_near_results = count($near_results); if ($nb_near_results && $nb_near_results < sfConfig::get('app_autocomplete_max_results')) { $results = $near_results; } else { return $this->ajax_feedback_autocomplete('Too many results. Please go on typing...'); } } else { $exact_results = Document::searchByName($string, $model, $user->getId(), $filter_personal_content, true); $nb_exact_results = count($exact_results); if ($nb_exact_results) { $results = $exact_results; $exact_matches = true; } else { return $this->ajax_feedback_autocomplete('Too many results. Please go on typing...'); } } } // build the actual results based on the user's prefered language $items = Language::getTheBest($results, $model); // 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'))) { $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[$this->model_class . 'I18n'][0]['name']), remove_accents($item[$this->model_class . 'I18n'][0]['name'])) <= 3) { $add_region = true; break 2; } } } } if (isset($add_region)) { // 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; } } } // create list of items $html = '<ul>'; foreach ($items as $item) { $identifier = $model == 'Document' ? $this->__(substr($item['module'], 0, -1)) . ' ' : ''; // if module = documents, add the object type inside brackets switch ($model) { case 'Outing': $postidentifier = ' (' . $item['date'] . ')'; // if outings, we append the date break; case 'Summit': case 'Hut': $postidentifier = ' - ' . $item['elevation'] . $this->__('meters'); // if summit or hut, append elevation break; case 'Book': $postidentifier = (check_not_empty($item['author']) ? ' - ' . $item['author'] : '') . (check_not_empty($item['publication_date']) ? ' - ' . $item['publication_date'] : ''); break; case 'User': $postidentifier = ' (' . $item['private_data']['username'] . ')'; // if user, append forum nickname break; default: $postidentifier = ''; } $postidentifier .= isset($item['area_name']) ? ' (' . $item['area_name'] . ')' : ''; // if region attached, we append it $html .= '<li id="' . $item['id'] . '">' . $item[$this->model_class . 'I18n'][0]['name'] . '<span class="informal">' . "<em>{$postidentifier}</em> <small>[{$identifier}" . $item['id'] . ']</small></span></li>'; } if (isset($exact_matches)) { $html .= '<div class="feedback">' . $this->__('only exact matches. Go on typing') . '</div>'; } if (isset($nb_near_results) && $nb_near_results) { $html .= '<div class="feedback">' . $this->__('only near matches. Go on typing') . '</div>'; } $html .= '</ul>'; return $this->renderText($html); }
?> </td> <td><?php echo get_paginated_activities($item['activities']); ?> </td> <td><?php $phone = $item['phone']; if (!empty($phone)) { echo $phone; } ?> </td> <td><?php $url = strval($item['url']); if (check_not_empty($url)) { echo link_to('<span></span>', $url, array('class' => 'external_link', 'title' => __('hut website'))); } ?> </td> <td><?php if (isset($item['linked_docs'])) { include_partial('parkings/parkings4list', array('parkings' => $item['linked_docs'])); } ?> </td> <td><?php include_partial('documents/regions4list', array('geoassociations' => $item['geoassociations'])); ?> </td> <td><?php
<?php use_helper('AutoComplete', 'General', 'Field'); $has_associated_docs = count($associated_docs); $has_extra_docs = isset($extra_docs) && check_not_empty($extra_docs); $show_link_to_delete = isset($show_link_to_delete) ? $show_link_to_delete : false; if (isset($document)) { $id = $document->get('id'); } // correctly set main_id and linked_id $module_letter = c2cTools::Module2Letter($module); $revert_ids = isset($type) ? substr($type, 0, 1) != $module_letter : null; // ghost summit-huts case if (isset($ghost_module)) { $ghost_module_letter = c2cTools::Module2Letter($ghost_module); $revert_ghost_ids = isset($ghost_type) ? substr($ghost_type, 0, 1) != $ghost_module_letter : null; } 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)) . __(' :') . '</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;
} else { $remarks = null; } $gear = $item_i18n['gear']; if (check_not_empty($gear) && !$gear instanceof sfOutputEscaperObjectDecorator) { if ($text_html) { $gear = parse_links(parse_bbcode($gear, null, false, false)); } } else { $gear = null; } $external_resources = $item_i18n['external_resources']; if (check_not_empty($external_resources) && !$external_resources instanceof sfOutputEscaperObjectDecorator) { if ($text_html) { $external_resources = parse_links(parse_bbcode($external_resources, null, false, false)); } } else { $external_resources = null; } $route_history = $item_i18n['route_history']; if (check_not_empty($route_history) && !$route_history instanceof sfOutputEscaperObjectDecorator) { if ($text_html) { $route_history = parse_links(parse_bbcode($route_history, null, false, false)); } } else { $route_history = null; } $properties = array_merge($properties, array('description' => $description, 'remarks' => $remarks, 'gear' => $gear, 'externalResources' => $external_resources, 'routeHistory' => $route_history)); } } echo json_encode(array('type' => 'Feature', 'id' => $item['id'], 'properties' => $properties, 'geometry' => $add_gpx_track ? geojson_geometry($item) : null));
$author_info_name = $version['history_metadata']['user_private_data']['topo_name']; $author_info_id = $version['history_metadata']['user_private_data']['id']; } } echo _format_data('author', link_to($author_info_name, '@document_by_id?module=users&id=' . $author_info_id)); ?> </li> <?php // FIXME sfOutputEscaperObjectDecorator shouldn't be used.. $access_elevation = check_not_empty($item['access_elevation']) && !$item['access_elevation'] instanceof sfOutputEscaperObjectDecorator ? $item['access_elevation'] : 0; $up_snow_elevation = check_not_empty($item['up_snow_elevation']) && !$item['up_snow_elevation'] instanceof sfOutputEscaperObjectDecorator ? $item['up_snow_elevation'] : 0; $down_snow_elevation = check_not_empty($item['down_snow_elevation']) && !$item['down_snow_elevation'] instanceof sfOutputEscaperObjectDecorator ? $item['down_snow_elevation'] : 0; if (check_not_empty($access_elevation) || check_not_empty($up_snow_elevation) || check_not_empty($down_snow_elevation)) { ?> <li><?php if (check_not_empty($access_elevation)) { echo field_data_arg_if_set('access_elevation', $access_elevation, '', 'meters') . ' '; } echo field_data_arg_range_if_set('up_snow_elevation', 'down_snow_elevation', $up_snow_elevation, $down_snow_elevation, 'elevation separator', '', '', 'meters'); ?> </li><?php } ?> </ul> <?php $activities = BaseDocument::convertStringToArray($item['activities']); if (!array_intersect(array(1, 2, 5), $activities)) { $conditions_levels = NULL; } echo '<div class="col_left col_66">'; if (!empty($conditions) || !empty($conditions_levels)) {
// it is already order by id $images = $images->getRawValue(); usort($images, array('c2cTools', 'cmpDateTimeDesc')); if ($mobile_version) { use_helper('JavascriptQueue'); echo javascript_queue('C2C.swipe_i18n = {"Big size": "' . __('Big size') . '",' . '"Original image": "' . __('Original image') . '",' . '"Informations": "' . __('Informations') . '"};'); } foreach ($images as $image) { $caption = $image['name']; $slug = make_slug($image['name']); $lang = $image['culture']; $image_id = $image['id']; $image_type = $image['image_type']; $tag_attributes = array('alt' => $caption); foreach (array('width', 'height', 'file_size') as $prop) { if (isset($image[$prop]) && check_not_empty($image[$prop])) { $tag_attributes['data-' . $prop] = $image[$prop]; } } $image_tag = image_tag(image_url($image['filename'], 'small'), $tag_attributes); $view_details = link_to('details', "@document_by_id_lang_slug?module=images&id={$image_id}&lang={$lang}&slug={$slug}", array('class' => 'view_details', 'title' => __('View image details'))); $view_original = link_to('original', absolute_link(image_url($image['filename'], null, true), true), array('class' => 'view_original', 'title' => __('View original image'))); $edit_image = link_to('edit', "@document_edit?module=images&id={$image_id}&lang={$lang}", array('class' => 'edit_image', 'title' => __('edit_tab_help'))); if ($user_can_dissociate) { $type = c2cTools::Module2Letter($module_name) . 'i'; $strict = (int) ($type == 'ii'); $link = '@default?module=documents&action=removeAssociation&main_' . $type . '_id=' . $document_id . '&linked_id=' . $image_id . '&type=' . $type . '&strict=' . $strict . '&reload=1'; $remove_association = link_to('unlink', $link, array('class' => 'unlink', 'confirm' => __("Are you sure you want to unlink image %1% named \"%2%\" ?", array('%1%' => $image_id, '%2%' => $caption)), 'title' => __('Unlink this association'))); } else { $remove_association = ''; }
public static function EWKT2GeoJSON($ewkt, $maxdecimaldigits = 6) { if (!check_not_empty($ewkt)) { return "null"; } $sql = "SELECT ST_AsGeoJSON(Transform(ST_GeomFromText(?, 900913), 4326), {$maxdecimaldigits}) AS geojson"; return sfDoctrine::connection()->standaloneQuery($sql, array($ewkt))->fetchObject()->geojson; }
?> <li><div class="section_subtitle" id="_hut_comments" data-tooltip=""><?php echo __('hut_comments'); ?> </div> <?php if ($has_hut_status) { echo __($hut_statuses[$hut_status]); } if ($has_hut_comments) { echo parse_links(parse_bbcode($hut_comments, null, false, false)); } ?> </li><?php } $outing_comments = $i18n['description']; if (check_not_empty($outing_comments) && !$outing_comments instanceof sfOutputEscaperObjectDecorator) { //FIXME sfOutputEscaperObjectDecorator ?> <li><div class="section_subtitle" id="_description" data-tooltip=""><?php echo __('comments'); ?> </div><?php echo parse_links(parse_bbcode($outing_comments, null, false, false)); ?> </li> <?php } } ?> </ul> <?php