/library/Zend/Dojo.php
PHP | 87 lines | 28 code | 9 blank | 50 comment | 2 complexity | aab2b5d1fb63bbef53138f3ecc71614e MD5 | raw file
Possible License(s): AGPL-1.0
1<?php
2/**
3 * Zend Framework
4 *
5 * LICENSE
6 *
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.
14 *
15 * @category Zend
16 * @package Zend_Dojo
17 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
18 * @license http://framework.zend.com/license/new-bsd New BSD License
19 */
20
21/**
22 * Enable Dojo components
23 *
24 * @package Zend_Dojo
25 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
26 * @license http://framework.zend.com/license/new-bsd New BSD License
27 * @version $Id: Dojo.php 24594 2012-01-05 21:27:01Z matthew $
28 */
29class Zend_Dojo
30{
31 /**
32 * Base path to AOL CDN
33 */
34 const CDN_BASE_AOL = 'http://o.aolcdn.com/dojo/';
35
36 /**
37 * Path to dojo on AOL CDN (following version string)
38 */
39 const CDN_DOJO_PATH_AOL = '/dojo/dojo.xd.js';
40
41 /**
42 * Base path to Google CDN
43 */
44 const CDN_BASE_GOOGLE = 'http://ajax.googleapis.com/ajax/libs/dojo/';
45
46 /**
47 * Path to dojo on Google CDN (following version string)
48 */
49 const CDN_DOJO_PATH_GOOGLE = '/dojo/dojo.xd.js';
50
51 /**
52 * Dojo-enable a form instance
53 *
54 * @param Zend_Form $form
55 * @return void
56 */
57 public static function enableForm(Zend_Form $form)
58 {
59 $form->addPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator', 'decorator')
60 ->addPrefixPath('Zend_Dojo_Form_Element', 'Zend/Dojo/Form/Element', 'element')
61 ->addElementPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator', 'decorator')
62 ->addDisplayGroupPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator')
63 ->setDefaultDisplayGroupClass('Zend_Dojo_Form_DisplayGroup');
64
65 foreach ($form->getSubForms() as $subForm) {
66 self::enableForm($subForm);
67 }
68
69 if (null !== ($view = $form->getView())) {
70 self::enableView($view);
71 }
72 }
73
74 /**
75 * Dojo-enable a view instance
76 *
77 * @param Zend_View_Interface $view
78 * @return void
79 */
80 public static function enableView(Zend_View_Interface $view)
81 {
82 if (false === $view->getPluginLoader('helper')->getPaths('Zend_Dojo_View_Helper')) {
83 $view->addHelperPath('Zend/Dojo/View/Helper', 'Zend_Dojo_View_Helper');
84 }
85 }
86}
87