本文整理汇总了PHP中get_id_from_name函数的典型用法代码示例。如果您正苦于以下问题:PHP get_id_from_name函数的具体用法?PHP get_id_from_name怎么用?PHP get_id_from_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_id_from_name函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: form_error
function form_error($param, $options = array(), $catalogue = 'messages')
{
$param_for_sf = str_replace(array('[', ']'), array('{', '}'), $param);
$param = str_replace(array('{', '}'), array('[', ']'), $param);
$options = _parse_attributes($options);
$request = sfContext::getInstance()->getRequest();
$style = $request->hasError($param_for_sf) ? '' : 'display:none;';
$options['style'] = $style . (isset($options['style']) ? $options['style'] : '');
if (!isset($options['class'])) {
$options['class'] = sfConfig::get('sf_validation_error_class', 'form_error');
}
if (!isset($options['id'])) {
$options['id'] = sfConfig::get('sf_validation_error_id_prefix', 'error_for_') . get_id_from_name($param);
}
$prefix = sfConfig::get('sf_validation_error_prefix', '');
if (isset($options['prefix'])) {
$prefix = $options['prefix'];
unset($options['prefix']);
}
$suffix = sfConfig::get('sf_validation_error_suffix', '');
if (isset($options['suffix'])) {
$suffix = $options['suffix'];
unset($options['suffix']);
}
$error = $request->getError($param_for_sf, $catalogue);
return content_tag('div', $prefix . $error . $suffix, $options) . "\n";
}
开发者ID:taryono,项目名称:school,代码行数:27,代码来源:ValidationHelper.php
示例2: render
public function render($name, $value = null, $attributes = array(), $errors = array())
{
$context = sfContext::getInstance();
$response = $context->getResponse();
$autocompleteDiv = "";
// content_tag('div' , '', array('id' => $this->generateId($name) . '_autocomplete', 'class' => 'autocomplete'));
$desc = '';
if (true === $this->getOption('desc')) {
$desc = '.data( "ui-autocomplete" )._renderItem = function( ul, item ) {
return $( "<li>" )
.append( "<a>" + item.label + "<br>" + item.desc + "</a>" )
.appendTo( ul );
}';
}
$autocompleteJs = $this->javascriptTag("\n \n \$(function(){\n \n \$('#" . $this->generateId($name) . "_ajaxtext').autocomplete({\n source: '" . url_for($this->getOption('url')) . "',\n delay:30,\n minChars:0,\n appendTo: '" . $this->getOption('appendTo') . "',\n max:30,\n width: 300,\n matchSubset:1,\n matchContains:1,\n cacheLength:10,\n autoFill:false,\n autoFocus: true,\n select: function( event, ui ) {\n \$('#" . $this->generateId($name) . "').val(ui.item.id);\n \$('#" . get_id_from_name($name) . "_ajaxcheckbox').prop('checked', true)\n \$('#" . get_id_from_name($name) . "_ajaxcheckboxText').html('" . __('kiválasztva') . "');\n \$('#" . $this->generateId($name) . "').trigger('change', [ui.item])\n } \n }){$desc}\n \n \n \n \$.fn.autocomplete.keypressEvent = function (evt, id){\n car = evt.keyCode || evt.charCode;\n if (car != 27 && car!=9) //ESC + TAB\n {\n \$('#'+id).val('');\n \$('#'+id+'_ajaxcheckbox').attr('checked',false);\n \$('#'+id+'_ajaxcheckboxText').html('" . __('nincs kiválasztva') . "'); \n \$('#" . $this->generateId($name) . "').trigger('change')\n } \n } \n \n });");
$ihidden = new sfWidgetFormInputHidden();
$ihiddenText = $ihidden->render($name, $value, $attributes);
if ($value != '') {
$checked = 'checked="checked"';
$checkboxtext = "<span id='" . get_id_from_name($name) . "_ajaxcheckboxText'>" . __('kiválasztva') . "</span>";
} else {
$checked = '';
$checkboxtext = "<span id='" . get_id_from_name($name) . "_ajaxcheckboxText'>" . __('nincs kiválasztva') . "</span>";
}
$checkbox = '<input type="checkbox" id="' . get_id_from_name($name) . '_ajaxcheckbox' . '" ' . $checked . ' disabled="disabled" />';
$attributesText = array_merge($attributes, array('name' => false, 'id' => get_id_from_name($name) . '_ajaxtext'));
$attributesText['onkeydown'] = "\$('#" . $this->generateId($name) . "_ajaxtext').autocomplete.keypressEvent(event, '" . $this->generateId($name) . "')";
$itextText = parent::render($name, $this->getValueFromId($value), $attributesText, $errors);
$indicator = '<span id="indicator-' . $this->generateId($name) . '" style="display: none;"> <img src="/sfFormExtraPlugin/images/indicator.gif" alt="loading" /></span>';
return $ihiddenText . $itextText . $checkbox . $checkboxtext . $indicator . $autocompleteDiv . $autocompleteJs;
}
开发者ID:nova76,项目名称:nova-plugins,代码行数:31,代码来源:novaWidgetFormjQqueryUIAutocomplete.class.php
示例3: render
/**
* Renders the widget.
*
* @param string $name The element name
* @param string $value The value selected in this widget
* @param array $attributes An array of HTML attributes to be merged with the default HTML attributes
* @param array $errors An array of errors for the field
*
* @return string An HTML tag string
*
* @see sfWidgetForm
*/
public function render($name, $value = null, $attributes = array(), $errors = array())
{
if ($this->getOption('multiple')) {
$attributes['multiple'] = 'multiple';
if ('[]' != substr($name, -2)) {
$name .= '[]';
}
}
if (!$this->getOption('renderer') && !$this->getOption('renderer_class') && $this->getOption('expanded')) {
unset($attributes['multiple']);
}
if (sfConfig::get('app_use_javascript_dropdown') == 'on') {
$choice_menu = convertChoicesToYuiMenu(get_id_from_name($name), $this->getOption('choices'), $this->getOption('multiple'), $this->getOption('expanded'));
$use_yui_menu = true;
if (isset($attributes['style'])) {
if (strstr($attributes['style'], 'display')) {
$use_yui_menu = false;
}
}
} else {
$choice_menu = '';
$use_yui_menu = false;
}
if (strlen($choice_menu) > 0 and $use_yui_menu) {
return '<table cellpadding="0" cellspacing="0"><tr><td style="padding: 0px;">' . $choice_menu . '</td><td style="padding: 0px;">' . $this->getRenderer()->render($name, $value, $attributes, $errors) . '</td></tr></table>';
} else {
return $this->getRenderer()->render($name, $value, $attributes, $errors);
}
}
开发者ID:noikiy,项目名称:qdpm,代码行数:41,代码来源:sfWidgetFormChoice.class.php
示例4: object_input_auto_complete_tag
function object_input_auto_complete_tag($object, $method, $options = array(), $default_value = null)
{
$peer_table = _get_option($options, 'peer_table');
$peer_field = _get_option($options, 'peer_field');
$input_name = _convert_method_to_name($method, $options);
echo input_auto_complete_tag("{$peer_table}_{$peer_field}_search", '', sfContext::getInstance()->getModuleName() . "/autocomplete?table={$peer_table}&field={$peer_field}", array('autocomplete' => 'off'), array('use_style' => true, 'after_update_element' => "function (inputField, selectedItem) { \$('" . get_id_from_name($input_name) . "').value = selectedItem.id; }", 'method' => 'get'));
echo input_hidden_tag($input_name);
}
开发者ID:psskhal,项目名称:symfony-sample,代码行数:8,代码来源:AdvancedAdminHelper.php
示例5: toHTML
/**
* Returns the rich text editor as HTML.
*
* @return string Rich text editor HTML representation
*/
public function toHTML()
{
$options = $this->options;
// we need to know the id for things the rich text editor
// in advance of building the tag
$id = _get_option($options, 'id', get_id_from_name($this->name, null));
// use tinymce's gzipped js?
$tinymce_file = _get_option($options, 'tinymce_gzip') ? '/tiny_mce_gzip.php' : '/tiny_mce.js';
// tinymce installed?
$js_path = sfConfig::get('sf_rich_text_js_dir') ? '/' . sfConfig::get('sf_rich_text_js_dir') . $tinymce_file : '/sf/tinymce/js' . $tinymce_file;
if (!is_readable(sfConfig::get('sf_web_dir') . $js_path)) {
throw new sfConfigurationException('You must install TinyMCE to use this helper (see rich_text_js_dir settings).');
}
sfContext::getInstance()->getResponse()->addJavascript($js_path);
use_helper('Javascript');
$tinymce_options = '';
$style_selector = '';
// custom CSS file?
if ($css_file = _get_option($options, 'css')) {
$css_path = stylesheet_path($css_file);
sfContext::getInstance()->getResponse()->addStylesheet($css_path);
$css = file_get_contents(sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . $css_path);
$styles = array();
preg_match_all('#^/\\*\\s*user:\\s*(.+?)\\s*\\*/\\s*\\015?\\012\\s*\\.([^\\s]+)#Smi', $css, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$styles[] = $match[1] . '=' . $match[2];
}
$tinymce_options .= ' content_css: "' . $css_path . '",' . "\n";
$tinymce_options .= ' theme_advanced_styles: "' . implode(';', $styles) . '"' . "\n";
$style_selector = 'styleselect,separator,';
}
$culture = sfContext::getInstance()->getUser()->getCulture();
$tinymce_js = '
tinyMCE.init({
mode: "exact",
language: "' . strtolower(substr($culture, 0, 2)) . '",
elements: "' . $id . '",
plugins: "table,advimage,advlink,flash",
theme: "advanced",
theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align: "left",
theme_advanced_path_location: "bottom",
theme_advanced_buttons1: "' . $style_selector . 'justifyleft,justifycenter,justifyright,justifyfull,separator,bold,italic,strikethrough,separator,sub,sup,separator,charmap",
theme_advanced_buttons2: "bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,image,flash,separator,cleanup,removeformat,separator,code",
theme_advanced_buttons3: "tablecontrols",
extended_valid_elements: "img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|style]",
relative_urls: false,
debug: false
' . ($tinymce_options ? ',' . $tinymce_options : '') . '
' . (isset($options['tinymce_options']) ? ',' . $options['tinymce_options'] : '') . '
});';
if (isset($options['tinymce_options'])) {
unset($options['tinymce_options']);
}
return content_tag('script', javascript_cdata_section($tinymce_js), array('type' => 'text/javascript')) . content_tag('textarea', $this->content, array_merge(array('name' => $this->name, 'id' => $id), _convert_options($options)));
}
开发者ID:Daniel-Marynicz,项目名称:symfony1-legacy,代码行数:61,代码来源:sfRichTextEditorTinyMCE.class.php
示例6: input_sf_asset_tag
function input_sf_asset_tag($name, $value, $options = array())
{
use_helper('Form', 'I18N');
use_javascript('/sfDoctrineAssetsLibraryPlugin/js/main', 'last');
$options = _convert_options($options);
$type = 'all';
if (isset($options['images_only'])) {
$type = 'image';
unset($options['images_only']);
}
if (!isset($options['id'])) {
$options['id'] = get_id_from_name($name);
}
$form_name = 'this.previousSibling.previousSibling.form.name';
if (isset($options['form_name'])) {
$form_name = "'" . $options['form_name'] . "'";
unset($options['form_name']);
}
// The popup should open in the currently selected subdirectory
$html = input_tag($name, $value, $options) . ' ';
$html .= image_tag('/sfDoctrineAssetsLibraryPlugin/images/folder_open', array('alt' => __('Insert Image'), 'style' => 'cursor: pointer; vertical-align: middle', 'onclick' => "\n initialDir = document.getElementById('" . $options['id'] . "').value.replace(/\\/[^\\/]*\$/, '');\n if(!initialDir) initialDir = '" . sfConfig::get('app_sfDoctrineAssetsLibrary_upload_dir', 'media') . "';\n sfAssetsLibrary.openWindow({\n form_name: " . $form_name . ",\n field_name: '" . $name . "',\n type: '" . $type . "',\n url: '" . url_for('sfAsset/list?dir=PLACEHOLDER') . "?popup=2'.replace('PLACEHOLDER', initialDir),\n scrollbars: 'yes'\n });"));
return $html;
}
开发者ID:vjousse,项目名称:sfDoctrineAssetsLibraryPlugin,代码行数:23,代码来源:sfAssetHelper.php
示例7: render
public function render($name, $value = null, $attributes = array(), $errors = array())
{
$context = sfContext::getInstance();
$response = $context->getResponse();
$response->addJavascript('/sfFormExtraPlugin/js/jquery.autocompleter.js', 'last');
$response->addStylesheet('/sfFormExtraPlugin/css/jquery.autocompleter.css');
$autocompleteDiv = content_tag('div', '', array('id' => $this->generateId($name) . '_autocomplete', 'class' => 'autocomplete'));
$autocompleteJs = $this->javascriptTag("\n jQuery(function(){\n jQuery('#" . $this->generateId($name) . "_ajaxtext').result(function(event, data, formatted) {\n " . $this->generateId($name) . "_jquery_autocomplete_changed = true;\n jQuery('#" . $this->generateId($name) . "').val(data[1]);\n jQuery('#" . get_id_from_name($name) . "_ajaxcheckbox').attr('checked',true);\n jQuery('#" . get_id_from_name($name) . "_ajaxcheckboxText').html('" . __('kiválasztva') . "');\n jQuery('#" . $this->generateId($name) . "').trigger('change', [data])\n });\n jQuery('#" . $this->generateId($name) . "_ajaxtext').autocomplete('" . url_for($this->getOption('url')) . "', {\n delay:30,\n minChars:0,\n extraParams : " . $this->getOption('extraParams') . ",\n max:30,\n width: 300,\n matchSubset:1,\n matchContains:1,\n cacheLength:10,\n autoFill:false,\n selectFirst: true\n });\n \n jQuery('#" . $this->generateId($name) . "_ajaxtext').bind('focus', function(){\n \t\t\tjQuery(this).setOptions({\n \t\t\t\tdelay:30,\n \t\t\t\tminChars:0,\n \t\t\t\textraParams : " . $this->getOption('extraParams') . ",\n \t\t\t\tmax:30,\n \t\t\t\twidth: 300,\n \t\t\t\tmatchSubset:1,\n \t\t\t\tmatchContains:1,\n \t\t\t\tcacheLength:10,\n \t\t\t\tautoFill:false,\n \t\t\t\tselectFirst: true\n \t\t\t});\n\t\t\t jQuery(this).flushCache(); \n }) \n \n jQuery.fn.autocomplete.keypressEvent = function (evt, id){\n car = evt.keyCode || evt.charCode;\n if (car != 27 && car!=9) //ESC + TAB\n {\n jQuery('#'+id).val('');\n jQuery('#'+id+'_ajaxcheckbox').attr('checked',false);\n jQuery('#'+id+'_ajaxcheckboxText').html('" . __('nincs kiválasztva') . "'); \n jQuery('#" . $this->generateId($name) . "').trigger('change')\n } \n } \n \n });");
$ihidden = new sfWidgetFormInputHidden();
$ihiddenText = $ihidden->render($name, $value, $attributes);
if ($value != '') {
$checked = 'checked="checked"';
$checkboxtext = "<span id='" . get_id_from_name($name) . "_ajaxcheckboxText'>" . __('kiválasztva') . "</span>";
} else {
$checked = '';
$checkboxtext = "<span id='" . get_id_from_name($name) . "_ajaxcheckboxText'>" . __('nincs kiválasztva') . "</span>";
}
$checkbox = '<input type="checkbox" id="' . get_id_from_name($name) . '_ajaxcheckbox' . '" ' . $checked . ' disabled="disabled" />';
$attributesText = array_merge($attributes, array('name' => false, 'id' => get_id_from_name($name) . '_ajaxtext'));
$attributesText['onkeydown'] = "jQuery('#" . $this->generateId($name) . "_ajaxtext').autocomplete.keypressEvent(event, '" . $this->generateId($name) . "')";
$itextText = parent::render($name, $this->getValueFromId($value), $attributesText, $errors);
$indicator = '<span id="indicator-' . $this->generateId($name) . '" style="display: none;"> <img src="/sfFormExtraPlugin/images/indicator.gif" alt="loading" /></span>';
return $ihiddenText . $itextText . $checkbox . $checkboxtext . $indicator . $autocompleteDiv . $autocompleteJs;
}
开发者ID:nova76,项目名称:nova-plugins,代码行数:24,代码来源:sfWidgetFormAutocomplete.class.php
示例8: array
$t->is(submit_tag(), '<input type="submit" name="commit" value="Save changes" />', 'submit_tag() default value is "Save changes"');
$t->is(submit_tag("save"), '<input type="submit" name="commit" value="save" />', 'submit_tag() takes a value as its first argument');
// options
$t->is(submit_tag('save', array('class' => 'foo')), '<input type="submit" name="commit" value="save" class="foo" />', 'submit_tag() takes an array of attribute options as its second argument');
$t->is(submit_tag('save', array('name' => 'foo')), '<input type="submit" name="foo" value="save" />', 'submit_tag() can override the "name" attribute');
// reset_tag()
$t->diag('reset_tag()');
$t->is(reset_tag(), '<input type="reset" name="reset" value="Reset" />', 'reset_tag() default value is "Reset"');
$t->is(reset_tag("save"), '<input type="reset" name="reset" value="save" />', 'reset_tag() takes a value as its first argument');
// options
$t->is(reset_tag('save', array('class' => 'foo')), '<input type="reset" name="reset" value="save" class="foo" />', 'reset_tag() takes an array of attribute options as its second argument');
$t->is(reset_tag('save', array('name' => 'foo')), '<input type="reset" name="foo" value="save" />', 'reset_tag() can override the "name" attribute');
// submit_image_tag()
$t->diag('submit_image_tag()');
$t->is(submit_image_tag('submit'), '<input type="image" name="commit" src="/images/submit.png" alt="Submit" />', 'submit_image_tag() takes an image source as its first argument');
$t->is(submit_image_tag('/img/submit.gif'), '<input type="image" name="commit" src="/img/submit.gif" alt="Submit" />', 'submit_image_tag() takes an image source as its first argument');
// options
$t->is(submit_image_tag('submit', array('class' => 'foo')), '<input type="image" name="commit" src="/images/submit.png" class="foo" alt="Submit" />', 'submit_image_tag() takes an array of attribute options as its second argument');
$t->is(submit_image_tag('submit', array('alt' => 'foo')), '<input type="image" name="commit" src="/images/submit.png" alt="foo" />', 'reset_tag() can override the "alt" attribute');
$t->is(submit_image_tag('submit', array('name' => 'foo')), '<input type="image" name="foo" src="/images/submit.png" alt="Submit" />', 'reset_tag() can override the "name" attribute');
// label_for()
$t->diag('label_for()');
$t->todo('label_for()');
// get_id_from_name()
$t->diag('get_id_from_name()');
$t->is(get_id_from_name('foo'), 'foo', 'get_id_from_name() returns the id if there is no [] in the id');
$t->is(get_id_from_name('foo[]', 'name'), 'foo_name', 'get_id_from_name() removes all [] from ids');
// _convert_options()
$t->diag('_convert_options()');
$t->is(_convert_options(array('class' => 'foo', 'multiple' => true)), array('class' => 'foo', 'multiple' => 'multiple'), '_convert_options() converts some options for XHTML compliance');
$t->is(_convert_options(array('class' => 'foo', 'multiple' => false)), array('class' => 'foo'), '_convert_options() converts some options for XHTML compliance');
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:31,代码来源:FormHelperTest.php
示例9: select_empresas2
function select_empresas2($name, $option_tags = null, $options = array())
{
$options = _parse_attributes($options);
if (!isset($options['control_name'])) {
$options['control_name'] = 'empresa[id_empresa]';
}
if (!isset($options['control_name_tablas'])) {
$options['control_name_tablas'] = 'tabla[id_tabla]';
}
$include_custom = _get_option($options, 'include_custom');
$include_blank = _get_option($options, 'include_custom') ? 'true' : 'false';
$param_include_custom = isset($include_custom) && $include_custom != '' ? " + '&include_custom=' + " . $include_custom . "" : null;
$id_select_empresa = get_id_from_name($options['control_name']);
$id_select_tablas = get_id_from_name($options['control_name_tablas']);
$select = select_tag($name, $option_tags, array('control_name' => $options['control_name'], 'onChange' => "recargar_tablas();"));
$html = $select;
$html .= "\n";
$js = "\n function recargar_tablas()\n {\n var empresa = document.getElementById('" . $id_select_empresa . "').value;\n " . remote_function(array('update' => $id_select_tablas, 'url' => 'empresas/update_select_tablas2', 'with' => "'id_empresa='+empresa + '&include_blank='+ " . $include_blank . "" . $param_include_custom . "")) . "\n }";
$html .= content_tag('script', $js, array('type' => 'text/javascript'));
return $html;
}
开发者ID:Esleelkartea,项目名称:legedia-ESLE,代码行数:21,代码来源:MisObjetosHelper.php
示例10: jq_input_auto_complete_tag
/**
* wrapper for script.aculo.us/prototype Ajax.Autocompleter.
* @author Bruno Adele <[email protected]>
* @param string name value of input field
* @param string default value for input field
* @param array input tag options. (size, autocomplete, etc...)
* @param array completion options. (use_style, etc...)
*
* Example:
* echo jq_input_auto_complete_tag('q','', 'search/index',array(
* 'size' => 15),array(
* 'use_style' => false,
* 'scrollHeight' => 480,
* 'scroll' => false,
* 'highlight' => false,
* ) ) ?>
*
* @return string input field tag, div for completion results, and
* auto complete javascript tags
*/
function jq_input_auto_complete_tag($name, $value, $url, $tag_options = array(), $completion_options = array())
{
// We need ui.autocomplete for this trick
jq_add_plugins_by_name(array("autocomplete"));
$tag_options = _convert_options($tag_options);
$comp_options = _convert_options($completion_options);
// Convert to JSON parameters
$jsonOptions = '';
foreach ($comp_options as $key => $val) {
if ($jsonOptions != '') {
$jsonOptions .= ', ';
}
switch ($key) {
case 'formatItem':
case 'formatResult':
$jsonOptions .= "{$key}: " . $val;
break;
default:
$jsonOptions .= "{$key}: " . json_encode($val);
break;
}
}
// Get Stylesheet
$context = sfContext::getInstance();
$response = $context->getResponse();
$comp_options = _convert_options($completion_options);
if (isset($comp_options['use_style']) && $comp_options['use_style'] == true) {
$response->addStylesheet(sfConfig::get('sf_jquery_web_dir') . '/css/JqueryAutocomplete');
}
// Get Id from name attribute
$tag_options['id'] = get_id_from_name(isset($tag_options['id']) ? $tag_options['id'] : $name);
// Add input form
$javascript = tag('input', array_merge(array('type' => 'text', 'name' => $name, 'value' => $value), _convert_options($tag_options)));
// Calc JQuery Javascript code
$autocomplete_script = sprintf('$("#%s").autocomplete("%s",{ %s });', $name, $url, $jsonOptions);
$javascript .= javascript_tag($autocomplete_script);
return $javascript;
}
开发者ID:slemoigne,项目名称:sympal,代码行数:58,代码来源:jQueryHelper.php
示例11: radiobutton_tag
/**
* Returns an XHTML compliant <input> tag with type="radio".
*
* <b>Examples:</b>
* <code>
* echo ' Yes '.radiobutton_tag('newsletter', 1);
* echo ' No '.radiobutton_tag('newsletter', 0);
* </code>
*
* @param string $name field name
* @param string $value radio button value (if selected)
* @param bool $checked is the radio button selected? (1 or 0)
* @param array $options additional HTML compliant <input> tag parameters
*
* @return string XHTML compliant <input> tag with type="radio"
*/
function radiobutton_tag($name, $value, $checked = false, $options = array())
{
$html_options = array_merge(array('type' => 'radio', 'name' => $name, 'id' => get_id_from_name($name . '[]', $value), 'value' => $value), _convert_options($options));
if ($checked) {
$html_options['checked'] = 'checked';
}
return tag('input', $html_options);
}
开发者ID:auphau,项目名称:joyreactor,代码行数:24,代码来源:UrlHelper.php
示例12: label_for
/**
* Returns a <label> tag with <i>$label</i> for the specified <i>$id</i> parameter.
*
* @param string $id id
* @param string $label label or title
* @param array $options additional HTML compliant <label> tag parameters
*
* @return string <label> tag with <i>$label</i> for the specified <i>$id</i> parameter.
*/
function label_for($id, $label, $options = array())
{
$options = _parse_attributes($options);
if (is_object($label) && method_exists($label, '__toString')) {
$label = $label->__toString();
}
return content_tag('label', $label, array_merge(array('for' => get_id_from_name($id, null)), $options));
}
开发者ID:souravmondal-cn,项目名称:symfonyweather,代码行数:17,代码来源:FormHelper.php
示例13: object_admin_check_list
function object_admin_check_list($object, $method, $options = array(), $callback = null)
{
$options = _parse_attributes($options);
// get the lists of objects
list($objects, $objects_associated, $assoc_ids) = _get_object_list($object, $method, $options, $callback);
// override field name
unset($options['control_name']);
$name = 'associated_' . _convert_method_to_name($method, $options) . '[]';
$html = '';
if (!empty($objects)) {
// which method to call?
$methodToCall = '__toString';
foreach (array('__toString', 'toString', 'getPrimaryKey') as $method) {
if (method_exists($objects[0], $method)) {
$methodToCall = $method;
break;
}
}
$html .= "<ul class=\"sf_admin_checklist\">\n";
foreach ($objects as $related_object) {
$relatedPrimaryKey = $related_object->getPrimaryKey();
// multi primary key handling
if (is_array($relatedPrimaryKey)) {
$relatedPrimaryKeyHtmlId = implode('/', $relatedPrimaryKey);
} else {
$relatedPrimaryKeyHtmlId = $relatedPrimaryKey;
}
$html .= '<li>' . checkbox_tag($name, $relatedPrimaryKeyHtmlId, in_array($relatedPrimaryKey, $assoc_ids)) . ' <label for="' . get_id_from_name($name, $relatedPrimaryKeyHtmlId) . '">' . $related_object->{$methodToCall}() . "</label></li>\n";
}
$html .= "</ul>\n";
}
return $html;
}
开发者ID:taryono,项目名称:school,代码行数:33,代码来源:ObjectAdminHelper.php
示例14: _auto_complete_field
/**
* wrapper for script.aculo.us/prototype Ajax.Autocompleter.
* @param string id value of input field
* @param string url of module/action to execute for autocompletion
* @param array completion options
* @return string javascript tag for Ajax.Autocompleter
*/
function _auto_complete_field($field_id, $url, $options = array())
{
$javascript = "new Ajax.Autocompleter(";
$javascript .= "'" . get_id_from_name($field_id) . "', ";
if (isset($options['update'])) {
$javascript .= "'" . $options['update'] . "', ";
} else {
$javascript .= "'" . get_id_from_name($field_id) . "_auto_complete', ";
}
$javascript .= array_or_string_for_javascript(url_for($url));
$js_options = array();
if (isset($options['tokens'])) {
$js_options['tokens'] = array_or_string_for_javascript($options['tokens']);
}
if (isset($options['with'])) {
$js_options['callback'] = "function(element, value) { return " . $options['with'] . "}";
}
if (isset($options['indicator'])) {
$js_options['indicator'] = array_or_string_for_javascript($options['indicator']);
}
if (isset($options['on_show'])) {
$js_options['onShow'] = $options['on_show'];
}
if (isset($options['on_hide'])) {
$js_options['onHide'] = $options['on_hide'];
}
if (isset($options['min_chars'])) {
$js_options['minChars'] = $options['min_chars'];
}
if (isset($options['frequency'])) {
$js_options['frequency'] = $options['frequency'];
}
if (isset($options['update_element'])) {
$js_options['updateElement'] = $options['update_element'];
}
if (isset($options['after_update_element'])) {
$js_options['afterUpdateElement'] = $options['after_update_element'];
}
if (isset($options['param_name'])) {
$js_options['paramName'] = "'" . $options['param_name'] . "'";
}
$javascript .= ', ' . options_for_javascript($js_options) . ');';
return javascript_tag($javascript);
}
开发者ID:retrofox,项目名称:sfPropelMooDooPlugin,代码行数:51,代码来源:JavascriptHelper.php
示例15: toHTML
//.........这里部分代码省略.........
public function toHTML()
{
$options = $this->options;
// we need to know the id for things the rich text editor
// in advance of building the tag
$id = _get_option($options, 'id', $this->name);
// use tinymce's gzipped js?
$tinymce_file = _get_option($options, 'tinymce_gzip') ? '/tiny_mce_gzip.php' : '/tiny_mce.js';
// tinymce installed?
$js_path = sfConfig::get('sf_rich_text_js_dir') ? '/' . sfConfig::get('sf_rich_text_js_dir') . $tinymce_file : '/sf/tinymce/js' . $tinymce_file;
if (!is_readable(sfConfig::get('sf_web_dir') . $js_path)) {
throw new sfConfigurationException('You must install TinyMCE to use this helper (see rich_text_js_dir settings).');
}
sfContext::getInstance()->getResponse()->addJavascript($js_path);
use_helper('Javascript');
$tinymce_options = '';
$style_selector = '';
// custom CSS file?
if ($css_file = _get_option($options, 'css')) {
$css_path = stylesheet_path($css_file);
sfContext::getInstance()->getResponse()->addStylesheet($css_path);
$css = file_get_contents(sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . $css_path);
$styles = array();
preg_match_all('#^/\\*\\s*user:\\s*(.+?)\\s*\\*/\\s*\\015?\\012\\s*\\.([^\\s]+)#Smi', $css, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$styles[] = $match[1] . '=' . $match[2];
}
$tinymce_options .= ' content_css: "' . $css_path . '",' . "\n";
$tinymce_options .= ' theme_advanced_styles: "' . implode(';', $styles) . '"' . "\n";
$style_selector = 'styleselect,separator,';
}
$config = sfConfig::get('sf_config_dir_name');
$path = sfConfigCache::getInstance()->checkConfig($config . DIRECTORY_SEPARATOR . 'tiny_mce.yml');
$config = sfYaml::load($path);
$culture = isset($config['culture']) ? $config['culture'] : sfContext::getInstance()->getUser()->getCulture();
$mode = $config['options']['mode'];
$plugins = implode(',', $config['options']['plugins']);
$theme = $config['options']['theme'];
$tbLocation = $config['options']['theme_settings']['theme_' . $theme . '_toolbar_location'];
$tbAlign = $config['options']['theme_settings']['theme_' . $theme . '_toolbar_align'];
$pathLocation = $config['options']['theme_settings']['theme_' . $theme . '_path_location'];
$buttons = array();
reset($config['options']['theme_settings']['buttons']);
while (($key = key($config['options']['theme_settings']['buttons'])) !== null) {
$current = current($config['options']['theme_settings']['buttons']);
$buttons[] = $key . ': "' . implode(',', $current) . '"';
next($config['options']['theme_settings']['buttons']);
}
$buttons = implode(",\n", $buttons);
$extendedValidElements = array();
reset($config['options']['theme_settings']['extended_valid_elements']);
while (($key = key($config['options']['theme_settings']['extended_valid_elements'])) !== null) {
$current = current($config['options']['theme_settings']['extended_valid_elements']);
$extendedValidElements[] = $key . '[' . implode('|', $current) . ']';
next($config['options']['theme_settings']['extended_valid_elements']);
}
$extendedValidElements = '"' . implode(",\n", $extendedValidElements) . '"';
$relativeUrls = $config['options']['relative_urls'] ? 'true' : 'false';
$debug = $config['options']['debug'] ? 'true' : 'false';
$tinymce_js = 'tinyMCE.init({';
// Mode
$tinymce_js .= "mode: '{$mode}'";
// Language
$tinymce_js .= ', language: "' . strtolower(substr($culture, 0, 2)) . '"';
// Elements
$tinymce_js .= ', elements: "' . $id . '"';
// Plugins
if ($plugins) {
$tinymce_js .= ', plugins: "' . $plugins . '"';
}
// Theme
$tinymce_js .= ", theme: '{$theme}'";
// Toolbar
$tinymce_js .= ', theme_' . $theme . '_toolbar_location: "' . $tbLocation . '"';
$tinymce_js .= ', theme_' . $theme . '_toolbar_align: "' . $tbAlign . '"';
$tinymce_js .= ', theme_' . $theme . '_path_location: "' . $pathLocation . '"';
// Buttons
if ($buttons) {
$tinymce_js .= ', ' . $buttons;
}
// Extended Valid Elements
$tinymce_js .= ', extended_valid_elements: ' . $extendedValidElements;
// Relative Urls
$tinymce_js .= ', relative_urls: ' . $relativeUrls;
// Debug
$tinymce_js .= ', debug: ' . $debug;
// Custom Options
$tinymce_js .= $tinymce_options ? ',' . $tinymce_options : '';
$tinymce_js .= isset($options['tinymce_options']) ? ',' . $options['tinymce_options'] : '';
if (isset($config['options']['misc'])) {
foreach ($config['options']['misc'] as $name => $value) {
$tinymce_js .= ", {$name}: \"{$value}\"";
}
}
if (isset($options['tinymce_options'])) {
unset($options['tinymce_options']);
}
$tinymce_js .= '});';
return content_tag('script', javascript_cdata_section($tinymce_js), array('type' => 'text/javascript')) . content_tag('textarea', $this->content, array_merge(array('name' => $this->name, 'id' => get_id_from_name($id, null)), _convert_options($options)));
}
开发者ID:sgrove,项目名称:cothinker,代码行数:101,代码来源:sfRichTextEditorTinyMCEExtended.class.php
示例16: zz_input_date_tag
function zz_input_date_tag($name, $value, $options = array())
{
$options = _parse_attributes($options);
$context = sfContext::getInstance();
if (isset($options['culture'])) {
$culture = $options['culture'];
unset($options['culture']);
} else {
$culture = $context->getUser()->getCulture();
}
// rich control?
$rich = false;
if (isset($options['rich'])) {
$rich = $options['rich'];
unset($options['rich']);
}
if (!$rich) {
throw new sfException('input_date_tag (rich=off) is not yet implemented');
}
$date_pattern = 'p';
if (isset($options['date_pattern'])) {
$date_pattern = $options['date_pattern'];
unset($options['date_pattern']);
}
// parse date
if ($value === null || $value === '') {
$value = '';
} else {
$dateFormat = new sfDateFormat($culture);
$value = $dateFormat->format($value, $date_pattern);
}
// register our javascripts and stylesheets
$langFile = '/sf/js/calendar/lang/calendar-' . strtolower(substr($culture, 0, 2));
$jss = array('/sf/js/calendar/calendar', is_readable(sfConfig::get('sf_symfony_data_dir') . '/web/' . $langFile . '.js') ? $langFile : '/sf/js/calendar/lang/calendar-en', '/sf/js/calendar/calendar-setup');
foreach ($jss as $js) {
$context->getResponse()->addJavascript($js);
}
$context->getResponse()->addStylesheet('/sf/js/calendar/skins/aqua/theme');
// date format
$dateFormatInfo = sfDateTimeFormatInfo::getInstance($culture);
$date_format = strtolower($dateFormatInfo->getShortDatePattern());
// calendar date format
$calendar_date_format = $date_format;
$calendar_date_format = strtr($calendar_date_format, array('M' => 'm', 'y' => 'Y'));
$calendar_date_format = preg_replace('/([mdy])+/i', '%\\1', $calendar_date_format);
$js = '
document.getElementById("trigger_' . $name . '").disabled = false;
Calendar.setup({
inputField : "' . get_id_from_name($name) . '",
ifFormat : "' . $calendar_date_format . '",
button : "trigger_' . $name . '"
});
';
// construct html
if (!isset($options['size'])) {
$options['size'] = 9;
}
$html = input_tag($name, $value, $options);
// calendar button
$calendar_button = '...';
$calendar_button_type = 'txt';
if (isset($options['calendar_button_img'])) {
$calendar_button = $options['calendar_button_img'];
$calendar_button_type = 'img';
unset($options['calendar_button_img']);
} else {
if (isset($options['calendar_button_txt'])) {
$calendar_button = $options['calendar_button_txt'];
$calendar_button_type = 'txt';
unset($options['calendar_button_txt']);
}
}
if ($calendar_button_type == 'img') {
$html .= image_tag($calendar_button, array('id' => 'trigger_' . $name, 'style' => 'cursor: pointer; vertical-align: middle'));
} else {
$html .= content_tag('button', $calendar_button, array('type' => 'button', 'disabled' => 'disabled', 'onclick' => 'return false', 'id' => 'trigger_' . $name));
}
if (isset($options['with_format'])) {
$html .= '(' . $date_format . ')';
unset($options['with_format']);
}
// add javascript
$html .= content_tag('script', $js, array('type' => 'text/javascript'));
return $html;
}
开发者ID:mediasadc,项目名称:alba,代码行数:85,代码来源:ZZDateHelper.php
示例17: bool_selector_from_list
function bool_selector_from_list($field, $config, $value)
{
$list = sfConfig::get($config);
$title = $list[$value];
$out = ucfirst(__($title)) . __(' :') . ' ';
$out .= select_tag($field . '[]', options_for_select(array($value => __('yes'), '!' . $value => __('no')), '', array('include_blank' => true)), array('id' => get_id_from_name($field) . '_' . $value));
return $out;
}
开发者ID:snouhaud,项目名称 |
请发表评论