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');
85 if ($type == 'textarea')
87 $this->setStyle(array('width' => '100%', 'height' => '50px'));
91 // ###################################################################
93 * If the type is either checkbox, radio, or option then this will
94 * set the selected/checked attribute
96 * @param boolean Active?
98 public function setActive($active)
100 if (!in_array($this->type
, array('checkbox', 'radio', 'option')))
102 trigger_error('BSPrinterBaseElement::setActive() can only be used on elements of type checkbox, radio, or option');
104 $this->active
= $active;
107 // ###################################################################
109 * Sets the JavaScript onclick action
111 * @param string onClick attribute value
113 public function setOnClick($onClick)
115 $this->onClick
= $onClick;
118 // ###################################################################
122 * @return string Element type
124 public function getType()
129 // ###################################################################
131 * Returns the name of the element
133 * @return string Name
135 public function getName()
140 // ###################################################################
142 * Sets the name of the element
144 * @param string A new name
146 public function setName($name)
151 // ###################################################################
153 * Returns the output HTML
155 * @return string Output HTML
157 public function paint()
159 $name = ' name="' . $this->name
. '"';
160 $value = ' value="' . $this->value
. '"';
161 $onclick = ($this->onClick ?
' onclick="' . $this->onClick
. '"' : '');
163 $attrs = $name . $value . $onclick;
172 return '<input type="' . $this->type
. '"' . $attrs . (($this->type
== 'text' OR $this->type
== 'password') ?
' size="35" maxlength="255"' : ''). $this->_prepareStyle() . ' />';
176 return '<input type="hidden"' . $name . $value . ' />';
181 return '<input type="' . $this->type
. '"' . $attrs . ($this->active ?
' checked="checked"' : '') . $this->_prepareStyle() . ' />';
185 return '<input type="file" size="35"' . $name . $this->_prepareStyle() . ' />';
189 return '<option' . $value . ($this->active ?
' selected="selected"' : '') . $this->_prepareStyle() . '>' . $this->name
. '</option>';
193 return '<select' . $name . $this->_prepareStyle() . '>' . $this->value
. '</select>';
197 if (!isset($this->style
['height']) OR !isset($this->style
['width']))
199 trigger_error('BSPrinterBaseElement of type "textarea" require a "height" and "width" style attribute');
202 return '<textarea' . $name . ' cols="50" rows="2"' . $this->_prepareStyle() . '>' . $this->value
. '</textarea>';
206 trigger_error('Invalid PrinterBaseElement type "' . $this->type
. '"');
212 /*=====================================================================*
213 || ###################################################################
216 || ###################################################################
217 \*=====================================================================*/