File indexing completed on 2024-04-28 06:00:01

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  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0018  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0019  */
0020 
0021 /**
0022  * Enable Dojo components
0023  *
0024  * @package    Zend_Dojo
0025  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0026  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0027  * @version    $Id$
0028  */
0029 class Zend_Dojo
0030 {
0031     /**
0032      * Base path to AOL CDN
0033      */
0034     const CDN_BASE_AOL = 'http://o.aolcdn.com/dojo/';
0035 
0036     /**
0037      * Path to dojo on AOL CDN (following version string)
0038      */
0039     const CDN_DOJO_PATH_AOL = '/dojo/dojo.xd.js';
0040 
0041     /**
0042      * Base path to Google CDN
0043      */
0044     const CDN_BASE_GOOGLE = 'http://ajax.googleapis.com/ajax/libs/dojo/';
0045 
0046     /**
0047      * Path to dojo on Google CDN (following version string)
0048      */
0049     const CDN_DOJO_PATH_GOOGLE = '/dojo/dojo.xd.js';
0050 
0051     /**
0052      * Dojo-enable a form instance
0053      *
0054      * @param  Zend_Form $form
0055      * @return void
0056      */
0057     public static function enableForm(Zend_Form $form)
0058     {
0059         $form->addPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator', 'decorator')
0060              ->addPrefixPath('Zend_Dojo_Form_Element', 'Zend/Dojo/Form/Element', 'element')
0061              ->addElementPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator', 'decorator')
0062              ->addDisplayGroupPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator')
0063              ->setDefaultDisplayGroupClass('Zend_Dojo_Form_DisplayGroup');
0064 
0065         foreach ($form->getSubForms() as $subForm) {
0066             self::enableForm($subForm);
0067         }
0068 
0069         if (null !== ($view = $form->getView())) {
0070             self::enableView($view);
0071         }
0072     }
0073 
0074     /**
0075      * Dojo-enable a view instance
0076      *
0077      * @param  Zend_View_Interface $view
0078      * @return void
0079      */
0080     public static function enableView(Zend_View_Interface $view)
0081     {
0082         if (false === $view->getPluginLoader('helper')->getPaths('Zend_Dojo_View_Helper')) {
0083             $view->addHelperPath('Zend/Dojo/View/Helper', 'Zend_Dojo_View_Helper');
0084         }
0085     }
0086 }
0087