type = $type;
$this->name = $name;
$this->value = $value;
$this->setCssClass('input');
if ($type == 'textarea')
{
$this->setStyle(array('width' => '100%', 'height' => '50px'));
}
}
// ###################################################################
/**
* 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('BSPrinterBaseElement::setActive() can only be used on elements of type checkbox, radio, or option');
}
$this->active = $active;
}
// ###################################################################
/**
* Sets the JavaScript onclick action
*
* @param string onClick attribute value
*/
public function setOnClick($onClick)
{
$this->onClick = $onClick;
}
// ###################################################################
/**
* Sets the accesskey attribute value
*
* @param string Access key
*/
public function setAccessKey($accessKey)
{
$this->accessKey = $accessKey;
}
// ###################################################################
/**
* Returns the type
*
* @return string Element type
*/
public function getType()
{
return $this->type;
}
// ###################################################################
/**
* Returns the name of the element
*
* @return string Name
*/
public function getName()
{
return $this->name;
}
// ###################################################################
/**
* Sets the name of the element
*
* @param string A new name
*/
public function setName($name)
{
$this->name = $name;
}
// ###################################################################
/**
* Returns the output HTML
*
* @return string Output HTML
*/
public function paint()
{
$name = ' name="' . $this->name . '"';
$value = ' value="' . $this->value . '"';
$onclick = ($this->onClick ? ' onclick="' . $this->onClick . '"' : '');
$accesskey = ($this->accessKey ? ' accesskey="' . $this->accessKey . '"' : '');
$attrs = $name . $value . $onclick . $accesskey;
switch ($this->type)
{
case 'text':
case 'password':
case 'button':
case 'submit':
case 'reset':
return 'type == 'text' OR $this->type == 'password') ? ' size="35" maxlength="255"' : ''). $this->_prepareStyle() . ' />';
break;
case 'hidden':
return '';
break;
case 'checkbox':
case 'radio':
return 'active ? ' checked="checked"' : '') . $this->_prepareStyle() . ' />';
break;
case 'upload':
return '_prepareStyle() . ' />';
break;
case 'option':
return '';
break;
case 'select':
return '';
break;
case 'textarea':
if (!isset($this->style['height']) OR !isset($this->style['width']))
{
trigger_error('BSPrinterBaseElement of type "textarea" require a "height" and "width" style attribute');
}
return '';
break;
default:
trigger_error('Invalid PrinterBaseElement type "' . $this->type . '"');
break;
}
}
}
/*=====================================================================*
|| ###################################################################
|| # $HeadURL$
|| # $Id$
|| ###################################################################
\*=====================================================================*/
?>