2 /*=====================================================================*
3 || ###################################################################
4 || # Blue Static ISSO Framework
5 || # Copyright ©2002-[#]year[#] Blue Static
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
23 * Base Printer Element (PrinterElement.php)
28 require_once('ISSO/PrinterElement.php');
31 * Base Printer Element
33 * This class represents the lowest level of printer elements:
34 * buttons, input fields, etc. These cannot have children elements
35 * and are only attached to a parent.
38 * @copyright Copyright (c)2002 - [#]year[#], Blue Static
43 class BSPrinterBaseElement
extends BSPrinterElement
46 * The name of the element
58 * The value of the element
64 * The checked/selected attribute (checkbox, radio, and option only)
70 * The JavaScript onClick attribute
78 function __construct($type, $name, $value = '')
82 $this->value
= $value;
83 $this->setCssClass('input');
86 // ###################################################################
88 * If the type is either checkbox, radio, or option then this will
89 * set the selected/checked attribute
91 * @param boolean Active?
93 public function setActive($active)
95 if (!in_array($this->type
, array('checkbox', 'radio', 'option')))
97 trigger_error('PrinterBaseElement::setActive() can only be used on elements of type checkbox, radio, or option');
99 $this->active
= $active;
102 // ###################################################################
104 * Sets the JavaScript onclick action
106 * @param string onClick attribute value
108 public function setOnClick($onClick)
110 $this->onClick
= $onClick;
113 // ###################################################################
117 * @return string Element type
119 public function getType()
124 // ###################################################################
126 * Returns the name of the element
128 * @return string Name
130 public function getName()
135 // ###################################################################
137 * Sets the name of the element
139 * @param string A new name
141 public function setName($name)
146 // ###################################################################
148 * Returns the output HTML
150 * @return string Output HTML
152 public function paint()
154 $name = ' name="' . $this->name
. '"';
155 $value = ' value="' . $this->value
. '"';
156 $onclick = ($this->onClick ?
' onclick="' . $this->onClick
. '"' : '');
158 $attrs = $name . $value . $onclick;
167 return '<input type="' . $this->type
. '"' . $attrs . (($this->type
== 'text' OR $this->type
== 'password') ?
' size="35" maxlength="255"' : ''). $this->_prepareStyle() . ' />';
171 return '<input type="hidden"' . $name . $value . ' />';
176 return '<input type="' . $this->type
. '"' . $attrs . ($this->active ?
' checked="checked"' : '') . $this->_prepareStyle() . ' />';
180 return '<input type="file" size="35"' . $name . $this->_prepareStyle() . ' />';
184 return '<option' . $value . ($this->active ?
' selected="selected"' : '') . $this->_prepareStyle() . '>' . $this->name
. '</option>';
188 return '<select' . $name . $this->_prepareStyle() . '>' . $this->value
. '</select>';
191 trigger_error('Invalid PrinterBaseElement type "' . $this->type
. '"');
197 /*=====================================================================*
198 || ###################################################################
201 || ###################################################################
202 \*=====================================================================*/