/usr/share/php/libzend-framework-php/ZendX/JQuery/Form/Decorator/UiWidgetElement.php is in libzend-framework-zendx-php 1.11.11-0ubuntu1.
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 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category ZendX
* @package ZendX_JQuery
* @subpackage View
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: UiWidgetElement.php 20165 2010-01-09 18:57:56Z bkarwin $
*/
/**
* @see Zend_Form_Decorator_ViewHelper
*/
require_once "Zend/Form/Decorator/ViewHelper.php";
/**
* @see ZendX_JQuery_Form_Decorator_UiWidgetElementMarker
*/
require_once "ZendX/JQuery/Form/Decorator/UiWidgetElementMarker.php";
/**
* Abstract Form Decorator for all jQuery UI Form Elements
*
* @package ZendX_JQuery
* @subpackage Form
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class ZendX_JQuery_Form_Decorator_UiWidgetElement
extends Zend_Form_Decorator_ViewHelper
implements ZendX_JQuery_Form_Decorator_UiWidgetElementMarker
{
/**
* Element attributes
*
* @var array
*/
protected $_attribs;
/**
* jQuery UI View Helper
*
* @var ZendX_JQuery_View_Helper_UiWidget
*/
public $helper;
/**
* jQuery related attributes/options
*
* @var array
*/
protected $_jQueryParams = array();
/**
* Get element attributes
*
* @return array
*/
public function getElementAttribs()
{
if (null === $this->_attribs) {
if($this->_attribs = parent::getElementAttribs()) {
if (array_key_exists('jQueryParams', $this->_attribs)) {
$this->setJQueryParams($this->_attribs['jQueryParams']);
unset($this->_attribs['jQueryParams']);
}
}
}
return $this->_attribs;
}
/**
* Set a single jQuery option parameter
*
* @param string $key
* @param mixed $value
* @return ZendX_JQuery_Form_Decorator_UiWidgetElement
*/
public function setJQueryParam($key, $value)
{
$this->_jQueryParams[(string) $key] = $value;
return $this;
}
/**
* Set jQuery option parameters
*
* @param array $params
* @return ZendX_JQuery_Form_Decorator_UiWidgetElement
*/
public function setJQueryParams(array $params)
{
$this->_jQueryParams = array_merge($this->_jQueryParams, $params);
return $this;
}
/**
* Retrieve a single jQuery option parameter
*
* @param string $key
* @return mixed|null
*/
public function getJQueryParam($key)
{
$this->getElementAttribs();
$key = (string) $key;
if (array_key_exists($key, $this->_jQueryParams)) {
return $this->_jQueryParams[$key];
}
return null;
}
/**
* Get jQuery option parameters
*
* @return array
*/
public function getJQueryParams()
{
$this->getElementAttribs();
return $this->_jQueryParams;
}
/**
* Render an jQuery UI Widget element using its associated view helper
*
* @param string $content
* @return string
* @throws Zend_Form_Decorator_Exception if element or view are not registered
*/
public function render($content)
{
$element = $this->getElement();
$view = $element->getView();
if (null === $view) {
require_once 'Zend/Form/Decorator/Exception.php';
throw new Zend_Form_Decorator_Exception('UiWidgetElement decorator cannot render without a registered view object');
}
if(method_exists($element, 'getJQueryParams')) {
$this->setJQueryParams($element->getJQueryParams());
}
$jQueryParams = $this->getJQueryParams();
$helper = $this->getHelper();
$separator = $this->getSeparator();
$value = $this->getValue($element);
$attribs = $this->getElementAttribs();
$name = $element->getFullyQualifiedName();
$id = $element->getId();
$attribs['id'] = $id;
$elementContent = $view->$helper($name, $value, $jQueryParams, $attribs);
switch ($this->getPlacement()) {
case self::APPEND:
return $content . $separator . $elementContent;
case self::PREPEND:
return $elementContent . $separator . $content;
default:
return $elementContent;
}
}
}
|