setParent($parent); $this->type = $type; $this->name = $name; $this->value = $value; } // ################################################################### /** * Sets the parent element * * @param BSPrinterElement The parent */ public function setParent(BSPrinterElement $parent) { $this->parent = $parent; $this->parent->addChild($this); } // ################################################################### /** * Returns the parent element * * @return BSPrinterElement The parent element */ public function getParent() { return $this->parent; } // ################################################################### /** * If the type is either checkbox, radio, or option then this will * set the selected/checked attribute * * @param boolean Active? */ public function setActive($active) { if (!in_array($this->type, array('checkbox', 'radio', 'option'))) { trigger_error('PrinterBaseElement::setActive() can only be used on elements of type checkbox, radio, or option'); } $this->active = $active; } // ################################################################### /** * Returns the output HTML * * @return string Output HTML */ public function paint() { $name = ' name="' . $this->name . '"'; $style = ($this->_prepareStyle() ? ' style="' . $this->_prepareStyle() . '"' : ''); $value = ($this->value ? ' value="' . $this->value . '"' : ''); switch ($this->type) { case 'text': case 'password': case 'button': case 'submit': case 'reset': return ''; break; case 'checkbox': case 'radio': return 'active ? ' checked="checked"' : '') . $style . ' />'; break; case 'option': return 'active ? ' selected="selected"' : '') . $style . '>' . $this->name . ''; break; default: trigger_error('Invalid PrinterBaseElement type "' . $this->type . '"'); break; } } } /*=====================================================================* || ################################################################### || # $HeadURL$ || # $Id$ || ################################################################### \*=====================================================================*/ ?>