[ Index ] |
|
Code source de XOOPS 2.0.17.1 |
1 <?php 2 // $Id: formelementtray.php 982 2007-08-11 15:13:43Z phppp $ 3 // ------------------------------------------------------------------------ // 4 // XOOPS - PHP Content Management System // 5 // Copyright (c) 2000 XOOPS.org // 6 // <http://www.xoops.org/> // 7 // ------------------------------------------------------------------------ // 8 // This program is free software; you can redistribute it and/or modify // 9 // it under the terms of the GNU General Public License as published by // 10 // the Free Software Foundation; either version 2 of the License, or // 11 // (at your option) any later version. // 12 // // 13 // You may not change or alter any portion of this comment or credits // 14 // of supporting developers from this source code or any supporting // 15 // source code which is considered copyrighted (c) material of the // 16 // original comment or credit authors. // 17 // // 18 // This program is distributed in the hope that it will be useful, // 19 // but WITHOUT ANY WARRANTY; without even the implied warranty of // 20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 21 // GNU General Public License for more details. // 22 // // 23 // You should have received a copy of the GNU General Public License // 24 // along with this program; if not, write to the Free Software // 25 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 26 // ------------------------------------------------------------------------ // 27 // Author: Kazumi Ono (AKA onokazu) // 28 // URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // 29 // Project: The XOOPS Project // 30 // ------------------------------------------------------------------------- // 31 if (!defined('XOOPS_ROOT_PATH')) { 32 die("XOOPS root path not defined"); 33 } 34 /** 35 * 36 * 37 * @package kernel 38 * @subpackage form 39 * 40 * @author Kazumi Ono <onokazu@xoops.org> 41 * @copyright copyright (c) 2000-2003 XOOPS.org 42 */ 43 44 /** 45 * A group of form elements 46 * 47 * @author Kazumi Ono <onokazu@xoops.org> 48 * @copyright copyright (c) 2000-2003 XOOPS.org 49 * 50 * @package kernel 51 * @subpackage form 52 */ 53 class XoopsFormElementTray extends XoopsFormElement { 54 55 /** 56 * array of form element objects 57 * @var array 58 * @access private 59 */ 60 var $_elements = array(); 61 62 /** 63 * required elements 64 * @var array 65 */ 66 var $_required = array(); 67 68 /** 69 * HTML to seperate the elements 70 * @var string 71 * @access private 72 */ 73 var $_delimeter; 74 75 /** 76 * constructor 77 * 78 * @param string $caption Caption for the group. 79 * @param string $delimiter HTML to separate the elements 80 */ 81 function XoopsFormElementTray($caption, $delimeter=" ", $name=""){ 82 $this->setName($name); 83 $this->setCaption($caption); 84 $this->_delimeter = $delimeter; 85 } 86 87 /** 88 * Is this element a container of other elements? 89 * 90 * @return bool true 91 */ 92 function isContainer() 93 { 94 return true; 95 } 96 97 /** 98 * Find out if there are required elements. 99 * 100 * @return bool 101 */ 102 function isRequired() { 103 return !empty($this->_required); 104 } 105 106 /** 107 * Add an element to the group 108 * 109 * @param object &$element {@link XoopsFormElement} to add 110 */ 111 function addElement(&$formElement, $required = false){ 112 $this->_elements[] =& $formElement; 113 if (!$formElement->isContainer()) { 114 if ($required) { 115 $formElement->_required = true; 116 $this->_required[] =& $formElement; 117 } 118 } else { 119 $required_elements =& $formElement->getRequired(); 120 $count = count($required_elements); 121 for ($i = 0 ; $i < $count; $i++) { 122 $this->_required[] =& $required_elements[$i]; 123 } 124 } 125 } 126 127 /** 128 * get an array of "required" form elements 129 * 130 * @return array array of {@link XoopsFormElement}s 131 */ 132 function &getRequired() 133 { 134 return $this->_required; 135 } 136 137 /** 138 * Get an array of the elements in this group 139 * 140 * @param bool $recurse get elements recursively? 141 * @return array Array of {@link XoopsFormElement} objects. 142 */ 143 function &getElements($recurse = false){ 144 if (!$recurse) { 145 return $this->_elements; 146 } else { 147 $ret = array(); 148 $count = count($this->_elements); 149 for ($i = 0; $i < $count; $i++) { 150 if (!$this->_elements[$i]->isContainer()) { 151 $ret[] =& $this->_elements[$i]; 152 } else { 153 $elements =& $this->_elements[$i]->getElements(true); 154 $count2 = count($elements); 155 for ($j = 0; $j < $count2; $j++) { 156 $ret[] =& $elements[$j]; 157 } 158 unset($elements); 159 } 160 } 161 return $ret; 162 } 163 } 164 165 /** 166 * Get the delimiter of this group 167 * 168 * @return string The delimiter 169 */ 170 function getDelimeter(){ 171 return $this->_delimeter; 172 } 173 174 /** 175 * prepare HTML to output this group 176 * 177 * @return string HTML output 178 */ 179 function render(){ 180 $count = 0; 181 $ret = ""; 182 foreach ( $this->getElements() as $ele ) { 183 if ($count > 0) { 184 $ret .= $this->getDelimeter(); 185 } 186 if ($ele->getCaption() != '') { 187 $ret .= $ele->getCaption()." "; 188 } 189 $ret .= $ele->render()."\n"; 190 if (!$ele->isHidden()) { 191 $count++; 192 } 193 } 194 return $ret; 195 } 196 } 197 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Nov 25 11:44:32 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |