1: <?php
2: /**
3: * Copyright 2007-2008 Maintainable Software, LLC
4: * Copyright 2008-2012 Horde LLC (http://www.horde.org/)
5: *
6: * @author Mike Naberezny <mike@maintainable.com>
7: * @author Derek DeVries <derek@maintainable.com>
8: * @author Chuck Hagenbuch <chuck@horde.org>
9: * @license http://www.horde.org/licenses/bsd
10: * @category Horde
11: * @package View
12: * @subpackage Helper
13: */
14:
15: /**
16: * An instance of this class is returned by
17: * Horde_View_Helper_Capture::capture().
18: *
19: * @author Mike Naberezny <mike@maintainable.com>
20: * @author Derek DeVries <derek@maintainable.com>
21: * @author Chuck Hagenbuch <chuck@horde.org>
22: * @license http://www.horde.org/licenses/bsd
23: * @category Horde
24: * @package View
25: * @subpackage Helper
26: */
27: class Horde_View_Helper_Capture_Base
28: {
29: /**
30: * Are we currently buffering?
31: *
32: * @var boolean
33: */
34: protected $_buffering = true;
35:
36: /**
37: * Starts capturing.
38: */
39: public function __construct()
40: {
41: ob_start();
42: }
43:
44: /**
45: * Stops capturing and returns what was captured.
46: *
47: * @return string The captured string.
48: * @throws Horde_View_Exception
49: */
50: public function end()
51: {
52: if ($this->_buffering) {
53: $this->_buffering = false;
54: $output = ob_get_clean();
55: return $output;
56: } else {
57: throw new Horde_View_Exception('Capture already ended');
58: }
59: }
60: }
61: