File indexing completed on 2024-12-29 05:27:35
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Dojo 0017 * @subpackage View 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 * @version $Id$ 0021 */ 0022 0023 /** Zend_Dojo_View_Helper_DijitContainer */ 0024 // require_once 'Zend/Dojo/View/Helper/DijitContainer.php'; 0025 0026 /** 0027 * Arbitrary dijit support 0028 * 0029 * @uses Zend_Dojo_View_Helper_DijitContainer 0030 * @package Zend_Dojo 0031 * @subpackage View 0032 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0033 * @license http://framework.zend.com/license/new-bsd New BSD License 0034 */ 0035 class Zend_Dojo_View_Helper_CustomDijit extends Zend_Dojo_View_Helper_DijitContainer 0036 { 0037 /** 0038 * Default dojoType; set the value when extending 0039 * @var string 0040 */ 0041 protected $_defaultDojoType; 0042 0043 /** 0044 * Render a custom dijit 0045 * 0046 * Requires that either the {@link $_defaultDojotype} property is set, or 0047 * that you pass a value to the "dojoType" key of the $params argument. 0048 * 0049 * @param string $id 0050 * @param string $value 0051 * @param array $params 0052 * @param array $attribs 0053 * @return string|Zend_Dojo_View_Helper_CustomDijit 0054 */ 0055 public function customDijit($id = null, $value = null, array $params = array(), array $attribs = array()) 0056 { 0057 if (null === $id) { 0058 return $this; 0059 } 0060 0061 if (!array_key_exists('dojoType', $params) 0062 && (null === $this->_defaultDojoType) 0063 ) { 0064 // require_once 'Zend/Dojo/View/Exception.php'; 0065 throw new Zend_Dojo_View_Exception('No dojoType specified; cannot create dijit'); 0066 } elseif (array_key_exists('dojoType', $params)) { 0067 $this->_dijit = $params['dojoType']; 0068 $this->_module = $params['dojoType']; 0069 unset($params['dojoType']); 0070 } else { 0071 $this->_dijit = $this->_defaultDojoType; 0072 $this->_module = $this->_defaultDojoType; 0073 } 0074 0075 if (array_key_exists('rootNode', $params)) { 0076 $this->setRootNode($params['rootNode']); 0077 unset($params['rootNode']); 0078 } 0079 0080 return $this->_createLayoutContainer($id, $value, $params, $attribs); 0081 } 0082 0083 /** 0084 * Begin capturing content. 0085 * 0086 * Requires that either the {@link $_defaultDojotype} property is set, or 0087 * that you pass a value to the "dojoType" key of the $params argument. 0088 * 0089 * @param string $id 0090 * @param array $params 0091 * @param array $attribs 0092 * @return void 0093 */ 0094 public function captureStart($id, array $params = array(), array $attribs = array()) 0095 { 0096 if (!array_key_exists('dojoType', $params) 0097 && (null === $this->_defaultDojoType) 0098 ) { 0099 // require_once 'Zend/Dojo/View/Exception.php'; 0100 throw new Zend_Dojo_View_Exception('No dojoType specified; cannot create dijit'); 0101 } elseif (array_key_exists('dojoType', $params)) { 0102 $this->_dijit = $params['dojoType']; 0103 $this->_module = $params['dojoType']; 0104 unset($params['dojoType']); 0105 } else { 0106 $this->_dijit = $this->_defaultDojoType; 0107 $this->_module = $this->_defaultDojoType; 0108 } 0109 0110 return parent::captureStart($id, $params, $attribs); 0111 } 0112 }