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

📄 group.php

📁 Piwik#Opensourcewebanalytics一款可以和GOOGLE媲美的开源统计系统,运用AJAX.功能强大.无色提示:按照需要PHP5.1以上和MySQL数据库支持。
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: *//** * HTML class for a form element group *  * PHP versions 4 and 5 * * LICENSE: This source file is subject to version 3.01 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_01.txt If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category    HTML * @package     HTML_QuickForm * @author      Adam Daniel <adaniel1@eesus.jnj.com> * @author      Bertrand Mansion <bmansion@mamasam.com> * @author      Alexey Borzov <avb@php.net> * @copyright   2001-2007 The PHP Group * @license     http://www.php.net/license/3_01.txt PHP License 3.01 * @version     CVS: $Id: group.php 444 2008-04-11 13:38:22Z johmathe $ * @link        http://pear.php.net/package/HTML_QuickForm *//** * Base class for form elements */ require_once 'HTML/QuickForm/element.php';/** * HTML class for a form element group *  * @category    HTML * @package     HTML_QuickForm * @author      Adam Daniel <adaniel1@eesus.jnj.com> * @author      Bertrand Mansion <bmansion@mamasam.com> * @author      Alexey Borzov <avb@php.net> * @version     Release: 3.2.9 * @since       1.0 */class HTML_QuickForm_group extends HTML_QuickForm_element{    // {{{ properties            /**     * Name of the element     * @var       string     * @since     1.0     * @access    private     */    var $_name = '';    /**     * Array of grouped elements     * @var       array     * @since     1.0     * @access    private     */    var $_elements = array();    /**     * String to separate elements     * @var       mixed     * @since     2.5     * @access    private     */    var $_separator = null;    /**     * Required elements in this group     * @var       array     * @since     2.5     * @access    private     */    var $_required = array();   /**    * Whether to change elements' names to $groupName[$elementName] or leave them as is     * @var      bool    * @since    3.0    * @access   private    */    var $_appendName = true;    // }}}    // {{{ constructor    /**     * Class constructor     *      * @param     string    $elementName    (optional)Group name     * @param     array     $elementLabel   (optional)Group label     * @param     array     $elements       (optional)Group elements     * @param     mixed     $separator      (optional)Use a string for one separator,     *                                      use an array to alternate the separators.     * @param     bool      $appendName     (optional)whether to change elements' names to     *                                      the form $groupName[$elementName] or leave      *                                      them as is.     * @since     1.0     * @access    public     * @return    void     */    function HTML_QuickForm_group($elementName=null, $elementLabel=null, $elements=null, $separator=null, $appendName = true)    {        $this->HTML_QuickForm_element($elementName, $elementLabel);        $this->_type = 'group';        if (isset($elements) && is_array($elements)) {            $this->setElements($elements);        }        if (isset($separator)) {            $this->_separator = $separator;        }        if (isset($appendName)) {            $this->_appendName = $appendName;        }    } //end constructor        // }}}    // {{{ setName()    /**     * Sets the group name     *      * @param     string    $name   Group name     * @since     1.0     * @access    public     * @return    void     */    function setName($name)    {        $this->_name = $name;    } //end func setName        // }}}    // {{{ getName()    /**     * Returns the group name     *      * @since     1.0     * @access    public     * @return    string     */    function getName()    {        return $this->_name;    } //end func getName    // }}}    // {{{ setValue()    /**     * Sets values for group's elements     *      * @param     mixed    Values for group's elements     * @since     1.0     * @access    public     * @return    void     */    function setValue($value)    {        $this->_createElementsIfNotExist();        foreach (array_keys($this->_elements) as $key) {            if (!$this->_appendName) {                $v = $this->_elements[$key]->_findValue($value);                if (null !== $v) {                    $this->_elements[$key]->onQuickFormEvent('setGroupValue', $v, $this);                }            } else {                $elementName = $this->_elements[$key]->getName();                $index       = strlen($elementName) ? $elementName : $key;                if (is_array($value)) {                    if (isset($value[$index])) {                        $this->_elements[$key]->onQuickFormEvent('setGroupValue', $value[$index], $this);                    }                } elseif (isset($value)) {                    $this->_elements[$key]->onQuickFormEvent('setGroupValue', $value, $this);                }            }        }    } //end func setValue        // }}}    // {{{ getValue()    /**     * Returns the value of the group     *     * @since     1.0     * @access    public     * @return    mixed     */    function getValue()    {        $value = null;        foreach (array_keys($this->_elements) as $key) {            $element =& $this->_elements[$key];            switch ($element->getType()) {                case 'radio':                     $v = $element->getChecked()? $element->getValue(): null;                    break;                case 'checkbox':                     $v = $element->getChecked()? true: null;                    break;                default:                    $v = $element->getValue();            }            if (null !== $v) {                $elementName = $element->getName();                if (is_null($elementName)) {                    $value = $v;                } else {                    if (!is_array($value)) {                        $value = is_null($value)? array(): array($value);                    }                    if ('' === $elementName) {                        $value[] = $v;                    } else {                        $value[$elementName] = $v;                    }                }            }        }        return $value;    } // end func getValue    // }}}    // {{{ setElements()    /**     * Sets the grouped elements     *     * @param     array     $elements   Array of elements     * @since     1.1     * @access    public     * @return    void     */    function setElements($elements)    {        $this->_elements = array_values($elements);        if ($this->_flagFrozen) {            $this->freeze();        }    } // end func setElements    // }}}    // {{{ getElements()    /**     * Gets the grouped elements     *     * @since     2.4     * @access    public     * @return    array     */    function &getElements()    {        $this->_createElementsIfNotExist();        return $this->_elements;    } // end func getElements    // }}}    // {{{ getGroupType()    /**     * Gets the group type based on its elements     * Will return 'mixed' if elements contained in the group     * are of different types.     *     * @access    public     * @return    string    group elements type     */    function getGroupType()    {        $this->_createElementsIfNotExist();        $prevType = '';        foreach (array_keys($this->_elements) as $key) {            $type = $this->_elements[$key]->getType();            if ($type != $prevType && $prevType != '') {                return 'mixed';            }            $prevType = $type;        }        return $type;    } // end func getGroupType    // }}}    // {{{ toHtml()    /**     * Returns Html for the group     * 

⌨️ 快捷键说明

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