* @author Romain Quetiez * @author Denis Flaven * @license http://www.opensource.org/licenses/gpl-3.0.html LGPL */ require_once('../application/webpage.class.inc.php'); require_once('../application/displayblock.class.inc.php'); class UIPasswordWidget { protected static $iWidgetIndex = 0; protected $sAttCode; protected $sNameSuffix; protected $iId; public function __construct($sAttCode, $iInputId, $sNameSuffix = '') { self::$iWidgetIndex++; $this->sAttCode = $sAttCode; $this->sNameSuffix = $sNameSuffix; $this->iId = $iInputId; } /** * Get the HTML fragment corresponding to the linkset editing widget * @param WebPage $oP The web page used for all the output * @param Hash $aArgs Extra context arguments * @return string The HTML fragment to be inserted into the page */ public function Display(WebPage $oPage, $aArgs = array()) { $sCode = $this->sAttCode.$this->sNameSuffix; $iWidgetIndex = self::$iWidgetIndex; $sPasswordValue = utils::ReadPostedParam("attr_$sCode", '*****'); $sConfirmPasswordValue = utils::ReadPostedParam("attr_{$sCode}_confirmed", '*****'); $sChangedValue = (($sPasswordValue != '*****') || ($sConfirmPasswordValue != '*****')) ? 1 : 0; $sHtmlValue = ''; $sHtmlValue = ' 
'; $sHtmlValue .= ' '.Dict::S('UI:PasswordConfirm').' '; $sHtmlValue .= ''; $oPage->add_ready_script("$('#$this->iId').bind('keyup change', function(evt) { return PasswordFieldChanged('$this->iId') } );"); // Bind to a custom event: validate $oPage->add_ready_script("$('#$this->iId').bind('keyup change validate', function(evt, sFormId) { return ValidatePasswordField('$this->iId', sFormId) } );"); // Bind to a custom event: validate $oPage->add_ready_script("$('#{$this->iId}_confirm').bind('keyup change', function(evt, sFormId) { return ValidatePasswordField('$this->iId', sFormId) } );"); // Bind to a custom event: validate return $sHtmlValue; } } ?>