~chroot64bit/zivios/gentoo-experimental

« back to all changes in this revision

Viewing changes to application/library/Zend/View.php

  • Committer: Mustafa A. Hashmi
  • Date: 2008-12-04 13:32:21 UTC
  • Revision ID: mhashmi@zivios.org-20081204133221-0nd1trunwevijj38
Inclusion of new installation framework with ties to zend layout and dojo layout

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 
18
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 
19
 */
 
20
 
 
21
 
 
22
/**
 
23
 * Abstract master class for extension.
 
24
 */
 
25
require_once 'Zend/View/Abstract.php';
 
26
 
 
27
 
 
28
/**
 
29
 * Concrete class for handling view scripts.
 
30
 *
 
31
 * @category   Zend
 
32
 * @package    Zend_View
 
33
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 
34
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 
35
 */
 
36
class Zend_View extends Zend_View_Abstract
 
37
{
 
38
    /**
 
39
     * Whether or not to use streams to mimic short tags
 
40
     * @var bool
 
41
     */
 
42
    private $_useViewStream = false;
 
43
 
 
44
    /**
 
45
     * Whether or not to use stream wrapper if short_open_tag is false
 
46
     * @var bool
 
47
     */
 
48
    private $_useStreamWrapper = false;
 
49
 
 
50
    /**
 
51
     * Constructor
 
52
     *
 
53
     * Register Zend_View_Stream stream wrapper if short tags are disabled.
 
54
     * 
 
55
     * @param  array $config 
 
56
     * @return void
 
57
     */
 
58
    public function __construct($config = array())
 
59
    {
 
60
        $this->_useViewStream = (bool) ini_get('short_open_tag') ? false : true;
 
61
        if ($this->_useViewStream) {
 
62
            if (!in_array('zend.view', stream_get_wrappers())) {
 
63
                require_once 'Zend/View/Stream.php';
 
64
                stream_wrapper_register('zend.view', 'Zend_View_Stream');
 
65
            }
 
66
        }
 
67
 
 
68
        if (array_key_exists('useStreamWrapper', $config)) {
 
69
            $this->setUseStreamWrapper($config['useStreamWrapper']);
 
70
        }
 
71
 
 
72
        parent::__construct($config);
 
73
    }
 
74
 
 
75
    /**
 
76
     * Set flag indicating if stream wrapper should be used if short_open_tag is off
 
77
     * 
 
78
     * @param  bool $flag 
 
79
     * @return Zend_View
 
80
     */
 
81
    public function setUseStreamWrapper($flag)
 
82
    {
 
83
        $this->_useStreamWrapper = (bool) $flag;
 
84
        return $this;
 
85
    }
 
86
 
 
87
    /**
 
88
     * Should the stream wrapper be used if short_open_tag is off?
 
89
     * 
 
90
     * @return bool
 
91
     */
 
92
    public function useStreamWrapper()
 
93
    {
 
94
        return $this->_useStreamWrapper;
 
95
    }
 
96
 
 
97
    /**
 
98
     * Includes the view script in a scope with only public $this variables.
 
99
     *
 
100
     * @param string The view script to execute.
 
101
     */
 
102
    protected function _run()
 
103
    {
 
104
        if ($this->_useViewStream && $this->useStreamWrapper()) {
 
105
            include 'zend.view://' . func_get_arg(0);
 
106
        } else {
 
107
            include func_get_arg(0);
 
108
        }
 
109
    }
 
110
}