⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 layout.php

📁 Bug tracker, and reporter.
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php/** * Zend Framework * * LICENSE * * This source file is subject to the new BSD license that is bundled * with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://framework.zend.com/license/new-bsd * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. * * @category   Zend * @package    Zend_Layout * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) * @license    http://framework.zend.com/license/new-bsd     New BSD License * @version    $Id: Layout.php 8064 2008-02-16 10:58:39Z thomas $ *//** * Provide Layout support for MVC applications * * @category   Zend * @package    Zend_Layout * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) * @license    http://framework.zend.com/license/new-bsd     New BSD License */class Zend_Layout{    /**     * Placeholder container for layout variables     * @var Zend_View_Helper_Placeholder_Container     */    protected $_container;    /**     * Key used to store content from 'default' named response segment     * @var string     */    protected $_contentKey = 'content';    /**     * Are layouts enabled?     * @var bool     */    protected $_enabled = true;    /**     * Helper class     * @var string     */    protected $_helperClass = 'Zend_Layout_Controller_Action_Helper_Layout';     /**     * Inflector used to resolve layout script     * @var Zend_Filter_Inflector     */    protected $_inflector;    /**     * Flag: is inflector enabled?     * @var bool     */    protected $_inflectorEnabled = true;    /**     * Inflector target     * @var string     */    protected $_inflectorTarget = ':script.:suffix';    /**     * Layout view     * @var string     */    protected $_layout = 'layout';    /**     * Layout view script path     * @var string     */    protected $_layoutPath;    /**     * Flag: is MVC integration enabled?     * @var bool     */    protected $_mvcEnabled = true;    /**     * Instance registered with MVC, if any     * @var Zend_Layout     */    protected static $_mvcInstance;    /**     * Flag: is MVC successful action only flag set?     * @var bool     */    protected $_mvcSuccessfulActionOnly = true;    /**     * Plugin class     * @var string     */    protected $_pluginClass = 'Zend_Layout_Controller_Plugin_Layout';        /**     * @var Zend_View_Interface     */    protected $_view;    /**     * View script suffix for layout script     * @var string     */    protected $_viewSuffix = 'phtml';    /**     * Constructor     *     * Accepts either:     * - A string path to layouts     * - An array of options     * - A Zend_Config object with options     *     * Layout script path, either as argument or as key in options, is      * required.     *     * If mvcEnabled flag is false from options, simply sets layout script path.      * Otherwise, also instantiates and registers action helper and controller      * plugin.     *      * @param  string|array|Zend_Config $options      * @return void     */     public function __construct($options = null, $initMvc = false)     {         if (null !== $options) {            if (is_string($options)) {                $this->setLayoutPath($options);            } elseif (is_array($options)) {                $this->setOptions($options);            } elseif ($options instanceof Zend_Config) {                $this->setConfig($options);            } else {                require_once 'Zend/Layout/Exception.php';                throw new Zend_Layout_Exception('Invalid option provided to constructor');            }        }        $this->_initVarContainer();        if ($initMvc) {            $this->_setMvcEnabled(true);            $this->_initMvc();        } else {            $this->_setMvcEnabled(false);        }    }    /**     * Static method for initialization with MVC support     *      * @param  string|array|Zend_Config $options      * @return Zend_Layout     */    public static function startMvc($options = null)    {        if (null === self::$_mvcInstance) {            self::$_mvcInstance = new self($options, true);        } else {            self::$_mvcInstance->setOptions($options);        }        return self::$_mvcInstance;    }    /**     * Retrieve MVC instance of Zend_Layout object     *      * @return Zend_Layout|null     */    public static function getMvcInstance()    {        return self::$_mvcInstance;    }    /**     * Set options en masse     *      * @param  array $options      * @return void     */    public function setOptions($options)    {        if ($options instanceof Zend_Config) {            $options = $options->toArray();        } elseif (!is_array($options)) {            require_once 'Zend/Layout/Exception.php';            throw new Zend_Layout_Exception('setOptions() expects either an array or a Zend_Config object');        }        foreach ($options as $key => $value) {            $method = 'set' . ucfirst($key);            if (method_exists($this, $method)) {                $this->$method($value);            }        }    }    /**     * Initialize MVC integration     *      * @return void     */    protected function _initMvc()    {        $this->_initPlugin();        $this->_initHelper();    }    /**     * Initialize front controller plugin     *      * @return void     */    protected function _initPlugin()    {        $pluginClass = $this->getPluginClass();        require_once 'Zend/Controller/Front.php';        $front = Zend_Controller_Front::getInstance();        if (!$front->hasPlugin($pluginClass)) {            require_once 'Zend/Loader.php';            Zend_Loader::loadClass($pluginClass);            $front->registerPlugin(                // register to run last | BUT before the ErrorHandler (if its available)                new $pluginClass($this),                 99            );        }    }    /**     * Initialize action helper     *      * @return void     */    protected function _initHelper()    {        $helperClass = $this->getHelperClass();        require_once 'Zend/Controller/Action/HelperBroker.php';        if (!Zend_Controller_Action_HelperBroker::hasHelper('layout')) {            require_once 'Zend/Loader.php';            Zend_Loader::loadClass($helperClass);            Zend_Controller_Action_HelperBroker::addHelper(                new $helperClass($this)            );        }    }    /**     * Set options from a config object     *      * @param  Zend_Config $config      * @return Zend_Layout     */    public function setConfig(Zend_Config $config)    {        $this->setOptions($config->toArray());        return $this;    }    /**     * Initialize placeholder container for layout vars     *      * @return Zend_View_Helper_Placeholder_Container     */    protected function _initVarContainer()    {        if (null === $this->_container) {            require_once 'Zend/View/Helper/Placeholder/Registry.php';            $this->_container = Zend_View_Helper_Placeholder_Registry::getRegistry()->getContainer(__CLASS__);        }        return $this->_container;    }    /**     * Set layout script to use     *     * Note: enables layout.     *      * @param  string $name      * @return Zend_Layout     */     public function setLayout($name)     {        $this->_layout = (string) $name;        $this->enableLayout();        return $this;    }     /**     * Get current layout script     *      * @return string     */     public function getLayout()     {        return $this->_layout;    }      /**     * Disable layout     *     * @return Zend_Layout     */     public function disableLayout()     {        $this->_enabled = false;        return $this;    }     /**     * Enable layout      *      * @return Zend_Layout     */    public function enableLayout()    {        $this->_enabled = true;        return $this;    }    /**     * Is layout enabled?     *      * @return bool     */    public function isEnabled()    {        return $this->_enabled;    }     /**     * Set layout script path     *      * @param  string $path      * @return Zend_Layout     */     public function setLayoutPath($path)     {        $this->_layoutPath = $path;        return $this;    }      /**     * Get current layout script path     *      * @return string     */     public function getLayoutPath()     {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -