|
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_Application |
|
17 * @subpackage Resource |
|
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: View.php 22965 2010-09-18 17:45:51Z intiilapa $ |
|
21 */ |
|
22 |
|
23 /** |
|
24 * @see Zend_Application_Resource_ResourceAbstract |
|
25 */ |
|
26 require_once 'Zend/Application/Resource/ResourceAbstract.php'; |
|
27 |
|
28 |
|
29 /** |
|
30 * Resource for settings view options |
|
31 * |
|
32 * @uses Zend_Application_Resource_ResourceAbstract |
|
33 * @category Zend |
|
34 * @package Zend_Application |
|
35 * @subpackage Resource |
|
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 class Zend_Application_Resource_View extends Zend_Application_Resource_ResourceAbstract |
|
40 { |
|
41 /** |
|
42 * @var Zend_View_Interface |
|
43 */ |
|
44 protected $_view; |
|
45 |
|
46 /** |
|
47 * Defined by Zend_Application_Resource_Resource |
|
48 * |
|
49 * @return Zend_View |
|
50 */ |
|
51 public function init() |
|
52 { |
|
53 $view = $this->getView(); |
|
54 |
|
55 $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer(); |
|
56 $viewRenderer->setView($view); |
|
57 Zend_Controller_Action_HelperBroker::addHelper($viewRenderer); |
|
58 return $view; |
|
59 } |
|
60 |
|
61 /** |
|
62 * Retrieve view object |
|
63 * |
|
64 * @return Zend_View |
|
65 */ |
|
66 public function getView() |
|
67 { |
|
68 if (null === $this->_view) { |
|
69 $options = $this->getOptions(); |
|
70 $this->_view = new Zend_View($options); |
|
71 |
|
72 if (isset($options['doctype'])) { |
|
73 $this->_view->doctype()->setDoctype(strtoupper($options['doctype'])); |
|
74 if (isset($options['charset']) && $this->_view->doctype()->isHtml5()) { |
|
75 $this->_view->headMeta()->setCharset($options['charset']); |
|
76 } |
|
77 } |
|
78 if (isset($options['contentType'])) { |
|
79 $this->_view->headMeta()->appendHttpEquiv('Content-Type', $options['contentType']); |
|
80 } |
|
81 } |
|
82 return $this->_view; |
|
83 } |
|
84 } |