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

E:/E/GEAMP/www/openbiz/openbiz/others/ZendX/JQuery/Form/Decorator/UiWidgetPane.php

00001 <?php
00023 require_once "Zend/Form/Decorator/Abstract.php";
00024 
00033 abstract class ZendX_JQuery_Form_Decorator_UiWidgetPane extends Zend_Form_Decorator_Abstract
00034 {
00039     protected $_helper;
00040 
00045     protected $_attribs;
00046 
00051     protected $_jQueryParams;
00052 
00057     protected $_title;
00058 
00064     public function getHelper()
00065     {
00066         if (null === $this->_helper) {
00067             require_once 'Zend/Form/Decorator/Exception.php';
00068             throw new Zend_Form_Decorator_Exception('No view helper specified fo UiWidgetContainer decorator');
00069         }
00070         return $this->_helper;
00071     }
00072 
00078     public function getAttribs()
00079     {
00080         if (null === $this->_attribs) {
00081             $attribs = $this->getElement()->getAttribs();
00082             if (array_key_exists('jQueryParams', $attribs)) {
00083                 $this->getJQueryParams();
00084                 unset($attribs['jQueryParams']);
00085             }
00086             $this->_attribs = $attribs;
00087         }
00088         return $this->_attribs;
00089     }
00090 
00096     public function getJQueryParams()
00097     {
00098         if (null === $this->_jQueryParams) {
00099             $attribs = $this->getElement()->getAttribs();
00100             $this->_jQueryParams = array();
00101             if (array_key_exists('jQueryParams', $attribs)) {
00102                 $this->_jQueryParams = $attribs['jQueryParams'];
00103             }
00104 
00105             $options = $this->getOptions();
00106             if (array_key_exists('jQueryParams', $options)) {
00107                 $this->_jQueryParams = array_merge($this->_jQueryParams, $options['jQueryParams']);
00108                 $this->removeOption('jQueryParams');
00109             }
00110         }
00111 
00112         // Ensure we have a title param
00113         if (!array_key_exists('title', $this->_jQueryParams)) {
00114             require_once "Zend/Form/Decorator/Exception.php";
00115             throw new Zend_Form_Decorator_Exception("UiWidgetPane Decorators have to have a jQueryParam 'title' to render. This title can been set via setJQueryParam('title') on the parent element.");
00116         }
00117 
00118         return $this->_jQueryParams;
00119     }
00120 
00129     public function render($content)
00130     {
00131         $element = $this->getElement();
00132         $view    = $element->getView();
00133         if (null === $view) {
00134             return $content;
00135         }
00136 
00137         $jQueryParams = $this->getJQueryParams();
00138         $attribs     = array_merge($this->getAttribs(), $this->getOptions());
00139 
00140         if(isset($jQueryParams['title']) && !empty($jQueryParams['title'])) {
00141             if (null !== ($translator = $element->getTranslator())) {
00142                 $jQueryParams['title'] = $translator->translate($jQueryParams['title']);
00143             }
00144         }
00145 
00146         if(isset($jQueryParams['containerId'])) {
00147             $id = $jQueryParams['containerId']."-container";
00148         } else {
00149             require_once "Zend/Form/Decorator/Exception.php";
00150             throw new Zend_Form_Decorator_Exception("UiWidgetPane Decorators have to have a jQueryParam 'containerId', to point at their parent container. This containerId has been set via setAttrib('id') on the parent element.");
00151         }
00152 
00153         $helper = $this->getHelper();
00154 
00155         return $view->$helper($id, $content, $jQueryParams, $attribs);
00156     }
00157 }

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