/** * @param string $value * @return string * @since 1.20 */ public function getRaw($value) { if (!empty($this->mParams['rawrow'])) { return $value; } return parent::getRaw($value); }
/** * @param array $params */ public function __construct($params) { parent::__construct($params); $this->msg = empty($params['licenses']) ? wfMessage('licenses')->inContentLanguage()->plain() : $params['licenses']; $this->selected = null; $this->makeLicenses(); }
public function __construct($info) { $info['nodata'] = true; if (isset($info['flags'])) { $this->mFlags = $info['flags']; } # Generate the label from a message, if possible if (isset($info['buttonlabel-message'])) { $msgInfo = $info['buttonlabel-message']; if (is_array($msgInfo)) { $msg = array_shift($msgInfo); } else { $msg = $msgInfo; $msgInfo = array(); } $this->buttonLabel = $this->msg($msg, $msgInfo)->parse(); } elseif (isset($info['buttonlabel'])) { if ($info['buttonlabel'] === ' ') { // Apparently some things set   directly and in an odd format $this->buttonLabel = ' '; } else { $this->buttonLabel = htmlspecialchars($info['buttonlabel']); } } elseif (isset($info['buttonlabel-raw'])) { $this->buttonLabel = $info['buttonlabel-raw']; } parent::__construct($info); }
function getInputHTML($value) { $valInSelect = false; if ($value !== false) { $value = strval($value); $valInSelect = in_array($value, HTMLFormField::flattenOptions($this->getOptions()), true); } $selected = $valInSelect ? $value : 'other'; $select = new XmlSelect($this->mName, $this->mID, $selected); $select->addOptions($this->getOptions()); $select->setAttribute('class', 'mw-htmlform-select-or-other'); $tbAttribs = array('id' => $this->mID . '-other', 'size' => $this->getSize()); if (!empty($this->mParams['disabled'])) { $select->setAttribute('disabled', 'disabled'); $tbAttribs['disabled'] = 'disabled'; } if (isset($this->mParams['tabindex'])) { $select->setAttribute('tabindex', $this->mParams['tabindex']); $tbAttribs['tabindex'] = $this->mParams['tabindex']; } $select = $select->getHTML(); if (isset($this->mParams['maxlength'])) { $tbAttribs['maxlength'] = $this->mParams['maxlength']; } if ($this->mClass !== '') { $tbAttribs['class'] = $this->mClass; } $textbox = Html::input($this->mName . '-other', $valInSelect ? '' : $value, 'text', $tbAttribs); return "{$select}<br />\n{$textbox}"; }
public function __construct($params) { parent::__construct($params); # Per HTML5 spec, hidden fields cannot be 'required' # http://www.w3.org/TR/html5/forms.html#hidden-state-%28type=hidden%29 unset($this->mParams['required']); }
public function __construct($params) { parent::__construct($params); # Per HTML5 spec, hidden fields cannot be 'required' # http://dev.w3.org/html5/spec/states-of-the-type-attribute.html#hidden-state unset($this->mParams['required']); }
/** * Constructor * * @param $params array */ public function __construct($params) { parent::__construct($params); $this->msg = empty($params['licenses']) ? wfMsg('licenses') : $params['licenses']; $this->selected = null; $this->makeLicenses(); }
public function __construct($params) { parent::__construct($params); // For differentiating the type of form, mainly if (isset($params['prefix'])) { $this->prefix = $params['prefix']; } }
function getDiv($value) { $this->tagFilter = ChangeTags::buildTagFilterSelector($value); if ($this->tagFilter) { return parent::getDiv($value); } return ''; }
public function __construct($info) { $info['nodata'] = true; if (isset($info['flags'])) { $this->mFlags = $info['flags']; } parent::__construct($info); }
function filterDataForSubmit($data) { $options = HTMLFormField::flattenOptions($this->getOptions()); $res = array(); foreach ($options as $opt) { $res["{$opt}"] = in_array($opt, $data); } return $res; }
/** * @param array $params * - type: HTML textfield type * - size: field size in characters (defaults to 45) * - placeholder/placeholder-message: set HTML placeholder attribute * - spellcheck: set HTML spellcheck attribute * - persistent: upon unsuccessful requests, retain the value (defaults to true, except * for password fields) */ public function __construct($params) { parent::__construct($params); if (isset($params['placeholder-message'])) { $this->mPlaceholder = $this->getMessage($params['placeholder-message'])->parse(); } elseif (isset($params['placeholder'])) { $this->mPlaceholder = $params['placeholder']; } }
public function __construct($params) { parent::__construct($params); if (isset($this->mParams['output-as-default'])) { $this->outputAsDefault = (bool) $this->mParams['output-as-default']; } # Per HTML5 spec, hidden fields cannot be 'required' # http://www.w3.org/TR/html5/forms.html#hidden-state-%28type=hidden%29 unset($this->mParams['required']); }
function validate($value, $alldata) { $p = parent::validate($value, $alldata); if ($p !== true) { return $p; } $validOptions = HTMLFormField::flattenOptions($this->getOptions()); if (in_array(strval($value), $validOptions, true)) { return true; } else { return $this->msg('htmlform-select-badoption')->parse(); } }
public function __construct($info) { if (isset($info['buttonclass'])) { $this->mButtonClass = $info['buttonclass']; } if (isset($info['buttonid'])) { $this->mButtonId = $info['buttonid']; } if (isset($info['buttonname'])) { $this->mButtonName = $info['buttonname']; } if (isset($info['buttondefault'])) { $this->mButtonValue = $info['buttondefault']; } if (isset($info['buttontype'])) { $this->mButtonType = $info['buttontype']; } parent::__construct($info); }
public function __construct($info) { $info['nodata'] = true; if (isset($info['flags'])) { $this->mFlags = $info['flags']; } # Generate the label from a message, if possible if (isset($info['buttonlabel-message'])) { $this->buttonLabel = $this->getMessage($info['buttonlabel-message'])->parse(); } elseif (isset($info['buttonlabel'])) { if ($info['buttonlabel'] === ' ') { // Apparently some things set   directly and in an odd format $this->buttonLabel = ' '; } else { $this->buttonLabel = htmlspecialchars($info['buttonlabel']); } } elseif (isset($info['buttonlabel-raw'])) { $this->buttonLabel = $info['buttonlabel-raw']; } $this->setShowEmptyLabel(false); parent::__construct($info); }
/** * @param $user User * @param $context IContextSource * @param $defaultPreferences * @return void */ static function datetimePreferences( $user, IContextSource $context, &$defaultPreferences ) { ## Date and time ##################################### $dateOptions = self::getDateOptions( $context ); if ( $dateOptions ) { $defaultPreferences['date'] = array( 'type' => 'radio', 'options' => $dateOptions, 'label' => ' ', 'section' => 'datetime/dateformat', ); } // Info $now = wfTimestampNow(); $lang = $context->getLanguage(); $nowlocal = Xml::element( 'span', array( 'id' => 'wpLocalTime' ), $lang->time( $now, true ) ); $nowserver = $lang->time( $now, false ) . Html::hidden( 'wpServerTime', (int)substr( $now, 8, 2 ) * 60 + (int)substr( $now, 10, 2 ) ); $defaultPreferences['nowserver'] = array( 'type' => 'info', 'raw' => 1, 'label-message' => 'servertime', 'default' => $nowserver, 'section' => 'datetime/timeoffset', ); $defaultPreferences['nowlocal'] = array( 'type' => 'info', 'raw' => 1, 'label-message' => 'localtime', 'default' => $nowlocal, 'section' => 'datetime/timeoffset', ); // Grab existing pref. $tzOffset = $user->getOption( 'timecorrection' ); $tz = explode( '|', $tzOffset, 3 ); $tzOptions = self::getTimezoneOptions( $context ); $tzSetting = $tzOffset; if ( count( $tz ) > 1 && $tz[0] == 'Offset' ) { $minDiff = $tz[1]; $tzSetting = sprintf( '%+03d:%02d', floor( $minDiff / 60 ), abs( $minDiff ) % 60 ); } elseif ( count( $tz ) > 1 && $tz[0] == 'ZoneInfo' && !in_array( $tzOffset, HTMLFormField::flattenOptions( $tzOptions ) ) ) { # Timezone offset can vary with DST $userTZ = timezone_open( $tz[2] ); if ( $userTZ !== false ) { $minDiff = floor( timezone_offset_get( $userTZ, date_create( 'now' ) ) / 60 ); $tzSetting = "ZoneInfo|$minDiff|{$tz[2]}"; } } $defaultPreferences['timecorrection'] = array( 'class' => 'HTMLSelectOrOtherField', 'label-message' => 'timezonelegend', 'options' => $tzOptions, 'default' => $tzSetting, 'size' => 20, 'section' => 'datetime/timeoffset', ); }
/** * Return an associative array mapping preferences keys to the kind of a preference they're * used for. Different kinds are handled differently when setting or reading preferences. * * See User::listOptionKinds for the list of valid option types that can be provided. * * @see User::listOptionKinds * @param $context IContextSource * @param array $options assoc. array with options keys to check as keys. Defaults to $this->mOptions. * @return array the key => kind mapping data */ public function getOptionKinds( IContextSource $context, $options = null ) { $this->loadOptions(); if ( $options === null ) { $options = $this->mOptions; } $prefs = Preferences::getPreferences( $this, $context ); $mapping = array(); // Multiselect and checkmatrix options are stored in the database with // one key per option, each having a boolean value. Extract those keys. $multiselectOptions = array(); foreach ( $prefs as $name => $info ) { if ( ( isset( $info['type'] ) && $info['type'] == 'multiselect' ) || ( isset( $info['class'] ) && $info['class'] == 'HTMLMultiSelectField' ) ) { $opts = HTMLFormField::flattenOptions( $info['options'] ); $prefix = isset( $info['prefix'] ) ? $info['prefix'] : $name; foreach ( $opts as $value ) { $multiselectOptions["$prefix$value"] = true; } unset( $prefs[$name] ); } } $checkmatrixOptions = array(); foreach ( $prefs as $name => $info ) { if ( ( isset( $info['type'] ) && $info['type'] == 'checkmatrix' ) || ( isset( $info['class'] ) && $info['class'] == 'HTMLCheckMatrix' ) ) { $columns = HTMLFormField::flattenOptions( $info['columns'] ); $rows = HTMLFormField::flattenOptions( $info['rows'] ); $prefix = isset( $info['prefix'] ) ? $info['prefix'] : $name; foreach ( $columns as $column ) { foreach ( $rows as $row ) { $checkmatrixOptions["$prefix-$column-$row"] = true; } } unset( $prefs[$name] ); } } // $value is ignored foreach ( $options as $key => $value ) { if ( isset( $prefs[$key] ) ) { $mapping[$key] = 'registered'; } elseif ( isset( $multiselectOptions[$key] ) ) { $mapping[$key] = 'registered-multiselect'; } elseif ( isset( $checkmatrixOptions[$key] ) ) { $mapping[$key] = 'registered-checkmatrix'; } elseif ( substr( $key, 0, 7 ) === 'userjs-' ) { $mapping[$key] = 'userjs'; } else { $mapping[$key] = 'unused'; } } return $mapping; }
protected function validate(HTMLFormField $field, $submitted) { return $field->validate($submitted, [self::$defaultOptions['fieldname'] => $submitted]); }
/** * HTMLMultiSelectField throws validation errors if we get input data * that doesn't match the data set in the form setup. This causes * problems if something gets removed from the watchlist while the * form is open (bug 32126), but we know that invalid items will * be harmless so we can override it here. * * @param $value String the value the field was submitted with * @param $alldata Array the data collected from the form * @return Mixed Bool true on success, or String error to display. */ function validate($value, $alldata) { // Need to call into grandparent to be a good citizen. :) return HTMLFormField::validate($value, $alldata); }
public function __construct($info) { $info['nodata'] = true; parent::__construct($info); }
public function validate($values, $alldata) { if (isset($this->mParams['required']) && $this->mParams['required'] !== false && !$values) { return $this->msg('htmlform-cloner-required')->parseAsBlock(); } if (isset($values['nonjs'])) { // The submission was a non-JS create/delete click, so fail // validation in case cancelSubmit() somehow didn't already handle // it. return false; } foreach ($values as $key => $value) { $fields = $this->createFieldsForKey($key); foreach ($fields as $fieldname => $field) { if (!array_key_exists($fieldname, $value)) { continue; } $ok = $field->validate($value[$fieldname], $alldata); if ($ok !== true) { return false; } } } return parent::validate($values, $alldata); }
/** * Constructor * * @param $params array Need a 'templates' key giving the templates list to parse. */ public function __construct($params) { parent::__construct($params); $this->selected = null; }
public function __construct($params) { parent::__construct($params); $this->mAllValue = isset($this->mParams['all']) ? $this->mParams['all'] : 'all'; }
function filterDataForSubmit($data) { $data = HTMLFormField::forceToStringRecursive($data); $options = HTMLFormField::flattenOptions($this->getOptions()); $res = []; foreach ($options as $opt) { $res["{$opt}"] = in_array($opt, $data, true); } return $res; }
/** * Return an associative array mapping preferences keys to the kind of a preference they're * used for. Different kinds are handled differently when setting or reading preferences. * * See User::listOptionKinds for the list of valid option types that can be provided. * * @see User::listOptionKinds * @param IContextSource $context * @param array $options Assoc. array with options keys to check as keys. * Defaults to $this->mOptions. * @return array The key => kind mapping data */ public function getOptionKinds(IContextSource $context, $options = null) { $this->loadOptions(); if ($options === null) { $options = $this->mOptions; } $prefs = Preferences::getPreferences($this, $context); $mapping = array(); // Pull out the "special" options, so they don't get converted as // multiselect or checkmatrix. $specialOptions = array_fill_keys(Preferences::getSaveBlacklist(), true); foreach ($specialOptions as $name => $value) { unset($prefs[$name]); } // Multiselect and checkmatrix options are stored in the database with // one key per option, each having a boolean value. Extract those keys. $multiselectOptions = array(); foreach ($prefs as $name => $info) { if (isset($info['type']) && $info['type'] == 'multiselect' || isset($info['class']) && $info['class'] == 'HTMLMultiSelectField') { $opts = HTMLFormField::flattenOptions($info['options']); $prefix = isset($info['prefix']) ? $info['prefix'] : $name; foreach ($opts as $value) { $multiselectOptions["{$prefix}{$value}"] = true; } unset($prefs[$name]); } } $checkmatrixOptions = array(); foreach ($prefs as $name => $info) { if (isset($info['type']) && $info['type'] == 'checkmatrix' || isset($info['class']) && $info['class'] == 'HTMLCheckMatrix') { $columns = HTMLFormField::flattenOptions($info['columns']); $rows = HTMLFormField::flattenOptions($info['rows']); $prefix = isset($info['prefix']) ? $info['prefix'] : $name; foreach ($columns as $column) { foreach ($rows as $row) { $checkmatrixOptions["{$prefix}{$column}-{$row}"] = true; } } unset($prefs[$name]); } } // $value is ignored foreach ($options as $key => $value) { if (isset($prefs[$key])) { $mapping[$key] = 'registered'; } elseif (isset($multiselectOptions[$key])) { $mapping[$key] = 'registered-multiselect'; } elseif (isset($checkmatrixOptions[$key])) { $mapping[$key] = 'registered-checkmatrix'; } elseif (isset($specialOptions[$key])) { $mapping[$key] = 'special'; } elseif (substr($key, 0, 7) === 'userjs-') { $mapping[$key] = 'userjs'; } else { $mapping[$key] = 'unused'; } } return $mapping; }
function filterDataForSubmit($data) { $columns = HTMLFormField::flattenOptions($this->mParams['columns']); $rows = HTMLFormField::flattenOptions($this->mParams['rows']); $res = []; foreach ($columns as $column) { foreach ($rows as $row) { // Make sure option hasn't been forced $thisTag = "{$column}-{$row}"; if ($this->isTagForcedOff($thisTag)) { $res[$thisTag] = false; } elseif ($this->isTagForcedOn($thisTag)) { $res[$thisTag] = true; } else { $res[$thisTag] = in_array($thisTag, $data); } } } return $res; }
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; }
/** * @param $data array * @return array */ function filterDataForSubmit($data) { // Support for separating MultiSelect preferences into multiple preferences // Due to lack of array support. foreach ($this->mFlatFields as $fieldname => $field) { $info = $field->mParams; if ($field instanceof HTMLMultiSelectField) { $options = HTMLFormField::flattenOptions($info['options']); $prefix = isset($info['prefix']) ? $info['prefix'] : $fieldname; foreach ($options as $opt) { $data["{$prefix}{$opt}"] = in_array($opt, $data[$fieldname]); } unset($data[$fieldname]); } } return $data; }
public function __construct($params) { parent::__construct($params); $this->mAllValue = array_key_exists('all', $params) ? $params['all'] : 'all'; }