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

📄 form.php

📁 Bug tracker, and reporter.
💻 PHP
📖 第 1 页 / 共 5 页
字号:
    {        if (null === $this->_view) {            require_once 'Zend/Controller/Action/HelperBroker.php';            $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');            $this->_view = $viewRenderer->view;        }        return $this->_view;    }    /**     * Instantiate a decorator based on class name or class name fragment     *      * @param  string $name      * @param  null|array $options      * @return Zend_Form_Decorator_Interface     */    protected function _getDecorator($name, $options)    {        $class = $this->getPluginLoader(self::DECORATOR)->load($name);        if (null === $options) {            $decorator = new $class;        } else {            $r = new ReflectionClass($class);            $decorator = $r->newInstance($options);        }        return $decorator;    }    /**     * Add a decorator for rendering the element     *      * @param  string|Zend_Form_Decorator_Interface $decorator      * @param  array|Zend_Config $options Options with which to initialize decorator     * @return Zend_Form_Element     */    public function addDecorator($decorator, $options = null)    {        if ($decorator instanceof Zend_Form_Decorator_Interface) {            $name = get_class($decorator);        } elseif (is_string($decorator)) {            $decorator = $this->_getDecorator($decorator, $options);            $name = get_class($decorator);        } elseif (is_array($decorator)) {            foreach ($decorator as $name => $spec) {                break;            }            if (is_numeric($name)) {                require_once 'Zend/Form/Exception.php';                throw new Zend_Form_Exception('Invalid alias provided to addDecorator; must be alphanumeric string');            }            if (is_string($spec)) {                $decorator = $this->_getDecorator($spec, $options);            } elseif ($spec instanceof Zend_Form_Decorator_Interface) {                $decorator = $spec;            }        } else {            require_once 'Zend/Form/Exception.php';            throw new Zend_Form_Exception('Invalid decorator provided to addDecorator; must be string or Zend_Form_Decorator_Interface');        }        $this->_decorators[$name] = $decorator;        return $this;    }    /**     * Add many decorators at once     *      * @param  array $decorators      * @return Zend_Form_Element     */    public function addDecorators(array $decorators)    {        foreach ($decorators as $decoratorInfo) {            if (is_string($decoratorInfo)) {                $this->addDecorator($decoratorInfo);            } elseif ($decoratorInfo instanceof Zend_Form_Decorator_Interface) {                $this->addDecorator($decoratorInfo);            } elseif (is_array($decoratorInfo)) {                $argc    = count($decoratorInfo);                $options = array();                if (isset($decoratorInfo['decorator'])) {                    $decorator = $decoratorInfo['decorator'];                    if (isset($decoratorInfo['options'])) {                        $options = $decoratorInfo['options'];                    }                    $this->addDecorator($decorator, $options);                } else {                    switch (true) {                        case (0 == $argc):                            break;                        case (1 <= $argc):                            $decorator  = array_shift($decoratorInfo);                        case (2 <= $argc):                            $options = array_shift($decoratorInfo);                        default:                            $this->addDecorator($decorator, $options);                            break;                    }                }            } else {                require_once 'Zend/Form/Exception.php';                throw new Zend_Form_Exception('Invalid decorator passed to addDecorators()');            }        }        return $this;    }    /**     * Overwrite all decorators     *      * @param  array $decorators      * @return Zend_Form_Element     */    public function setDecorators(array $decorators)    {        $this->clearDecorators();        return $this->addDecorators($decorators);    }    /**     * Retrieve a registered decorator     *      * @param  string $name      * @return false|Zend_Form_Decorator_Abstract     */    public function getDecorator($name)    {        if (!isset($this->_decorators[$name])) {            $decorators = array_keys($this->_decorators);            $len = strlen($name);            foreach ($decorators as $decorator) {                if (0 === substr_compare($decorator, $name, -$len, $len, true)) {                    return $this->_decorators[$decorator];                }            }            return false;        }        return $this->_decorators[$name];    }    /**     * Retrieve all decorators     *      * @return array     */    public function getDecorators()    {        return $this->_decorators;    }    /**     * Remove a single decorator     *      * @param  string $name      * @return bool     */    public function removeDecorator($name)    {        $decorator = $this->getDecorator($name);        if ($decorator) {            $name = get_class($decorator);            unset($this->_decorators[$name]);            return true;        }        return false;    }    /**     * Clear all decorators     *      * @return Zend_Form_Element     */    public function clearDecorators()    {        $this->_decorators = array();        return $this;    }    /**     * Set all element decorators as specified     *      * @param  array $decorators      * @return Zend_Form     */    public function setElementDecorators(array $decorators)    {        foreach ($this->getElements() as $element) {            $element->setDecorators($decorators);        }        return $this;    }    /**     * Set all display group decorators as specified     *      * @param  array $decorators      * @return Zend_Form     */    public function setDisplayGroupDecorators(array $decorators)    {        foreach ($this->getDisplayGroups() as $group) {            $group->setDecorators($decorators);        }        return $this;    }    /**     * Set all subform decorators as specified     *      * @param  array $decorators      * @return Zend_Form     */    public function setSubFormDecorators(array $decorators)    {        foreach ($this->getSubForms() as $form) {            $form->setDecorators($decorators);        }        return $this;    }    /**     * Render form     *      * @param  Zend_View_Interface $view      * @return string     */    public function render(Zend_View_Interface $view = null)    {        if (null !== $view) {            $this->setView($view);        }        $content = '';        foreach ($this->getDecorators() as $decorator) {            $decorator->setElement($this);            $content = $decorator->render($content);        }        return $content;    }    /**     * Serialize as string     *     * Proxies to {@link render()}.     *      * @return string     */    public function __toString()    {        try {            $return = $this->render();            return $return;        } catch (Exception $e) {            trigger_error($e->getMessage(), E_USER_WARNING);            return '';        }    }     // Localization:     /**     * Set translator object     *      * @param  Zend_Translate|Zend_Translate_Adapter|null $translator      * @return Zend_Form     */    public function setTranslator($translator = null)    {        if (null === $translator) {            $this->_translator = null;        } elseif ($translator instanceof Zend_Translate_Adapter) {            $this->_translator = $translator;        } elseif ($translator instanceof Zend_Translate) {            $this->_translator = $translator->getAdapter();        } else {            require_once 'Zend/Form/Exception.php';            throw new Zend_Form_Exception('Invalid translator specified');        }        return $this;    }    /**     * Set global default translator object     *      * @param  Zend_Translate|Zend_Translate_Adapter|null $translator      * @return void     */    public static function setDefaultTranslator($translator = null)    {        if (null === $translator) {            self::$_translatorDefault = null;        } elseif ($translator instanceof Zend_Translate_Adapter) {            self::$_translatorDefault = $translator;        } elseif ($translator instanceof Zend_Translate) {            self::$_translatorDefault = $translator->getAdapter();        } else {            require_once 'Zend/Form/Exception.php';            throw new Zend_Form_Exception('Invalid translator specified');        }    }    /**     * Retrieve translator object     *      * @return Zend_Translate|null     */    public function getTranslator()    {        if ($this->translatorIsDisabled()) {            return null;        }        if (null === $this->_translator) {            return self::getDefaultTranslator();        }        return $this->_translator;    }    /**     * Get global default translator object     *      * @return null|Zend_Translate     */    public static function getDefaultTranslator()    {        if (null === self::$_translatorDefault) {            require_once 'Zend/Registry.php';            if (Zend_Registry::isRegistered('Zend_Translate')) {                $translator = Zend_Registry::get('Zend_Translate');                if ($translator instanceof Zend_Translate_Adapter) {                    return $translator;                } elseif ($translator instanceof Zend_Translate) {                    return $translator->getAdapter();                }            }        }        return self::$_translatorDefault;    }    /**     * Indicate whether or not translation should be disabled     *      * @param  bool $flag      * @return Zend_Form     */    public function setDisableTranslator($flag)    {        $this->_translatorDisabled = (bool) $flag;        return $this;    }    /**     * Is translation disabled?     *      * @return bool     */    public function translatorIsDisabled()    {        return $this->_translatorDisabled;    }    /**     * Overloading: access to elements, form groups, and display groups     *      * @param  string $name      * @return Zend_Form_Element|Zend_Form|null     */    public function __get($name)    {        if (isset($this->_elements[$name])) {            return $this->_elements[$name];        } elseif (isset($this->_subForms[$name])) {            return $this->_subForms[$name];        } elseif (isset($this->_displayGroups[$name])) {            return $this->_displayGroups[$name];        }        return null;    }    /**     * Overloading: access to elements, form groups, and display groups     *      * @param  string $name      * @param  Zend_Form_Element|Zend_Form $value      * @return void     * @throws Zend_Form_Exception for invalid $value     */    public function __set($name, $value)    {        if ($value instanceof Zend_Form_Element) {            $this->addElement($value, $name);            return;        } elseif ($value instanceof Zend_Form) {            $this->addSubForm($value, $name);            return;        } elseif (is_array($value)) {            $this->addDisplayGroup($value, $name);            return;        }        require_once 'Zend/Form/Exception.php';        if (is_object($value)) {            $type = get_class($value);        } else {            $type = gettype($value);        }        throw new Zend_Form_Exception('Only form elements and groups may be overloaded; variable of type "' . $type . '" provided');    }    /**     * Overloading: access to elements, form groups, and display groups     *      * @param  string $name      * @return boolean     */    public function __isset($name)    {        if (isset($this->_elements[$name])            || isset($this->_subForms[$name])            || isset($this->_displayGroups[$name]))        {            return true;        }        return false;    }    /**     * Overloading: access to elements, form groups, and display groups     *      * @param  string $name      * @return void     */    public function __unset($name)    {        if (isset($this->_elements[$name])) {            unset($this->_elements[$name]);        } elseif (isset($this->_subForms[$name])) {            unset($this->_subForms[$name]);        } elseif (isset($this->_displayGroups[$name])) {            unset($this->_displayGroups[$name]);        }    }     // Interfaces: Iterator, Countable    /**     * Current element/subform/display group     *      * @return Zend_Form_Element|Zend_Form_DisplayGroup|Zend_Form     */    public function current()    {        $this->_sort();        current($this->_order);        $key = key($this->_order);        if (isset($this->_elements[$key])) {            return $this->getElement($key);        } elseif (isset($this->_subForms[$key])) {            return $this->getSubForm($key);        } elseif (isset($this->_displayGroups[$key])) {            return $this->getDisplayGroup($key);        } else {            require_once 

⌨️ 快捷键说明

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