/library/Zend/Dojo.php

https://bitbucket.org/hamidrezas/melobit · PHP · 87 lines · 28 code · 9 blank · 50 comment · 2 complexity · aab2b5d1fb63bbef53138f3ecc71614e MD5 · raw file

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