本文整理汇总了PHP中picto_tag函数的典型用法代码示例。如果您正苦于以下问题:PHP picto_tag函数的具体用法?PHP picto_tag怎么用?PHP picto_tag使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了picto_tag函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: filters_switcher_link
function filters_switcher_link($mainFilterSwitchOn)
{
$options_on = $options_off = array();
$options_on['id'] = 'filter_switch_on';
$options_off['id'] = 'filter_switch_off';
if ($mainFilterSwitchOn) {
$options_off['style'] = 'display: none;';
} else {
$options_on['style'] = 'display: none;';
}
$html = picto_tag('action_on', __('some filters active'), $options_on);
$html .= picto_tag('action_off', __('some filters have been defined but are not activated'), $options_off);
if (defined('PUN_ROOT')) {
// we are in the forum
// it is not possible to activate/disactivate filter because the FiltersSwitchFilter will not get executed.
// moreover, forums are not filtered on activities, regions, langs.
return $html;
} else {
return link_to_function($html, "\$('#indicator').show();" . "\$.ajax('" . url_for('@default?module=common&action=switchallfilters') . "')" . ".done(function() { \$('#filter_switch_on, #filter_switch_off').toggle(); window.location.reload(); })" . ".always(function() { \$('#indicator').hide(); })");
}
}
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:21,代码来源:GeneralHelper.php
示例2: start_section_tag
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;
}
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:23,代码来源:SectionsHelper.php
示例3: picto_header_list_tag
function picto_header_list_tag($picto, $title = '')
{
sfLoader::loadHelpers(array('General'));
return '<th>' . picto_tag($picto, __($title)) . '</th>';
}
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:5,代码来源:PaginationHelper.php
示例4: use_helper
<?php
use_helper('Field', 'Link');
$item_i18n = $item['ProductI18n'][0];
?>
<div><?php
echo list_link($item_i18n, 'products');
?>
</div>
<div><?php
echo displayWithSuffix($item['elevation'], 'meters'), ' - ', get_paginated_value_from_list($item['product_type'], 'mod_products_types_list');
if (isset($item['linked_docs'])) {
echo '<div>', __('access'), ' ';
include_partial('parkings/parkings4list', array('parkings' => $item['linked_docs']));
echo '</div>';
}
?>
<div><?php
include_partial('documents/regions4list', array('geoassociations' => $item['geoassociations']));
?>
</div>
<div><?php
echo picto_tag('picto_images', __('nb_linked_images')), ' ', isset($item['nb_images']) ? $item['nb_images'] : '0', ' ', picto_tag('action_comment', __('nb_comments')), ' ', isset($item['nb_comments']) ? link_to($item['nb_comments'], '@document_comment?module=products&id=' . $item_i18n['id'] . '&lang=' . $item_i18n['culture']) : '0';
?>
</div>
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:25,代码来源:_mobile_list_body.php
示例5: use_helper
<?php
use_helper('General');
?>
<br />
<?php
echo picto_tag('picto_huts') . __('Hut:') . ' ' . (isset($autofocus) ? input_tag('hnam', null, array('autofocus' => 'autofocus')) : input_tag('hnam'));
echo __('elevation') . ' ' . elevation_selector('halt');
?>
<br />
<?php
echo __('shelter_type') . ' ' . field_value_selector('htyp', 'mod_huts_shelter_types_list', array('keepfirst' => false, 'multiple' => true));
echo __('is_staffed') . __(' :') . ' ' . bool_selector('hsta');
?>
<br />
<?php
echo __('staffed_capacity') . ' ' . elevation_selector('hscap', null);
?>
<br />
<?php
echo __('unstaffed_capacity') . ' ' . elevation_selector('hucap', null);
?>
<br />
<?php
echo __('has_unstaffed_matress') . ' ' . field_value_selector('hmat', 'app_boolean_list');
echo __('has_unstaffed_blanket') . ' ' . field_value_selector('hbla', 'app_boolean_list');
echo __('has_unstaffed_gas') . ' ' . field_value_selector('hgas', 'app_boolean_list');
echo __('has_unstaffed_wood') . ' ' . field_value_selector('hwoo', 'app_boolean_list');
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:28,代码来源:_huts_filter.php
示例6: simple_pager_navigation
echo simple_pager_navigation($count, count($routes_outings), 'routings_group_');
}
?>
</div>
<?php
}
// routes outings list link
include_partial('outings/linked_outings', array('id' => $ids, 'module' => 'routes', 'nb_outings' => $nb_routes_outings, 'document' => $document));
}
}
// new outing button
if ($show_link_tool) {
echo '<div class="add_content">' . link_to(picto_tag('picto_add', __('Associate new outing')) . __('Associate new outing'), "outings/edit?link={$id}") . '</div>';
}
echo end_section_tag();
// associated images section
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));
if ($is_connected) {
$version = $document->getVersion();
$txt = __('Edit');
echo '<div id="edit_route_button" class="add_content">', link_to(picto_tag('picto_tools', $txt) . $txt, "@document_edit_archive?module=routes&id={$id}&lang={$lang}&version={$version}"), '</div>';
}
}
// annex docs section
include_partial('documents/annex_docs', array('document' => $document, 'related_articles' => $associated_articles, 'related_portals' => $related_portals, 'show_link_to_delete' => $show_link_to_delete));
}
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');
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:31,代码来源:viewSuccess.php
示例7: select_tag
if (array_key_exists($cat, $choices)) {
$choices[$cat] .= ' *';
}
}
echo select_tag("categories[{$image_number}]", options_for_select($choices), array('multiple' => true, 'size' => 6));
?>
</div>
<br />
<div class="image_form_error"<?php
echo isset($image_title) ? ' style="display:none"' : '';
?>
>
↓ <?php
echo __('this name is too short (4 characters minimum)');
?>
↓</div>
<?php
// if image_title is set, we prefill the title input
// note that we use raw value, since input_tag will escape values anyway
// and we thus prevent double escaping
$image_title = isset($image_title) ? $sf_data->getRaw('image_title') : '';
echo __('name'), ' ', input_tag("name[{$image_number}]", $image_title, array('maxlength' => '150', 'class' => 'large_input', 'placeholder' => __('write a caption'))), ' ', input_hidden_tag("image_unique_filename[{$image_number}]", $image_filename);
echo '<br /><br />';
$license_choices = array_map('__', sfConfig::get('mod_images_type_list'));
if ($default_license == 1) {
$types = sfConfig::get('mod_images_type_list');
echo __('image_type') . ' ' . __($types[1]) . ' ' . link_to(picto_tag('cc-by-sa-mini', 'CC-by-sa'), getMetaArticleRoute('licenses', false, 'cc-by-sa'));
echo input_hidden_tag("image_type[{$image_number}]", 1);
} else {
echo __('image_type') . ' ' . select_tag("image_type[{$image_number}]", options_for_select($license_choices, $default_license));
}
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:31,代码来源:_temp_image_success.php
示例8: use_helper
<?php
use_helper('FilterForm', 'General', 'MyForm');
$is_connected = $sf_user->isConnected();
echo around_selector('sarnd');
$ranges_raw = $sf_data->getRaw('ranges');
$selected_areas_raw = $sf_data->getRaw('selected_areas');
include_partial('areas/areas_selector', array('ranges' => $ranges_raw, 'selected_areas' => $selected_areas_raw, 'use_personalization' => true));
?>
<br />
<br />
<?php
echo '<div class="fieldname">' . picto_tag('picto_outings') . __('name') . ' </div>' . input_tag('onam', null, array('autofocus' => 'autofocus'));
echo georef_selector('With GPS track:');
$activities_raw = $sf_data->getRaw('activities');
include_partial('routes_filter', array('activities' => $activities_raw));
include_partial('summits/summits_short_filter');
include_partial('huts/huts_short_filter');
include_partial('parkings/parkings_filter');
echo __('outing_with_public_transportation') . ' ' . bool_selector('owtp');
?>
<br /><br />
<?php
echo __('Date') . __(' :') . ' ' . date_selector(array('month' => true, 'year' => true, 'day' => true));
?>
<div data-act-filter="1 2 5 7" style="display:none">
<?php
echo __('avalanche_infos') . ' ' . select_tag('avdate', options_for_select(array('2-3-4-5' => __('yes'), '1' => __('no'), ' ' => __('filled in'), '-' => __('nonwell informed')), '', array('include_blank' => true)));
?>
</div>
<br />
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:31,代码来源:_filter_form.php
示例9: field_export
function field_export($module, $id, $lang, $version = null)
{
$route_suffix = !empty($version) ? "_version?version={$version}&" : '?';
$route_suffix .= "module={$module}&id={$id}&lang={$lang}";
$title = 'download geo data under %1% format';
$result = '<div class="no_print">' . content_tag('span', __('Export:'), array('class' => 'section_subtitle', 'id' => 'geo_export', 'data-tooltip' => '')) . ' ' . picto_tag('action_gps') . ' ' . link_to('GPX', "@export_gpx{$route_suffix}", array('title' => __($title, array('%1%' => 'GPX')), 'rel' => 'nofollow'));
if (!c2cTools::mobileVersion()) {
$result .= ' ' . picto_tag('action_kml') . ' ' . link_to('KML', "@export_kml{$route_suffix}", array('title' => __($title, array('%1%' => 'KML')), 'rel' => 'nofollow')) . ' ' . picto_tag('action_json') . ' ' . link_to('JSON', "@export_json{$route_suffix}", array('title' => __($title, array('%1%' => 'JSON')), 'rel' => 'nofollow'));
}
$result .= '</div>';
return $result;
}
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:12,代码来源:FieldHelper.php
示例10: picto_tag
echo picto_tag('action_edit') . f_link_to(__('User profile'), 'profile.php?section=personality');
?>
</li>
<li><?php
echo picto_tag('action_contact') . link_to(__('Mailing lists link'), 'users/mailinglists');
?>
</li>
<?php
} else {
?>
<li><?php
echo picto_tag('action_edit') . link_to(__('create an account?'), getMetaArticleRoute('create_account'));
?>
</li>
<?php
}
if ($is_connected) {
?>
<li class="lilast"><?php
echo picto_tag('action_cc') . link_to(__('User image management'), 'users/manageimages');
?>
</li>
<?php
}
?>
</ul>
</li>
</ul>
<br class="clearer" />
</div>
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:30,代码来源:_menu_content.php
示例11: start_section_tag
if ($is_not_archive && $is_not_merged) {
echo start_section_tag('Linked documents', 'associated_docs');
$id_no_associated_docs = "no_associated_docs";
$id_list_associated_docs = "list_associated_docs";
if (!count($associated_documents)) {
echo '<p class="default_text" id="' . $id_no_associated_docs . '">' . __("No document uses this picture.") . '</p>';
}
if (count($associated_documents) > 0) {
echo '<ul id="' . $id_list_associated_docs . '">';
foreach ($associated_documents as $doc) {
$doc_id = $doc['id'];
$module = $doc['module'];
$type = c2cTools::Module2Letter($module) . 'i';
$idstring = $type . '_' . $doc_id;
echo '<li id="', $idstring, '">';
echo picto_tag('picto_' . $module, __($module));
echo ' ' . link_to($doc['name'], "@document_by_id_lang_slug?module={$module}&id=" . $doc_id . '&lang=' . $doc['culture'] . '&slug=' . make_slug($doc['name']));
if ($show_link_to_delete) {
echo c2c_link_to_delete_element($type, $doc_id, $id, false, 1);
}
echo '</li>';
}
echo '</ul>';
} elseif ($show_link_tool) {
echo '<ul id="' . $id_list_associated_docs . '"><li style="display:none"></li></ul>';
}
if ($show_link_tool) {
?>
<div id="association_tool" class="plus">
<p><?php
echo __('You can associate this picture with any existing document using the following tool:');
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:31,代码来源:viewSuccess.php
示例12: foreach
foreach ($alist as $k => $act) {
if (!in_array($k + 1, $act_filter)) {
$unselected_act[] = $k;
}
}
foreach ($unselected_act as $act_id) {
$light[$act_id] = '_light';
}
foreach ($act_filter as $act_id) {
$activities_class[] = 'act' . $act_id;
}
}
?>
<div id="quick_switch<?php
echo empty($activities_class) ? '' : '" class="' . implode(' ', $activities_class);
?>
">
<?php
foreach ($alist as $act_id => $activity) {
$alt = $act_filter == array($act_id) ? __('switch_off_activity_personalisation') : __('switch_to_' . $alist[$act_id]);
$image_tag = picto_tag('activity_' . ($act_id + 1) . $light[$act_id], $alt);
echo link_to($image_tag, '@quick_activity?activity=' . ($act_id + 1), array('class' => 'qck_sw'));
}
?>
</div>
<?php
include_partial('common/menu_content', array('sf_cache_key' => ($is_connected ? 'connected' : 'not_connected') . '_' . $lang, 'lang' => $lang, 'is_connected' => $is_connected));
?>
</div>
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:29,代码来源:_menu.php
示例13: use_helper
<?php
use_helper('General');
?>
<br />
<?php
echo '<div class="fieldname">' . picto_tag('picto_summits') . __('Summit:') . ' </div>' . input_tag('snam');
echo __('elevation') . ' ' . elevation_selector('salt');
echo __('summit_type') . ' ' . field_value_selector('styp', 'app_summits_summit_types', array('blank' => true));
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:9,代码来源:_summits_short_filter.php
示例14: use_helper
use_helper('General');
$mobile_version = c2cTools::mobileVersion();
?>
<fieldset id="fs_area">
<legend class="select_title">
<?php
if (!isset($show_picto)) {
$show_picto = true;
}
if ($show_picto) {
echo picto_tag('picto_areas') . ' - ';
}
echo link_to_function(__('ranges'), "console.log('plop');\$('#indicator').show();\n \$.ajax('" . url_for('/areas/getmultipleselect?area_type=1') . "')\n .always(function() { \$('#indicator').hide(); })\n .done(function(data) { \$('#area_selector').html(data); })") . ' - ' . link_to_function(__('regions'), "\$('#indicator').show();\n \$.ajax('" . url_for('/areas/getmultipleselect?area_type=3') . "')\n .always(function() { \$('#indicator').hide(); })\n .done(function(data) { \$('#area_selector').html(data); })") . ' - ' . link_to_function(__('countries'), "\$('#indicator').show();\n \$.ajax('" . url_for('/areas/getmultipleselect?area_type=2') . "')\n .always(function() { \$('#indicator').hide(); })\n .done(function(data) { \$('#area_selector').html(data); })");
if (!$mobile_version) {
echo ' - ' . picto_tag('picto_close', __('Reduce the list'), array('onclick' => "C2C.changeSelectSize('places', false)")) . picto_tag('picto_open', __('Enlarge the list'), array('onclick' => "C2C.changeSelectSize('places', true)"));
}
?>
</legend>
<div id="area_selector">
<?php
//rq FIXME bug in symfony 1.0.11 which does not work with optgroups and escaping, see http://trac.symfony-project.org/ticket/3923
// plus using sf_data->getRaw is not enough because it is passed through different partials
$ranges_raw = array();
foreach ($ranges as $key => $value) {
if ($value instanceof sfOutputEscaperArrayDecorator) {
$rr = array();
foreach ($value as $k => $v) {
$rr[$k] = $v;
}
$ranges_raw[$key] = $rr;
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:30,代码来源:_areas_selector.php
示例15: use_helper
<?php
use_helper('Field');
$id = $sf_params->get('id');
$is_connected = $sf_user->isConnected();
$is_not_archive = !$document->isArchive();
$is_not_merged = !$document->get('redirects_to');
$mobile_version = c2cTools::mobileVersion();
$is_gite_camping = $document->get('shelter_type') == 5 || $document->get('shelter_type') == 6;
$show_link_tool = !$is_gite_camping && $is_not_archive && $is_not_merged && $is_connected && !$mobile_version;
if ($is_gite_camping) {
$access_label = 'access';
} else {
$access_label = null;
}
echo field_text_data_if_set($document, 'staffed_period', null, array('needs_translation' => $needs_translation, 'images' => $images));
echo field_text_data_if_set($document, 'description', null, array('needs_translation' => $needs_translation, 'images' => $images));
if (count($associated_routes)) {
echo field_text_data($document, 'pedestrian_access', $access_label, array('needs_translation' => $needs_translation, 'images' => $images));
include_partial('routes/linked_routes', array('associated_routes' => $associated_routes, 'document' => $document, 'id' => $id, 'module' => 'huts', 'type' => '', 'strict' => true, 'show_list_link' => false));
} else {
echo field_text_data_if_set($document, 'pedestrian_access', $access_label, array('needs_translation' => $needs_translation, 'images' => $images));
}
if ($show_link_tool) {
echo '<div class="add_content">' . link_to(picto_tag('picto_add', __('Associate new access')) . __('Associate new access'), "@hut_addroute?document_id={$id}") . '</div>';
}
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:26,代码来源:_i18n.php
示例16: use_helper
<?php
use_helper('FilterForm', 'General');
echo picto_tag('picto_areas') . __('region_name') . ' ' . input_tag('anam', null, array('autofocus' => 'autofocus'));
echo __('area_type') . ' ' . field_value_selector('atyp', 'mod_areas_area_types_list');
?>
<br />
<?php
echo __('filter language') . __(' :') . ' ' . lang_selector('acult');
?>
<br />
<?php
include_partial('documents/filter_sort');
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:13,代码来源:_filter_form.php
示例17: image_url
$title = $i18n_item['name'];
$filename = $item['filename'];
$image_type = $item['image_type'];
$thumb_url = image_url($filename, 'small');
$image_route = '@document_by_id_lang_slug?module=images&id=' . $item['id'] . '&lang=' . $i18n_item['culture'] . '&slug=' . make_slug($i18n_item['name']);
echo link_to(image_tag($thumb_url, array('class' => 'img', 'alt' => $title)), $mobile_version ? $image_route : absolute_link(image_url($filename, 'big', true), true), array('title' => $title, 'data-lightbox' => 'document_images', 'class' => 'view_big', 'id' => 'lightbox_' . $item['id'] . '_' . $image_type));
?>
<div class="image_license <?php
echo 'license_' . $image_type;
?>
"></div>
</div>
<?php
echo $title . '<br />';
echo link_to(__('Details'), $image_route);
if (!empty($item['nb_comments'])) {
echo ' - ' . picto_tag('action_comment', __('nb_comments'), array('style' => 'margin-bottom:-4px')) . ' (' . link_to($item['nb_comments'], '@document_comment?module=images&id=' . $item['id'] . '&lang=' . $i18n_item['culture']) . ')';
}
?>
</div>
<?php
}
?>
<div style="clear:both"><?php
echo $pager_navigation;
?>
</div>
<?php
}
echo end_content_tag();
include_partial('common/content_bottom');
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:31,代码来源:listSuccess.php
示例18: foreach
<table id="conditions_levels_table">
<colgroup></colgroup>
<?php
foreach ($level_fields as $field) {
?>
<colgroup id="<?php
echo $field;
?>
"></colgroup>
<?php
}
?>
<thead>
<tr>
<th><?php
echo link_to(picto_tag('picto_add', __('add a condition level')), '#', array('class' => 'add-condition-level'));
?>
</th>
<?php
foreach ($level_fields as $field) {
?>
<th><?php
echo __($field);
?>
</th>
<?php
}
?>
</tr>
</thead>
<tbody id="conditions_levels_tbody">
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:31,代码来源:_form_fields.php
示例19: __
<li><span class="picto action_description"></span> <?php
echo __('Guidebook contribs:');
echo '<ul>';
$module_list = array('routes', 'summits', 'sites', 'huts', 'parkings', 'products', 'books', 'areas', 'articles', 'images');
foreach ($module_list as $module) {
$module_title = $module;
$url_param = '';
if ($module == 'articles') {
$module_title = 'collaborative articles';
$url_param = 'ctyp=1&';
}
if ($module == 'images') {
$module_title = 'collaborative images';
$url_param = 'ityp=1&';
}
echo '<li>' . picto_tag('picto_' . $module) . ' ' . __($module_title) . __(' :') . ' ' . link_to(__('creations'), "{$module}/whatsnew?{$url_param}" . "mode=creations&users={$id}") . ' (' . link_to(__('tracking'), "{$module}/whatsnew?{$url_param}" . "createdby={$id}") . ') - ' . link_to(__('editions'), "{$module}/whatsnew?{$url_param}" . "users={$id}") . ' (' . link_to(__('tracking'), "{$module}/whatsnew?{$url_param}" . "editedby={$id}") . ')' . '</li>';
}
echo '</ul>';
if ($is_moderator) {
/* echo '<p><span class="picto action_list"></span> '
. link_to(__('List all user collaborative contribs'), "documents/whatsnew?dtyp=collab&users=$id") . ' ('
. link_to(__('creations'), "documents/whatsnew?dtyp=collab&mode=creations&users=$id") . ')'
. '</p>'; */
echo '<p><span class="picto action_list"></span> ' . link_to(__('List all user contribs'), "documents/whatsnew?users={$id}") . ' (' . link_to(__('creations'), "documents/whatsnew?mode=creations&users={$id}") . ')' . '</p>';
}
?>
</li>
</ul>
<?php
echo end_section_tag();
include_partial('documents/images', array('images' => $associated_images, 'document_id' => $id, 'dissociation' => 'moderator', 'author_specific' => !$is_moderator, 'is_protected' => $document->get('is_protected')));
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:31,代码来源:viewSuccess.php
示例20: c2c_form_add_multi_module
/**
* 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;
}
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:74,代码来源:AutoCompleteHelper.php
注:本文中的picto_tag函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论