]>
src.bluestatic.org Git - isso.git/blob - PrinterBaseElement.php
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
84 function __construct($type, $name, $value = '')
88 $this->value
= $value;
89 $this->setCssClass('input');
91 if ($type == 'textarea')
93 $this->setStyle(array('width' => '100%', 'height' => '50px'));
97 // ###################################################################
99 * If the type is either checkbox, radio, or option then this will
100 * set the selected/checked attribute
102 * @param boolean Active?
104 public function setActive($active)
106 if (!in_array($this->type
, array('checkbox', 'radio', 'option')))
108 trigger_error('BSPrinterBaseElement::setActive() can only be used on elements of type checkbox, radio, or option');
110 $this->active
= $active;
113 // ###################################################################
115 * Sets the JavaScript onclick action
117 * @param string onClick attribute value
119 public function setOnClick($onClick)
121 $this->onClick
= $onClick;
124 // ###################################################################
126 * Sets the accesskey attribute value
128 * @param string Access key
130 public function setAccessKey($accessKey)
132 $this->accessKey
= $accessKey;
135 // ###################################################################
139 * @return string Element type
141 public function getType()
146 // ###################################################################
148 * Returns the name of the element
150 * @return string Name
152 public function getName()
157 // ###################################################################
159 * Sets the name of the element
161 * @param string A new name
163 public function setName($name)
168 // ###################################################################
170 * Returns the output HTML
172 * @return string Output HTML
174 public function paint()
176 $name = ' name="' . $this->name
. '"';
177 $value = ' value="' . $this->value
. '"';
178 $onclick = ($this->onClick
? ' onclick="' . $this->onClick
. '"' : '');
179 $accesskey = ($this->accessKey
? ' accesskey="' . $this->accessKey
. '"' : '');
181 $attrs = $name . $value . $onclick . $accesskey;
190 return '<input type="' . $this->type
. '"' . $attrs . (($this->type
== 'text' OR $this->type
== 'password') ? ' size="35" maxlength="255"' : ''). $this->_prepareStyle() . ' />';
194 return '<input type="hidden"' . $name . $value . ' />';
199 return '<input type="' . $this->type
. '"' . $attrs . ($this->active
? ' checked="checked"' : '') . $this->_prepareStyle() . ' />';
203 return '<input type="file" size="35"' . $name . $this->_prepareStyle() . ' />';
207 return '<option' . $value . ($this->active
? ' selected="selected"' : '') . $this->_prepareStyle() . '>' . $this->name
. '</option>';
211 return '<select' . $name . $this->_prepareStyle() . $accesskey . '>' . $this->value
. '</select>';
215 if (!isset($this->style
['height']) OR !isset($this->style
['width']))
217 trigger_error('BSPrinterBaseElement of type "textarea" require a "height" and "width" style attribute');
220 return '<textarea' . $name . ' cols="50" rows="2"' . $this->_prepareStyle() . $accesskey . '>' . $this->value
. '</textarea>';
224 trigger_error('Invalid PrinterBaseElement type "' . $this->type
. '"');
230 /*=====================================================================*
231 || ###################################################################
234 || ###################################################################
235 \*=====================================================================*/