UiWidgetPane.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 "UiWidget.php";
  26. /**
  27. * jQuery Pane Base class, adds captureStart/captureEnd functionality for panes.
  28. *
  29. * @uses ZendX_JQuery_View_Helper_JQuery_Container
  30. * @package ZendX_JQuery
  31. * @subpackage View
  32. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  33. * @license http://framework.zend.com/license/new-bsd New BSD License
  34. */
  35. abstract class ZendX_JQuery_View_Helper_UiWidgetPane extends ZendX_JQuery_View_Helper_UiWidget
  36. {
  37. /**
  38. * Capture Lock information
  39. *
  40. * @var array
  41. */
  42. protected $_captureLock = array();
  43. /**
  44. * Current capture additional information
  45. *
  46. * @var array
  47. */
  48. protected $_captureInfo = array();
  49. /**
  50. * Begin capturing content for layout container
  51. *
  52. * @param string $id
  53. * @param string $name
  54. * @param array $options
  55. * @return void
  56. */
  57. public function captureStart($id, $name, array $options=array())
  58. {
  59. if (array_key_exists($id, $this->_captureLock)) {
  60. require_once 'ZendX/JQuery/View/Exception.php';
  61. throw new ZendX_JQuery_View_Exception(sprintf('Lock already exists for id "%s"', $id));
  62. }
  63. $this->_captureLock[$id] = true;
  64. $this->_captureInfo[$id] = array(
  65. 'name' => $name,
  66. 'options' => $options,
  67. );
  68. return ob_start();
  69. }
  70. /**
  71. * Finish capturing content for layout container
  72. *
  73. * @param string $id
  74. * @return string
  75. */
  76. public function captureEnd($id)
  77. {
  78. if (!array_key_exists($id, $this->_captureLock)) {
  79. require_once 'ZendX/JQuery/View/Exception.php';
  80. throw new ZendX_JQuery_View_Exception(sprintf('No capture lock exists for id "%s"; nothing to capture', $id));
  81. }
  82. $content = ob_get_clean();
  83. extract($this->_captureInfo[$id]);
  84. unset($this->_captureLock[$id], $this->_captureInfo[$id]);
  85. return $this->_addPane($id, $name, $content, $options);
  86. }
  87. /**
  88. * Add an additional pane to the current Widget Container
  89. *
  90. * @param string $id
  91. * @param string $name
  92. * @param string $content
  93. * @param array $options
  94. */
  95. abstract protected function _addPane($id, $name, $content, array $options=array());
  96. }