Go to the documentation of this file.
103 'api' =>
'HTMLApiField',
104 'text' =>
'HTMLTextField',
105 'textarea' =>
'HTMLTextAreaField',
106 'select' =>
'HTMLSelectField',
107 'radio' =>
'HTMLRadioField',
108 'multiselect' =>
'HTMLMultiSelectField',
109 'check' =>
'HTMLCheckField',
110 'toggle' =>
'HTMLCheckField',
111 'int' =>
'HTMLIntField',
112 'float' =>
'HTMLFloatField',
113 'info' =>
'HTMLInfoField',
114 'selectorother' =>
'HTMLSelectOrOtherField',
115 'selectandother' =>
'HTMLSelectAndOtherField',
116 'submit' =>
'HTMLSubmitField',
117 'hidden' =>
'HTMLHiddenField',
118 'edittools' =>
'HTMLEditTools',
119 'checkmatrix' =>
'HTMLCheckMatrix',
123 'email' =>
'HTMLTextField',
124 'password' =>
'HTMLTextField',
125 'url' =>
'HTMLTextField',
212 $this->mTitle =
false;
213 $this->mMessagePrefix = $messagePrefix;
214 } elseif ( is_null(
$context ) && $messagePrefix !==
'' ) {
215 $this->mMessagePrefix = $messagePrefix;
216 } elseif ( is_string(
$context ) && $messagePrefix ===
'' ) {
223 $loadedDescriptor =
array();
224 $this->mFlatFields =
array();
226 foreach ( $descriptor
as $fieldname => $info ) {
227 $section = isset( $info[
'section'] )
231 if ( isset( $info[
'type'] ) && $info[
'type'] ==
'file' ) {
232 $this->mUseMultipart =
true;
238 $field->mParent = $this;
242 $field->setShowEmptyLabel(
false );
245 $setSection =& $loadedDescriptor;
247 $sectionParts = explode(
'/',
$section );
249 while ( count( $sectionParts ) ) {
250 $newName = array_shift( $sectionParts );
252 if ( !isset( $setSection[$newName] ) ) {
253 $setSection[$newName] =
array();
256 $setSection =& $setSection[$newName];
260 $setSection[$fieldname] = $field;
261 $this->mFlatFields[$fieldname] = $field;
264 $this->mFieldTree = $loadedDescriptor;
278 if ( !in_array( $format, $this->availableDisplayFormats ) ) {
279 throw new MWException(
'Display format must be one of ' .
280 print_r( $this->availableDisplayFormats,
true ) );
282 $this->displayFormat = $format;
302 return $this->displayFormat ===
'vform';
310 static function addJS() {
331 if ( isset( $descriptor[
'class'] ) ) {
332 $class = $descriptor[
'class'];
333 } elseif ( isset( $descriptor[
'type'] ) ) {
334 $class = self::$typeMappings[$descriptor[
'type']];
335 $descriptor[
'class'] = $class;
341 throw new MWException(
"Descriptor with no class for $fieldname: " . print_r( $descriptor,
true ) );
358 $descriptor[
'fieldname'] = $fieldname;
360 # @todo This will throw a fatal error whenever someone try to use
361 # 'class' to feed a CSS class instead of 'cssclass'. Would be
362 # great to avoid the fatal error and show a nice error.
363 $obj =
new $class( $descriptor );
378 # Check if we have the info we need
379 if ( !$this->mTitle instanceof
Title && $this->mTitle !==
false ) {
380 throw new MWException(
"You must call setTitle() on an HTMLForm" );
383 # Load data from the request.
399 } elseif ( $this->
getRequest()->wasPosted() ) {
400 $editToken = $this->
getRequest()->getVal(
'wpEditToken' );
401 if ( $this->
getUser()->isLoggedIn() || $editToken !=
null ) {
405 $submit = $this->
getUser()->matchEditToken( $editToken );
446 # Check for validation
447 foreach ( $this->mFlatFields
as $fieldname => $field ) {
448 if ( !empty( $field->mParams[
'nodata'] ) ) {
451 if ( $field->validate(
452 $this->mFieldData[$fieldname],
456 return isset( $this->mValidationErrorMessage )
457 ? $this->mValidationErrorMessage
458 :
array(
'htmlform-invalid-input' );
463 if ( !is_callable( $callback ) ) {
464 throw new MWException(
'HTMLForm: no submit callback provided. Use ' .
465 'setSubmitCallback() to set one.' );
470 $res = call_user_func( $callback, $data, $this );
487 $this->mSubmitCallback = $cb;
501 $this->mValidationErrorMessage = $msg;
556 $this->mHeader .= $msg;
558 if ( !isset( $this->mSectionHeaders[
$section] ) ) {
559 $this->mSectionHeaders[
$section] =
'';
561 $this->mSectionHeaders[
$section] .= $msg;
578 $this->mHeader = $msg;
580 $this->mSectionHeaders[
$section] = $msg;
596 $this->mFooter .= $msg;
598 if ( !isset( $this->mSectionFooters[
$section] ) ) {
599 $this->mSectionFooters[
$section] =
'';
601 $this->mSectionFooters[
$section] .= $msg;
618 $this->mFooter = $msg;
620 $this->mSectionFooters[
$section] = $msg;
634 $this->mPost .= $msg;
697 $this->mButtons[] = compact(
'name',
'value',
'id',
'attribs' );
725 function getHTML( $submitResult ) {
726 # For good measure (it is the default)
727 $this->
getOutput()->preventClickjacking();
728 $this->
getOutput()->addModules(
'mediawiki.htmlform' );
732 'mediawiki.ui.button',
760 # Include a <fieldset> wrapper for style, if requested.
761 if ( $this->mWrapperLegend !==
false ) {
764 # Use multipart/form-data
765 $encType = $this->mUseMultipart
766 ?
'multipart/form-data'
767 :
'application/x-www-form-urlencoded';
772 'class' =>
array(
'visualClear' ),
773 'enctype' => $encType,
775 if ( !empty( $this->mId ) ) {
780 array_push(
$attribs[
'class'],
'mw-ui-vform',
'mw-ui-container' );
797 $this->
getUser()->getEditToken(),
798 array(
'id' =>
'wpEditToken' )
807 foreach ( $this->mHiddenFields
as $data ) {
822 if ( $this->mShowSubmit ) {
825 if ( isset( $this->mSubmitID ) ) {
829 if ( isset( $this->mSubmitName ) ) {
833 if ( isset( $this->mSubmitTooltip ) ) {
847 'mw-ui-constructive',
855 if ( $this->mShowReset ) {
860 'value' => $this->
msg(
'htmlform-reset' )->
text()
865 foreach ( $this->mButtons
as $button ) {
868 'name' => $button[
'name'],
869 'value' => $button[
'value']
872 if ( $button[
'attribs'] ) {
873 $attrs += $button[
'attribs'];
876 if ( isset( $button[
'id'] ) ) {
877 $attrs[
'id'] = $button[
'id'];
884 array(
'class' =>
'mw-htmlform-submit-buttons' ),
"\n$buttons" ) .
"\n";
889 if ( $this->mShowSubmit && $this->
isVForm() ) {
901 return $this->
displaySection( $this->mFieldTree, $this->mTableId );
912 if ( $errors instanceof
Status ) {
913 if ( $errors->isOK() ) {
916 $errorstr = $this->
getOutput()->parse( $errors->getWikiText() );
918 } elseif ( is_array( $errors ) ) {
940 if ( is_array(
$error ) ) {
941 $msg = array_shift(
$error );
967 $this->mSubmitText =
$t;
991 return $this->mSubmitText
993 : $this->
msg(
'htmlform-submit' )->text();
1002 $this->mSubmitName =
$name;
1013 $this->mSubmitTooltip =
$name;
1027 $this->mSubmitID =
$t;
1043 $this->mShowSubmit = !$suppressSubmit;
1058 $this->mTableId = $id;
1068 public function setId( $id ) {
1085 $this->mWrapperLegend = $legend;
1115 $this->mMessagePrefix = $p;
1138 return $this->mTitle ===
false
1150 public function setMethod( $method =
'post' ) {
1151 $this->mMethod = $method;
1175 $fieldsetIDPrefix =
'',
1176 &$hasUserVisibleFields =
false ) {
1180 $subsectionHtml =
'';
1185 $getFieldHtmlMethod =
'getTableRow';
1189 $getFieldHtmlMethod =
'getDiv';
1195 foreach ( $fields
as $key =>
$value ) {
1197 $v = empty(
$value->mParams[
'nodata'] )
1198 ? $this->mFieldData[$key]
1202 $labelValue = trim(
$value->getLabel() );
1203 if ( $labelValue !=
' ' && $labelValue !==
'' ) {
1207 if ( get_class(
$value ) !==
'HTMLHiddenField' &&
1208 get_class(
$value ) !==
'HTMLApiField'
1210 $hasUserVisibleFields =
true;
1212 } elseif ( is_array(
$value ) ) {
1213 $subsectionHasVisibleFields =
false;
1217 "$fieldsetIDPrefix$key-",
1218 $subsectionHasVisibleFields );
1221 if ( $subsectionHasVisibleFields ===
true ) {
1223 $hasUserVisibleFields =
true;
1227 if ( isset( $this->mSectionHeaders[$key] ) ) {
1230 if ( isset( $this->mSectionFooters[$key] ) ) {
1231 $section .= $this->mSectionFooters[$key];
1234 $attributes =
array();
1235 if ( $fieldsetIDPrefix ) {
1250 $classes[] =
'mw-htmlform-nolabel';
1254 'class' => implode(
' ', $classes ),
1257 if ( $sectionName ) {
1270 if ( $this->mSubSectionBeforeFields ) {
1271 return $subsectionHtml .
"\n" .
$html;
1273 return $html .
"\n" . $subsectionHtml;
1281 $fieldData =
array();
1283 foreach ( $this->mFlatFields
as $fieldname => $field ) {
1284 if ( !empty( $field->mParams[
'nodata'] ) ) {
1286 } elseif ( !empty( $field->mParams[
'disabled'] ) ) {
1287 $fieldData[$fieldname] = $field->getDefault();
1289 $fieldData[$fieldname] = $field->loadDataFromRequest( $this->
getRequest() );
1295 $field = $this->mFlatFields[
$name];
1299 $this->mFieldData = $fieldData;
1311 $this->mShowReset = !$suppressReset;
1338 return $this->
msg(
"{$this->mMessagePrefix}-$key" )->text();
1352 $this->mAction = $action;
1368 if ( $this->mAction !==
false ) {
1381 return $this->
getTitle()->getLocalURL();
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. $title:Title object for the current page $request:WebRequest $ignoreRedirect:boolean to skip redirect check $target:Title/string of redirect target $article:Article object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) $article:article(object) being checked 'IsTrustedProxy':Override the result of wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of User::isValidEmailAddr(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetMagic':DEPRECATED, use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetSpecialPageAliases':DEPRECATED, use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Associative array mapping language codes to prefixed links of the form "language:title". & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
getContext()
Get the RequestContext object.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
msg()
Get a Message object with context set Parameters are the same as wfMessage()
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
static hidden( $name, $value, $attribs=array())
Convenience function to produce an input element with type=hidden.
getRequest()
Get the WebRequest object.
getUser()
Get the User object.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
isGood()
Returns whether the operation completed and didn't have any error or warnings.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
static tooltipAndAccesskeyAttribs( $name)
Returns the attributes for the tooltip and access key.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
static element( $element, $attribs=array(), $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
getOutput()
Get the OutputPage object.
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form externallinks including delete and has completed for all link tables default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
when a variable name is used in a it is silently declared as a new masking the global
setContext(IContextSource $context)
Set the IContextSource object.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
static escapeId( $id, $options=array())
Given a value, escape it so that it can be used in an id attribute and return it.
Allows to change the fields on the form that will be generated $name
Interface for objects which can provide a context on request.
Represents a title within MediaWiki.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
static submitButton( $value, $attribs=array())
Convenience function to build an HTML submit button.
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead where the first element is the message key and the remaining elements are used as parameters to the message based on mime etc Preferred in most cases over UploadVerification object with all info about the upload string as detected by MediaWiki Handlers will typically only apply for specific mime types object & $error
static rawElement( $element, $attribs=array(), $contents='')
Returns an HTML element in a string.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
static fieldset( $legend=false, $content=false, $attribs=array())
Shortcut for creating fieldsets.