83 public static function getTitleFor( $name, $subpage =
false, $fragment =
'' ) {
84 return Title::newFromTitleValue(
85 self::getTitleValueFor( $name, $subpage, $fragment )
99 $name = MediaWikiServices::getInstance()->getSpecialPageFactory()->
100 getLocalNameFor( $name, $subpage );
113 $name = MediaWikiServices::getInstance()->getSpecialPageFactory()->
114 getLocalNameFor( $name, $subpage );
116 return Title::makeTitleSafe(
NS_SPECIAL, $name );
140 $name =
'', $restriction =
'', $listed =
true,
141 $function =
false,
$file =
'', $includable =
false
143 $this->mName = $name;
144 $this->mRestriction = $restriction;
145 $this->mListed = $listed;
146 $this->mIncludable = $includable;
162 return $this->mRestriction;
173 return $this->mListed;
183 return wfSetVar( $this->mListed, $listed );
193 return wfSetVar( $this->mListed, $x );
201 return $this->mIncludable;
231 return wfSetVar( $this->mIncluding, $x );
239 if ( !isset( $this->mLocalName ) ) {
240 $this->mLocalName = MediaWikiServices::getInstance()->getSpecialPageFactory()->
241 getLocalNameFor( $this->mName );
244 return $this->mLocalName;
281 return $this->mRestriction !=
'' && !MediaWikiServices::getInstance()
282 ->getPermissionManager()
283 ->groupHasPermission(
'*', $this->mRestriction );
295 return MediaWikiServices::getInstance()
296 ->getPermissionManager()
297 ->userHasRight( $user, $this->mRestriction );
346 $reasonMsg =
'exception-nologin-text', $titleMsg =
'exception-nologin'
348 if ( $this->
getUser()->isAnon() ) {
407 $level = $level ?: $this->
getName();
408 $key =
'SpecialPage:reauth:' . $this->
getName();
411 $securityStatus = AuthManager::singleton()->securitySensitiveOperationStatus( $level );
412 if ( $securityStatus === AuthManager::SEC_OK ) {
413 $uniqueId = $request->getVal(
'postUniqueId' );
415 $key .=
':' . $uniqueId;
416 $session = $request->getSession();
417 $data = $session->getSecret( $key );
419 $session->remove( $key );
424 } elseif ( $securityStatus === AuthManager::SEC_REAUTH ) {
425 $title = self::getTitleFor(
'Userlogin' );
426 $queryParams = $request->getQueryValues();
428 if ( $request->wasPosted() ) {
429 $data = array_diff_assoc( $request->getValues(), $request->getQueryValues() );
433 $key .=
':' . $uniqueId;
434 $queryParams[
'postUniqueId'] = $uniqueId;
435 $session = $request->getSession();
437 $session->setSecret( $key, $data );
442 'returnto' => $this->
getFullTitle()->getPrefixedDBkey(),
443 'returntoquery' =>
wfArrayToCgi( array_diff_key( $queryParams, [
'title' =>
true ] ) ),
452 $titleMessage =
wfMessage(
'specialpage-securitylevel-not-allowed-title' );
453 $errorMessage =
wfMessage(
'specialpage-securitylevel-not-allowed' );
479 return self::prefixSearchArray( $search, $limit, $subpages, $offset );
502 $title = Title::newFromText( $search );
508 $searchEngine = MediaWikiServices::getInstance()->newSearchEngine();
509 $searchEngine->setLimitOffset( $limit, $offset );
510 $searchEngine->setNamespaces( [] );
511 $result = $searchEngine->defaultPrefixSearch( $search );
512 return array_map(
function (
Title $t ) {
513 return $t->getPrefixedText();
529 $escaped = preg_quote( $search,
'/' );
530 return array_slice( preg_grep(
"/^$escaped/i",
531 array_slice( $subpages, $offset ) ), 0, $limit );
539 $out->setArticleRelated(
false );
542 if ( $this->
getConfig()->
get(
'UseMediaWikiUIEverywhere' ) ) {
543 $out->addModuleStyles( [
544 'mediawiki.ui.input',
545 'mediawiki.ui.radio',
546 'mediawiki.ui.checkbox',
558 final public function run( $subPage ) {
568 if ( !Hooks::run(
'SpecialPageBeforeExecute', [ $this, $subPage ] ) ) {
586 Hooks::run(
'SpecialPageAfterExecute', [ $this, $subPage ] );
640 if ( $summaryMessageKey ==
'' ) {
641 $msg = MediaWikiServices::getInstance()->getContentLanguage()->lc( $this->
getName() ) .
644 $msg = $summaryMessageKey;
646 if ( !$this->
msg( $msg )->isDisabled() && !$this->
including() ) {
648 "<div class='mw-specialpage-summary'>\n$1\n</div>", $msg );
662 return $this->
msg( strtolower( $this->mName ) )->text();
673 return self::getTitleFor( $this->mName, $subpage );
694 return $this->mContext;
696 wfDebug( __METHOD__ .
" called and \$mContext is null. " .
697 "Return RequestContext::getMain(); for sanity\n" );
699 return RequestContext::getMain();
780 return 'noindex,nofollow';
792 public function msg( $key, ...$params ) {
793 $message = $this->
getContext()->msg( $key, ...$params );
799 $message->setInterfaceMessageFlag(
false );
813 foreach ( $this->
getConfig()->
get(
'FeedClasses' ) as $format => $class ) {
814 $theseParams = $params + [
'feedformat' => $format ];
816 $this->
getOutput()->addFeedLink( $format, $url );
834 MediaWikiServices::getInstance()->getContentLanguage()->lc( $this->
getName() ) .
837 if ( !$msg->isDisabled() ) {
838 $helpUrl = Skin::makeUrl( $msg->plain() );
839 $this->
getOutput()->addHelpLink( $helpUrl,
true );
841 $this->
getOutput()->addHelpLink( $to, $overrideBaseUrl );
857 $msg = $this->
msg(
'specialpages-specialpagegroup-' . strtolower( $name ) )->inContentLanguage();
858 if ( !$msg->isBlank() ) {
859 $group = $msg->text();
905 if ( $this->linkRenderer ) {
906 return $this->linkRenderer;
908 return MediaWikiServices::getInstance()->getLinkRenderer();
917 $this->linkRenderer = $linkRenderer;
931 array $query = [], $atend =
false, $subpage =
false
936 return $prevNext->buildPrevNextNavigation(
$title, $offset, $limit, $query, $atend );
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfReadOnly()
Check whether the wiki is in read-only mode.
wfSetVar(&$dest, $source, $force=false)
Sets dest to source and returns the original value of dest If source is NULL, it just returns the val...
wfTransactionalTimeLimit()
Set PHP's time limit to the larger of php.ini or $wgTransactionalTimeLimit.
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e....
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
An error page which can definitely be safely rendered using the OutputPage.
Some internal bits split of from Skin.php.
static generateHex( $chars)
Generate a run of cryptographically random data and return it in hexadecimal string format.
Show an error when a user tries to do something they do not have the necessary permissions for.
Show an error when the wiki is locked/read-only and the user tries to do something that requires writ...
Parent class for all special pages.
__construct( $name='', $restriction='', $listed=true, $function=false, $file='', $includable=false)
Default constructor for special pages Derivative classes should call this from their constructor Note...
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setContext( $context)
Sets the context this SpecialPage is executed in.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
getName()
Get the name of this Special Page.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
static getSafeTitleFor( $name, $subpage=false)
Get a localised Title object for a page name with a possibly unvalidated subpage.
getLocalName()
Get the localised name of the special page.
afterExecute( $subPage)
Gets called after.
getRestriction()
Get the permission that a user must have to execute this page.
getDescription()
Returns the name that goes in the <h1> in the special page itself, and also the name that will be l...
run( $subPage)
Entry point.
getOutput()
Get the OutputPage being used for this instance.
requireLogin( $reasonMsg='exception-nologin-text', $titleMsg='exception-nologin')
If the user is not logged in, throws UserNotLoggedIn error.
beforeExecute( $subPage)
Gets called before.
checkLoginSecurityLevel( $level=null)
Verifies that the user meets the security level, possibly reauthenticating them in the process.
getUser()
Shortcut to get the User executing this instance.
static prefixSearchArray( $search, $limit, array $subpages, $offset)
Helper function for implementations of prefixSearchSubpages() that filter the values in memory (as op...
setListed( $listed)
Set whether this page is listed in Special:Specialpages, at run-time.
buildPrevNextNavigation( $offset, $limit, array $query=[], $atend=false, $subpage=false)
Generate (prev x| next x) (20|50|100...) type links for paging.
isListed()
Whether this special page is listed in Special:SpecialPages.
getSkin()
Shortcut to get the skin being used for this instance.
checkPermissions()
Checks if userCanExecute, and if not throws a PermissionsError.
execute( $subPage)
Default execute method Checks user permissions.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
isCached()
Is this page cached? Expensive pages are cached or disabled in miser mode.
addFeedLinks( $params)
Adds RSS/atom links.
setReauthPostData(array $data)
Record preserved POST data after a reauthentication.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getConfig()
Shortcut to get main config object.
listed( $x=null)
Get or set whether this special page is listed in Special:SpecialPages.
doesWrites()
Indicates whether this special page may perform database writes.
getRequest()
Get the WebRequest being used for this instance.
getFinalGroupName()
Get the group that the special page belongs in on Special:SpecialPage Use this method,...
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
displayRestrictionError()
Output an error message telling the user what access level they have to have.
static getTitleValueFor( $name, $subpage=false, $fragment='')
Get a localised TitleValue object for a specified special page name.
getSubpagesForPrefixSearch()
Return an array of subpages that this special page will accept for prefix searches.
getPageTitle( $subpage=false)
Get a self-referential title object.
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
getLanguage()
Shortcut to get user's language.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
getLoginSecurityLevel()
Tells if the special page does something security-sensitive and needs extra defense against a stolen ...
setLinkRenderer(LinkRenderer $linkRenderer)
IContextSource $mContext
Current request context.
including( $x=null)
Whether the special page is being evaluated via transclusion.
maxIncludeCacheTime()
How long to cache page when it is being included.
prefixSearchString( $search, $limit, $offset)
Perform a regular substring search for prefixSearchSubpages.
isRestricted()
Can be overridden by subclasses with more complicated permissions schemes.
MediaWiki Linker LinkRenderer null $linkRenderer
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
userCanExecute(User $user)
Checks if the given user (identified by an object) can execute this special page (as defined by $mRes...
getFullTitle()
Return the full title, including $par.
getRobotPolicy()
Return the robot policy.
isExpensive()
Is this page expensive (for some definition of expensive)? Expensive pages are disabled or cached in ...
isIncludable()
Whether it's allowed to transclude the special page via {{Special:Foo/params}}.
Represents a page (or page fragment) title within MediaWiki.
Represents a title within MediaWiki.
Redirect a user to the login page.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Interface for objects which can provide a MediaWiki context on request.
Interface for localizing messages in MediaWiki.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.