Overview

Packages

  • Archive
    • Zip
  • class
    • mail
  • kernel
    • block
    • comment
    • config
    • core
    • database
    • form
    • member
    • notification
    • util
  • Legacy
  • None
  • PHP
  • PHPMailer
  • ShadePlus
  • ShadeSoap
  • Smarty
    • plugins
  • XCube
  • XOOPS
  • XOOPS2

Classes

  • XoopsForm
  • XoopsFormBreak
  • XoopsFormButton
  • XoopsFormCheckBox
  • XoopsFormDateTime
  • XoopsFormDhtmlTextArea
  • XoopsFormElement
  • XoopsFormElementTray
  • XoopsFormFile
  • XoopsFormHidden
  • XoopsFormLabel
  • XoopsFormPassword
  • XoopsFormRadio
  • XoopsFormRadioYN
  • XoopsFormSelect
  • XoopsFormSelectCountry
  • XoopsFormSelectGroup
  • XoopsFormSelectLang
  • XoopsFormSelectMatchOption
  • XoopsFormSelectTheme
  • XoopsFormSelectTimezone
  • XoopsFormSelectUser
  • XoopsFormText
  • XoopsFormTextArea
  • XoopsFormTextDateSelect
  • XoopsFormToken
  • XoopsGroupFormCheckBox
  • XoopsGroupPermForm
  • XoopsSimpleForm
  • XoopsTableForm
  • XoopsThemeForm
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: // $Id: formselect.php,v 1.1 2007/05/15 02:34:42 minahito Exp $
  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: 
 32: if (!defined('XOOPS_ROOT_PATH')) exit();
 33: 
 34: /**
 35:  * @package     kernel
 36:  * @subpackage  form
 37:  * 
 38:  * @author      Kazumi Ono  <onokazu@xoops.org>
 39:  * @copyright   copyright (c) 2000-2003 XOOPS.org
 40:  */
 41: 
 42: /**
 43:  * A select field
 44:  * 
 45:  * @package     kernel
 46:  * @subpackage  form
 47:  * 
 48:  * @author      Kazumi Ono  <onokazu@xoops.org>
 49:  * @copyright   copyright (c) 2000-2003 XOOPS.org
 50:  */
 51: class XoopsFormSelect extends XoopsFormElement {
 52: 
 53:     /**
 54:      * Options
 55:      * @var array   
 56:      * @access  private
 57:      */
 58:     var $_options = array();
 59: 
 60:     /**
 61:      * Allow multiple selections?
 62:      * @var bool    
 63:      * @access  private
 64:      */
 65:     var $_multiple = false;
 66: 
 67:     /**
 68:      * Number of rows. "1" makes a dropdown list.
 69:      * @var int 
 70:      * @access  private
 71:      */
 72:     var $_size;
 73: 
 74:     /**
 75:      * Pre-selcted values
 76:      * @var array   
 77:      * @access  private
 78:      */
 79:     var $_value = array();
 80: 
 81:     /**
 82:      * Constructor
 83:      * 
 84:      * @param   string  $caption    Caption
 85:      * @param   string  $name       "name" attribute
 86:      * @param   mixed   $value      Pre-selected value (or array of them).
 87:      * @param   int     $size       Number or rows. "1" makes a drop-down-list
 88:      * @param   bool    $multiple   Allow multiple selections?
 89:      */
 90:     function XoopsFormSelect($caption, $name, $value=null, $size=1, $multiple=false){
 91:         $this->setCaption($caption);
 92:         $this->setName($name);
 93:         $this->_multiple = $multiple;
 94:         $this->_size = intval($size);
 95:         if (isset($value)) {
 96:             $this->setValue($value);
 97:         }
 98:     }
 99: 
100:     /**
101:      * Are multiple selections allowed?
102:      * 
103:      * @return  bool
104:      */
105:     function isMultiple(){
106:         return $this->_multiple;
107:     }
108: 
109:     /**
110:      * Get the size
111:      * 
112:      * @return  int
113:      */
114:     function getSize(){
115:         return $this->_size;
116:     }
117: 
118:     /**
119:      * Get an array of pre-selected values
120:      * 
121:      * @return  array
122:      */
123:     function getValue(){
124:         return $this->_value;
125:     }
126: 
127:     /**
128:      * Set pre-selected values
129:      * 
130:      * @param   $value  mixed
131:      */
132:     function setValue($value){
133:         if (is_array($value)) {
134:             foreach ($value as $v) {
135:                 $this->_value[] = $v;
136:             }
137:         } else {
138:             $this->_value[] = $value;
139:         }
140:     }
141: 
142:     /**
143:      * Add an option
144:      * 
145:      * @param   string  $value  "value" attribute
146:      * @param   string  $name   "name" attribute
147:      */
148:     function addOption($value, $name=""){
149:         if ( $name != "" ) {
150:             $this->_options[$value] = $name;
151:         } else {
152:             $this->_options[$value] = $value;
153:         }
154:     }
155: 
156:     /**
157:      * Add multiple options
158:      * 
159:      * @param   array   $options    Associative array of value->name pairs
160:      */
161:     function addOptionArray($options){
162:         if ( is_array($options) ) {
163:             foreach ( $options as $k=>$v ) {
164:                 $this->addOption($k, $v);
165:             }
166:         }
167:     }
168: 
169:     /**
170:      * Get all options
171:      * 
172:      * @return  array   Associative array of value->name pairs
173:      */
174:     function getOptions(){
175:         return $this->_options;
176:     }
177: 
178:     /**
179:      * Prepare HTML for output
180:      * 
181:      * @return  string  HTML
182:      */
183:     function render(){
184:         $root =& XCube_Root::getSingleton();
185:         $renderSystem =& $root->getRenderSystem(XOOPSFORM_DEPENDENCE_RENDER_SYSTEM);
186:         
187:         $renderTarget =& $renderSystem->createRenderTarget('main');
188:     
189:         $renderTarget->setAttribute('legacy_module', 'legacy');
190:         $renderTarget->setTemplateName("legacy_xoopsform_select.html");
191:         $renderTarget->setAttribute("element", $this);
192: 
193:         $renderSystem->render($renderTarget);
194:     
195:         return $renderTarget->getResult();
196:     }
197: }
198: ?>
XOOPS Cube Legacy :: API documentation generated by ApiGen 2.7.0