File indexing completed on 2024-12-22 05:37:18

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_View
0017  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0018  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0019  * @version    $Id$
0020  */
0021 
0022 
0023 /**
0024  * Abstract master class for extension.
0025  */
0026 // require_once 'Zend/View/Abstract.php';
0027 
0028 
0029 /**
0030  * Concrete class for handling view scripts.
0031  *
0032  * @category  Zend
0033  * @package   Zend_View
0034  * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0035  * @license   http://framework.zend.com/license/new-bsd     New BSD License
0036  *
0037  * Convenience methods for build in helpers (@see __call):
0038  *
0039  * @method string baseUrl($file = null)
0040  * @method string currency($value = null, $currency = null)
0041  * @method Zend_View_Helper_Cycle cycle(array $data = array(), $name = Zend_View_Helper_Cycle::DEFAULT_NAME)
0042  * @method Zend_View_Helper_Doctype doctype($doctype = null)
0043  * @method string fieldset($name, $content, $attribs = null)
0044  * @method string form($name, $attribs = null, $content = false)
0045  * @method string formButton($name, $value = null, $attribs = null)
0046  * @method string formCheckbox($name, $value = null, $attribs = null, array $checkedOptions = null)
0047  * @method string formErrors($errors, array $options = null)
0048  * @method string formFile($name, $attribs = null)
0049  * @method string formHidden($name, $value = null, array $attribs = null)
0050  * @method string formImage($name, $value = null, $attribs = null)
0051  * @method string formLabel($name, $value = null, array $attribs = null)
0052  * @method string formMultiCheckbox($name, $value = null, $attribs = null, $options = null, $listsep = "<br />\n")
0053  * @method string formNote($name, $value = null)
0054  * @method string formPassword($name, $value = null, $attribs = null)
0055  * @method string formRadio($name, $value = null, $attribs = null, $options = null, $listsep = "<br />\n")
0056  * @method string formReset($name = '', $value = 'Reset', $attribs = null)
0057  * @method string formSelect($name, $value = null, $attribs = null, $options = null, $listsep = "<br />\n")
0058  * @method string formSubmit($name, $value = null, $attribs = null)
0059  * @method string formText($name, $value = null, $attribs = null)
0060  * @method string formTextarea($name, $value = null, $attribs = null)
0061  * @method Zend_View_Helper_Gravatar gravatar($email = "", $options = array(), $attribs = array())
0062  * @method Zend_View_Helper_HeadLink headLink(array $attributes = null, $placement = Zend_View_Helper_Placeholder_Container_Abstract::APPEND)
0063  * @method Zend_View_Helper_HeadMeta headMeta($content = null, $keyValue = null, $keyType = 'name', $modifiers = array(), $placement = Zend_View_Helper_Placeholder_Container_Abstract::APPEND)
0064  * @method Zend_View_Helper_HeadScript headScript($mode = Zend_View_Helper_HeadScript::FILE, $spec = null, $placement = 'APPEND', array $attrs = array(), $type = 'text/javascript')
0065  * @method Zend_View_Helper_HeadStyle headStyle($content = null, $placement = 'APPEND', $attributes = array())
0066  * @method Zend_View_Helper_HeadTitle headTitle($title = null, $setType = null)
0067  * @method string htmlFlash($data, array $attribs = array(), array $params = array(), $content = null)
0068  * @method string htmlList(array $items, $ordered = false, $attribs = false, $escape = true)
0069  * @method string htmlObject($data, $type, array $attribs = array(), array $params = array(), $content = null)
0070  * @method string htmlPage($data, array $attribs = array(), array $params = array(), $content = null)
0071  * @method string htmlQuicktime($data, array $attribs = array(), array $params = array(), $content = null)
0072  * @method Zend_View_Helper_InlineScript inlineScript($mode = Zend_View_Helper_HeadScript::FILE, $spec = null, $placement = 'APPEND', array $attrs = array(), $type = 'text/javascript')
0073  * @method string|void json($data, $keepLayouts = false, $encodeData = true)
0074  * @method Zend_View_Helper_Layout layout()
0075  * @method Zend_View_Helper_Navigation navigation(Zend_Navigation_Container $container = null)
0076  * @method string paginationControl(Zend_Paginator $paginator = null, $scrollingStyle = null, $partial = null, $params = null)
0077  * @method string partial($name = null, $module = null, $model = null)
0078  * @method string partialLoop($name = null, $module = null, $model = null)
0079  * @method Zend_View_Helper_Placeholder_Container_Abstract placeholder($name)
0080  * @method void renderToPlaceholder($script, $placeholder)
0081  * @method string serverUrl($requestUri = null)
0082  * @method string translate($messageid = null)
0083  * @method string url(array $urlOptions = array(), $name = null, $reset = false, $encode = true)
0084  * @method Zend_Http_UserAgent userAgent(Zend_Http_UserAgent $userAgent = null)
0085  */
0086 class Zend_View extends Zend_View_Abstract
0087 {
0088     /**
0089      * Whether or not to use streams to mimic short tags
0090      * @var bool
0091      */
0092     private $_useViewStream = false;
0093 
0094     /**
0095      * Whether or not to use stream wrapper if short_open_tag is false
0096      * @var bool
0097      */
0098     private $_useStreamWrapper = false;
0099 
0100     /**
0101      * Constructor
0102      *
0103      * Register Zend_View_Stream stream wrapper if short tags are disabled.
0104      *
0105      * @param  array $config
0106      * @return void
0107      */
0108     public function __construct($config = array())
0109     {
0110         $this->_useViewStream = (bool) ini_get('short_open_tag') ? false : true;
0111         if ($this->_useViewStream) {
0112             if (!in_array('zend.view', stream_get_wrappers())) {
0113                 // require_once 'Zend/View/Stream.php';
0114                 stream_wrapper_register('zend.view', 'Zend_View_Stream');
0115             }
0116         }
0117 
0118         if (array_key_exists('useStreamWrapper', $config)) {
0119             $this->setUseStreamWrapper($config['useStreamWrapper']);
0120         }
0121 
0122         parent::__construct($config);
0123     }
0124 
0125     /**
0126      * Set flag indicating if stream wrapper should be used if short_open_tag is off
0127      *
0128      * @param  bool $flag
0129      * @return Zend_View
0130      */
0131     public function setUseStreamWrapper($flag)
0132     {
0133         $this->_useStreamWrapper = (bool) $flag;
0134         return $this;
0135     }
0136 
0137     /**
0138      * Should the stream wrapper be used if short_open_tag is off?
0139      *
0140      * @return bool
0141      */
0142     public function useStreamWrapper()
0143     {
0144         return $this->_useStreamWrapper;
0145     }
0146 
0147     /**
0148      * Includes the view script in a scope with only public $this variables.
0149      *
0150      * @param string The view script to execute.
0151      */
0152     protected function _run()
0153     {
0154         if ($this->_useViewStream && $this->useStreamWrapper()) {
0155             include 'zend.view://' . func_get_arg(0);
0156         } else {
0157             include func_get_arg(0);
0158         }
0159     }
0160 }