|
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_View |
|
17 * @subpackage Helper |
|
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
19 * @version $Id: Layout.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
20 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
21 */ |
|
22 |
|
23 /** Zend_View_Helper_Abstract.php */ |
|
24 require_once 'Zend/View/Helper/Abstract.php'; |
|
25 |
|
26 /** |
|
27 * View helper for retrieving layout object |
|
28 * |
|
29 * @package Zend_View |
|
30 * @subpackage Helper |
|
31 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
32 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
33 */ |
|
34 class Zend_View_Helper_Layout extends Zend_View_Helper_Abstract |
|
35 { |
|
36 /** @var Zend_Layout */ |
|
37 protected $_layout; |
|
38 |
|
39 /** |
|
40 * Get layout object |
|
41 * |
|
42 * @return Zend_Layout |
|
43 */ |
|
44 public function getLayout() |
|
45 { |
|
46 if (null === $this->_layout) { |
|
47 require_once 'Zend/Layout.php'; |
|
48 $this->_layout = Zend_Layout::getMvcInstance(); |
|
49 if (null === $this->_layout) { |
|
50 // Implicitly creates layout object |
|
51 $this->_layout = new Zend_Layout(); |
|
52 } |
|
53 } |
|
54 |
|
55 return $this->_layout; |
|
56 } |
|
57 |
|
58 /** |
|
59 * Set layout object |
|
60 * |
|
61 * @param Zend_Layout $layout |
|
62 * @return Zend_Layout_Controller_Action_Helper_Layout |
|
63 */ |
|
64 public function setLayout(Zend_Layout $layout) |
|
65 { |
|
66 $this->_layout = $layout; |
|
67 return $this; |
|
68 } |
|
69 |
|
70 /** |
|
71 * Return layout object |
|
72 * |
|
73 * Usage: $this->layout()->setLayout('alternate'); |
|
74 * |
|
75 * @return Zend_Layout |
|
76 */ |
|
77 public function layout() |
|
78 { |
|
79 return $this->getLayout(); |
|
80 } |
|
81 } |