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

📄 standard.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_Controller * @subpackage Dispatcher * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) * @license    http://framework.zend.com/license/new-bsd     New BSD License *//** Zend_Loader */require_once 'Zend/Loader.php';/** Zend_Controller_Dispatcher_Abstract */require_once 'Zend/Controller/Dispatcher/Abstract.php';/** Zend_Controller_Request_Abstract */require_once 'Zend/Controller/Request/Abstract.php';/** Zend_Controller_Response_Abstract */require_once 'Zend/Controller/Response/Abstract.php';/** Zend_Controller_Action */require_once 'Zend/Controller/Action.php';/** * @category   Zend * @package    Zend_Controller * @subpackage Dispatcher * @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_Controller_Dispatcher_Standard extends Zend_Controller_Dispatcher_Abstract{    /**     * Current dispatchable directory     * @var string     */    protected $_curDirectory;    /**     * Current module (formatted)     * @var string     */    protected $_curModule;    /**     * Controller directory(ies)     * @var array     */    protected $_controllerDirectory = array();    /**     * Constructor: Set current module to default value     *     * @param  array $params     * @return void     */    public function __construct(array $params = array())    {        parent::__construct($params);        $this->_curModule = $this->getDefaultModule();    }    /**     * Add a single path to the controller directory stack     *     * @param string $path     * @param string $module     * @return Zend_Controller_Dispatcher_Standard     */    public function addControllerDirectory($path, $module = null)    {        if (null === $module) {            $module = $this->_defaultModule;        }        $module = (string) $module;        $path   = rtrim((string) $path, '/\\');        $this->_controllerDirectory[$module] = $path;        return $this;    }    /**     * Set controller directory     *     * @param array|string $directory     * @return Zend_Controller_Dispatcher_Standard     */    public function setControllerDirectory($directory, $module = null)    {        $this->_controllerDirectory = array();        if (is_string($directory)) {            $this->addControllerDirectory($directory, $module);        } elseif (is_array($directory)) {            foreach ((array) $directory as $module => $path) {                $this->addControllerDirectory($path, $module);            }        } else {            throw new Zend_Controller_Exception('Controller directory spec must be either a string or an array');        }        return $this;    }    /**     * Return the currently set directories for Zend_Controller_Action class     * lookup     *     * If a module is specified, returns just that directory.     *     * @param  string $module Module name     * @return array|string Returns array of all directories by default, single     * module directory if module argument provided     */    public function getControllerDirectory($module = null)    {        if (null === $module) {            return $this->_controllerDirectory;        }        $module = (string) $module;        if (array_key_exists($module, $this->_controllerDirectory)) {            return $this->_controllerDirectory[$module];        }        return null;    }    /**     * Remove a controller directory by module name     *      * @param  string $module      * @return bool     */    public function removeControllerDirectory($module)    {        $module = (string) $module;        if (array_key_exists($module, $this->_controllerDirectory)) {            unset($this->_controllerDirectory[$module]);            return true;        }        return false;    }    /**     * Format the module name.     *     * @param string $unformatted     * @return string     */    public function formatModuleName($unformatted)    {        if (($this->_defaultModule == $unformatted) && !$this->getParam('prefixDefaultModule')) {            return $unformatted;        }        return ucfirst($this->_formatName($unformatted));    }    /**     * Format action class name     *     * @param string $moduleName Name of the current module     * @param string $className Name of the action class     * @return string Formatted class name     */    public function formatClassName($moduleName, $className)    {        return $this->formatModuleName($moduleName) . '_' . $className;    }    /**     * Convert a class name to a filename     *     * @param string $class     * @return string     */    public function classToFilename($class)    {        return str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';    }    /**     * Returns TRUE if the Zend_Controller_Request_Abstract object can be     * dispatched to a controller.     *     * Use this method wisely. By default, the dispatcher will fall back to the     * default controller (either in the module specified or the global default)     * if a given controller does not exist. This method returning false does     * not necessarily indicate the dispatcher will not still dispatch the call.     *     * @param Zend_Controller_Request_Abstract $action     * @return boolean     */    public function isDispatchable(Zend_Controller_Request_Abstract $request)    {        $className = $this->getControllerClass($request);        if (!$className) {            return false;        }        if (class_exists($className, false)) {            return true;        }        $fileSpec    = $this->classToFilename($className);        $dispatchDir = $this->getDispatchDirectory();        $test        = $dispatchDir . DIRECTORY_SEPARATOR . $fileSpec;        return Zend_Loader::isReadable($test);    }    /**     * Dispatch to a controller/action     *     * By default, if a controller is not dispatchable, dispatch() will throw     * an exception. If you wish to use the default controller instead, set the     * param 'useDefaultControllerAlways' via {@link setParam()}.     *     * @param Zend_Controller_Request_Abstract $request     * @param Zend_Controller_Response_Abstract $response     * @return boolean     * @throws Zend_Controller_Dispatcher_Exception     */    public function dispatch(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response)    {        $this->setResponse($response);        /**         * Get controller class         */        if (!$this->isDispatchable($request)) {

⌨️ 快捷键说明

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