}
$target = User::newFromName( $params['user'] );
- // Bug 38633 - if the target is a user (not an IP address), but it doesn't exist or is unusable, error.
- if ( $target instanceof User && ( $target->isAnon() /* doesn't exist */ || !User::isUsableName( $target->getName() ) ) ) {
+ // Bug 38633 - if the target is a user (not an IP address), but it
+ // doesn't exist or is unusable, error.
+ if ( $target instanceof User &&
+ ( $target->isAnon() /* doesn't exist */ || !User::isUsableName( $target->getName() ) )
+ ) {
$this->dieUsageMsg( array( 'nosuchuser', $params['user'] ) );
}
return array(
'user' => 'Username, IP address or IP range you want to block',
'token' => 'A block token previously obtained through prop=info',
- 'expiry' => 'Relative expiry time, e.g. \'5 months\' or \'2 weeks\'. If set to \'infinite\', \'indefinite\' or \'never\', the block will never expire.',
+ 'expiry' => 'Relative expiry time, e.g. \'5 months\' or \'2 weeks\'. ' .
+ 'If set to \'infinite\', \'indefinite\' or \'never\', the block will never expire.',
'reason' => 'Reason for block',
'anononly' => 'Block anonymous users only (i.e. disable anonymous edits for this IP)',
'nocreate' => 'Prevent account creation',
- 'autoblock' => 'Automatically block the last used IP address, and any subsequent IP addresses they try to login from',
- 'noemail' => 'Prevent user from sending email through the wiki. (Requires the "blockemail" right.)',
+ 'autoblock' => 'Automatically block the last used IP address, and ' .
+ 'any subsequent IP addresses they try to login from',
+ 'noemail'
+ => 'Prevent user from sending email through the wiki. (Requires the "blockemail" right.)',
'hidename' => 'Hide the username from the block log. (Requires the "hideuser" right.)',
- 'allowusertalk' => 'Allow the user to edit their own talk page (depends on $wgBlockAllowsUTEdit)',
+ 'allowusertalk'
+ => 'Allow the user to edit their own talk page (depends on $wgBlockAllowsUTEdit)',
'reblock' => 'If the user is already blocked, overwrite the existing block',
'watchuser' => 'Watch the user/IP\'s user and talk pages',
);
$difftext = $de->getDiffBody();
if ( $difftext === false ) {
- $this->dieUsage( 'The diff cannot be retrieved. ' .
- 'Maybe one or both revisions do not exist or you do not have permission to view them.', 'baddiff' );
+ $this->dieUsage(
+ 'The diff cannot be retrieved. Maybe one or both revisions do ' .
+ 'not exist or you do not have permission to view them.',
+ 'baddiff'
+ );
} else {
ApiResult::setContent( $vals, $difftext );
}
array( 'code' => 'inputneeded', 'info' => 'A title or a revision is needed' ),
array( 'invalidtitle', 'title' ),
array( 'nosuchpageid', 'pageid' ),
- array( 'code' => 'baddiff', 'info' => 'The diff cannot be retrieved. Maybe one or both revisions do not exist or you do not have permission to view them.' ),
+ array(
+ 'code' => 'baddiff',
+ 'info' => 'The diff cannot be retrieved. Maybe one or both ' .
+ 'revisions do not exist or you do not have permission to view them.'
+ ),
) );
}
// Use userCan in order to hit GlobalBlock checks (according to Special:userlogin)
$loginTitle = SpecialPage::getTitleFor( 'Userlogin' );
if ( !$loginTitle->userCan( 'createaccount', $this->getUser() ) ) {
- $this->dieUsage( 'You do not have the right to create a new account', 'permdenied-createaccount' );
+ $this->dieUsage(
+ 'You do not have the right to create a new account',
+ 'permdenied-createaccount'
+ );
}
if ( $this->getUser()->isBlockedFromCreateAccount() ) {
$this->dieUsage( 'You cannot create a new account because you are blocked', 'blocked' );
if ( $params['mailpassword'] ) {
// If mailpassword was set, disable the password and send an email.
$user->setPassword( null );
- $status->merge( $loginForm->mailPasswordInternal( $user, false, 'createaccount-title', 'createaccount-text' ) );
+ $status->merge( $loginForm->mailPasswordInternal(
+ $user,
+ false,
+ 'createaccount-title',
+ 'createaccount-text'
+ ) );
} elseif ( $wgEmailAuthentication && Sanitizer::validateEmail( $user->getEmail() ) ) {
// Send out an email authentication message if needed
$status->merge( $user->sendConfirmationMail() );
'realname' => 'Real name of user (optional)',
'mailpassword' => 'If set to any value, a random password will be emailed to the user',
'reason' => 'Optional reason for creating the account to be put in the logs',
- 'language' => 'Language code to set as default for the user (optional, defaults to content language)'
+ 'language'
+ => 'Language code to set as default for the user (optional, defaults to content language)'
);
}
$errors = parent::getPossibleErrors();
// All local errors are from LoginForm, which means they're actually message keys.
foreach ( $localErrors as $error ) {
- $errors[] = array( 'code' => $error, 'info' => wfMessage( $error )->inLanguage( 'en' )->useDatabase( false )->parse() );
+ $errors[] = array(
+ 'code' => $error,
+ 'info' => wfMessage( $error )->inLanguage( 'en' )->useDatabase( false )->parse()
+ );
}
$errors[] = array(
global $wgMinimalPasswordLength;
$errors[] = array(
'code' => 'passwordtooshort',
- 'info' => wfMessage( 'passwordtooshort', $wgMinimalPasswordLength )->inLanguage( 'en' )->useDatabase( false )->parse()
+ 'info' => wfMessage( 'passwordtooshort', $wgMinimalPasswordLength )
+ ->inLanguage( 'en' )->useDatabase( false )->parse()
);
return $errors;
* @ingroup API
*/
class ApiDelete extends ApiBase {
-
/**
* Extracts the title, token, and reason from the request parameters and invokes
* the local delete() function with these as arguments. It does not make use of
$user = $this->getUser();
if ( $titleObj->getNamespace() == NS_FILE ) {
- $status = self::deleteFile( $pageObj, $user, $params['token'], $params['oldimage'], $reason, false );
+ $status = self::deleteFile(
+ $pageObj,
+ $user,
+ $params['token'],
+ $params['oldimage'],
+ $reason,
+ false
+ );
} else {
$status = self::delete( $pageObj, $user, $params['token'], $reason );
}
* @param $suppress bool
* @return Status|array
*/
- public static function deleteFile( Page $page, User $user, $token, $oldimage, &$reason = null, $suppress = false ) {
+ public static function deleteFile( Page $page, User $user, $token, $oldimage,
+ &$reason = null, $suppress = false
+ ) {
$title = $page->getTitle();
$errors = self::getPermissionsError( $title, $user, $token );
if ( count( $errors ) ) {
'title' => "Title of the page you want to delete. Cannot be used together with {$p}pageid",
'pageid' => "Page ID of the page you want to delete. Cannot be used together with {$p}title",
'token' => 'A delete token previously retrieved through prop=info',
- 'reason' => 'Reason for the deletion. If not set, an automatically generated reason will be used',
+ 'reason'
+ => 'Reason for the deletion. If not set, an automatically generated reason will be used',
'watch' => 'Add the page to your watchlist',
- 'watchlist' => 'Unconditionally add or remove the page from your watchlist, use preferences or do not change watch',
+ 'watchlist' => 'Unconditionally add or remove the page from your ' .
+ 'watchlist, use preferences or do not change watch',
'unwatch' => 'Remove the page from your watchlist',
'oldimage' => 'The name of the old image to delete as provided by iiprop=archivename'
);
public function getExamples() {
return array(
'api.php?action=delete&title=Main%20Page&token=123ABC' => 'Delete the Main Page',
- 'api.php?action=delete&title=Main%20Page&token=123ABC&reason=Preparing%20for%20move' => 'Delete the Main Page with the reason "Preparing for move"',
+ 'api.php?action=delete&title=Main%20Page&token=123ABC&reason=Preparing%20for%20move'
+ => 'Delete the Main Page with the reason "Preparing for move"',
);
}
* @ingroup API
*/
class ApiEditPage extends ApiBase {
-
public function execute() {
$user = $this->getUser();
$params = $this->extractRequestParams();
$contentHandler = ContentHandler::getForModelID( $params['contentmodel'] );
}
- // @todo ask handler whether direct editing is supported at all! make allowFlatEdit() method or some such
+ // @todo Ask handler whether direct editing is supported at all! make
+ // allowFlatEdit() method or some such
if ( !isset( $params['contentformat'] ) || $params['contentformat'] == '' ) {
$params['contentformat'] = $contentHandler->getDefaultFormat();
if ( !is_null( $params['section'] ) ) {
if ( !$contentHandler->supportsSections() ) {
$modelName = $contentHandler->getModelID();
- $this->dieUsage( "Sections are not supported for this content model: $modelName.", 'sectionsnotsupported' );
+ $this->dieUsage(
+ "Sections are not supported for this content model: $modelName.",
+ 'sectionsnotsupported'
+ );
}
if ( $params['section'] == 'new' ) {
}
if ( $undoRev->getPage() != $pageObj->getID() ) {
- $this->dieUsageMsg( array( 'revwrongpage', $undoRev->getID(), $titleObj->getPrefixedText() ) );
+ $this->dieUsageMsg( array( 'revwrongpage', $undoRev->getID(),
+ $titleObj->getPrefixedText() ) );
}
if ( $undoafterRev->getPage() != $pageObj->getID() ) {
- $this->dieUsageMsg( array( 'revwrongpage', $undoafterRev->getID(), $titleObj->getPrefixedText() ) );
+ $this->dieUsageMsg( array( 'revwrongpage', $undoafterRev->getID(),
+ $titleObj->getPrefixedText() ) );
}
- $newContent = $contentHandler->getUndoContent( $pageObj->getRevision(), $undoRev, $undoafterRev );
+ $newContent = $contentHandler->getUndoContent(
+ $pageObj->getRevision(),
+ $undoRev,
+ $undoafterRev
+ );
if ( !$newContent ) {
$this->dieUsageMsg( 'undo-failure' );
// If no summary was given and we only undid one rev,
// use an autosummary
- if ( is_null( $params['summary'] ) && $titleObj->getNextRevisionID( $undoafterRev->getID() ) == $params['undo'] ) {
- $params['summary'] = wfMessage( 'undo-summary', $params['undo'], $undoRev->getUserText() )->inContentLanguage()->text();
+ if ( is_null( $params['summary'] ) &&
+ $titleObj->getNextRevisionID( $undoafterRev->getID() ) == $params['undo']
+ ) {
+ $params['summary'] = wfMessage( 'undo-summary' )
+ ->params ( $params['undo'], $undoRev->getUserText() )->inContentLanguage()->text();
}
}
// The following is needed to give the hook the full content of the
// new revision rather than just the current section. (Bug 52077)
- if ( !is_null( $params['section'] ) && $contentHandler->supportsSections() && $titleObj->exists() ) {
-
+ if ( !is_null( $params['section'] ) &&
+ $contentHandler->supportsSections() && $titleObj->exists()
+ ) {
$sectionTitle = '';
// If sectiontitle is set, use it, otherwise use the summary as the section title (for
// backwards compatibility with old forms/bots).
$contentObj = $contentHandler->unserializeContent( $content, $contentFormat );
- $fullContentObj = $articleObject->replaceSectionContent( $params['section'], $contentObj, $sectionTitle );
+ $fullContentObj = $articleObject->replaceSectionContent(
+ $params['section'],
+ $contentObj,
+ $sectionTitle
+ );
if ( $fullContentObj ) {
$content = $fullContentObj->serialize( $contentFormat );
} else {
array( 'emptynewsection' ),
array( 'unknownerror', 'retval' ),
array( 'code' => 'nosuchsection', 'info' => 'There is no section section.' ),
- array( 'code' => 'invalidsection', 'info' => 'The section parameter must be set to an integer or \'new\'' ),
- array( 'code' => 'sectionsnotsupported', 'info' => 'Sections are not supported for this type of page.' ),
- array( 'code' => 'editnotsupported', 'info' => 'Editing of this type of page is not supported using '
- . 'the text based edit API.' ),
- array( 'code' => 'appendnotsupported', 'info' => 'This type of page can not be edited by appending '
- . 'or prepending text.' ),
- array( 'code' => 'badformat', 'info' => 'The requested serialization format can not be applied to '
- . 'the page\'s content model' ),
+ array(
+ 'code' => 'invalidsection',
+ 'info' => 'The section parameter must be set to an integer or \'new\''
+ ),
+ array(
+ 'code' => 'sectionsnotsupported',
+ 'info' => 'Sections are not supported for this type of page.'
+ ),
+ array(
+ 'code' => 'editnotsupported',
+ 'info' => 'Editing of this type of page is not supported using the text based edit API.'
+ ),
+ array(
+ 'code' => 'appendnotsupported',
+ 'info' => 'This type of page can not be edited by appending or prepending text.' ),
+ array(
+ 'code' => 'badformat',
+ 'info' => 'The requested serialization format can not be applied to the page\'s content model'
+ ),
array( 'customcssprotected' ),
array( 'customjsprotected' ),
)
'section' => 'Section number. 0 for the top section, \'new\' for a new section',
'sectiontitle' => 'The title for a new section',
'text' => 'Page content',
- 'token' => array( 'Edit token. You can get one of these through prop=info.',
- "The token should always be sent as the last parameter, or at least, after the {$p}text parameter"
+ 'token' => array(
+ 'Edit token. You can get one of these through prop=info.',
+ "The token should always be sent as the last parameter, or at " .
+ "least, after the {$p}text parameter"
),
- 'summary' => "Edit summary. Also section title when {$p}section=new and {$p}sectiontitle is not set",
+ 'summary'
+ => "Edit summary. Also section title when {$p}section=new and {$p}sectiontitle is not set",
'minor' => 'Minor edit',
'notminor' => 'Non-minor edit',
'bot' => 'Mark this edit as bot',
- 'basetimestamp' => array( 'Timestamp of the base revision (obtained through prop=revisions&rvprop=timestamp).',
+ 'basetimestamp' => array(
+ 'Timestamp of the base revision (obtained through prop=revisions&rvprop=timestamp).',
'Used to detect edit conflicts; leave unset to ignore conflicts'
),
- 'starttimestamp' => array( 'Timestamp when you obtained the edit token.',
+ 'starttimestamp' => array(
+ 'Timestamp when you obtained the edit token.',
'Used to detect edit conflicts; leave unset to ignore conflicts'
),
'recreate' => 'Override any errors about the article having been deleted in the meantime',
'nocreate' => 'Throw an error if the page doesn\'t exist',
'watch' => 'Add the page to your watchlist',
'unwatch' => 'Remove the page from your watchlist',
- 'watchlist' => 'Unconditionally add or remove the page from your watchlist, use preferences or do not change watch',
- 'md5' => array( "The MD5 hash of the {$p}text parameter, or the {$p}prependtext and {$p}appendtext parameters concatenated.",
- 'If set, the edit won\'t be done unless the hash is correct' ),
+ 'watchlist' => 'Unconditionally add or remove the page from your ' .
+ 'watchlist, use preferences or do not change watch',
+ 'md5' => array(
+ "The MD5 hash of the {$p}text parameter, or the {$p}prependtext " .
+ "and {$p}appendtext parameters concatenated.",
+ 'If set, the edit won\'t be done unless the hash is correct'
+ ),
'prependtext' => "Add this text to the beginning of the page. Overrides {$p}text",
'appendtext' => array( "Add this text to the end of the page. Overrides {$p}text.",
"Use {$p}section=new to append a new section" ),
public function getExamples() {
return array(
- 'api.php?action=edit&title=Test&summary=test%20summary&text=article%20content&basetimestamp=20070824123454&token=%2B\\'
+ 'api.php?action=edit&title=Test&summary=test%20summary&' .
+ 'text=article%20content&basetimestamp=20070824123454&token=%2B\\'
=> 'Edit a page (anonymous user)',
- 'api.php?action=edit&title=Test&summary=NOTOC&minor=&prependtext=__NOTOC__%0A&basetimestamp=20070824123454&token=%2B\\'
+ 'api.php?action=edit&title=Test&summary=NOTOC&minor=&' .
+ 'prependtext=__NOTOC__%0A&basetimestamp=20070824123454&token=%2B\\'
=> 'Prepend __NOTOC__ to a page (anonymous user)',
- 'api.php?action=edit&title=Test&undo=13585&undoafter=13579&basetimestamp=20070824123454&token=%2B\\'
+ 'api.php?action=edit&title=Test&undo=13585&undoafter=13579&' .
+ 'basetimestamp=20070824123454&token=%2B\\'
=> 'Undo r13579 through r13585 with autosummary (anonymous user)',
);
}
public function getExamples() {
return array(
- 'api.php?action=emailuser&target=WikiSysop&text=Content' => 'Send an email to the User "WikiSysop" with the text "Content"',
+ 'api.php?action=emailuser&target=WikiSysop&text=Content'
+ => 'Send an email to the User "WikiSysop" with the text "Content"',
);
}
$feedTitle = $wgSitename . ' - ' . $msg . ' [' . $wgLanguageCode . ']';
$feedUrl = SpecialPage::getTitleFor( 'Watchlist' )->getFullURL();
- $feed = new $wgFeedClasses[$params['feedformat']] ( $feedTitle, htmlspecialchars( $msg ), $feedUrl );
+ $feed = new $wgFeedClasses[$params['feedformat']] (
+ $feedTitle,
+ htmlspecialchars( $msg ),
+ $feedUrl
+ );
ApiFormatFeedWrapper::setResult( $this->getResult(), $feed, $feedItems );
} catch ( Exception $e ) {
-
// Error results should not be cached
$this->getMain()->setCacheMaxAge( 0 );
- $feedTitle = $wgSitename . ' - Error - ' . wfMessage( 'watchlist' )->inContentLanguage()->text() . ' [' . $wgLanguageCode . ']';
+ // @todo FIXME: Localise brackets
+ $feedTitle = $wgSitename . ' - Error - ' .
+ wfMessage( 'watchlist' )->inContentLanguage()->text() .
+ ' [' . $wgLanguageCode . ']';
$feedUrl = SpecialPage::getTitleFor( 'Watchlist' )->getFullURL();
$feedFormat = isset( $params['feedformat'] ) ? $params['feedformat'] : 'rss';
// The anchor won't work for sections that have dupes on page
// as there's no way to strip that info from ApiWatchlist (apparently?).
// RegExp in the line below is equal to Linker::formatAutocomments().
- if ( $this->linkToSections && $comment !== null && preg_match( '!(.*)/\*\s*(.*?)\s*\*/(.*)!', $comment, $matches ) ) {
+ if ( $this->linkToSections && $comment !== null &&
+ preg_match( '!(.*)/\*\s*(.*?)\s*\*/(.*)!', $comment, $matches )
+ ) {
global $wgParser;
+
$sectionTitle = $wgParser->stripSectionName( $matches[2] );
$sectionTitle = Sanitizer::normalizeSectionNameWhitespace( $sectionTitle );
$titleUrl .= Title::newFromText( '#' . $sectionTitle )->getFragmentForURL();
$this->checkPermissions( $this->getUser() );
$sourceUrl = $this->file->getArchiveVirtualUrl( $this->archiveName );
- $status = $this->file->upload( $sourceUrl, $this->params['comment'], $this->params['comment'], 0, false, false, $this->getUser() );
+ $status = $this->file->upload(
+ $sourceUrl,
+ $this->params['comment'],
+ $this->params['comment'],
+ 0,
+ false,
+ false,
+ $this->getUser()
+ );
if ( $status->isGood() ) {
$result = array( 'result' => 'Success' );
public function getExamples() {
return array(
- 'api.php?action=filerevert&filename=Wiki.png&comment=Revert&archivename=20110305152740!Wiki.png&token=123ABC'
+ 'api.php?action=filerevert&filename=Wiki.png&comment=Revert&' .
+ 'archivename=20110305152740!Wiki.png&token=123ABC'
=> 'Revert Wiki.png to the version of 20110305152740',
);
}
* @ingroup API
*/
abstract class ApiFormatBase extends ApiBase {
-
private $mIsHtml, $mFormat, $mUnescapeAmps, $mHelp, $mCleared;
private $mBufferResult = false, $mBuffer, $mDisabled = false;
<!DOCTYPE HTML>
<html>
<head>
-<?php if ( $this->mUnescapeAmps ) {
+<?php
+ if ( $this->mUnescapeAmps ) {
?> <title>MediaWiki API</title>
-<?php } else {
+<?php
+ } else {
?> <title>MediaWiki API Result</title>
-<?php } ?>
+<?php
+ }
+?>
</head>
<body>
<?php
-
-
if ( !$isHelpScreen ) {
+// @codingStandardsIgnoreStart Exclude long line from CodeSniffer checks
?>
<br />
<small>
</small>
<pre style='white-space: pre-wrap;'>
<?php
-
-
- } else { // don't wrap the contents of the <pre> for help screens
- // because these are actually formatted to rely on
- // the monospaced font for layout purposes
+// @codingStandardsIgnoreEnd
+ // don't wrap the contents of the <pre> for help screens
+ // because these are actually formatted to rely on
+ // the monospaced font for layout purposes
+ } else {
?>
<pre>
<?php
-
}
}
}
</body>
</html>
<?php
-
-
}
}
// identify URLs
$protos = wfUrlProtocolsWithoutProtRel();
// This regex hacks around bug 13218 (" included in the URL)
- $text = preg_replace( "#(((?i)$protos).*?)(")?([ \\'\"<>\n]|<|>|")#", '<a href="\\1">\\1</a>\\3\\4', $text );
+ $text = preg_replace(
+ "#(((?i)$protos).*?)(")?([ \\'\"<>\n]|<|>|")#",
+ '<a href="\\1">\\1</a>\\3\\4',
+ $text
+ );
/**
* Temporary fix for bad links in help messages. As a special case,
public function getParamDescription() {
return array(
- 'callback' => 'If specified, wraps the output into a given function call. For safety, all user-specific data will be restricted.',
- 'utf8' => 'If specified, encodes most (but not all) non-ASCII characters as UTF-8 instead of replacing them with hexadecimal escape sequences.',
+ 'callback' => 'If specified, wraps the output into a given function ' .
+ 'call. For safety, all user-specific data will be restricted.',
+ 'utf8' => 'If specified, encodes most (but not all) non-ASCII ' .
+ 'characters as UTF-8 instead of replacing them with hexadecimal escape sequences.',
);
}
// Some versions of PHP have a broken wddx_serialize_value, see
// PHP bug 45314. Test encoding an affected character (U+00A0)
// to avoid this.
- $expected = "<wddxPacket version='1.0'><header/><data><string>\xc2\xa0</string></data></wddxPacket>";
+ $expected =
+ "<wddxPacket version='1.0'><header/><data><string>\xc2\xa0</string></data></wddxPacket>";
if ( function_exists( 'wddx_serialize_value' )
&& !$this->getIsHtml()
&& wddx_serialize_value( "\xc2\xa0" ) == $expected
}
if ( is_null( $subElemIndName ) && count( $indElements ) ) {
- ApiBase::dieDebug( __METHOD__, "($elemName, ...) has integer keys without _element value. Use ApiResult::setIndexedTagName()." );
+ ApiBase::dieDebug( __METHOD__, "($elemName, ...) has integer keys " .
+ "without _element value. Use ApiResult::setIndexedTagName()." );
}
if ( count( $subElements ) && count( $indElements ) && !is_null( $subElemContent ) ) {
return;
}
- $this->printText( '<?xml-stylesheet href="' . htmlspecialchars( $nt->getLocalURL( 'action=raw' ) ) . '" type="text/xsl" ?>' );
+ $this->printText( '<?xml-stylesheet href="' .
+ htmlspecialchars( $nt->getLocalURL( 'action=raw' ) ) . '" type="text/xsl" ?>' );
}
public function getAllowedParams() {
* @ingroup API
*/
class ApiHelp extends ApiBase {
-
/**
* Module for displaying help
*/
// In case the '+' was typed into URL, it resolves as a space
$subNames = explode( ' ', $m );
}
+
$module = $this->getMain();
- for ( $i = 0; $i < count( $subNames ); $i++ ) {
+ $subNamesCount = count( $subNames );
+ for ( $i = 0; $i < $subNamesCount; $i++ ) {
$subs = $module->getModuleManager();
if ( $subs === null ) {
$module = null;
} else {
$module = $subs->getModule( $subNames[$i] );
}
+
if ( $module === null ) {
if ( count( $subNames ) === 2
&& $i === 1
$type = $subs->getModuleGroup( $subNames[$i] );
}
}
+
if ( $module !== null ) {
$r[] = $this->buildModuleHelp( $module, $type );
}
public function getParamDescription() {
return array(
- 'modules' => 'List of module names (value of the action= parameter). Can specify submodules with a \'+\'',
- 'querymodules' => 'Use modules=query+value instead. List of query module names (value of prop=, meta= or list= parameter)',
+ 'modules' => 'List of module names (value of the action= parameter). ' .
+ 'Can specify submodules with a \'+\'',
+ 'querymodules' => 'Use modules=query+value instead. List of query ' .
+ 'module names (value of prop=, meta= or list= parameter)',
);
}
return array(
'api.php?action=help' => 'Whole help page',
'api.php?action=help&modules=protect' => 'Module (action) help page',
- 'api.php?action=help&modules=query+categorymembers' => 'Help for the query/categorymembers module',
- 'api.php?action=help&modules=login|query+info' => 'Help for the login and query/info modules',
+ 'api.php?action=help&modules=query+categorymembers'
+ => 'Help for the query/categorymembers module',
+ 'api.php?action=help&modules=login|query+info'
+ => 'Help for the login and query/info modules',
);
}
public function getExamples() {
return array(
- 'api.php?action=import&interwikisource=meta&interwikipage=Help:ParserFunctions&namespace=100&fullhistory=&token=123ABC'
+ 'api.php?action=import&interwikisource=meta&interwikipage=Help:ParserFunctions&' .
+ 'namespace=100&fullhistory=&token=123ABC'
=> 'Import [[meta:Help:Parserfunctions]] to namespace 100 with full history',
);
}
$result['result'] = 'NotExists';
break;
- case LoginForm::RESET_PASS: // bug 20223 - Treat a temporary password as wrong. Per SpecialUserLogin - "The e-mailed temporary password should not be used for actual logins;"
+ // bug 20223 - Treat a temporary password as wrong. Per SpecialUserLogin:
+ // The e-mailed temporary password should not be used for actual logins.
+ case LoginForm::RESET_PASS:
case LoginForm::WRONG_PASS:
$result['result'] = 'WrongPass';
break;
public function getDescription() {
return array(
'Log in and get the authentication tokens.',
- 'In the event of a successful log-in, a cookie will be attached',
- 'to your session. In the event of a failed log-in, you will not',
- 'be able to attempt another log-in through this method for 5 seconds.',
- 'This is to prevent password guessing by automated password crackers'
+ 'In the event of a successful log-in, a cookie will be attached to your session.',
+ 'In the event of a failed log-in, you will not be able to attempt another log-in',
+ 'through this method for 5 seconds. This is to prevent password guessing by',
+ 'automated password crackers'
);
}
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(), array(
- array( 'code' => 'NeedToken', 'info' => 'You need to resubmit your login with the specified token. See https://bugzilla.wikimedia.org/show_bug.cgi?id=23076' ),
+ array(
+ 'code' => 'NeedToken', 'info' => 'You need to resubmit your ' .
+ 'login with the specified token. See ' .
+ 'https://bugzilla.wikimedia.org/show_bug.cgi?id=23076'
+ ),
array( 'code' => 'WrongToken', 'info' => 'You specified an invalid token' ),
array( 'code' => 'NoName', 'info' => 'You didn\'t set the lgname parameter' ),
array( 'code' => 'Illegal', 'info' => 'You provided an illegal username' ),
array( 'code' => 'NotExists', 'info' => 'The username you provided doesn\'t exist' ),
- array( 'code' => 'EmptyPass', 'info' => 'You didn\'t set the lgpassword parameter or you left it empty' ),
+ array(
+ 'code' => 'EmptyPass',
+ 'info' => 'You didn\'t set the lgpassword parameter or you left it empty'
+ ),
array( 'code' => 'WrongPass', 'info' => 'The password you provided is incorrect' ),
- array( 'code' => 'WrongPluginPass', 'info' => 'Same as "WrongPass", returned when an authentication plugin rather than MediaWiki itself rejected the password' ),
- array( 'code' => 'CreateBlocked', 'info' => 'The wiki tried to automatically create a new account for you, but your IP address has been blocked from account creation' ),
+ array(
+ 'code' => 'WrongPluginPass',
+ 'info' => 'Same as "WrongPass", returned when an authentication ' .
+ 'plugin rather than MediaWiki itself rejected the password'
+ ),
+ array(
+ 'code' => 'CreateBlocked',
+ 'info' => 'The wiki tried to automatically create a new account ' .
+ 'for you, but your IP address has been blocked from account creation'
+ ),
array( 'code' => 'Throttled', 'info' => 'You\'ve logged in too many times in a short time' ),
array( 'code' => 'Blocked', 'info' => 'User is blocked' ),
) );
'none' => 'ApiFormatNone',
);
+ // @codingStandardsIgnoreStart String contenation on "msg" not allowed to break long line
/**
* List of user roles that are specifically relevant to the API.
* array( 'right' => array ( 'msg' => 'Some message with a $1',
'params' => array( ApiBase::LIMIT_SML2, ApiBase::LIMIT_BIG2 )
)
);
+ // @codingStandardsIgnoreEnd
/**
* @var ApiFormatBase
/**
* Constructs an instance of ApiMain that utilizes the module and format specified by $request.
*
- * @param $context IContextSource|WebRequest - if this is an instance of FauxRequest, errors are thrown and no printing occurs
+ * @param $context IContextSource|WebRequest - if this is an instance of
+ * FauxRequest, errors are thrown and no printing occurs
* @param bool $enableWrite should be set to true if the api may modify data
*/
public function __construct( $context = null, $enableWrite = false ) {
} else {
$origins = explode( ' ', $originHeader );
}
+
if ( !in_array( $originParam, $origins ) ) {
// origin parameter set but incorrect
// Send a 403 response
return false;
}
- if ( self::matchOrigin( $originParam, $wgCrossSiteAJAXdomains, $wgCrossSiteAJAXdomainExceptions ) ) {
+
+ $matchOrigin = self::matchOrigin(
+ $originParam,
+ $wgCrossSiteAJAXdomains,
+ $wgCrossSiteAJAXdomainExceptions
+ );
+
+ if ( $matchOrigin ) {
$response->header( "Access-Control-Allow-Origin: $originParam" );
$response->header( 'Access-Control-Allow-Credentials: true' );
$this->getOutput()->addVaryHeader( 'Origin' );
* @param string $value Origin header
* @param array $rules Set of wildcard rules
* @param array $exceptions Set of wildcard rules
- * @return bool True if $value matches a rule in $rules and doesn't match any rules in $exceptions, false otherwise
+ * @return bool True if $value matches a rule in $rules and doesn't match
+ * any rules in $exceptions, false otherwise
*/
protected static function matchOrigin( $value, $rules, $exceptions ) {
foreach ( $rules as $rule ) {
'code' => 'internal_api_error_' . get_class( $e ),
'info' => $info,
);
- ApiResult::setContent( $errMessage, $wgShowExceptionDetails ? "\n\n{$e->getTraceAsString()}\n\n" : '' );
+ ApiResult::setContent(
+ $errMessage,
+ $wgShowExceptionDetails ? "\n\n{$e->getTraceAsString()}\n\n" : ''
+ );
}
// Remember all the warnings to re-add them later
if ( !isset( $moduleParams['token'] ) ) {
$this->dieUsageMsg( array( 'missingparam', 'token' ) );
} else {
- if ( !$this->getUser()->matchEditToken( $moduleParams['token'], $salt, $this->getContext()->getRequest() ) ) {
+ if ( !$this->getUser()
+ ->matchEditToken( $moduleParams['token'], $salt, $this->getContext()->getRequest() )
+ ) {
$this->dieUsageMsg( 'sessionfailure' );
}
}
static $table;
if ( !$table ) {
$chars = ';@$!*(),/:';
- for ( $i = 0; $i < strlen( $chars ); $i++ ) {
+ $numChars = strlen( $chars );
+ for ( $i = 0; $i < $numChars; $i++ ) {
$table[rawurlencode( $chars[$i] )] = $chars[$i];
}
}
'smaxage' => 'Set the s-maxage header to this many seconds. Errors are never cached',
'maxage' => 'Set the max-age header to this many seconds. Errors are never cached',
'requestid' => 'Request ID to distinguish requests. This will just be output back to you',
- 'servedby' => 'Include the hostname that served the request in the results. Unconditionally shown on error',
+ 'servedby' => 'Include the hostname that served the request in the ' .
+ 'results. Unconditionally shown on error',
'origin' => array(
- 'When accessing the API using a cross-domain AJAX request (CORS), set this to the originating domain.',
- 'This must be included in any pre-flight request, and therefore must be part of the request URI (not the POST body).',
- 'This must match one of the origins in the Origin: header exactly, so it has to be set to something like http://en.wikipedia.org or https://meta.wikimedia.org .',
- 'If this parameter does not match the Origin: header, a 403 response will be returned.',
- 'If this parameter matches the Origin: header and the origin is whitelisted, an Access-Control-Allow-Origin header will be set.',
+ 'When accessing the API using a cross-domain AJAX request (CORS), set this to the',
+ 'originating domain. This must be included in any pre-flight request, and',
+ 'therefore must be part of the request URI (not the POST body). This must match',
+ 'one of the origins in the Origin: header exactly, so it has to be set to ',
+ 'something like http://en.wikipedia.org or https://meta.wikimedia.org . If this',
+ 'parameter does not match the Origin: header, a 403 response will be returned. If',
+ 'this parameter matches the Origin: header and the origin is whitelisted, an',
+ 'Access-Control-Allow-Origin header will be set.',
),
);
}
return array(
'',
'',
- '**********************************************************************************************************',
- '** **',
- '** This is an auto-generated MediaWiki API documentation page **',
- '** **',
- '** Documentation and Examples: **',
- '** https://www.mediawiki.org/wiki/API **',
- '** **',
- '**********************************************************************************************************',
+ '**********************************************************************************************',
+ '** **',
+ '** This is an auto-generated MediaWiki API documentation page **',
+ '** **',
+ '** Documentation and Examples: **',
+ '** https://www.mediawiki.org/wiki/API **',
+ '** **',
+ '**********************************************************************************************',
'',
'Status: All features shown on this page should be working, but the API',
' is still in active development, and may change at any time.',
' In the case of an invalid action being passed, these will have a value',
' of "unknown_action"',
'',
- ' For more information see https://www.mediawiki.org/wiki/API:Errors_and_warnings',
+ ' For more information see https://www.mediawiki.org' .
+ '/wiki/API:Errors_and_warnings',
'',
'Documentation: https://www.mediawiki.org/wiki/API:Main_page',
'FAQ https://www.mediawiki.org/wiki/API:FAQ',
'Mailing list: https://lists.wikimedia.org/mailman/listinfo/mediawiki-api',
'Api Announcements: https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce',
- 'Bugs & Requests: https://bugzilla.wikimedia.org/buglist.cgi?component=API&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&order=bugs.delta_ts',
+ 'Bugs & Requests: https://bugzilla.wikimedia.org/buglist.cgi?component=API&' .
+ 'bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&order=bugs.delta_ts',
'',
'',
'',
' Victor Vasiliev - vasilvv @ gmail . com',
' Bryan Tong Minh - bryan . tongminh @ gmail . com',
' Sam Reed - sam @ reedyboy . net',
- ' Yuri Astrakhan "<Firstname><Lastname>@gmail.com" (creator, lead developer Sep 2006-Sep 2007, 2012-present)',
+ ' Yuri Astrakhan "<Firstname><Lastname>@gmail.com" (creator, lead ' .
+ 'developer Sep 2006-Sep 2007, 2012-present)',
'',
'Please send your comments, suggestions and questions to mediawiki-api@lists.wikimedia.org',
'or file a bug report at https://bugzilla.wikimedia.org/'
/**
* @param $module ApiBase
- * @param string $paramName What type of request is this? e.g. action, query, list, prop, meta, format
+ * @param string $paramName What type of request is this? e.g. action,
+ * query, list, prop, meta, format
* @return string
*/
public static function makeHelpMsgHeader( $module, $paramName ) {
$this->dieUsageMsg( reset( $retval ) );
}
- $r = array( 'from' => $fromTitle->getPrefixedText(), 'to' => $toTitle->getPrefixedText(), 'reason' => $params['reason'] );
+ $r = array(
+ 'from' => $fromTitle->getPrefixedText(),
+ 'to' => $toTitle->getPrefixedText(),
+ 'reason' => $params['reason']
+ );
if ( $fromTitle->exists() ) {
//NOTE: we assume that if the old title exists, it's because it was re-created as
'noredirect' => 'Don\'t create a redirect',
'watch' => 'Add the page and the redirect to your watchlist',
'unwatch' => 'Remove the page and the redirect from your watchlist',
- 'watchlist' => 'Unconditionally add or remove the page from your watchlist, use preferences or do not change watch',
+ 'watchlist' => 'Unconditionally add or remove the page from your ' .
+ 'watchlist, use preferences or do not change watch',
'ignorewarnings' => 'Ignore any warnings'
);
}
public function getExamples() {
return array(
- 'api.php?action=move&from=Badtitle&to=Goodtitle&token=123ABC&reason=Misspelled%20title&movetalk=&noredirect='
+ 'api.php?action=move&from=Badtitle&to=Goodtitle&token=123ABC&' .
+ 'reason=Misspelled%20title&movetalk=&noredirect='
);
}
* @ingroup API
*/
class ApiOptions extends ApiBase {
-
/**
* Changes preferences of the current user.
*/
'token' => 'An options token previously obtained through the action=tokens',
'reset' => 'Resets preferences to the site defaults',
'resetkinds' => 'List of types of options to reset when the "reset" option is set',
- 'change' => 'List of changes, formatted name=value (e.g. skin=vector), value cannot contain pipe characters. If no value is given (not even an equals sign), e.g., optionname|otheroption|..., the option will be reset to its default value',
+ 'change' => 'List of changes, formatted name=value (e.g. skin=vector), ' .
+ 'value cannot contain pipe characters. If no value is given (not ' .
+ 'even an equals sign), e.g., optionname|otheroption|..., the ' .
+ 'option will be reset to its default value',
'optionname' => 'A name of a option which should have an optionvalue set',
- 'optionvalue' => 'A value of the option specified by the optionname, can contain pipe characters',
+ 'optionvalue' => 'A value of the option specified by the optionname, ' .
+ 'can contain pipe characters',
);
}
return array(
'Change preferences of the current user',
'Only options which are registered in core or in one of installed extensions,',
- 'or as options with keys prefixed with \'userjs-\' (intended to be used by user scripts), can be set.'
+ 'or as options with keys prefixed with \'userjs-\' (intended to be used by user',
+ 'scripts), can be set.'
);
}
return array(
'api.php?action=options&reset=&token=123ABC',
'api.php?action=options&change=skin=vector|hideminor=1&token=123ABC',
- 'api.php?action=options&reset=&change=skin=monobook&optionname=nickname&optionvalue=[[User:Beau|Beau]]%20([[User_talk:Beau|talk]])&token=123ABC',
+ 'api.php?action=options&reset=&change=skin=monobook&optionname=nickname&' .
+ 'optionvalue=[[User:Beau|Beau]]%20([[User_talk:Beau|talk]])&token=123ABC',
);
}
}
=>'If translations for extmetadata property are available, fetch all of them.',
'extmetadatafilter'
=> "If specified and non-empty, only these keys will be returned for {$p}prop=extmetadata",
- 'continue' => 'If the query response includes a continue value, use it here to get another page of results',
+ 'continue' => 'If the query response includes a continue value, ' .
+ 'use it here to get another page of results',
'localonly' => 'Look only for files in the local repository',
);
}