added standard input field

This commit is contained in:
Roland Gruber 2010-07-03 12:31:34 +00:00
parent 45699c7e51
commit d012e97218
1 changed files with 94 additions and 21 deletions

View File

@ -217,7 +217,25 @@ class htmlTableRow extends htmlElement {
$types = array(); $types = array();
echo "<tr>\n"; echo "<tr>\n";
for ($i = 0; $i < sizeof($this->cells); $i++) { for ($i = 0; $i < sizeof($this->cells); $i++) {
echo "<td>\n"; // check if alignment option was given
$align = '';
if ($this->cells[$i]->alignment !== null) {
switch ($this->cells[$i]->alignment) {
case htmlElement::ALIGN_BOTTOM:
$align = 'valign="bottom"';
break;
case htmlElement::ALIGN_TOP:
$align = 'valign="top"';
break;
case htmlElement::ALIGN_LEFT:
$align = 'align="left"';
break;
case htmlElement::ALIGN_RIGHT:
$align = 'align="right"';
break;
}
}
echo "<td $align>\n";
$types = array_merge($types, $this->cells[$i]->generateHTML($module, $input, $values, $restricted, $tabindex, $scope)); $types = array_merge($types, $this->cells[$i]->generateHTML($module, $input, $values, $restricted, $tabindex, $scope));
echo "</td>\n"; echo "</td>\n";
} }
@ -228,14 +246,12 @@ class htmlTableRow extends htmlElement {
} }
/** /**
* An extended input field that combines label, input field and help. * A standard input field.
* *
* @package metaHTML * @package metaHTML
*/ */
class htmlTableExtendedInputField extends htmlElement { class htmlInputField extends htmlElement {
/** Descriptive label */
private $label;
/** unique field name */ /** unique field name */
private $fieldName; private $fieldName;
/** field value */ /** field value */
@ -244,24 +260,16 @@ class htmlTableExtendedInputField extends htmlElement {
private $fieldSize = 30; private $fieldSize = 30;
/** field max length (default 255) */ /** field max length (default 255) */
private $fieldMaxLength = 255; private $fieldMaxLength = 255;
/** help ID */
private $helpID;
/** required field */
private $required = false;
/** /**
* Constructor * Constructor
* *
* @param String $label descriptive label
* @param String $fieldName unique field name * @param String $fieldName unique field name
* @param String $fieldValue value of input field (optional) * @param String $fieldValue value of input field (optional)
* @param String $helpID help ID (optional)
*/ */
function __construct($label, $fieldName, $fieldValue = null, $helpID = null) { function __construct($fieldName, $fieldValue = null) {
$this->label = htmlspecialchars($label);
$this->fieldName = htmlspecialchars($fieldName); $this->fieldName = htmlspecialchars($fieldName);
$this->fieldValue = htmlspecialchars($fieldValue); $this->fieldValue = htmlspecialchars($fieldValue);
$this->helpID = $helpID;
} }
/** /**
@ -279,12 +287,6 @@ class htmlTableExtendedInputField extends htmlElement {
if (isset($values[$this->fieldName])) { if (isset($values[$this->fieldName])) {
$this->fieldValue = $values[$this->fieldName][0]; $this->fieldValue = $values[$this->fieldName][0];
} }
// print label text
echo $this->label;
if ($this->required) {
echo '*';
}
echo "\n</td>\n<td>\n";
// print input field // print input field
$name = ' name="' . $this->fieldName . '"'; $name = ' name="' . $this->fieldName . '"';
$value = ''; $value = '';
@ -299,13 +301,84 @@ class htmlTableExtendedInputField extends htmlElement {
$fieldTabIndex = ' tabindex="' . $tabindex . '"'; $fieldTabIndex = ' tabindex="' . $tabindex . '"';
$tabindex++; $tabindex++;
echo '<input type="text"' . $name . $value . $maxLength . $size . $fieldTabIndex . '>'; echo '<input type="text"' . $name . $value . $maxLength . $size . $fieldTabIndex . '>';
return array($this->fieldName => 'text');
}
/**
* Sets the maximum field length.
*
* @param int $fieldMaxLength length
*/
public function setFieldMaxLength($fieldMaxLength) {
$this->fieldMaxLength = $fieldMaxLength;
}
/**
* Sets the field size.
*
* @param int $fieldSize size
*/
public function setFieldSize($fieldSize) {
$this->fieldSize = $fieldSize;
}
}
/**
* An extended input field that combines label, input field and help.
*
* @package metaHTML
*/
class htmlTableExtendedInputField extends htmlInputField {
/** Descriptive label */
private $label;
/** help ID */
private $helpID;
/** required field */
private $required = false;
/**
* Constructor
*
* @param String $label descriptive label
* @param String $fieldName unique field name
* @param String $fieldValue value of input field (optional)
* @param String $helpID help ID (optional)
*/
function __construct($label, $fieldName, $fieldValue = null, $helpID = null) {
parent::__construct($fieldName, $fieldValue);
$this->label = htmlspecialchars($label);
$this->helpID = $helpID;
}
/**
* Prints the HTML code for this element.
*
* @param string $module Name of account module
* @param array $input List of meta-HTML elements
* @param array $values List of values which override the defaults in $input (name => value)
* @param boolean $restricted If true then no buttons will be displayed
* @param integer $tabindex Start value of tabulator index for input fields
* @param string $scope Account type
* @return array List of input field names and their type (name => type)
*/
function generateHTML($module, $input, $values, $restricted, &$tabindex, $scope) {
// print label text
echo $this->label;
if ($this->required) {
echo '*';
}
echo "\n</td>\n<td>\n";
// print input field
$return = parent::generateHTML($module, $input, $values, $restricted, $tabindex, $scope);
// print help link // print help link
if ($this->helpID != null) { if ($this->helpID != null) {
echo "\n</td>\n<td>\n"; echo "\n</td>\n<td>\n";
$helpLink = new htmlHelpLink($this->helpID); $helpLink = new htmlHelpLink($this->helpID);
$helpLink->generateHTML($module, $input, $values, $restricted, $tabindex, $scope); $helpLink->generateHTML($module, $input, $values, $restricted, $tabindex, $scope);
} }
return array($this->fieldName => 'text'); return $return;
} }
/** /**