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

📄 controller.php

📁 完美的在线教育系统
💻 PHP
📖 第 1 页 / 共 2 页
字号:
                    }                }                return false;            }        }        return true;    }   /**    * Returns the name of the page before the given.    *     * @access public    * @param  string     * @return string    */    function getPrevName($pageName)    {        $prev = null;        foreach (array_keys($this->_pages) as $key) {            if ($key == $pageName) {                return $prev;            }            $prev = $key;        }    }   /**    * Returns the name of the page after the given.    *     * @access public    * @param  string     * @return string    */    function getNextName($pageName)    {        $prev = null;        foreach (array_keys($this->_pages) as $key) {            if ($prev == $pageName) {                return $key;            }            $prev = $key;        }        return null;    }   /**    * Finds the (first) invalid page    *     * @access public    * @return string  Name of an invalid page    */    function findInvalid()    {        $data =& $this->container();        foreach (array_keys($this->_pages) as $key) {            if (!$data['valid'][$key]) {                return $key;            }        }        return null;    }   /**    * Extracts the names of the current page and the current action from    * HTTP request data.     *    * @access public    * @return array     first element is page name, second is action name    */    function getActionName()    {        if (is_array($this->_actionName)) {            return $this->_actionName;        }        $names = array_map('preg_quote', array_keys($this->_pages));        $regex = '/^_qf_(' . implode('|', $names) . ')_(.+?)(_x)?$/';        foreach (array_keys($_REQUEST) as $key) {            if (preg_match($regex, $key, $matches)) {                return array($matches[1], $matches[2]);            }        }        if (isset($_REQUEST['_qf_default'])) {            $matches = explode(':', $_REQUEST['_qf_default'], 2);            if (isset($this->_pages[$matches[0]])) {                return $matches;            }        }        reset($this->_pages);        return array(key($this->_pages), 'display');    }   /**    * Initializes default form values.    *    * @access public    * @param  array  default values    * @param  mixed  filter(s) to apply to default values    * @throws PEAR_Error    */    function setDefaults($defaultValues = null, $filter = null)    {        if (is_array($defaultValues)) {            $data =& $this->container();            return $this->_setDefaultsOrConstants($data['defaults'], $defaultValues, $filter);        }    }   /**    * Initializes constant form values.    * These values won't get overridden by POST or GET vars    *    * @access public    * @param  array  constant values    * @param  mixed  filter(s) to apply to constant values    * @throws PEAR_Error    */    function setConstants($constantValues = null, $filter = null)    {        if (is_array($constantValues)) {            $data =& $this->container();            return $this->_setDefaultsOrConstants($data['constants'], $constantValues, $filter);        }    }   /**    * Adds new values to defaults or constants array    *    * @access   private    * @param    array   array to add values to (either defaults or constants)    * @param    array   values to add    * @param    mixed   filters to apply to new values    * @throws   PEAR_Error    */    function _setDefaultsOrConstants(&$values, $newValues, $filter = null)    {        if (isset($filter)) {            if (is_array($filter) && (2 != count($filter) || !is_callable($filter))) {                foreach ($filter as $val) {                    if (!is_callable($val)) {                        return PEAR::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm_Controller::_setDefaultsOrConstants()", 'HTML_QuickForm_Error', true);                    } else {                        $newValues = $this->_arrayMapRecursive($val, $newValues);                    }                }            } elseif (!is_callable($filter)) {                return PEAR::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm_Controller::_setDefaultsOrConstants()", 'HTML_QuickForm_Error', true);            } else {                $newValues = $this->_arrayMapRecursive($val, $newValues);            }        }        $values = HTML_QuickForm::arrayMerge($values, $newValues);    }   /**    * Recursively applies the callback function to the value    *     * @param    mixed   Callback function    * @param    mixed   Value to process    * @access   private    * @return   mixed   Processed values    */    function _arrayMapRecursive($callback, $value)    {        if (!is_array($value)) {            return call_user_func($callback, $value);        } else {            $map = array();            foreach ($value as $k => $v) {                $map[$k] = $this->_arrayMapRecursive($callback, $v);            }            return $map;        }    }   /**    * Sets the default values for the given page    *    * @access public    * @param  string  Name of a page    */    function applyDefaults($pageName)    {        $data =& $this->container();        if (!empty($data['defaults'])) {            $this->_pages[$pageName]->setDefaults($data['defaults']);        }        if (!empty($data['constants'])) {            $this->_pages[$pageName]->setConstants($data['constants']);        }    }   /**    * Returns the form's values    *     * @access public    * @param  string    name of the page, if not set then returns values for all pages    * @return array    */    function exportValues($pageName = null)    {        $data   =& $this->container();        $values =  array();        if (isset($pageName)) {            $pages = array($pageName);        } else {            $pages = array_keys($data['values']);        }        foreach ($pages as $page) {            // skip elements representing actions            foreach ($data['values'][$page] as $key => $value) {                if (0 !== strpos($key, '_qf_')) {                    if (isset($values[$key]) && is_array($value)) {                        $values[$key] = HTML_QuickForm::arrayMerge($values[$key], $value);                    } else {                        $values[$key] = $value;                    }                }            }        }        return $values;    }   /**    * Returns the element's value    *     * @access public    * @param  string    name of the page    * @param  string    name of the element in the page    * @return mixed     value for the element    */    function exportValue($pageName, $elementName)    {        $data =& $this->container();        return isset($data['values'][$pageName][$elementName])? $data['values'][$pageName][$elementName]: null;    }}?>

⌨️ 快捷键说明

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