2 /*=====================================================================*
3 || ###################################################################
4 || # Blue Static ISSO Framework [#]issoversion[#]
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 parent containing element
47 * @var BSPrinterElement
52 * The name of the element
64 * The value of the element
70 * The checked/selected attribute (checkbox, radio, and option only)
78 function __construct(BSPrinterElement
$parent, $type, $name, $value = '')
80 $this->setParent($parent);
83 $this->value
= $value;
86 // ###################################################################
88 * Sets the parent element
90 * @param BSPrinterElement The parent
92 public function setParent(BSPrinterElement
$parent)
94 $this->parent
= $parent;
95 $this->parent
->addChild($this);
98 // ###################################################################
100 * Returns the parent element
102 * @return BSPrinterElement The parent element
104 public function getParent()
106 return $this->parent
;
109 // ###################################################################
111 * If the type is either checkbox, radio, or option then this will
112 * set the selected/checked attribute
114 * @param boolean Active?
116 public function setActive($active)
118 if (!in_array($this->type
, array('checkbox', 'radio', 'option')))
120 trigger_error('PrinterBaseElement::setActive() can only be used on elements of type checkbox, radio, or option');
122 $this->active
= $active;
125 // ###################################################################
127 * Returns the output HTML
129 * @return string Output HTML
131 public function paint()
133 $name = ' name="' . $this->name
. '"';
134 $style = ($this->_prepareStyle() ?
' style="' . $this->_prepareStyle() . '"' : '');
135 $value = ($this->value ?
' value="' . $this->value
. '"' : '');
143 return '<input type="' . $this->type
. '"' . $name . $value . $style . ' />';
148 return '<input type="' . $this->type
. '"' . $name . $value . ($this->active ?
' checked="checked"' : '') . $style . ' />';
152 return '<option' . $value . ($this->active ?
' selected="selected"' : '') . $style . '>' . $this->name
. '</option>';
156 trigger_error('Invalid PrinterBaseElement type "' . $this->type
. '"');
162 /*=====================================================================*
163 || ###################################################################
166 || ###################################################################
167 \*=====================================================================*/