function show_georef_map($lon, $lat, $layer) { $lang = sfContext::getInstance()->getUser()->getCulture(); if (empty($layer)) { $layer = sfContext::getInstance()->getModuleName(); } $html = '<div class="section" id="georef_container" style="display:none;">'; $html .= '<div id="map" style="height:400px;width:100%">'; $html .= '<div id="mapLoading">' . image_tag(sfConfig::get('app_static_url') . '/static/images/indicator.gif'); $html .= __('Map is loading...') . '</div>'; $html .= '</div>'; $html .= '</div>'; $async_map = sfConfig::get('app_async_map', false) && !sfContext::getInstance()->getRequest()->getParameter('debug', false); $js = "\n C2C.map_init = function() {\n Ext.get('georef_container').show();\n var lon = Ext.getDom('lon') && Ext.getDom('lon').value || 0;\n var lat = Ext.getDom('lat') && Ext.getDom('lat').value || 0;\n c2corg.Map({\n div: 'map',\n lang: '{$lang}',\n loading: 'mapLoading',\n layers: ['{$layer}'],\n connected: true,\n georef: {\n initialState: {\n lon: lon,\n lat: lat,\n zoom: 15\n },\n callback: function(lonlat) {\n if (lonlat) {\n Ext.getDom('lon').value = Math.round(lonlat.lon*1E6)/1E6;\n Ext.getDom('lat').value = Math.round(lonlat.lat*1E6)/1E6;\n } else {\n Ext.getDom('lon').value = '';\n Ext.getDom('lat').value = '';\n }\n c2corg.coords.update_degminsec('lon');\n c2corg.coords.update_degminsec('lat');\n }\n }\n });\n };"; // asynchronous map loading if ($async_map) { use_helper('MyMinify'); $c2c_script_url = minify_get_combined_files_url(array('/static/js/carto/build/carto.min.js', "/static/js/carto/build/lang-{$lang}.min.js", '/static/js/popup.js', '/static/js/carto/embedded.js'), (bool) sfConfig::get('app_minify_debug')); $js .= "C2C.async_map_init = function() {\n \$.ajax({\n url: '{$c2c_script_url}',\n dataType: 'script',\n cache: true\n }).done(function() {\n C2C.map_init();\n Ext.EventManager.fireDocReady();\n });\n };"; } // if coordinates not set, open automatically open the map if (!$lon && !$lat && !in_array($layer, array('sites', 'users', 'images', 'portals'))) { if ($async_map) { $js .= "C2C.async_map_init()"; } else { $js .= "\$(window).load(C2C.map_init)"; } } $html .= javascript_queue($js); return $html; }
/** * 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; } }
<?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 });"); } }
include_partial('documents/i18n_section', array('document' => $document, 'languages' => $sf_data->getRaw('languages'), 'needs_translation' => $needs_translation, 'images' => $associated_images, 'ids' => $ids)); echo end_section_tag(); include_partial($mobile_version ? 'documents/mobile_map_section' : 'documents/map_section', array('document' => $document)); if ($is_not_archive && $is_not_merged) { echo start_section_tag('Linked routes', 'routes'); include_partial('routes/linked_routes', array('associated_routes' => $associated_routes, 'document' => $document, 'id' => $ids, 'module' => 'parkings', 'type' => 'pr', 'strict' => true)); echo end_section_tag(); echo start_section_tag('Latest outings', 'outings'); include_partial('outings/linked_outings', array('id' => $ids, 'module' => 'parkings', 'items' => $latest_outings, 'nb_outings' => $nb_routes_outings, 'lat' => $lat, 'lon' => $lon)); echo end_section_tag(); if ($section_list['books']) { echo start_section_tag('Linked books', 'linked_books'); include_partial('books/linked_books', array('associated_books' => $associated_books, 'document' => $document, 'type' => 'bp', 'strict' => true)); echo end_section_tag(); } include_partial('documents/images', array('images' => $associated_images, 'document_id' => $id, 'dissociation' => 'moderator', 'is_protected' => $document->get('is_protected'))); if ($mobile_version) { include_partial('documents/mobile_comments', array('id' => $id, 'lang' => $lang, 'nb_comments' => $nb_comments)); } include_partial('documents/annex_docs', array('related_portals' => $related_portals)); } include_partial('documents/license', array('license' => 'by-sa', 'version' => $current_version, 'created_at' => isset($created_at) ? $created_at : null, 'timer' => $timer)); echo end_content_tag(); if (!$mobile_version) { $js = 'if ("geolocation" in navigator) { navigator.geolocation.getCurrentPosition(function(position) { $("#get_directions").next().each(function() { this.href = this.href + \'?lon=\' + position.coords.longitude + \'&lat=\' + position.coords.latitude})})}'; echo javascript_queue($js); } include_partial('common/content_bottom');
//echo form_tag('@user_edit'); echo c2c_form_remote_tag('@signUp'); echo tips_tag('After subscription you will receive an email with a generated password, to confirm, login within %1% days', array('%1%' => sfConfig::get('app_pending_users_lifetime'))); echo group_tag('Username:'******'login_name', 'input_tag', $sf_params->get('login_name'), array('autofocus' => 'autofocus', 'class' => 'long_input')); echo group_tag('Email:', 'email', 'input_tag', $sf_params->get('email'), array('class' => 'long_input', 'type' => 'email')); echo content_tag('div', __('Did you mean %1%?', array('%1%' => '<a class="suggested-email"></a>')), array('class' => 'email-suggestion', 'style' => 'display:none')); echo group_tag('Copy following string:', 'captcha', 'input_tag', null, array('class' => 'long_input')); ?> <img src="<?php echo url_for('@sf_captcha'); ?> " alt="captcha" title="<?php echo __('Copy following string:'); ?> " /> <p class="tips"><?php echo __('captcha test is case-insensitive'); ?> </p> <p style="margin-top:20px"><?php echo c2c_submit_tag(__('Signup')); ?> <?php echo login_link_to(); ?> </p> </form> <?php // load mailcheck, helps users correctly entering their email echo javascript_queue("\$.ajax({ url: '" . minify_get_combined_files_url(array('/static/js/mailcheck.min.js', '/static/js/mailcheck.c2c.js')) . "',\ndataType: 'script', cache: true });");
/** * Executes getautocomplete action. * returns a bit of html and JS to perform autocomplete */ public function executeGetautocomplete() { sfLoader::loadHelpers(array('MyForm')); // retrieve module name on which to perform autocomplete if ($this->hasRequestParameter('module_id')) { $module_id = $this->getRequestParameter('module_id'); $modules = sfConfig::get('app_modules_list'); $module_name = $modules[$module_id]; } elseif ($this->hasRequestParameter('module_name')) { $module_name = $this->getRequestParameter('module_name'); } else { return $this->renderText(''); } $field_prefix = $this->getRequestParameter('field_prefix', ''); $extra_params = $this->getRequestParameter('extra_params'); sfLoader::loadHelpers(array('AutoComplete')); if ($module_name == 'users' && $this->getModuleName() == 'images' && !$this->getUser()->hasCredential('moderator')) { $user = $this->getUser(); $out = input_hidden_tag('document_id', $user->getId(), array('id' => $field_prefix . '_document_id')) . input_hidden_tag('document_module', $module_name, array('id' => $field_prefix . '_document_module')) . $user->getUsername() . ' ' . c2c_submit_tag(__('Link'), array('class' => 'samesize', 'picto' => 'action_create')); } else { if ($module_name != 'routes') { $display_button = $this->getRequestParameter('button') != '0'; $out = input_hidden_tag('document_id', '0', array('id' => $field_prefix . '_document_id')) . input_hidden_tag('document_module', $module_name, array('id' => $field_prefix . '_document_module')) . c2c_auto_complete($module_name, $field_prefix . '_document_id', array('field_prefix' => $field_prefix, 'display_button' => $display_button, 'extra_params' => $extra_params)) . ($display_button ? '</form>' : ''); } else { $summit_id = $field_prefix . '_summit_id'; $div_select = $field_prefix . '_routes_select'; $updated_failure = sfConfig::get('app_ajax_feedback_div_name_failure'); $id = $field_prefix . '_rsummits_name'; $out = input_hidden_tag('document_module', $module_name, array('id' => $field_prefix . '_document_module')) . __('Summit : ') . input_tag('summits_name', '', array('size' => 45, 'id' => $id, 'data-suggest-no-exclude' => 1)) . '<div id="' . $field_prefix . '_associated_routes" name="associated_routes" style="display:none;">' . '<div id="' . $div_select . '" name="' . $div_select . '"></div>' . javascript_queue("var indicator = \$('#indicator');" . "\$('#{$id}').c2cAutocomplete({" . "url: '" . url_for("summits/autocomplete") . "'," . "minChars: " . sfConfig::get('app_autocomplete_min_chars') . (isset($extra_params) ? ", params: '{$extra_params}'" : '') . "}).on('itemselect', function(e, item) {" . "indicator.show();" . "\$.get('" . url_for('summits/getroutes') . "'," . "'summit_id=' + item.id + '&div_prefix={$field_prefix}_&div_name=document_id')" . ".always(function() { indicator.hide(); })" . ".fail(function(data) { C2C.showFailure(data.responseText); })" . ".done(function(data) {" . "\$('#{$div_select}').html(data).parent().show();" . "C2C.getWizardRouteRatings('{$field_prefix}_document_id');" . "});" . "});"); if ($this->getRequestParameter('button') != '0') { $out .= c2c_submit_tag(__('Link'), array('class' => 'samesize', 'picto' => 'action_create')); } $out .= '</div>'; } } return $this->renderText($out); }
<?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"> </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);
echo __('See'); ?> </span> <?php echo select_tag('menu_select', options_for_select($menu_see), array('class' => 'menu_select', 'id' => 'menu_select2')); ?> </div> </div> <div class="menu_entry"> <div class="menu_item middle"> <?php echo f_link_to('<span class="select_button">' . __('Forums') . '</span>', '?lang=' . $lang); ?> </div> </div> <div class="menu_entry"> <div class="menu_item right"> <span class="select_button"><?php echo __('More...'); ?> </span> <?php echo select_tag('menu_select', options_for_select($menu_more), array('class' => 'menu_select', 'id' => 'menu_select3')); ?> </div> </div> </div> </div> <?php echo javascript_queue('$(".menu_select").change(function() { window.location = $(this).find("option:selected").val(); });');
</th> <?php } ?> </tr> </thead> <tbody id="conditions_levels_tbody"> <?php foreach ($conditions_levels as $level => $data) { include_partial('conditions_level', array('fields' => $level_fields, 'level' => $level, 'data' => $data)); } ?> </tbody> </table> <?php echo javascript_queue("\nvar tbody = \$('#conditions_levels_tbody');\nvar next_id = tbody.find('tr').length;\n\n\$('.add-condition-level').click(function(e) {\n e.preventDefault();\n tbody.append('" . addcslashes(get_partial('conditions_level', array('fields' => $level_fields, 'level' => '%%var%%', 'data' => null)), "..\\'\"\\/") . "'.replace(/%%var%%/g, next_id));\n next_id++;\n});\n\ntbody.on('click', '.remove-condition-level', function(e) {\n e.preventDefault();\n \$(this).closest('tr').remove();\n});\n"); echo end_group_tag(); // end of conditions levels fields ?> </div> <?php $activities = $document->getRaw('activities'); if (array_intersect($activities, array(3, 4, 5)) || in_array(2, $activities) && !array_intersect($activities, array(1, 6, 7))) { $conditions_title = 'conditions_and_equipment'; if (array_intersect($activities, array(2, 5))) { $conditions_default = 'conditions_ice_default'; } else { $conditions_default = 'conditions_rock_default'; } } else { if (array_intersect($activities, array(1, 7))) {
<?php use_helper('JavascriptQueue'); ?> <div id="preview" style="display:none;"> </div> <?php if ($concurrent_edition) { echo javascript_queue("\$.post('" . url_for($sf_context->getModuleName() . "/ViewCurrent?id={$id}&lang={$lang}") . "')\n.done(function(data) {\n var preview = \$('#preview');\n preview.html(data).show();\n \$('html, body').animate({scrollTop: preview.offset().top - 35}, 2000);\n});"); }
?> <?php if ($is_connected && !$is_archive && !$redirected) { ?> <li><?php echo button_rotate(90, $id); ?> </li> <li><?php echo button_rotate(-90, $id); ?> </li> <?php if (!$has_rights && $document->get('image_type') == 2) { echo javascript_queue('if (' . $creator_id . ' != $("#name_to_use").attr("data-user-id")) { $(".action_rotate").hide(); }'); } ?> <?php } ?> <?php if ($has_rights && !$is_archive) { ?> <li><?php echo button_delete($module, $id); ?> </li> <li><?php echo button_delete_culture($module, $id, $document->get('culture'));
function show_map($container_div, $document, $lang, $layers_list = null, $height = null, $center = null, $has_geom = null, $connected = false) { // define div identifiers $map_container_div_id = $container_div . '_section_container'; $app_static_url = sfConfig::get('app_static_url'); $objects_list = array(); if ($has_geom or is_null($has_geom)) { if ($document->get('geom_wkt') != null) { // FIXME // When using polygons in openlayers, we have a bug preventing to pan the map when mouse cursor is above // a polygon object // As a workaround, we have replaced polygons by linestrings in javascript code. This was not working well with // multipolygons. // Eventually we directly modify this helper to replace MULTIPOLYGON by MULTILINESTRINGS $geom = $document->get('geom_wkt'); if (substr($geom, 0, 7) == 'POLYGON') { $geom = str_replace('POLYGON', 'MULTILINESTRING', $geom); } if (substr($geom, 0, 12) == 'MULTIPOLYGON') { $geom = str_replace(array('MULTIPOLYGON', '((', '))'), array('MULTILINESTRING', '(', ')'), $geom); } $objects_list[] = _convertObjectToGeoJSON($document, $geom); } } // we display possible associated docs foreach (array('summits', 'parkings', 'huts') as $type) { if (!isset($document->{$type})) { continue; } _addAssociatedDocsWithGeom($document->{$type}, $objects_list); } if (is_null($layers_list)) { $layers_list = '[]'; } else { if (!is_array($layers_list)) { $layers_list = str_replace(' ', '', $layers_list); $layers_list = explode(',', $layers_list); } $layers_list = "['" . implode("','", $layers_list) . "']"; } if (is_null($height)) { $height = 400; } else { $height = min(800, max(400, $height)); } if (is_null($center)) { $init_center = '[]'; } else { if (!is_array($center)) { $init_center = str_replace(' ', '', $center); } else { $init_center = implode(', ', $center); } $init_center = '[' . $init_center . ']'; } $html = '<section class="section" id="' . $map_container_div_id . '"><div class="article_contenu">'; $html .= '<div id="map" style="height:' . $height . 'px;width:auto">'; $html .= '<div id="mapLoading" style="position:absolute">' . image_tag($app_static_url . '/static/images/indicator.gif'); $html .= __('Map is loading...') . '</div>'; $html .= '</div>'; $html .= '</div></section>'; $async_map = sfConfig::get('app_async_map', false) && !sfContext::getInstance()->getRequest()->getParameter('debug', false); $connected = $connected ? 'true' : 'false'; $js = "\n C2C.map_init = function() {\n c2corg.Map({\n div: 'map',\n lang: '{$lang}',\n loading: 'mapLoading',\n layers: {$layers_list},\n center: {$init_center},\n features: " . _makeFeatureCollection($objects_list) . ",\n connected: {$connected}\n });\n };"; // asynchronous map loading if ($async_map) { use_helper('MyMinify'); $c2c_script_url = minify_get_combined_files_url(array('/static/js/carto/build/carto.min.js', "/static/js/carto/build/lang-{$lang}.min.js", '/static/js/popup.js', '/static/js/carto/embedded.js'), (bool) sfConfig::get('app_minify_debug')); // Ext.onReady doesn't seem to fire if extjs is loaded after the dom has been loaded // (but works in chrome???) // so we manually trigger it to be sure $js .= "\n C2C.async_map_init = function() {\n \$.ajax({\n url: '{$c2c_script_url}',\n dataType: 'script',\n cache: true\n }).done(function() {\n C2C.map_init();\n Ext.EventManager.fireDocReady();\n });\n };"; } $html .= javascript_queue($js); return $html; }
<?php echo __('You can add %1%, with %3% x %2% px and %4% mo', array('%1%' => implode(', ', $validation['file_extensions']), '%2%' => $validation['max_size']['height'], '%3%' => $validation['max_size']['width'], '%4%' => $validation['weight'] / pow(1024, 2))) . ' ' . __('Minsize is %1% x %2%', array('%1%' => $validation['min_size']['height'], '%2%' => $validation['min_size']['width'])); ?> </p> <p class="mandatory_fields_warning"><?php echo __('All fields are mandatory'); ?> </p> <?php echo global_form_errors_tag(); echo form_tag('images/upload?mod=' . $sf_params->get('mod') . '&document_id=' . $sf_params->get('document_id'), array('multipart' => true)); ?> <div id="files_to_upload" class="legacy"> <?php include_partial('file_form', array('image_number' => 0, 'default_license' => $default_license == null ? 2 : $default_license)); ?> </div> <p><?php echo picto_tag('picto_add'); ?> <a href="#" id="add_file_link"><?php echo __('add an other file'); ?> </a></p> <?php echo submit_tag(__('save'), array('id' => 'submit_files')); echo javascript_queue("\n var next_file_id = 1;\n\n \$('#submit_files').click(function() {\n \$('#indicator').show();\n });\n\n \$('#add_file_link').click(function() {\n var new_fields = '" . addcslashes(get_partial('file_form', array('image_number' => '%%next_file_id%%', 'default_license' => $default_license == null ? 2 : $default_license)), "..\\'\"\\/") . "';\n new_fields = new_fields.replace('%%next_file_id%%', next_file_id, 'g');\n \$('#files_to_upload').append(new_fields);\n next_file_id++;\n });\n "); ?> </p> </form>
if ($list_format) { echo link_to($route->get('name'), $route_link, $options) . '<div class="short_data">' . summarize_route($route, true, false, $avalaible_activities, true) . $georef; if ($show_link_to_delete && isset($route['directly_linked'])) { echo c2c_link_to_delete_element($type, $doc_id, $route_id, true, $strict); } echo '</div>'; } else { echo '<td>' . link_to($route->get('name'), $route_link, $options) . '</td>' . summarize_route($route, true, true, $avalaible_activities, false) . '<td>' . $georef . '</td>'; if ($show_link_to_delete && isset($route['directly_linked'])) { echo '<td>' . c2c_link_to_delete_element($type, $doc_id, $route_id, true, $strict) . '</td>'; } } echo '</' . $line_tag . '>'; } } if ($list_format) { echo '</ul>'; } else { echo '</tbody></table>'; } if (!$activity_section) { if (!empty($routes_list_link)) { echo '<p class="list_link">' . picto_tag('picto_routes') . ' ' . $routes_list_link . '</p>'; } break; } } if ($activity_section && !$is_popup) { echo javascript_queue('C2C.initRoutes();'); } }
<?php if (in_array($module, array('areas', 'articles', 'books', 'huts', 'outings', 'parkings', 'routes', 'sites', 'summits'))) { ?> <br /> <br /> <hr /> <br /> <?php use_helper('Form', 'JavascriptQueue', 'MyMinify'); $google_i18n = array('first page', 'previous page', 'next page', 'Document title', 'Extract', 'No result'); $google_i18n = array_map('__', $google_i18n); $cse = sfConfig::get('app_google_cse'); $script = minify_get_combined_files_url('/static/js/google_search.js'); echo javascript_queue("\$.extend(C2C.GoogleSearch = C2C.GoogleSearch || {}, {\n i18n: ['" . implode("', '", $google_i18n) . "']," . "\n base_url: 'https://www.googleapis.com/customsearch/v1?key=" . sfConfig::get('app_google_api_key') . '&cx=' . $cse[$module] . "&callback=C2C.GoogleSearch.handleResponse',\n alternate_url: 'https://www.google.com/cse?cx=" . $cse[$module] . "'});\n\$.ajax({\n url: '{$script}',\n dataType: 'script',\n cache: true })\n.done(function() {\n \$('#google_search_input').prop('disabled', false);\n});"); ?> <div id="google_search"> <?php echo __('Search with google'); echo form_tag('https://www.google.com/search', array('method' => 'get', 'onsubmit' => 'C2C.GoogleSearch.q=$("#google_search_input").val(); C2C.GoogleSearch.search(); return false;')); echo input_tag('q', null, array('id' => 'google_search_input', 'data-lang' => __('meta_language'), 'onblur' => "if (this.value == '') this.className = '';", 'disabled' => 'disabled', 'onfocus' => "this.className = 'no-logo';")); echo input_hidden_tag('sitesearch', "camptocamp.org/{$module}"); ?> <div id="google_search_submit" onclick="$(this).parent().submit();"></div> </form> <div id="google_search_results"></div> </div> <?php }
if ($show_link_tool) { echo '<ul id="' . $id_list_associated_docs . '"><li style="display:none"></li></ul>', '<div id="association_tool" class="plus">', '<p>', __('You can associate this book with existing document using the following tool:'), '</p>'; $modules_list = array('summits', 'sites', 'routes', 'huts', 'articles'); echo c2c_form_add_multi_module('books', $id, $modules_list, 13, array('field_prefix' => $id_list_associated_docs, 'hide' => false, 'removed_id' => $id_no_associated_docs)); echo '</div>'; } echo end_section_tag(); } include_partial('documents/images', array('images' => $associated_images, 'document_id' => $id, 'dissociation' => 'moderator', 'is_protected' => $document->get('is_protected'))); if ($document['isbn']) { // TODO checks on ISBN value (multiple isbns?) $script = minify_get_combined_files_url('/static/js/books.js'); $isbn_or_issn = 'ISBN:'; foreach ($document['book_types'] as $type) { if ($type == '18') { $isbn_or_issn = 'ISSN:'; break; } } echo start_section_tag('Buy the book', 'buy_books', 'opened', false, false, true); echo javascript_queue("\$.extend(C2C.GoogleBooks = C2C.GoogleBooks || {}, {\n preview_logo_src: 'http://books.google.com/intl/{$lang}/googlebooks/images/gbs_preview_button1.png'," . "\n translation: '" . __('Google Book Search') . "'," . "\n book_isbn: '" . $isbn_or_issn . $document['isbn'] . "'});\n \$.ajax({\n url: '{$script}',\n dataType: 'script',\n cache: true })\n .done(function() {\n C2C.GoogleBooks.search();\n });"); echo end_section_tag(); } if ($mobile_version) { include_partial('documents/mobile_comments', array('id' => $id, 'lang' => $lang, 'nb_comments' => $nb_comments)); } include_partial('documents/annex_docs', array('related_portals' => $related_portals)); } include_partial('documents/license', array('license' => 'by-sa', 'version' => $current_version, 'created_at' => isset($created_at) ? $created_at : null, 'timer' => $timer)); echo end_content_tag(); include_partial('common/content_bottom');
<?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}); });"); }
/** * Create a form that allow to link the current document with several kinds of other docs * * @param module current document module * @param id current document id * @param modules_list list of modules available for association * @param default_selected default selected module in the dropdown list * @param field_prefix used to prevent to have ids conflict when multiple forms * @param $options * $hide if true, display button to hide/show the form + some text * $indicator, the ID of the HTML object used to display indications on the ajax status (Loading, Success, ...) * $removed_id, the ID of the HTML object to hide * $suggest_near_docs, for suggesting docs based on geolocalization * $suggest_friends, for suggesting people you go out with most * * FIXME js code is quite messy, would be great to move most of it into separate js file */ function c2c_form_add_multi_module($module, $id, $modules_list, $default_selected, $options) { // optional values $field_prefix = _option($options, 'field_prefix', 'list_associated_docs'); $hide = _option($options, 'hide', true); $indicator = _option($options, 'indicator', 'indicator'); $removed_id = _option($options, 'removed_id'); $suggest_near_docs = _option($options, 'suggest_near_docs', false); $suggest_friends = _option($options, 'suggest_friends', false); $conf = sfConfig::get('app_modules_list'); $modules_list = array_intersect($conf, $modules_list); $modules_list_i18n = array_map('__', $modules_list); // modules for which lookig for neighboors has some sense $near_docs_modules_list = array_intersect($conf, array('huts', 'parkings', 'sites', 'summits', 'routes')); $near_docs_module_ids_list = array_keys($near_docs_modules_list); // for site-site, parking-parking or summit-summit associations, be explicit about association direction if (in_array($module, array('sites', 'parkings', 'summits'))) { $modules_list_i18n[array_search($module, $modules_list)] = __('sub-' . $module); } // dropdown for choosing the type of docs to link $select_modules = select_tag('dropdown_modules', options_with_classes_for_select($modules_list_i18n, array($default_selected), array(), 'picto picto_'), array('class' => 'picto picto_' . $default_selected)); $picto_add = $hide ? '' : picto_tag('picto_add', in_array('users', $modules_list) ? __('Link an existing user or document') : __('Link an existing document')) . ' '; $out = $picto_add . $select_modules; // js code fro autocompletion $js = "\$('#dropdown_modules').change(function() {" . "var \$this = \$(this), value = \$this.val(), indicator = \$('#{$indicator}').show();" . "\$this.attr('class', 'picto picto_' + value);" . "\$.get('" . url_for("/{$module}/getautocomplete") . "', 'module_id=' + value + '&field_prefix={$field_prefix}" . ($suggest_near_docs ? "' + (['" . implode("','", $near_docs_module_ids_list) . "'].indexOf(value) > -1 ?\n '&extra_params=" . urlencode("lat=" . $suggest_near_docs['lat'] . "&lon=" . $suggest_near_docs['lon']) . "' : '')" : '\'') . ")" . ".always(function() { indicator.hide(); })" . ".done(function(data) { \$('#{$field_prefix}_form').html(data);"; if ($suggest_near_docs || $suggest_friends) { $suggest_exclude = _option($options, 'suggest_exclude', []); // additional code for suggesting documents in the neighborhood or friends when relevant $js = "function getSuggestions() {" . "var input = \$('#{$field_prefix}_form').find('input[autocomplete=off]')," . "module = input.attr('name').replace('_name', '')," . "exclude = " . json_encode($suggest_exclude) . "," . "suggestions_div = \$('.autocomplete-suggestions').empty();" . "if (['" . implode("','", $near_docs_modules_list) . "'].indexOf(module) > -1 || module == 'users') {" . "var params = (module == 'users') ? { id: \$('#name_to_use').attr('data-user-id') } :" . "{ lat:" . $suggest_near_docs['lat'] . ", lon:" . $suggest_near_docs['lon'] . " };" . "if (input.not('[data-suggest-no-exclude]') && exclude[module] && exclude[module].length) {" . "params['exclude'] = exclude[module].join(',');" . "}" . "\$.getJSON('/'+module+'/suggest', params)" . ".done(function(data) {" . "if (data.length) suggestions_div.append('" . __('Suggestions: ') . "');" . "\$.each(data, function(index, obj) {" . "suggestions_div.append(\$('<a href=\"'+obj.url+'\">'+obj.name+'</a>').click(function(e) {" . "if (e.which !== 1) return;" . "e.preventDefault();" . "\$('#{$field_prefix}_form input[type=text]').triggerHandler('forceselect.autocomplete'," . "\$('<span id='+obj.id+'>'+obj.name+'</span>'));" . "}), ' ');" . "});" . "});" . "}" . "}" . "\$('#{$field_prefix}_form_association a').one('click', getSuggestions);" . $js; $js .= "getSuggestions();"; } $js .= "});});"; $out .= javascript_queue($js); // form start $out .= c2c_form_remote_add_element("{$module}/addAssociation?main_id={$id}", $field_prefix, $indicator, $removed_id); // default form content $auto_complete_options = array('field_prefix' => $field_prefix); if ($suggest_near_docs && in_array($modules_list[$default_selected], $near_docs_modules_list)) { $auto_complete_options['extra_params'] = "lat=" . $suggest_near_docs['lat'] . "&lon=" . $suggest_near_docs['lon']; } $out .= '<div id="' . $field_prefix . '_form' . '" class="ac_form">' . input_hidden_tag('document_id', '0', array('id' => $field_prefix . '_document_id')) . input_hidden_tag('document_module', $modules_list[$default_selected], array('id' => $field_prefix . '_document_module')) . c2c_auto_complete($modules_list[$default_selected], $field_prefix . '_document_id', $auto_complete_options) . '</div></form><div class="autocomplete-suggestions"></div>'; // this is where the linked docs will be displayed after ajax $out = '<div class="doc_add">' . $out . '</div>'; if ($hide) { $picto_add_rm = '<span class="assoc_img picto_add" title="' . __('show form') . '"></span>' . '<span class="assoc_img picto_rm" title="' . __('hide form') . '"></span>'; $picto_add_rm = link_to_function($picto_add_rm, "C2C.toggleForm('{$field_prefix}_form')"); $title = '<div id="_association_tool" class="section_subtitle extra" data-tooltip>' . (in_array('users', $modules_list) ? __('Link an existing user or document') : __('Link an existing document')) . __(' :') . '</div> '; $pictos = ' '; foreach ($modules_list as $module) { $pictos .= picto_tag('picto_' . $module, __($module)); } $pictos = link_to_function($pictos, "C2C.toggleForm('{$field_prefix}_form')"); $pictos = '<div class="short_data">' . $pictos . '</div>'; $out = '<div class="one_kind_association empty_content">' . '<div class="association_tool hide" id="' . $field_prefix . '_form_association">' . $picto_add_rm . $title . $pictos . '<ul id="' . $field_prefix . '"><li style="display:none"></li></ul>' . $out . '</div></div>'; } return $out; }
<ol id="languages-order"> <?php foreach ($sf_user->getPreferedLanguageList() as $language_code) { ?> <li id="<?php echo "lang_" . $language_code; ?> "><?php echo format_language_c2c($language_code); ?> </li> <?php } ?> </ol> <?php echo end_fieldset_tag(); echo __('Reorder these languages according to your preferences, using drag-and-drop'); // html5sortable is fine for desktop version, but it has no supprot for touch. It is very small and // follows the same api as jquery sortable // on the other hand, slip.js has touch support, but is a bit bigger // We don't show js feedback on mobile version (would be janky) if (c2cTools::mobileVersion()) { echo javascript_queue("\$.ajax({\n url: '" . minify_get_combined_files_url('/static/js/slip.js') . "',\n dataType: 'script',\n cache: true })\n.done(function() {\n var ol = document.getElementById('languages-order');\n ol.addEventListener('slip:beforeswipe', function(e) {\n e.preventDefault();\n }, false);\n ol.addEventListener('slip:beforewait', function(e) {\n e.preventDefault();\n }, false);\n ol.addEventListener('slip:reorder', function(e) {\n e.target.parentNode.insertBefore(e.target, e.detail.insertBefore);\n \$.post('" . url_for('users/sortPreferedLanguages') . "',\n \$('#languages-order li').map(function() { return 'order[]=' + this.id.match(/^lang_(.*)\$/)[1]; }).get().join('&'));\n return false;\n }, false);\n new Slip(ol);\n});"); } else { echo javascript_queue("\$.ajax({\n url: '" . minify_get_combined_files_url('/static/js/jquery.sortable.js') . "',\n dataType: 'script',\n cache: true })\n.done(function() {\n \$('#languages-order').sortable({forcePlaceholderSize: true}).on('sortupdate', function() {\n \$('#indicator').show();\n \$.post('" . url_for('users/sortPreferedLanguages') . "',\n \$('#languages-order li').map(function() { return 'order[]=' + this.id.match(/^lang_(.*)\$/)[1]; }).get().join('&'))\n .always(function() { \$('#indicator').hide(); })\n .done(function(data) { C2C.showSuccess(data); });\n });\n});"); } ?> </div> <!-- end div customize -->
<?php use_helper('JavascriptQueue'); echo javascript_queue("\$('#image_type').change(function() {\n var i = \$(this).val();\n \$('#license_collab').toggle(i == 2);\n \$('#license_perso').toggle(i == 1);\n \$('#license_copyright').toggle(i == 3);\n});"); ?> <div id="license_collab" style="display:<?php echo $license == 'by-sa' ? 'block' : 'none'; ?> "> <?php include_partial('documents/license', array('license' => 'by-sa')); ?> </div> <div id="license_perso" style="display:<?php echo $license == 'by-nc-nd' ? 'block' : 'none'; ?> "> <?php include_partial('documents/license', array('license' => 'by-nc-nd')); ?> </div> <div id="license_copyright" style="display:<?php echo $license == 'copyright' ? 'block' : 'none'; ?> "> <?php include_partial('documents/license', array('license' => 'copyright')); ?> </div>
<input id="pickfiles" class="plupload-pickfiles" type="button" value="<?php echo __('Add images'); ?> " disabled="disabled" /> <input class="plupload-cancel" type="button" value="<?php echo __('cancel'); ?> " /> <input class="plupload-submit" type="submit" value="<?php echo __('save'); ?> " disabled="disabled" /> <div class="tooltip top" style="display:none"> <div class="tooltip-inner"><?php echo __('plupload invalid image titles'); ?> </div> <div class="tooltip-arrow"></div> </div> </div> <?php $jsfiles = array('/static/js/mixitup.js', '/static/js/plupload.full.min.js', '/static/js/plupload.wrapper.js'); if (!c2cTools::mobileVersion()) { $jsfiles[] = '/static/js/plupload.dropdown.js'; } $plupload_js = minify_get_combined_files_url($jsfiles); $backup_url = url_for("@image_jsupload?mod={$mod}&document_id={$document_id}?noplupload=true"); echo javascript_queue("var height = \$(window).height() - \$('.modal-header').outerHeight(true) - \$('.plupload-tips').outerHeight(true)" . "- \$('#plupload-container').outerHeight(true) - \$('.modal-footer').outerHeight(true)" . "- parseInt(\$('.modal-body').css('paddingBottom'), 10)*2 - 30;" . "\$('#images_validate_form').height(height);" . "\$.ajax({ url: '{$plupload_js}', dataType: 'script', cache: true })" . ".done(function() { C2C.PlUploadWrapper('/images/addpltempimage/mod/{$mod}/document_id/{$document_id}', '{$backup_url}', {" . "badselect: '" . __('plupload bad selection') . "', extensions: '" . __('plupload extension') . "', unknownerror: '" . __('plupload unknown') . "'," . "sending: '" . __('plupload sending') . "', waiting: '" . __('plupload waiting') . "', serverop: '" . __('plupload serverop') . "'," . "cancel: '" . __('cancel') . "', drop: '" . __('plupload drop') . "'" . "});" . "});"); ?> </form>
echo javascript_queue(' var section_list = $("#on_the_web_section_list"); function load2() { $.get("' . $sf_data->getRaw('feed_url') . '").done(function(data) { var $xml = $(data), date, count = 0; $xml.find("item").each(function() { var $this = $(this), item = {}, els; $.each(["title", "link", "description", "pubDate", "author"], function(i, v) { item[v] = $this.find(v).text(); }); if (!count) section_list.html(""); count++; if (count > 10) return; if (date != item.pubDate) { els = item.pubDate.split("-"); datespan = $("<span/>", { "class": "date", text: els[2] + "/" + els[1] }); } else { datespan = ""; } date = item.pubDate; lang = item.description.split(" , ")[5]; author = item.author.substring(item.author.indexOf("(") - 1); section_list.append($("<li/>", { "class": (count % 2) ? "even" : "odd" }) .append(datespan, $("<a/>", { href: item.link, hreflang: lang, text: item.title }), $("<span/>", { "class": "meta", text: author }))); }); }).fail(function() { section_list.html("' . __('No recent changes available') . '"); }); } function load() { if (window.XDomainRequest) { $.ajax({url: "' . $script_url . '",dataType: "script",cache: true}).done(load2); } else { load2(); } } if (!C2C.shouldHide(' . $cookie_position . ', ' . (!$default_open ? 'false' : 'true') . ') && $("#on_the_web").is(":visible")) { load(); } else { $("#on_the_web_toggle").one("click", load); } ');
echo ' '; echo button_to_function(__('save'), "\$('.images_submit').hide(); \$('#images_validate_form').submit()", array('disabled' => 'disabled', 'class' => 'images_submit')); echo input_hidden_tag('action', 'addtempimages'); echo input_hidden_tag('image_number', 0); ?> <span id="image_add_str" style="display:none"> <?php echo __('add an other image'); ?> </span> </div> </form> </div> <?php echo form_tag('images/jsupload?mod=' . $mod . '&document_id=' . $document_id, array('id' => 'images_validate_form')); ?> <div> </div> <ul id="files_to_upload" class="legacy"> </ul> <div> <?php echo button_to_function(__('save'), "\$('.images_submit').hide(); \$('#images_validate_form').submit()", array('disabled' => 'disabled', 'class' => 'images_submit')); ?> </div> <?php $image_upload_js = minify_get_combined_files_url('/static/js/image_upload.js'); echo javascript_queue("\$.ajax({ url: '{$image_upload_js}', dataType: 'script', cache: true }).done(function() {\n window.setTimeout(C2C.ImageUpload.init, 1000)});"); ?> </form>
<?php if (in_array($module, array('areas', 'articles', 'books', 'huts', 'outings', 'parkings', 'routes', 'sites', 'summits'))) { ?> <br /> <div id="google_search"> <?php use_helper('Form', 'JavascriptQueue', 'MyMinify'); echo image_tag('//www.google.com/uds/css/small-logo.png'); echo __('Results from google for %1%', array('%1%' => $query_string)); ?> <div id="google_search_results"></div> </div> <?php $google_i18n = array('first page', 'previous page', 'next page', 'Document title', 'Extract', 'No result'); $google_i18n = array_map('__', $google_i18n); $cse = sfConfig::get('app_google_cse'); $script = minify_get_combined_files_url('/static/js/google_search.js'); echo javascript_queue("\$.extend(C2C.GoogleSearch = C2C.GoogleSearch || {}, {\n i18n: ['" . implode("', '", $google_i18n) . "']," . "\n base_url: 'https://www.googleapis.com/customsearch/v1?key=" . sfConfig::get('app_google_api_key') . '&cx=' . $cse[$module] . "&callback=C2C.GoogleSearch.handleResponse',\n q: '" . urlencode($query_string) . "'});\n\$.ajax({\n url: '{$script}',\n dataType: 'script',\n cache: true })\n.done(function() {\n C2C.GoogleSearch.search();\n});"); }
function select_all_header_list_tag($title = '') { use_helper('JavascriptQueue'); if (!empty($title)) { $title = ' title="' . $title . '"'; } return "<th{$title}>" . '<input type="checkbox" id="select_all" /></th>' . javascript_queue("\$('#select_all').change(function() {\n \$('table.list td input[type=checkbox]').attr('checked', \$(this).is(':checked'));\n });"); }
if (isset($center)) { $center = $sf_data->getRaw('center'); } else { $center = null; } echo show_map('map_container', $document, $sf_user->getCulture(), $layers_list, $height, $center, $has_geom, $sf_user->isConnected()); echo end_section_tag(true); // fold_init_map.js ~ 390b ?> <script> !function(e,t){var n=e.setSectionStatus e.setSectionStatus=function(i,o,c){if(n(i,o,c)){var a=e.section_open,l=t.getElementById(i+"_section_container") l.style.display="none",l.title=a var s=t.getElementById(i+"_toggle") s.className=s.className.replace("picto_close","picto_open"),s.alt="+",s.title=a,t.getElementById("tip_"+i).innerHTML="["+a+"]"}}}(window.C2C=window.C2C||{},document) </script> <?php $cookie_position = array_search('map_container', sfConfig::get('app_personalization_cookie_fold_positions')); ?> <script> C2C.setSectionStatus('map_container', <?php echo $cookie_position; ?> , true); </script> <?php $async_map = sfConfig::get('app_async_map', false) && !sfContext::getInstance()->getRequest()->getParameter('debug', false); $init = $async_map ? 'C2C.async_map_init();' : '$(window).load(C2C.map_init);'; $delayed_init = $async_map ? 'C2C.async_map_init' : 'C2C.map_init'; echo javascript_queue("\n var id = 'map_container';\n if (!C2C.shouldHide({$cookie_position}, true)) {" . $init . "} else {\n \$('#'+id).one('click', " . $delayed_init . ");\n }\n \$('#'+id).click(function() {\n C2C.registerFoldStatus(id, {$cookie_position}, !\$('#'+id+'_section_container').is(':visible'));\n \$('.x-window.x-resizable-pinned').toggle();\n }); "); }
<?php use_helper('JavascriptQueue'); echo javascript_queue("\$('#article_type').change(function() {\n var i = (\$('#article_type').val() == 2);\n \$('#license_collab').toggle(!i);\n \$('#license_perso').toggle(i);\n});"); ?> <div id="license_collab" style="display:<?php echo $license == 'by-sa' ? 'block' : 'none'; ?> "> <?php include_partial('documents/license', array('license' => 'by-sa')); ?> </div> <div id="license_perso" style="display:<?php echo $license == 'by-sa' ? 'none' : 'block'; ?> "> <?php include_partial('documents/license', array('license' => 'by-nc-nd')); ?> </div>
<div id="fake_div"> <div id="outing_wizard"> <hr /> <h4><?php echo __('Step 1: choose a summit'); ?> </h4> <div> <?php echo global_form_errors_tag(); echo select_tag('wizard_type', options_for_select(array('summits' => __('Summit:'), 'sites' => __('Site:')), 0)); echo input_tag('summits_name', '', array('size' => '35')); echo input_tag('sites_name', '', array('size' => '35', 'style' => 'display:none')); echo javascript_queue("var indicator = \$('#indicator');\n\$('#wizard_type').change(function() {\n \$('#summits_name, #sites_name').val('').toggle();\n \$('#wizard_no_route, #wizard_route, #summit_link, #last_ok').hide();\n\n var summit = \$(this).val() == 'summits';\n \$('#wizard_routes_hints').toggle(summit);\n \$('#wizard_sites_hints').toggle(!summit);\n \n});\n\n\$('#summits_name').c2cAutocomplete({\n url: '" . url_for('summits/autocomplete') . "',\n minChars: " . sfConfig::get('app_autocomplete_min_chars') . "\n}).on('itemselect', function(e, item) {\n indicator.show();\n \$('#summit_id').val(item.id);\n \$('#wizard_no_route, .wizard_hints').hide();\n \$.get('" . url_for('summits/getroutes') . "',\n 'summit_id=' + \$('#summit_id').val() + '&div_name=routes')\n .always(function() { indicator.hide(); })\n .done(function(data) {\n \$('#divRoutes').html(data);\n \$('#last_ok h4').html(\$('#wizard_routes_hints h4').last().html());\n \$('#wizard_no_route').hide();\n \$('#summit_link, #wizard_route, #last_ok').show();\n C2C.getWizardRouteRatings('routes');\n })\n .fail(function(data) {\n \$('#wizard_route, #wizard_hints, #wizard_route_descr, #last_ok').hide();\n \$('#summit_link, #wizard_no_route').show();\n C2C.showFailure(data.responseText);\n })\n});\n\n\$('#sites_name').c2cAutocomplete({\n url: '" . url_for('sites/autocomplete') . "',\n minChars: " . sfConfig::get('app_autocomplete_min_chars') . "\n}).on('itemselect', function(e, item) {\n \$('.wizard_hints').hide();\n \$('#last_ok h4').html(\$('#wizard_sites_hints h4').last().html());\n \$('#last_ok').show();\n \$('#link').val(item.id);\n});\n"); echo form_tag('outings/wizard'); echo input_hidden_tag('summit_id', '0'); ?> <p id="summit_link" style="display: none"> <a href="#" onclick="window.open('/summits/' + $('#summit_id').val());"><?php echo __('Show the summit'); ?> </a> </p> <p id="wizard_summit_create" class="wizard_tip"><?php echo __('No summit matching your search?') . ' ' . link_to(__('Add your summit'), '@document_edit?module=summits&id=&lang='); ?> </p> </form> </div>
function search_box_tag($id_prefix = '', $autocomplete = true) { $sf_context = sfContext::getInstance(); $list = array(); foreach (sfConfig::get('app_modules_list') as $module) { switch ($module) { case 'documents': // remove "all documents" option because it load too much the server // $list['documents'] = __('all'); break; default: $list[$module] = __($module); } } $list['forums'] = __('forums'); $selected = $sf_context->getRequest()->getParameter('type'); if (empty($selected)) { $current_module = $sf_context->getModuleName(); if (in_array($current_module, array('documents', 'common', 'portals'))) { $selected = 'summits'; // FIXME should be routes, but we use summits until performance are improved } else { if (empty($current_module)) { $selected = 'forums'; } else { $selected = $current_module; } } } $options = options_with_classes_for_select($list, $selected, array(), 'picto picto_'); $select_js = 'this.setAttribute("class", "picto picto_" + this.options[this.selectedIndex].value);'; $html = select_tag('type', $options, array('onchange' => $select_js, 'class' => 'picto picto_' . $selected, 'id' => $id_prefix . 'type')); $input_html_options = array('class' => 'searchbox action_filter', 'id' => $id_prefix . 'q', 'type' => 'search', 'placeholder' => __('Search'), 'accesskey' => 'f', 'title' => __('Search on c2c') . ' [alt-shift-f]'); if ($autocomplete) { $html .= input_tag('q', '', $input_html_options); $html .= javascript_queue("\$('#q').c2cAutocomplete({\n url: '" . url_for('@quicksearch') . "',\n minChars: " . sfConfig::get('app_autocomplete_min_chars') . ",\n params: 'q=' + \$('#{$id_prefix}q').val() + '&type=' + \$('#{$id_prefix}type').val()\n }).on('itemselect', function(e, item) { window.location = '/documents/' + item.id; });"); } else { $html .= input_tag('q', $sf_context->getRequest()->getParameter('q'), $input_html_options); } return $html; }