PageRenderTime 40ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/library/Zend/Dojo/View/Helper/DijitContainer.php

https://bitbucket.org/ksekar/campus
PHP | 92 lines | 32 code | 8 blank | 52 comment | 2 complexity | c5a27a76ae48dfc08bd5eefd555f4456 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.0, MIT
  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. * @subpackage View
  18. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id: DijitContainer.php 24594 2012-01-05 21:27:01Z matthew $
  21. */
  22. /** Zend_Dojo_View_Helper_Dijit */
  23. require_once 'Zend/Dojo/View/Helper/Dijit.php';
  24. /**
  25. * Dijit layout container base class
  26. *
  27. * @uses Zend_Dojo_View_Helper_Dijit
  28. * @package Zend_Dojo
  29. * @subpackage View
  30. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  31. * @license http://framework.zend.com/license/new-bsd New BSD License
  32. */
  33. abstract class Zend_Dojo_View_Helper_DijitContainer extends Zend_Dojo_View_Helper_Dijit
  34. {
  35. /**
  36. * Capture locks
  37. * @var array
  38. */
  39. protected $_captureLock = array();
  40. /**
  41. * Metadata information to use with captured content
  42. * @var array
  43. */
  44. protected $_captureInfo = array();
  45. /**
  46. * Begin capturing content for layout container
  47. *
  48. * @param string $id
  49. * @param array $params
  50. * @param array $attribs
  51. * @return void
  52. */
  53. public function captureStart($id, array $params = array(), array $attribs = array())
  54. {
  55. if (array_key_exists($id, $this->_captureLock)) {
  56. require_once 'Zend/Dojo/View/Exception.php';
  57. throw new Zend_Dojo_View_Exception(sprintf('Lock already exists for id "%s"', $id));
  58. }
  59. $this->_captureLock[$id] = true;
  60. $this->_captureInfo[$id] = array(
  61. 'params' => $params,
  62. 'attribs' => $attribs,
  63. );
  64. ob_start();
  65. return;
  66. }
  67. /**
  68. * Finish capturing content for layout container
  69. *
  70. * @param string $id
  71. * @return string
  72. */
  73. public function captureEnd($id)
  74. {
  75. if (!array_key_exists($id, $this->_captureLock)) {
  76. require_once 'Zend/Dojo/View/Exception.php';
  77. throw new Zend_Dojo_View_Exception(sprintf('No capture lock exists for id "%s"; nothing to capture', $id));
  78. }
  79. $content = ob_get_clean();
  80. extract($this->_captureInfo[$id]);
  81. unset($this->_captureLock[$id], $this->_captureInfo[$id]);
  82. return $this->_createLayoutContainer($id, $content, $params, $attribs);
  83. }
  84. }