UiWidget.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 ZendX
  16. * @package ZendX_JQuery
  17. * @subpackage View
  18. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * @see ZendX_JQuery_View_Helper_UiWidget
  24. */
  25. require_once "Zend/View/Helper/HtmlElement.php";
  26. /**
  27. * @see ZendX_JQuery
  28. */
  29. require_once "ZendX/JQuery.php";
  30. /**
  31. * jQuery Ui Widget Base class
  32. *
  33. * @uses ZendX_JQuery_View_Helper_JQuery_Container
  34. * @package ZendX_JQuery
  35. * @subpackage View
  36. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  37. * @license http://framework.zend.com/license/new-bsd New BSD License
  38. */
  39. abstract class ZendX_JQuery_View_Helper_UiWidget extends Zend_View_Helper_HtmlElement
  40. {
  41. /**
  42. * Contains reference to the jQuery view helper
  43. *
  44. * @var ZendX_JQuery_View_Helper_JQuery_Container
  45. */
  46. protected $jquery;
  47. /**
  48. * Set view and enable jQuery Core and UI libraries
  49. *
  50. * @param Zend_View_Interface $view
  51. * @return ZendX_JQuery_View_Helper_Widget
  52. */
  53. public function setView(Zend_View_Interface $view)
  54. {
  55. parent::setView($view);
  56. $this->jquery = $this->view->jQuery();
  57. $this->jquery->enable()
  58. ->uiEnable();
  59. return $this;
  60. }
  61. /**
  62. * Helps with building the correct Attributes Array structure.
  63. *
  64. * @param String $id
  65. * @param String $value
  66. * @param Array $attribs
  67. * @return Array $attribs
  68. */
  69. protected function _prepareAttributes($id, $value, $attribs)
  70. {
  71. if(!isset($attribs['id'])) {
  72. $attribs['id'] = $id;
  73. }
  74. $attribs['name'] = $id;
  75. $attribs['value'] = (string) $value;
  76. return $attribs;
  77. }
  78. }