- Allow control over white space wrapping of auto-generated SquirrelMail
option widgets.
- Add informational type option widget
+ - Add password type option widget
Version 1.5.1 (branched on 2006-02-12)
--------------------------------------
* Password input field
* @param string $sName field name
* @param string $sValue initial password value
- * @param array $aAttribs (since 1.5.1) extra attributes
- * @return string html formated password field
+ * @param integer $iSize field size (number of characters)
+ * @param integer $iMaxlength maximum number of characters the user may enter
+ * @param array $aAttribs (since 1.5.1) extra attributes - should be given
+ * in the form array('attribute_name' => 'attribute_value', ...)
+ * @return string html formated password field
*/
-function addPwField($sName, $sValue = null, $aAttribs=array()) {
+function addPwField($sName, $sValue = '', $iSize = 0, $iMaxlength = 0, $aAttribs=array()) {
$aAttribs['name'] = $sName;
- $aAttribs['value'] = (! is_null($sValue) ? $sValue : '');
+ $aAttribs['value'] = $sValue;
+ if ($iSize) $aAttribs['size'] = (int)$iSize;
+ if ($iMaxlength) $aAttribs['maxlength'] = (int)$iMaxlength;
// add default css
if (! isset($aAttribs['class'])) $aAttribs['class'] = 'sqmpwfield';
return addInputField('password',$aAttribs);
/* Get the widget for this option type. */
switch ($this->type) {
+ case SMOPT_TYPE_PASSWORD:
+ $result = $this->createWidget_String(TRUE);
+ break;
case SMOPT_TYPE_STRING:
$result = $this->createWidget_String();
break;
/**
* Create string field
+ *
+ * @param boolean $password When TRUE, the text in the input
+ * widget will be obscured (OPTIONAL;
+ * default = FALSE).
+ *
* @return string html formated option field
+ *
*/
- function createWidget_String() {
+ function createWidget_String($password=FALSE) {
switch ($this->size) {
case SMOPT_SIZE_TINY:
$width = 5;
}
//TODO: might be better to have a separate template file for all widgets, because then the layout of the widget and the "trailing text" can be customized - they are still hard coded here
- return addInput('new_' . $this->name, $this->value, $width, 0, $this->aExtraAttribs) . ' ' . htmlspecialchars($this->trailing_text);
+ if ($password)
+addPwField($sName, $sValue = null, $aAttribs=array()) {
+ return addPwField('new_' . $this->name, $this->value, $width, 0, $this->aExtraAttribs) . ' ' . htmlspecialchars($this->trailing_text);
+ else
+ return addInput('new_' . $this->name, $this->value, $width, 0, $this->aExtraAttribs) . ' ' . htmlspecialchars($this->trailing_text);
}
/**
define('SMOPT_TYPE_STRLIST_RADIO', 14);
define('SMOPT_TYPE_SUBMIT', 15);
define('SMOPT_TYPE_INFO', 16);
+define('SMOPT_TYPE_PASSWORD', 17);
// Define constants for the layout scheme for edit lists
define('SMOPT_EDIT_LIST_LAYOUT_LIST', 0);