function object_input_asset_tag($object, $method, $options = array()) { $options = _parse_attributes($options); $name = _convert_method_to_name($method, $options); $value = _get_object_value($object, $method); return input_asset_tag($name, $value, $options); }
function my_object_select_tag($object, $method, $disabled, $options = array(), $default_value = null) { $options = _parse_attributes($options); $related_class = _get_option($options, 'related_class', false); if (false === $related_class && preg_match('/^get(.+?)Id$/', $method, $match)) { $related_class = $match[1]; } $peer_method = _get_option($options, 'peer_method'); $text_method = _get_option($options, 'text_method'); $select_options = _get_options_from_objects(sfContext::getInstance()->retrieveObjects($related_class, $peer_method), $text_method); if ($value = _get_option($options, 'include_custom')) { $select_options = array('' => $value) + $select_options; } else { if (_get_option($options, 'include_title')) { $select_options = array('' => '-- ' . _convert_method_to_name($method, $options) . ' --') + $select_options; } else { if (_get_option($options, 'include_blank')) { $select_options = array('' => '') + $select_options; } } } if (is_object($object)) { $value = _get_object_value($object, $method, $default_value); } else { $value = $object; } $option_tags = my_options_for_select($select_options, $value, $disabled, $options); return select_tag(_convert_method_to_name($method, $options), $option_tags, $options); }
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); }
/** * ObjectHelper for admin generator. * * @package symfony * @subpackage helper * @author Fabien Potencier <*****@*****.**> * @version SVN: $Id: ObjectAdminHelper.php 3746 2007-04-11 08:08:38Z fabien $ */ function object_admin_input_file_tag($object, $method, $options = array()) { $options = _parse_attributes($options); $name = _convert_method_to_name($method, $options); $html = ''; $value = _get_object_value($object, $method); if ($value) { if ($include_link = _get_option($options, 'include_link')) { $image_path = image_path('/' . sfConfig::get('sf_upload_dir_name') . '/' . $include_link . '/' . $value); $image_text = ($include_text = _get_option($options, 'include_text')) ? __($include_text) : __('[show file]'); $html .= sprintf('<a onclick="window.open(this.href);return false;" href="%s">%s</a>', $image_path, $image_text) . "\n"; } if ($include_remove = _get_option($options, 'include_remove')) { $html .= checkbox_tag(strpos($name, ']') !== false ? substr($name, 0, -1) . '_remove]' : $name) . ' ' . ($include_remove != true ? __($include_remove) : __('remove file')) . "\n"; } } return input_file_tag($name, $options) . "\n<br />" . $html; }
/** * Returns a <select> tag populated with all the states in a country. * * @param string object name * @param string method name * @param array additional HTML compliant <select> tag parameters. May also include the following options: * 'states[]' -- an array containing a list of states to be removed from the list * 'country' -- a value that will select the states from a country code * 'sort' -- will cause the list to be re-sorted alphabetically * @param string default object value (usually a two-character state code) * @return string <select> tag populated with all the states in the default or selected country. * @see select_state_tag */ function object_select_state_tag($object, $method, $options = array(), $default_value = null) { $options = _parse_attributes($options); $value = _get_object_value($object, $method, $default_value); return select_state_tag(_convert_method_to_name($method, $options), $value, $options); }
/** * Returns a checkbox html tag. * * @param object $object An object. * @param string $method An object column. * @param array $options Checkbox options. * @param bool $default_value Checkbox value. * * @return string An html string which represents a checkbox tag. * */ function object_checkbox_tag($object, $method, $options = array(), $default_value = null) { $options = _parse_attributes($options); $checked = (bool) _get_object_value($object, $method, $default_value); return checkbox_tag(_convert_method_to_name($method, $options), isset($options['value']) ? $options['value'] : 1, $checked, $options); }
function object_admin_select_language($object, $method, $options = array(), $default_value = null) { //$params = array_merge(array('control_name' => $this->getSingularName() . '[' . $column->getName() . ']'), $params); $options = _parse_attributes($options); $value = _get_object_value($object, $method, $default_value); if (isset($options['limitmethod'])) { $options['languages'] = _get_object_value($object, $options['limitmethod']); } return select_language_tag($options['control_name'], $value, $options); }
function object_radiobutton_tag($object, $method, $options = array(), $default_value = null) { $options = _parse_attributes($options); $text_options = explode(":", $options['text_options']); $value_options = explode(":", $options['value_options']); $radiobuttons_html = ""; $radionbutton_name = _convert_method_to_name($method, $options); unset($options['text_options'], $options['value_options']); $value = _get_object_value($object, $method, $default_value); if ($value == "") { $value = $options['default_value']; } foreach ($text_options as $key => $text) { $radiobuttons_html .= radiobutton_tag($radionbutton_name, $value_options[$key], $value_options[$key] == $value ? true : false, $options) . $text; } return $radiobuttons_html; }