本文整理汇总了PHP中_get_option函数的典型用法代码示例。如果您正苦于以下问题:PHP _get_option函数的具体用法?PHP _get_option怎么用?PHP _get_option使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_get_option函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: adv_options_for_select
/**
* Override of the standard options_for_select, that allows the usage of the 'include_zero_custom' option
* to insert a custom field returning the 0 value on top of the options
*
* @return String
* @author Guglielmo Celata
**/
function adv_options_for_select($options = array(), $selected = '', $html_options = array())
{
$html_options = _parse_attributes($html_options);
if (is_array($selected)) {
$selected = array_map('strval', array_values($selected));
}
$html = '';
if ($value = _get_option($html_options, 'include_zero_custom')) {
$html .= content_tag('option', $value, array('value' => '0')) . "\n";
} else {
if ($value = _get_option($html_options, 'include_custom')) {
$html .= content_tag('option', $value, array('value' => '')) . "\n";
} else {
if (_get_option($html_options, 'include_blank')) {
$html .= content_tag('option', '', array('value' => '')) . "\n";
}
}
}
foreach ($options as $key => $value) {
if (is_array($value)) {
$html .= content_tag('optgroup', options_for_select($value, $selected, $html_options), array('label' => $key)) . "\n";
} else {
$option_options = array('value' => $key);
if (is_array($selected) && in_array(strval($key), $selected, true) || strval($key) == strval($selected)) {
$option_options['selected'] = 'selected';
}
$html .= content_tag('option', $value, $option_options) . "\n";
}
}
return $html;
}
示例2: object_enum_tag
function object_enum_tag($object, $method, $options)
{
$enumValues = _get_option($options, 'enumValues', array());
$currentValue = _get_object_value($object, $method);
$enumValues = array_combine($enumValues, $enumValues);
return select_tag(_convert_method_to_name($method, $options), options_for_select($enumValues, $currentValue), $options);
}
示例3: 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);
}
示例4: 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', $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;
$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]",
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' => get_id_from_name($id, null)), _convert_options($options)));
}
示例5: gtip
/**
* Returns a link with a gTip (tooltip) attached to it
*
* @param string $content content to show inside the a tag (tooltip controller)
* @param string $content_tip content to show inside the tooltip if not ajax (tooltip container)
* @param array $options Options of the a link and tooltip
*
* @author Gerald Estadieu <gestadieu@gmail.com>
* @since 15 Apr 2007
*
*/
function gtip($content, $content_tip = '', $options = array())
{
_loadRessources();
$html_options = _parse_attributes($options);
$html_options['class'] = _get_option($options, 'class', '') . ' gtip';
$tooltip = '';
$href = _get_option($options, 'href', '');
if (isset($options['id'])) {
$tooltip = content_tag('div', $content_tip, array('id' => $options['id'], 'style' => 'display:none;'));
unset($html_options['id']);
$html_options['query_string'] = $options['query_string'] ? 'gtip=' . $options['id'] . '&' . $options['query_string'] : 'gtip=' . $options['id'];
}
return link_to($content, $href, $html_options) . $tooltip;
}
示例6: object_multiselect_language_tag
/**
* Returns a <selectize> tag populated with all the languages in the world (or almost).
*
* The select_language_tag builds off the traditional select_tag function, and is conveniently populated with
* all the languages in the world (sorted alphabetically). Each option in the list has a two or three character
* language/culture code for its value and the language's name as its display title. The country data is
* retrieved via the sfCultureInfo class, which stores a wide variety of i18n and i10n settings for various
* countries and cultures throughout the world. Here's an example of an <option> tag generated by the select_country_tag:
*
* <samp>
* <option value="en">English</option>
* </samp>
*
* <b>Examples:</b>
* <code>
* echo select_language_tag('language', 'de');
* </code>
*
* @param string $name field name
* @param string $selected selected field values (two or three-character language/culture code)
* @param array $options additional HTML compliant <select> tag parameters
*
* @return string <selectize> tag populated with all the languages in the world.
* @see select_tag, options_for_select, sfCultureInfo
*/
function object_multiselect_language_tag($name, $selected = null, $options = array())
{
$c = new sfCultureInfo(sfContext::getInstance()->getUser()->getCulture());
$languages = $c->getLanguages();
if ($language_option = _get_option($options, 'languages')) {
foreach ($languages as $key => $value) {
if (!in_array($key, $language_option)) {
unset($languages[$key]);
}
}
}
asort($languages);
$option_tags = options_for_select($languages, $selected, $options);
unset($options['include_blank'], $options['include_custom']);
return select_tag($name, $option_tags, $options);
}
示例7: 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', $this->name);
$php_file = sfConfig::get('sf_rich_text_fck_js_dir') . DIRECTORY_SEPARATOR . 'fckeditor.php';
if (!is_readable(sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . $php_file)) {
throw new sfConfigurationException('You must install FCKEditor to use this helper (see rich_text_fck_js_dir settings).');
}
// FCKEditor.php class is written with backward compatibility of PHP4.
// This reportings are to turn off errors with public properties and already declared constructor
$error_reporting = error_reporting(E_ALL);
require_once sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . $php_file;
// turn error reporting back to your settings
error_reporting($error_reporting);
$fckeditor = new FCKeditor($this->name);
$fckeditor->BasePath = sfContext::getInstance()->getRequest()->getRelativeUrlRoot() . '/' . sfConfig::get('sf_rich_text_fck_js_dir') . '/';
$fckeditor->Value = $this->content;
if (isset($options['width'])) {
$fckeditor->Width = $options['width'];
} elseif (isset($options['cols'])) {
$fckeditor->Width = (string) ((int) $options['cols'] * 10) . 'px';
}
if (isset($options['height'])) {
$fckeditor->Height = $options['height'];
} elseif (isset($options['rows'])) {
$fckeditor->Height = (string) ((int) $options['rows'] * 10) . 'px';
}
if (isset($options['tool'])) {
$fckeditor->ToolbarSet = $options['tool'];
}
if (isset($options['config'])) {
$fckeditor->Config['CustomConfigurationsPath'] = javascript_path($options['config']);
}
$content = $fckeditor->CreateHtml();
if (sfConfig::get('sf_compat_10')) {
// fix for http://trac.symfony-project.com/ticket/732
// fields need to be of type text to be picked up by fillin. they are hidden by inline css anyway:
// <input type="hidden" id="name" name="name" style="display:none" value="<p>default</p>">
$content = str_replace('type="hidden"', 'type="text"', $content);
}
return $content;
}
示例8: 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', $this->name);
$php_file = sfConfig::get('sf_rich_text_fck_js_dir') . DIRECTORY_SEPARATOR . 'fckeditor.php';
if (!is_readable(sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . $php_file)) {
throw new sfConfigurationException('You must install FCKEditor to use this helper (see rich_text_fck_js_dir settings).');
}
// FCKEditor.php class is written with backward compatibility of PHP4.
// This reportings are to turn off errors with public properties and already declared constructor
$error_reporting = ini_get('error_reporting');
error_reporting(E_ALL);
require_once sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . $php_file;
// turn error reporting back to your settings
error_reporting($error_reporting);
$fckeditor = new FCKeditor($this->name);
$fckeditor->BasePath = sfContext::getInstance()->getRequest()->getRelativeUrlRoot() . '/' . sfConfig::get('sf_rich_text_fck_js_dir') . '/';
$fckeditor->Value = $this->content;
if (isset($options['width'])) {
$fckeditor->Width = $options['width'];
} elseif (isset($options['cols'])) {
$fckeditor->Width = (string) ((int) $options['cols'] * 10) . 'px';
}
if (isset($options['height'])) {
$fckeditor->Height = $options['height'];
} elseif (isset($options['rows'])) {
$fckeditor->Height = (string) ((int) $options['rows'] * 10) . 'px';
}
if (isset($options['tool'])) {
$fckeditor->ToolbarSet = $options['tool'];
}
if (isset($options['config'])) {
$fckeditor->Config['CustomConfigurationsPath'] = javascript_path($options['config']);
}
$content = $fckeditor->CreateHtml();
return $content;
}
示例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;
}
示例10: _convert_method_to_name
function _convert_method_to_name($method, &$options)
{
$name = _get_option($options, 'control_name');
if (!$name) {
if (is_array($method)) {
$name = implode('-', $method[1]);
} else {
$name = sfInflector::underscore($method);
$name = preg_replace('/^get_?/', '', $name);
}
}
return $name;
}
示例11: textarea_tag
/**
* Returns a <textarea> tag, optionally wrapped with an inline rich-text JavaScript editor.
*
* The texarea_tag helper generates a standard HTML <textarea> tag and can be manipulated with
* any number of standard HTML parameters via the <i>$options</i> array variable. However, the
* textarea tag also has the unique capability of being transformed into a WYSIWYG rich-text editor
* such as TinyMCE (http://tinymce.moxiecode.com) very easily with the use of some specific options:
*
* <b>Options:</b>
* - rich: A rich text editor class (for example sfRichTextEditorTinyMCE for TinyMCE).
*
* <b>Examples:</b>
* <code>
* echo textarea_tag('notes');
* </code>
*
* <code>
* echo textarea_tag('description', 'This is a description', array('rows' => 10, 'cols' => 50));
* </code>
*
* @param string $name field name
* @param string $content populated field value
* @param array $options additional HTML compliant <textarea> tag parameters
*
* @return string <textarea> tag optionally wrapped with a rich-text WYSIWYG editor
*/
function textarea_tag($name, $content = null, $options = array())
{
$options = _parse_attributes($options);
if ($size = _get_option($options, 'size')) {
list($options['cols'], $options['rows']) = explode('x', $size, 2);
}
// rich control?
if ($rich = _get_option($options, 'rich', false)) {
if (true === $rich) {
$rich = sfConfig::get('sf_rich_text_editor_class', 'TinyMCE');
}
// switch for backward compatibility
switch ($rich) {
case 'tinymce':
$rich = 'TinyMCE';
break;
case 'fck':
$rich = 'FCK';
break;
}
$editorClass = 'sfRichTextEditor' . $rich;
if (!class_exists($editorClass)) {
throw new sfConfigurationException(sprintf('The rich text editor "%s" does not exist.', $editorClass));
}
$sfEditor = new $editorClass();
if (!in_array('sfRichTextEditor', class_parents($sfEditor))) {
throw new sfConfigurationException(sprintf('The editor "%s" must extend sfRichTextEditor.', $editorClass));
}
$sfEditor->initialize($name, $content, $options);
return $sfEditor->toHTML();
}
return content_tag('textarea', escape_once(is_object($content) ? $content->__toString() : $content), array_merge(array('name' => $name, 'id' => get_id_from_name(_get_option($options, 'id', $name), null)), _convert_options($options)));
}
示例12: _get_propel_object_list
function _get_propel_object_list($object, $method, $options)
{
// get the lists of objects
$through_class = _get_option($options, 'through_class');
$objects = sfPropelManyToMany::getAllObjects($object, $through_class);
$objects_associated = sfPropelManyToMany::getRelatedObjects($object, $through_class);
$ids = array_map(create_function('$o', 'return $o->getPrimaryKey();'), $objects_associated);
return array($objects, $objects_associated, $ids);
}
示例13: double_list
/**
* two multiline select tags with associated and unassociated items
*
* @return string
* @param object object
* @param string method of object
* @param array options
* @param array html options of select tags
**/
function double_list($object, $method, $options = array(), $html_options = array())
{
$options = _parse_attributes($options);
// get the lists of objects
list($all_objects, $objects_associated, $associated_ids) = _get_object_list($object, $method, _get_option($options, 'through_class'), _get_option($options, 'peer_method'));
// options
$html_options['multiple'] = _get_option($html_options, 'multiple', true);
$html_options['size'] = _get_option($html_options, 'size', 5);
$html_options['class'] = 'double_list';
$label_assoc = _get_option($options, 'associated_label', 'Zugeh�rige Gruppen');
$label_all = _get_option($options, 'unassociated_label', 'Gruppenliste');
$name1 = _get_option($options, 'associated', 'isSelected');
$name2 = _get_option($options, 'unassociated', 'unSelected');
$form = _get_option($options, 'form_id', 'editForm');
// unassociated objects
$objects_unassociated = array();
foreach ($all_objects as $object) {
if (!in_array($object->getPrimaryKey(), $associated_ids)) {
$objects_unassociated[] = $object;
}
}
// select tags
$select1 = select_tag($name1, options_for_select(_get_options_from_objects($objects_associated), '', $options), $html_options);
unset($html_options['class']);
$select2 = select_tag($name2, options_for_select(_get_options_from_objects($objects_unassociated), '', $options), $html_options);
// output skeloton
$html = "\n<table><tr>\n\t<td class='first'><div class='first' style='padding-bottom:0px;padding-left:15px;'>{$label_assoc}</div>%s</td>\n\t<td class='first'><div class='first' style='padding-bottom:0px;padding-left:15px;'> </div>%s<br/>%s</td>\n\t<td class='first'><div class='first' style='padding-bottom:0px;padding-left:15px;'>{$label_all}</div>%s</td>\n</tr></table>\n";
// include js library
$response = sfContext::getInstance()->getResponse();
$response->addJavascript('/js/double_list.js', 'last');
return sprintf($html, $select1, link_to_function(image_tag('resultset_previous'), "double_list_move(\$('{$name2}'), \$('{$name1}'))"), link_to_function(image_tag('resultset_next'), "double_list_move(\$('{$name1}'), \$('{$name2}'))", 'style=display:block'), $select2, $form);
}
示例14: select_datetime_tag
/**
* Returns a variable number of <select> tags populated with date and time related select boxes.
*
* The select_datetime_tag is the culmination of both the select_date_tag and the select_time_tag.
* By default, the <i>$value</i> parameter is set to the current date and time. To override this, simply pass a valid
* date, time, datetime string or correctly formatted array (see example) to the <i>$value</i> parameter.
* You can also set the <i>$value</i> parameter to null which will disable the <i>$value</i>, however this
* will only be useful if you pass 'include_blank' or 'include_custom' to the <i>$options</i> parameter.
* To include seconds to the result, use set the 'include_second' option in the <i>$options</i> parameter to true.
* <b>Note:</b> The <i>$name</i> parameter will automatically converted to array names.
* For example, a <i>$name</i> of "datetime" becomes:
* <samp>
* <select name="datetime[month]">...</select>
* <select name="datetime[day]">...</select>
* <select name="datetime[year]">...</select>
* <select name="datetime[hour]">...</select>
* <select name="datetime[minute]">...</select>
* <select name="datetime[second]">...</select>
* </samp>
*
* <b>Options:</b>
* - include_blank - Includes a blank <option> tag at the beginning of the string with an empty value.
* - include_custom - Includes an <option> tag with a custom display title at the beginning of the string with an empty value.
* - include_second - If set to true, includes the "seconds" select tag as part of the result.
* - discard_month - If set to true, will only return select tags for day and year.
* - discard_day - If set to true, will only return select tags for month and year.
* - discard_year - If set to true, will only return select tags for month and day.
* - use_month_numbers - If set to true, will show the month's numerical value (1 - 12) instead of the months full name.
* - use_short_month - If set to true, will show the month's short name (i.e. Jan, Feb, Mar) instead of its full name.
* - year_start - If set, the range of years will begin at this four-digit date (i.e. 1979)
* - year_end - If set, the range of years will end at this four-digit date (i.e. 2025)
* - second_step - If set, the seconds will be incremented in blocks of X, where X = 'second_step'
* - minute_step - If set, the minutes will be incremented in blocks of X, where X = 'minute_step'
* - 12hour_time - If set to true, will return integers 1 through 12 instead of the default 0 through 23.
* - date_seperator - Includes a string of defined text between each generated select tag
* - time_seperator - Includes a string of defined text between each generated select tag
* - ampm_seperator - Includes a string of defined text between the minute/second select box and the AM/PM select box
*
* <b>Examples:</b>
* <code>
* echo submit_datetime_tag('datetime');
* </code>
*
* <code>
* echo select_datetime_tag('datetime', '1979-10-30');
* </code>
*
* <code>
* $datetime = array('year' => '1979', 'month' => 10, 'day' => 30, 'hour' => '15', 'minute' => 46);
* echo select_datetime_tag('time', $datetime, array('use_short_month' => true, '12hour_time' => true));
* </code>
*
* @param string field name (automatically becomes an array of date and time parts)
* @param mixed accepts a valid time string or properly formatted time array
* @param array additional HTML compliant <select> tag parameters
* @return string a variable number of <select> tags populated with date and time related select boxes
* @see select date_tag, select_time_tag
*/
function select_datetime_tag($name, $value = null, $options = array(), $html_options = array())
{
$options = _parse_attributes($options);
$datetime_seperator = _get_option($options, 'datetime_seperator', '');
$date = select_date_tag($name, $value, $options, $html_options);
$time = select_time_tag($name, $value, $options, $html_options);
return $date . $datetime_seperator . $time;
}
示例15: _convert_include_custom_for_select
function _convert_include_custom_for_select($options, &$select_options)
{
if (_get_option($options, 'include_blank')) {
$select_options[''] = '';
} else {
if ($include_custom = _get_option($options, 'include_custom')) {
$select_options[''] = $include_custom;
}
}
}