web/lib/Zend/Dojo.php
changeset 64 162c1de6545a
parent 19 1c2f13fd785c
child 68 ecaf28ffe26e
equal deleted inserted replaced
63:5b37998e522e 64:162c1de6545a
       
     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-2010 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-2010 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 20096 2010-01-06 02:05:09Z bkarwin $
       
    28  */
       
    29 class 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