00001 <?php 00023 require_once "Zend/Form/Decorator/Abstract.php"; 00024 00033 abstract class ZendX_JQuery_Form_Decorator_UiWidgetContainer extends Zend_Form_Decorator_Abstract 00034 { 00039 protected $_helper; 00040 00045 protected $_attribs; 00046 00051 protected $_jQueryParams; 00052 00058 public function getHelper() 00059 { 00060 if (null === $this->_helper) { 00061 require_once 'Zend/Form/Decorator/Exception.php'; 00062 throw new Zend_Form_Decorator_Exception('No view helper specified fo DijitContainer decorator'); 00063 } 00064 return $this->_helper; 00065 } 00066 00072 public function getAttribs() 00073 { 00074 if (null === $this->_attribs) { 00075 $attribs = $this->getElement()->getAttribs(); 00076 if (array_key_exists('jQueryParams', $attribs)) { 00077 $this->getJQueryParams(); 00078 unset($attribs['jQueryParams']); 00079 } 00080 $this->_attribs = $attribs; 00081 } 00082 return $this->_attribs; 00083 } 00084 00090 public function getJQueryParams() 00091 { 00092 if (null === $this->_jQueryParams) { 00093 $this->_jQueryParams = array(); 00094 if($attribs = $this->getElement()->getAttribs()) { 00095 if (array_key_exists('jQueryParams', $attribs)) { 00096 $this->_jQueryParams = $attribs['jQueryParams']; 00097 } 00098 } 00099 00100 if($options = $this->getOptions()) { 00101 if (array_key_exists('jQueryParams', $options)) { 00102 $this->_jQueryParams = array_merge($this->_jQueryParams, $options['jQueryParams']); 00103 $this->removeOption('jQueryParams'); 00104 } 00105 } 00106 } 00107 00108 return $this->_jQueryParams; 00109 } 00110 00122 public function render($content) 00123 { 00124 $element = $this->getElement(); 00125 $view = $element->getView(); 00126 if (null === $view) { 00127 return $content; 00128 } 00129 00130 $jQueryParams = $this->getJQueryParams(); 00131 $attribs = $this->getOptions(); 00132 00133 $helper = $this->getHelper(); 00134 $id = $element->getId() . '-container'; 00135 00136 return $view->$helper($id, $jQueryParams, $attribs); 00137 } 00138 }