source: temp/test-xoops.ec-cube.net/html/class/xoopsform/formtext.php @ 405

Revision 405, 4.1 KB checked in by root, 20 years ago (diff)
Line 
1<?php
2// $Id: formtext.php,v 1.2 2005/03/18 12:51:55 onokazu 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 * @package     kernel
33 * @subpackage  form
34 *
35 * @author      Kazumi Ono  <[email protected]>
36 * @copyright   copyright (c) 2000-2003 XOOPS.org
37 */
38 
39/**
40 * A simple text field
41 *
42 * @package     kernel
43 * @subpackage  form
44 *
45 * @author      Kazumi Ono  <[email protected]>
46 * @copyright   copyright (c) 2000-2003 XOOPS.org
47 */
48class XoopsFormText extends XoopsFormElement {
49
50    /**
51     * Size
52     * @var int
53     * @access  private
54     */
55    var $_size;
56
57    /**
58     * Maximum length of the text
59     * @var int
60     * @access  private
61     */
62    var $_maxlength;
63
64    /**
65     * Initial text
66     * @var string 
67     * @access  private
68     */
69    var $_value;
70
71    /**
72     * Constructor
73     *
74     * @param   string  $caption    Caption
75     * @param   string  $name       "name" attribute
76     * @param   int     $size       Size
77     * @param   int     $maxlength  Maximum length of text
78     * @param   string  $value      Initial text
79     */
80    function XoopsFormText($caption, $name, $size, $maxlength, $value=""){
81        $this->setCaption($caption);
82        $this->setName($name);
83        $this->_size = intval($size);
84        $this->_maxlength = intval($maxlength);
85        $this->setValue($value);
86    }
87
88    /**
89     * Get size
90     *
91     * @return  int
92     */
93    function getSize(){
94        return $this->_size;
95    }
96
97    /**
98     * Get maximum text length
99     *
100     * @return  int
101     */
102    function getMaxlength(){
103        return $this->_maxlength;
104    }
105
106    /**
107     * Get initial text value
108     *
109     * @return  string
110     */
111    function getValue(){
112        return $this->_value;
113    }
114
115    /**
116     * Set initial text value
117     *
118     * @param   $value  string
119     */
120    function setValue($value){
121        $this->_value = $value;
122    }
123
124    /**
125     * Prepare HTML for output
126     *
127     * @return  string  HTML
128     */
129    function render(){
130        return "<input type='text' name='".$this->getName()."' id='".$this->getName()."' size='".$this->getSize()."' maxlength='".$this->getMaxlength()."' value='".$this->getValue()."'".$this->getExtra()." />";
131    }
132}
133?>
Note: See TracBrowser for help on using the repository browser.