allow disabling of input elements

This commit is contained in:
Roland Gruber 2010-09-13 19:30:57 +00:00
parent 5de4462da7
commit 11076396f3
1 changed files with 96 additions and 6 deletions

View File

@ -289,6 +289,8 @@ class htmlInputField extends htmlElement {
private $fieldMaxLength = 255; private $fieldMaxLength = 255;
/** password field */ /** password field */
private $isPassword = false; private $isPassword = false;
/** enabled or disabled */
private $isEnabled = true;
/** /**
* Constructor * Constructor
@ -333,7 +335,11 @@ class htmlInputField extends htmlElement {
if ($this->isPassword) { if ($this->isPassword) {
$inputType = 'password'; $inputType = 'password';
} }
echo '<input type="' . $inputType . '"' . $name . $value . $maxLength . $size . $fieldTabIndex . '>'; $disabled = '';
if (!$this->isEnabled) {
$disabled = ' disabled';
}
echo '<input type="' . $inputType . '"' . $name . $value . $maxLength . $size . $fieldTabIndex . $disabled . '>';
return array($this->fieldName => 'text'); return array($this->fieldName => 'text');
} }
@ -364,6 +370,15 @@ class htmlInputField extends htmlElement {
$this->isPassword = $isPassword; $this->isPassword = $isPassword;
} }
/**
* Specifies if this component is enabled and accepts user modification.
*
* @param boolean $isEnabled enabled if true
*/
public function setIsEnabled($isEnabled) {
$this->isEnabled = $isEnabled;
}
} }
/** /**
@ -487,6 +502,8 @@ class htmlButton extends htmlElement {
protected $isImageButton; protected $isImageButton;
/** title */ /** title */
private $title = null; private $title = null;
/** enabled or disabled */
private $isEnabled = true;
/** /**
* Constructor. * Constructor.
@ -533,7 +550,11 @@ class htmlButton extends htmlElement {
if ($this->title != null) { if ($this->title != null) {
$title = ' title="' . $this->title . '"'; $title = ' title="' . $this->title . '"';
} }
echo '<input type="submit"' . $name . $value . $style . $class . $title . '>'; $disabled = '';
if (!$this->isEnabled) {
$disabled = ' disabled';
}
echo '<input type="submit"' . $name . $value . $style . $class . $title . $disabled . '>';
return array($this->name => 'submit'); return array($this->name => 'submit');
} }
@ -546,6 +567,15 @@ class htmlButton extends htmlElement {
$this->title = htmlspecialchars($title); $this->title = htmlspecialchars($title);
} }
/**
* Specifies if this component is enabled and accepts user modification.
*
* @param boolean $isEnabled enabled if true
*/
public function setIsEnabled($isEnabled) {
$this->isEnabled = $isEnabled;
}
} }
/** /**
@ -595,6 +625,8 @@ class htmlSelect extends htmlElement {
private $sortElements = true; private $sortElements = true;
/** right to left text direction */ /** right to left text direction */
private $rightToLeftTextDirection = false; private $rightToLeftTextDirection = false;
/** enabled or disabled */
private $isEnabled = true;
/** /**
* Constructor. * Constructor.
@ -637,7 +669,11 @@ class htmlSelect extends htmlElement {
if ($this->rightToLeftTextDirection) { if ($this->rightToLeftTextDirection) {
$class = ' class="rightToLeftText"'; $class = ' class="rightToLeftText"';
} }
echo '<select' . $class . $name . $size . $multi . ' tabindex="' . $tabindex . "\">\n"; $disabled = '';
if (!$this->isEnabled) {
$disabled = ' disabled';
}
echo '<select' . $class . $name . $size . $multi . $disabled . ' tabindex="' . $tabindex . "\">\n";
$tabindex++; $tabindex++;
// sorting // sorting
if ($this->sortElements) { if ($this->sortElements) {
@ -714,6 +750,15 @@ class htmlSelect extends htmlElement {
$this->rightToLeftTextDirection = $rightToLeftTextDirection; $this->rightToLeftTextDirection = $rightToLeftTextDirection;
} }
/**
* Specifies if this component is enabled and accepts user modification.
*
* @param boolean $isEnabled enabled if true
*/
public function setIsEnabled($isEnabled) {
$this->isEnabled = $isEnabled;
}
} }
/** /**
@ -827,6 +872,8 @@ class htmlInputCheckbox extends htmlElement {
private $name; private $name;
/** value */ /** value */
private $checked; private $checked;
/** enabled or disabled */
private $isEnabled = true;
/** /**
* Constructor. * Constructor.
@ -865,10 +912,23 @@ class htmlInputCheckbox extends htmlElement {
} }
$tabindexValue = ' tabindex="' . $tabindex . '"'; $tabindexValue = ' tabindex="' . $tabindex . '"';
$tabindex++; $tabindex++;
echo '<input type="checkbox" name="' . $this->name . '"' . $tabindexValue . $checked . '>'; $disabled = '';
if (!$this->isEnabled) {
$disabled = ' disabled';
}
echo '<input type="checkbox" name="' . $this->name . '"' . $tabindexValue . $checked . $disabled . '>';
return array($this->name => 'checkbox'); return array($this->name => 'checkbox');
} }
/**
* Specifies if this component is enabled and accepts user modification.
*
* @param boolean $isEnabled enabled if true
*/
public function setIsEnabled($isEnabled) {
$this->isEnabled = $isEnabled;
}
} }
/** /**
@ -943,6 +1003,8 @@ class htmlInputFileUpload extends htmlElement {
/** unique name of input element */ /** unique name of input element */
private $name; private $name;
/** enabled or disabled */
private $isEnabled = true;
/** /**
* Constructor. * Constructor.
@ -967,10 +1029,23 @@ class htmlInputFileUpload extends htmlElement {
function generateHTML($module, $input, $values, $restricted, &$tabindex, $scope) { function generateHTML($module, $input, $values, $restricted, &$tabindex, $scope) {
$tabindexValue = ' tabindex="' . $tabindex . '"'; $tabindexValue = ' tabindex="' . $tabindex . '"';
$tabindex++; $tabindex++;
echo '<input type="file" name="' . $this->name . '"' . $tabindexValue . '>'; $disabled = '';
if (!$this->isEnabled) {
$disabled = ' disabled';
}
echo '<input type="file" name="' . $this->name . '"' . $tabindexValue . $disabled . '>';
return array($this->name => 'file'); return array($this->name => 'file');
} }
/**
* Specifies if this component is enabled and accepts user modification.
*
* @param boolean $isEnabled enabled if true
*/
public function setIsEnabled($isEnabled) {
$this->isEnabled = $isEnabled;
}
} }
/** /**
@ -1039,6 +1114,8 @@ class htmlInputTextarea extends htmlElement {
private $colCount; private $colCount;
/** row count */ /** row count */
private $rowCount; private $rowCount;
/** enabled or disabled */
private $isEnabled = true;
/** /**
* Constructor. * Constructor.
@ -1074,10 +1151,23 @@ class htmlInputTextarea extends htmlElement {
$rowCount = ' rows="' . $this->rowCount . '"'; $rowCount = ' rows="' . $this->rowCount . '"';
$tabindexValue = ' tabindex="' . $tabindex . '"'; $tabindexValue = ' tabindex="' . $tabindex . '"';
$tabindex++; $tabindex++;
echo '<textarea name="' . $this->name . '"' . $tabindexValue . $colCount . $rowCount . '>' . $this->value . '</textarea>'; $disabled = '';
if (!$this->isEnabled) {
$disabled = ' disabled';
}
echo '<textarea name="' . $this->name . '"' . $tabindexValue . $colCount . $rowCount . $disabled . '>' . $this->value . '</textarea>';
return array($this->name => 'textarea'); return array($this->name => 'textarea');
} }
/**
* Specifies if this component is enabled and accepts user modification.
*
* @param boolean $isEnabled enabled if true
*/
public function setIsEnabled($isEnabled) {
$this->isEnabled = $isEnabled;
}
} }
/** /**