$isArray = is_array( $paramSettings[self::PARAM_TYPE] );
if ( !$isArray
- || $isArray && count( $paramSettings[self::PARAM_TYPE] ) > self::LIMIT_SML1) {
+ || $isArray && count( $paramSettings[self::PARAM_TYPE] ) > self::LIMIT_SML1 ) {
$desc .= $paramPrefix . "Maximum number of values " .
self::LIMIT_SML1 . " (" . self::LIMIT_SML2 . " for bots)";
}
if ( !$titleObj || $titleObj->isExternal() ) {
$this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
}
-
- if( $params['redirect'] ) {
- if( $titleObj->isRedirect() ) {
+
+ if ( $params['redirect'] ) {
+ if ( $titleObj->isRedirect() ) {
$oldTitle = $titleObj;
-
+
$titles = Title::newFromRedirectArray( Revision::newFromTitle( $oldTitle )->getText( Revision::FOR_THIS_USER ) );
- //array_shift( $titles );
-
+ // array_shift( $titles );
+
$this->getResult()->addValue( null, 'foo', $titles );
-
-
+
+
$redirValues = array();
foreach ( $titles as $id => $newTitle ) {
-
- if( !isset( $titles[ $id - 1 ] ) ) {
+
+ if ( !isset( $titles[ $id - 1 ] ) ) {
$titles[ $id - 1 ] = $oldTitle;
}
-
+
$redirValues[] = array(
'from' => $titles[ $id - 1 ]->getPrefixedText(),
'to' => $newTitle->getPrefixedText()
);
-
+
$titleObj = $newTitle;
}
-
+
$this->getResult()->setIndexedTagName( $redirValues, 'r' );
$this->getResult()->addValue( null, 'redirects', $redirValues );
'allrev' => 'Include multiple revisions of the same page within given timeframe',
'wlowner' => "The user whose watchlist you want (must be accompanied by {$this->getModulePrefix()}token if it's not you)",
'wltoken' => 'Security token that requested user set in their preferences',
- 'linktodiffs'=> 'Link to change differences instead of article pages'
+ 'linktodiffs' => 'Link to change differences instead of article pages'
);
}
$wgTitle = $titleObj;
- //If for some reason the "oldid" is actually the current revision, it may be cached
+ // If for some reason the "oldid" is actually the current revision, it may be cached
if ( $titleObj->getLatestRevID() === $oldid ) {
$p_result = false;
$pcache = ParserCache::singleton();
private $mPropModuleNames, $mListModuleNames, $mMetaModuleNames;
/**
- * @var ApiPageSet
+ * @var ApiPageSet
*/
private $mPageSet;
private function doExport( $pageSet, $result ) {
$exportTitles = array();
$titles = $pageSet->getGoodTitles();
- if( count( $titles ) ) {
+ if ( count( $titles ) ) {
foreach ( $titles as $title ) {
if ( $title->userCanRead() ) {
$exportTitles[] = $title;
if ( $skip && $message === $params['from'] ) {
$skip = false;
}
-
- if( $useto && $message > $params['to'] ) {
+
+ if ( $useto && $message > $params['to'] ) {
break;
}
$from = ( is_null( $params['from'] ) ? null : $this->titlePartToKey( $params['from'] ) );
$to = ( is_null( $params['to'] ) ? null : $this->titlePartToKey( $params['to'] ) );
$this->addWhereRange( 'page_title', $dir, $from, $to );
-
+
if ( isset( $params['prefix'] ) ) {
$this->addWhere( 'page_title' . $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) );
}
// We've reached the one extra which shows that there are additional pages to be had. Stop here...
// We need to keep the parent page of this redir in
if ( $this->hasNS ) {
- $parentID = $this->pageMap[$row->{$this->bl_ns}][$row->{$this->bl_title}];
+ $parentID = $this->pageMap[$row-> { $this->bl_ns } ][$row-> { $this->bl_title } ];
} else {
- $parentID = $this->pageMap[NS_IMAGE][$row->{$this->bl_title}];
+ $parentID = $this->pageMap[NS_IMAGE][$row-> { $this->bl_title } ];
}
$this->continueStr = $this->getContinueRedirStr( $parentID, $row->page_id );
break;
if ( $this->fld_userid ) {
$vals['userid'] = $row->user_id;
}
-
+
if ( !$row->log_user ) {
$vals['anon'] = '';
}
public function execute() {
$this->params = $this->extractRequestParams();
-
+
# Only operate on existing pages
$pages = $this->getPageSet()->getGoodTitles();
if ( !count( $pages ) ) {
# Nothing to do
return;
}
-
+
$this->addTables( 'page_props' );
$this->addFields( array( 'pp_page', 'pp_propname', 'pp_value' ) );
$this->addWhereFld( 'pp_page', array_keys( $pages ) );
-
+
if ( $this->params['continue'] ) {
$this->addWhere( 'pp_page >=' . intval( $this->params['continue'] ) );
}
-
+
# Force a sort order to ensure that properties are grouped by page
$this->addOption( 'ORDER BY', 'pp_page' );
-
+
$res = $this->select( __METHOD__ );
$currentPage = 0; # Id of the page currently processed
$props = array();
$result = $this->getResult();
-
+
foreach ( $res as $row ) {
if ( $currentPage != $row->pp_page ) {
- # Different page than previous row, so add the properties to
+ # Different page than previous row, so add the properties to
# the result and save the new page id
-
+
if ( $currentPage ) {
if ( !$this->addPageProps( $result, $currentPage, $props ) ) {
# addPageProps() indicated that the result did not fit
# so stop adding data. Reset props so that it doesn't
# get added again after loop exit
-
+
$props = array();
break;
}
-
+
$props = array();
}
-
+
$currentPage = $row->pp_page;
}
-
+
$props[$row->pp_propname] = $row->pp_value;
}
-
+
if ( count( $props ) ) {
# Add any remaining properties to the results
$this->addPageProps( $result, $currentPage, $props );
}
/**
- * Add page properties to an ApiResult, adding a continue
+ * Add page properties to an ApiResult, adding a continue
* parameter if it doesn't fit.
*
* @param $result ApiResult
*/
private function addPageProps( $result, $page, $props ) {
$fit = $result->addValue( array( 'query', 'pages' ), $page, $props );
-
+
if ( !$fit ) {
$this->setContinueEnumParameter( 'continue', $page );
}
return 'public';
}
- public function getAllowedParams() {
+ public function getAllowedParams() {
return array( 'continue' => null );
}
if ( is_null( $cachedPatrolToken ) ) {
$cachedPatrolToken = $wgUser->editToken( 'patrol' );
}
-
+
return $cachedPatrolToken;
}
$this->getResult()->setParsedLimit( $this->getModuleName(), $limit );
}
-
+
if ( !is_null( $this->token ) || $pageCount > 0 ) {
$this->addFields( Revision::selectPageFields() );
}
}
}
- //Bug 24166 - API error when using rvprop=tags
+ // Bug 24166 - API error when using rvprop=tags
$this->addTables( 'revision' );
}
if ( $this->parseContent ) {
global $wgEnableParserCache;
-
+
$popts = new ParserOptions();
$popts->setTidy( true );
-
+
$articleObj = new Article( $title );
$p_result = false;
$pcache->save( $p_result, $articleObj, $popts );
}
}
-
+
$text = $p_result->getText();
}
ApiResult::setContent( $vals, $text );
protected function appendUserGroups( $property, $numberInGroup ) {
global $wgGroupPermissions, $wgAddGroups, $wgRemoveGroups, $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf;
-
+
$data = array();
foreach ( $wgGroupPermissions as $group => $permissions ) {
$arr = array(
'name' => $group,
'rights' => array_keys( $permissions, true ),
);
-
+
if ( $numberInGroup ) {
global $wgAutopromote;
-
+
if ( $group == 'user' ) {
$arr['number'] = SiteStats::users();
-
+
// '*' and autopromote groups have no size
} elseif ( $group !== '*' && !isset( $wgAutopromote[$group] ) ) {
$arr['number'] = SiteStats::numberInGroup( $group );
}
}
-
+
$groupArr = array(
'add' => $wgAddGroups,
'remove' => $wgRemoveGroups,
'add-self' => $wgGroupsAddToSelf,
'remove-self' => $wgGroupsRemoveFromSelf
);
-
- foreach( $groupArr as $type => $rights ) {
- if( isset( $rights[$group] ) ) {
+
+ foreach ( $groupArr as $type => $rights ) {
+ if ( isset( $rights[$group] ) ) {
$arr[$type] = $rights[$group];
$this->getResult()->setIndexedTagName( $arr[$type], 'group' );
}
}
-
+
$this->getResult()->setIndexedTagName( $arr['rights'], 'permission' );
$data[] = $arr;
}
-
+
$this->getResult()->setIndexedTagName( $data, 'group' );
return $this->getResult()->addValue( 'query', $property, $data );
}
}
if ( $this->fld_userid ) {
- $vals['user'] = $row->rc_user;
+ $vals['user'] = $row->rc_user;
}
if ( !$row->rc_user ) {
parent::__construct( $main, $format );
$this->setRootElement( 'rsd' );
}
-
+
public function getMimeType() {
return 'application/rsd+xml';
}
// Prepare the API result
$result = array();
-
+
$warnings = $this->getApiWarnings();
- if ( $warnings ) {
+ if ( $warnings ) {
$result['result'] = 'Warning';
$result['warnings'] = $warnings;
// in case the warnings can be fixed with some further user action, let's stash this upload
// and return a key they can use to restart it
- try {
+ try {
$result['sessionkey'] = $this->performStash();
- } catch ( MWException $e ) {
+ } catch ( MWException $e ) {
$result['warnings']['stashfailed'] = $e->getMessage();
}
- } elseif ( $this->mParams['stash'] ) {
+ } elseif ( $this->mParams['stash'] ) {
// Some uploads can request they be stashed, so as not to publish them immediately.
// In this case, a failure to stash ought to be fatal
try {
- $result['result'] = 'Success';
+ $result['result'] = 'Success';
$result['sessionkey'] = $this->performStash();
- } catch ( MWException $e ) {
+ } catch ( MWException $e ) {
$this->dieUsage( $e->getMessage(), 'stashfailed' );
}
} else {
$result = $this->performUpload();
}
- if ( $result['result'] === 'Success' ) {
+ if ( $result['result'] === 'Success' ) {
$result['imageinfo'] = $this->mUpload->getImageInfo( $this->getResult() );
}
$this->getResult()->addValue( null, $this->getModuleName(), $result );
-
+
// Cleanup any temporary mess
$this->mUpload->cleanupTempFile();
}
try {
$sessionKey = $this->mUpload->stashSessionFile()->getSessionKey();
} catch ( MWException $e ) {
- throw new MWException( 'Stashing temporary file failed: ' . get_class($e) . ' ' . $e->getMessage() );
+ throw new MWException( 'Stashing temporary file failed: ' . get_class( $e ) . ' ' . $e->getMessage() );
}
return $sessionKey;
}
/**
* Select an upload module and set it to mUpload. Dies on failure. If the
- * request was a status request and not a true upload, returns false;
+ * request was a status request and not a true upload, returns false;
* otherwise true
- *
+ *
* @return bool
*/
protected function selectUploadModule() {
// Status request for an async upload
$sessionData = UploadFromUrlJob::getSessionData( $this->mParams['statuskey'] );
if ( !isset( $sessionData['result'] ) ) {
- $this->dieUsage( 'No result in session data', 'missingresult');
+ $this->dieUsage( 'No result in session data', 'missingresult' );
}
if ( $sessionData['result'] == 'Warning' ) {
$sessionData['warnings'] = $this->transformWarnings( $sessionData['warnings'] );
}
$this->getResult()->addValue( null, $this->getModuleName(), $sessionData );
return false;
-
- }
+
+ }
// The following modules all require the filename parameter to be set
if ( is_null( $this->mParams['filename'] ) ) {
$this->dieUsageMsg( array( 'missingparam', 'filename' ) );
}
-
+
if ( $this->mParams['sessionkey'] ) {
// Upload stashed in a previous request
$this->dieUsage( 'Using leavemessage without ignorewarnings is not supported',
'missing-ignorewarnings' );
}
-
+
if ( $this->mParams['leavemessage'] ) {
$async = 'async-leavemessage';
} else {
$this->mParams['url'], $async );
}
-
+
return true;
}