7
* This source file is subject to the new BSD license that is bundled
8
* with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://framework.zend.com/license/new-bsd
11
* If you did not receive a copy of the license and are unable to
12
* obtain it through the world-wide-web, please send an email
13
* to license@zend.com so we can send you a copy immediately.
18
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
19
* @version $Id: Dojo.php 16541 2009-07-07 06:59:03Z bkarwin $
20
* @license http://framework.zend.com/license/new-bsd New BSD License
24
require_once 'Zend/Registry.php';
27
* Zend_Dojo_View_Helper_Dojo: Dojo View Helper
29
* Allows specifying stylesheets, path to dojo, module paths, and onLoad
34
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
35
* @license http://framework.zend.com/license/new-bsd New BSD License
37
class Zend_Dojo_View_Helper_Dojo
40
* @const Programmatic dijit creation style constants
42
const PROGRAMMATIC_SCRIPT = 1;
43
const PROGRAMMATIC_NOSCRIPT = -1;
47
* @var Zend_View_Interface
52
* @var Zend_Dojo_View_Helper_Dojo_Container
54
protected $_container;
57
* @var bool Whether or not dijits should be declared programmatically
59
protected static $_useProgrammatic = true;
64
* Retrieve container from registry or create new container and store in
69
public function __construct()
71
$registry = Zend_Registry::getInstance();
72
if (!isset($registry[__CLASS__])) {
73
require_once 'Zend/Dojo/View/Helper/Dojo/Container.php';
74
$container = new Zend_Dojo_View_Helper_Dojo_Container();
75
$registry[__CLASS__] = $container;
77
$this->_container = $registry[__CLASS__];
83
* @param Zend_Dojo_View_Interface $view
86
public function setView(Zend_View_Interface $view)
89
$this->_container->setView($view);
93
* Return dojo container
95
* @return Zend_Dojo_View_Helper_Dojo_Container
97
public function dojo()
99
return $this->_container;
103
* Proxy to container methods
105
* @param string $method
108
* @throws Zend_Dojo_View_Exception For invalid method calls
110
public function __call($method, $args)
112
if (!method_exists($this->_container, $method)) {
113
require_once 'Zend/Dojo/View/Exception.php';
114
throw new Zend_Dojo_View_Exception(sprintf('Invalid method "%s" called on dojo view helper', $method));
117
return call_user_func_array(array($this->_container, $method), $args);
121
* Set whether or not dijits should be created declaratively
125
public static function setUseDeclarative()
127
self::$_useProgrammatic = false;
131
* Set whether or not dijits should be created programmatically
133
* Optionally, specifiy whether or not dijit helpers should generate the
139
public static function setUseProgrammatic($style = self::PROGRAMMATIC_SCRIPT)
141
if (!in_array($style, array(self::PROGRAMMATIC_SCRIPT, self::PROGRAMMATIC_NOSCRIPT))) {
142
$style = self::PROGRAMMATIC_SCRIPT;
144
self::$_useProgrammatic = $style;
148
* Should dijits be created declaratively?
152
public static function useDeclarative()
154
return (false === self::$_useProgrammatic);
158
* Should dijits be created programmatically?
162
public static function useProgrammatic()
164
return (false !== self::$_useProgrammatic);
168
* Should dijits be created programmatically but without scripts?
172
public static function useProgrammaticNoScript()
174
return (self::PROGRAMMATIC_NOSCRIPT === self::$_useProgrammatic);