diff -r 5b37998e522e -r 162c1de6545a web/lib/Zend/Dojo/Form/Element/Dijit.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/lib/Zend/Dojo/Form/Element/Dijit.php Fri Mar 11 15:05:35 2011 +0100 @@ -0,0 +1,189 @@ +addPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator', 'decorator'); + parent::__construct($spec, $options); + } + + /** + * Set a dijit parameter + * + * @param string $key + * @param mixed $value + * @return Zend_Dojo_Form_Element_Dijit + */ + public function setDijitParam($key, $value) + { + $key = (string) $key; + $this->dijitParams[$key] = $value; + return $this; + } + + /** + * Set multiple dijit params at once + * + * @param array $params + * @return Zend_Dojo_Form_Element_Dijit + */ + public function setDijitParams(array $params) + { + $this->dijitParams = array_merge($this->dijitParams, $params); + return $this; + } + + /** + * Does the given dijit parameter exist? + * + * @param string $key + * @return bool + */ + public function hasDijitParam($key) + { + return array_key_exists($key, $this->dijitParams); + } + + /** + * Get a single dijit parameter + * + * @param string $key + * @return mixed + */ + public function getDijitParam($key) + { + $key = (string) $key; + if ($this->hasDijitParam($key)) { + return $this->dijitParams[$key]; + } + return null; + } + + /** + * Retrieve all dijit parameters + * + * @return array + */ + public function getDijitParams() + { + return $this->dijitParams; + } + + /** + * Remove a single dijit parameter + * + * @param string $key + * @return Zend_Dojo_Form_Element_Dijit + */ + public function removeDijitParam($key) + { + $key = (string) $key; + if (array_key_exists($key, $this->dijitParams)) { + unset($this->dijitParams[$key]); + } + return $this; + } + + /** + * Clear all dijit parameters + * + * @return Zend_Dojo_Form_Element_Dijit + */ + public function clearDijitParams() + { + $this->dijitParams = array(); + return $this; + } + + /** + * Load default decorators + * + * @return void + */ + public function loadDefaultDecorators() + { + if ($this->loadDefaultDecoratorsIsDisabled()) { + return; + } + + $decorators = $this->getDecorators(); + if (empty($decorators)) { + $this->addDecorator('DijitElement') + ->addDecorator('Errors') + ->addDecorator('Description', array('tag' => 'p', 'class' => 'description')) + ->addDecorator('HtmlTag', array('tag' => 'dd')) + ->addDecorator('Label', array('tag' => 'dt')); + } + } + + /** + * Set the view object + * + * Ensures that the view object has the dojo view helper path set. + * + * @param Zend_View_Interface $view + * @return Zend_Dojo_Form_Element_Dijit + */ + public function setView(Zend_View_Interface $view = null) + { + if (null !== $view) { + if (false === $view->getPluginLoader('helper')->getPaths('Zend_Dojo_View_Helper')) { + $view->addHelperPath('Zend/Dojo/View/Helper', 'Zend_Dojo_View_Helper'); + } + } + return parent::setView($view); + } +}