• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List

E:/E/GEAMP/www/openbiz/openbiz/others/ZendX/JQuery/Form/Element/UiWidget.php

00001 <?php
00023 require_once "Zend/Form/Element.php";
00024 
00033 class ZendX_JQuery_Form_Element_UiWidget extends Zend_Form_Element
00034 {
00040     public $jQueryParams = array();
00041 
00047     public $options = array();
00048 
00056     public function __construct($spec, $options = null)
00057     {
00058         $this->addPrefixPath('ZendX_JQuery_Form_Decorator', 'ZendX/JQuery/Form/Decorator', 'decorator');
00059         parent::__construct($spec, $options);
00060     }
00061 
00068     public function getJQueryParam($key)
00069     {
00070         $key = (string) $key;
00071         return $this->jQueryParams[$key];
00072     }
00073 
00079     public function getJQueryParams()
00080     {
00081         return $this->jQueryParams;
00082     }
00083 
00091     public function setJQueryParam($key, $value)
00092     {
00093         $key = (string) $key;
00094         $this->jQueryParams[$key] = $value;
00095         return $this;
00096     }
00097 
00104     public function setJQueryParams($params)
00105     {
00106         $this->jQueryParams = array_merge($this->jQueryParams, $params);
00107         return $this;
00108     }
00109 
00115     public function loadDefaultDecorators()
00116     {
00117         if ($this->loadDefaultDecoratorsIsDisabled()) {
00118             return;
00119         }
00120 
00121         $decorators = $this->getDecorators();
00122         if (empty($decorators)) {
00123             $this->addDecorator('UiWidgetElement')
00124                  ->addDecorator('Errors')
00125                  ->addDecorator('Description', array('tag' => 'p', 'class' => 'description'))
00126                  ->addDecorator('HtmlTag', array('tag' => 'dd'))
00127                  ->addDecorator('Label', array('tag' => 'dt'));
00128         }
00129     }
00130 
00139     public function setView(Zend_View_Interface $view = null)
00140     {
00141         if (null !== $view) {
00142             if (false === $view->getPluginLoader('helper')->getPaths('ZendX_JQuery_View_Helper')) {
00143                 $view->addHelperPath('ZendX/JQuery/View/Helper', 'ZendX_JQuery_View_Helper');
00144             }
00145         }
00146         return parent::setView($view);
00147     }
00148 
00155     public function getDecorators()
00156     {
00157         $decorators = parent::getDecorators();
00158         if(count($decorators) > 0) {
00159             // Only check this if there are decorators present, otherwise it could
00160             // be that the decorators have not been initialized yet.
00161             $foundUiWidgetElementMarker = false;
00162             foreach($decorators AS $decorator) {
00163                 if($decorator instanceof ZendX_JQuery_Form_Decorator_UiWidgetElementMarker) {
00164                     $foundUiWidgetElementMarker = true;
00165                 }
00166             }
00167             if($foundUiWidgetElementMarker === false) {
00168                 require_once "ZendX/JQuery/Form/Exception.php";
00169                 throw new ZendX_JQuery_Form_Exception(
00170                     "Cannot render jQuery form element without at least one decorator ".
00171                     "implementing the 'ZendX_JQuery_Form_Decorator_UiWidgetElementMarker' interface. ".
00172                     "Default decorator for this marker interface is the 'ZendX_JQuery_Form_Decorator_UiWidgetElement'. ".
00173                     "Hint: The ViewHelper decorator does not render jQuery elements correctly."
00174                 );
00175             }
00176         }
00177 
00178         return $decorators;
00179     }
00180 }

Generated on Thu Apr 19 2012 17:01:19 for openbiz by  doxygen 1.7.2