function getInputHTML($value)
 {
     $datalist = new XmlSelect(false, $this->mName . '-datalist');
     $datalist->setTagName('datalist');
     $datalist->addOptions($this->getOptions());
     return parent::getInputHTML($value) . $datalist->getHTML();
 }
 public function getInputHtml($value)
 {
     // add mw-searchInput class to enable search suggestions for non-OOUI, too
     $this->mClass .= 'mw-searchInput';
     // return the HTMLTextField html
     return parent::getInputHTML($value);
 }
Example #3
0
 function validate($value, $alldata)
 {
     $p = parent::validate($value, $alldata);
     if ($p !== true) {
         return $p;
     }
     if ($value === '') {
         // required was already checked by parent::validate
         return true;
     }
     $date = $this->parseDate($value);
     if (!$date) {
         // Messages: htmlform-date-invalid htmlform-time-invalid htmlform-datetime-invalid
         return $this->msg("htmlform-{$this->mType}-invalid")->parseAsBlock();
     }
     if (isset($this->mParams['min'])) {
         $min = $this->parseDate($this->mParams['min']);
         if ($min && $date < $min) {
             // Messages: htmlform-date-toolow htmlform-time-toolow htmlform-datetime-toolow
             return $this->msg("htmlform-{$this->mType}-toolow", $this->formatDate($min))->parseAsBlock();
         }
     }
     if (isset($this->mParams['max'])) {
         $max = $this->parseDate($this->mParams['max']);
         if ($max && $date > $max) {
             // Messages: htmlform-date-toohigh htmlform-time-toohigh htmlform-datetime-toohigh
             return $this->msg("htmlform-{$this->mType}-toohigh", $this->formatDate($max))->parseAsBlock();
         }
     }
     return true;
 }
 function validate($value, $alldata)
 {
     $p = parent::validate($value, $alldata);
     if ($p !== true) {
         return $p;
     }
     $value = trim($value);
     # http://dev.w3.org/html5/spec/common-microsyntaxes.html#real-numbers
     # with the addition that a leading '+' sign is ok.
     if (!preg_match('/^((\\+|\\-)?\\d+(\\.\\d+)?(E(\\+|\\-)?\\d+)?)?$/i', $value)) {
         return $this->msg('htmlform-float-invalid')->parseAsBlock();
     }
     # The "int" part of these message names is rather confusing.
     # They make equal sense for all numbers.
     if (isset($this->mParams['min'])) {
         $min = $this->mParams['min'];
         if ($min > $value) {
             return $this->msg('htmlform-int-toolow', $min)->parseAsBlock();
         }
     }
     if (isset($this->mParams['max'])) {
         $max = $this->mParams['max'];
         if ($max < $value) {
             return $this->msg('htmlform-int-toohigh', $max)->parseAsBlock();
         }
     }
     return true;
 }
Example #5
0
 public function getInputHtml($value)
 {
     // add the required module and css class for user suggestions in non-OOUI mode
     $this->mParent->getOutput()->addModules('mediawiki.userSuggest');
     $this->mClass .= ' mw-autocomplete-user';
     // return parent html
     return parent::getInputHtml($value);
 }
 function __construct($params)
 {
     parent::__construct($params);
     $this->getOptions();
     if (!in_array('other', $this->mOptions, true)) {
         $msg = isset($params['other']) ? $params['other'] : wfMessage('htmlform-selectorother-other')->text();
         $this->mOptions[$msg] = 'other';
     }
 }
 function __construct($params)
 {
     parent::__construct($params);
     $this->getOptions();
     if (!in_array('other', $this->mOptions, true)) {
         $msg = isset($params['other']) ? $params['other'] : wfMessage('htmlform-selectorother-other')->text();
         // Have 'other' always as first element
         $this->mOptions = array($msg => 'other') + $this->mOptions;
     }
 }
Example #8
0
 function validate($value, $alldata)
 {
     $p = parent::validate($value, $alldata);
     if ($p !== true) {
         return $p;
     }
     $value = trim($value);
     // TODO: further validation
     return true;
 }
 public function validate($value, $alldata)
 {
     // check, if a user exists with the given username
     $user = User::newFromName($value, false);
     if (!$user) {
         return $this->msg('htmlform-user-not-valid', $value)->parse();
     } elseif ($this->mParams['exists'] && $user->getId() === 0 && !($this->mParams['ipallowed'] && User::isIP($value))) {
         return $this->msg('htmlform-user-not-exists', $user->getName())->parse();
     }
     return parent::validate($value, $alldata);
 }
 public function validate($value, $alldata)
 {
     if ($this->mParent->getMethod() === 'get' && $value === '') {
         // If the form is a GET form and has no value, assume it hasn't been
         // submitted yet, and skip validation
         return parent::validate($value, $alldata);
     }
     try {
         if (!$this->mParams['relative']) {
             $title = Title::newFromTextThrow($value);
         } else {
             // Can't use Title::makeTitleSafe(), because it doesn't throw useful exceptions
             global $wgContLang;
             $namespaceName = $wgContLang->getNsText($this->mParams['namespace']);
             $title = Title::newFromTextThrow($namespaceName . ':' . $value);
         }
     } catch (MalformedTitleException $e) {
         $msg = $this->msg($e->getErrorMessage());
         $params = $e->getErrorMessageParameters();
         if ($params) {
             $msg->params($params);
         }
         return $msg->parse();
     }
     $text = $title->getPrefixedText();
     if ($this->mParams['namespace'] !== false && !$title->inNamespace($this->mParams['namespace'])) {
         return $this->msg('htmlform-title-badnamespace', $this->mParams['namespace'], $text)->parse();
     }
     if ($this->mParams['creatable'] && !$title->canExist()) {
         return $this->msg('htmlform-title-not-creatable', $text)->escaped();
     }
     if ($this->mParams['exists'] && !$title->exists()) {
         return $this->msg('htmlform-title-not-exists', $text)->parse();
     }
     return parent::validate($value, $alldata);
 }
Example #11
0
 public function validate($value, $alldata)
 {
     try {
         $title = Title::newFromTextThrow($value);
     } catch (MalformedTitleException $e) {
         $msg = $this->msg($e->getErrorMessage());
         $params = $e->getErrorMessageParameters();
         if ($params) {
             $msg->params($params);
         }
         return $msg->parse();
     }
     $text = $title->getPrefixedText();
     if ($this->mParams['namespace'] !== false && !$title->inNamespace($this->mParams['namespace'])) {
         return $this->msg('htmlform-title-badnamespace', $this->mParams['namespace'], $text)->parse();
     }
     if ($this->mParams['creatable'] && !$title->canExist()) {
         return $this->msg('htmlform-title-not-creatable', $text)->escaped();
     }
     if ($this->mParams['exists'] && !$title->exists()) {
         return $this->msg('htmlform-title-not-exists', $text)->parse();
     }
     return parent::validate($value, $alldata);
 }
Example #12
0
 /**
  * This page can be shown if uploading is enabled.
  * Handle permission checking elsewhere in order to be able to show
  * custom error messages.
  *
  * @param User $user
  * @return bool
  */
 public function userCanExecute(User $user)
 {
     return UploadBase::isEnabled() && parent::userCanExecute($user);
 }
Example #13
0
 function __construct($params)
 {
     if (!in_array('other', $params['options'], true)) {
         $params['options'][wfMsg('htmlform-selectorother-other')] = 'other';
     }
     parent::__construct($params);
 }
	/**
	 * @param $value
	 * @param $alldata
	 * @return string
	 */
	function filter( $value, $alldata ) {
		$value = parent::filter( $value, $alldata );
		return implode( ', ', $this->tidy( $value ) );
	}
 function getInputHTML($value)
 {
     $oldClass = $this->mClass;
     $this->mClass = (array) $this->mClass;
     $valInSelect = false;
     $ret = '';
     if ($this->getOptions()) {
         if ($value !== false) {
             $value = strval($value);
             $valInSelect = in_array($value, HTMLFormField::flattenOptions($this->getOptions()), true);
         }
         $selected = $valInSelect ? $value : 'other';
         $select = new XmlSelect($this->mName . '-select', $this->mID . '-select', $selected);
         $select->addOptions($this->getOptions());
         $select->setAttribute('class', 'mw-htmlform-select-or-other');
         if (!empty($this->mParams['disabled'])) {
             $select->setAttribute('disabled', 'disabled');
         }
         if (isset($this->mParams['tabindex'])) {
             $select->setAttribute('tabindex', $this->mParams['tabindex']);
         }
         $ret = $select->getHTML() . "<br />\n";
         $this->mClass[] = 'mw-htmlform-hide-if';
     }
     if ($valInSelect) {
         $value = '';
     } else {
         $key = array_search(strval($value), $this->autocomplete, true);
         if ($key !== false) {
             $value = $key;
         }
     }
     $this->mClass[] = 'mw-htmlform-autocomplete';
     $ret .= parent::getInputHTML($valInSelect ? '' : $value);
     $this->mClass = $oldClass;
     return $ret;
 }
Example #16
0
 function __construct($params)
 {
     if (!in_array('other', $params['options'], true)) {
         $msg = isset($params['other']) ? $params['other'] : wfMessage('htmlform-selectorother-other')->text();
         $params['options'][$msg] = 'other';
     }
     parent::__construct($params);
 }
 public function getInputHTML($value)
 {
     return $this->mClassWithButton->getElement(parent::getInputHTML($value));
 }