/usr/share/php/Horde/View/Helper/Form.php is in php-horde-view 2.0.6-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | <?php
/**
* Copyright 2007-2008 Maintainable Software, LLC
* Copyright 2008-2016 Horde LLC (http://www.horde.org/)
*
* @author Mike Naberezny <mike@maintainable.com>
* @author Derek DeVries <derek@maintainable.com>
* @author Chuck Hagenbuch <chuck@horde.org>
* @license http://www.horde.org/licenses/bsd
* @category Horde
* @package View
* @subpackage Helper
*/
/**
* @author Mike Naberezny <mike@maintainable.com>
* @author Derek DeVries <derek@maintainable.com>
* @author Chuck Hagenbuch <chuck@horde.org>
* @license http://www.horde.org/licenses/bsd
* @category Horde
* @package View
* @subpackage Helper
*/
class Horde_View_Helper_Form extends Horde_View_Helper_Base
{
private $_instanceTag = 'Horde_View_Helper_Form_InstanceTag_Form';
public function formFor($objectName)
{
$args = func_get_args();
$options = is_array(end($args)) ? array_pop($args) : array();
if (isset($options['url'])) {
$urlOptions = $options['url'];
unset($options['url']);
} else {
$urlOptions = array();
}
if (isset($options['html'])) {
$htmlOptions = $options['html'];
unset($options['url']);
} else {
$htmlOptions = array();
}
echo $this->formTag($urlOptions, $htmlOptions);
$options['end'] = '</form>';
$args[] = $options;
return call_user_func_array(array($this, 'fieldsFor'), $args);
}
public function fieldsFor($objectName)
{
$args = func_get_args();
$options = is_array(end($args)) ? array_pop($args) : array();
$object = isset($args[1]) ? $args[1] : null;
$builder = isset($options['builder'])
? $options['builder']
: Horde_View_Base::$defaultFormBuilder;
return new $builder($objectName, $object, $this->_view, $options);
}
/**
* Returns a label tag tailored for labelling an input field for a
* specified attribute (identified by $method) on an object assigned to the
* template (identified by $objectName).
*
* The text of label will default to the attribute name unless you specify
* it explicitly. Additional options on the label tag can be passed as a
* hash with $options. These options will be tagged onto the HTML as an
* HTML element attribute as in the example shown.
*
* Examples:
*
* <code>
* $this->label('post', 'title');
* // => <label for="post_title">Title</label>
*
* $this->label('post', 'title', 'A short title')
* // => <label for="post_title">A short title</label>
*
* $this->label('post', 'title', 'A short title',
* array('class' => 'title_label'));
* // => <label for="post_title" class="title_label">A short title</label>
* </code>
*/
public function label($objectName, $method, $text, $options = array())
{
$object = isset($options['object']) ? $options['object'] : null;
unset($options['object']);
$tag = new $this->_instanceTag($objectName, $method, $this->_view, $object);
return $tag->toLabelTag($text, $options);
}
public function textField($objectName, $method, $options = array())
{
$object = isset($options['object']) ? $options['object'] : null;
unset($options['object']);
$tag = new $this->_instanceTag($objectName, $method, $this->_view, $object);
return $tag->toInputFieldTag('text', $options);
}
public function passwordField($objectName, $method, $options = array())
{
$object = isset($options['object']) ? $options['object'] : null;
unset($options['object']);
$tag = new $this->_instanceTag($objectName, $method, $this->_view, $object);
return $tag->toInputFieldTag('password', $options);
}
public function hiddenField($objectName, $method, $options = array())
{
$object = isset($options['object']) ? $options['object'] : null;
unset($options['object']);
$tag = new $this->_instanceTag($objectName, $method, $this->_view, $object);
return $tag->toInputFieldTag('hidden', $options);
}
public function fileField($objectName, $method, $options = array())
{
$object = isset($options['object']) ? $options['object'] : null;
unset($options['object']);
$tag = new $this->_instanceTag($objectName, $method, $this->_view, $object);
return $tag->toInputFieldTag('file', $options);
}
public function checkBox($objectName, $method, $options = array(),
$checkedValue = '1', $uncheckedValue = '0')
{
$object = isset($options['object']) ? $options['object'] : null;
unset($options['object']);
$tag = new $this->_instanceTag($objectName, $method, $this->_view, $object);
return $tag->toCheckBoxTag($options, $checkedValue, $uncheckedValue);
}
public function radioButton($objectName, $method, $tagValue, $options = array())
{
$object = isset($options['object']) ? $options['object'] : null;
unset($options['object']);
$tag = new $this->_instanceTag($objectName, $method, $this->_view, $object);
return $tag->toRadioButtonTag($tagValue, $options);
}
public function textArea($objectName, $method, $options = array())
{
$object = isset($options['object']) ? $options['object'] : null;
unset($options['object']);
$tag = new $this->_instanceTag($objectName, $method, $this->_view, $object);
return $tag->toTextAreaTag($options);
}
}
|