X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryIWBacklinks.php;h=2fe4bd9198c01e0067b03f0cbb07ad506a93fadf;hb=d5a7166771613dfe4ed9fb75fa5efeced6134bd1;hp=618387d2b791ed5839671ddf17e165ccce89ad19;hpb=a13b5429abe617b09783000a650b237c1f0eb608;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryIWBacklinks.php b/includes/api/ApiQueryIWBacklinks.php index 618387d2b7..a10ba164a2 100644 --- a/includes/api/ApiQueryIWBacklinks.php +++ b/includes/api/ApiQueryIWBacklinks.php @@ -51,7 +51,14 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase { $params = $this->extractRequestParams(); if ( isset( $params['title'] ) && !isset( $params['prefix'] ) ) { - $this->dieUsageMsg( array( 'missingparam', 'prefix' ) ); + $this->dieWithError( + [ + 'apierror-invalidparammix-mustusewith', + $this->encodeParamName( 'title' ), + $this->encodeParamName( 'prefix' ), + ], + 'invalidparammix' + ); } if ( !is_null( $params['continue'] ) ) { @@ -76,11 +83,11 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase { $iwprefix = isset( $prop['iwprefix'] ); $iwtitle = isset( $prop['iwtitle'] ); - $this->addTables( array( 'iwlinks', 'page' ) ); + $this->addTables( [ 'iwlinks', 'page' ] ); $this->addWhere( 'iwl_from = page_id' ); - $this->addFields( array( 'page_id', 'page_title', 'page_namespace', 'page_is_redirect', - 'iwl_from', 'iwl_prefix', 'iwl_title' ) ); + $this->addFields( [ 'page_id', 'page_title', 'page_namespace', 'page_is_redirect', + 'iwl_from', 'iwl_prefix', 'iwl_title' ] ); $sort = ( $params['dir'] == 'descending' ? ' DESC' : '' ); if ( isset( $params['prefix'] ) ) { @@ -89,24 +96,24 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase { $this->addWhereFld( 'iwl_title', $params['title'] ); $this->addOption( 'ORDER BY', 'iwl_from' . $sort ); } else { - $this->addOption( 'ORDER BY', array( + $this->addOption( 'ORDER BY', [ 'iwl_title' . $sort, 'iwl_from' . $sort - ) ); + ] ); } } else { - $this->addOption( 'ORDER BY', array( + $this->addOption( 'ORDER BY', [ 'iwl_prefix' . $sort, 'iwl_title' . $sort, 'iwl_from' . $sort - ) ); + ] ); } $this->addOption( 'LIMIT', $params['limit'] + 1 ); $res = $this->select( __METHOD__ ); - $pages = array(); + $pages = []; $count = 0; $result = $this->getResult(); @@ -126,7 +133,7 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase { if ( !is_null( $resultPageSet ) ) { $pages[] = Title::newFromRow( $row ); } else { - $entry = array( 'pageid' => $row->page_id ); + $entry = [ 'pageid' => $row->page_id ]; $title = Title::makeTitle( $row->page_namespace, $row->page_title ); ApiQueryBase::addTitleInfo( $entry, $title ); @@ -143,7 +150,7 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase { $entry['iwtitle'] = $row->iwl_title; } - $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $entry ); + $fit = $result->addValue( [ 'query', $this->getModuleName() ], null, $entry ); if ( !$fit ) { $this->setContinueEnumParameter( 'continue', @@ -155,7 +162,7 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase { } if ( is_null( $resultPageSet ) ) { - $result->addIndexedTagName( array( 'query', $this->getModuleName() ), 'iw' ); + $result->addIndexedTagName( [ 'query', $this->getModuleName() ], 'iw' ); } else { $resultPageSet->populateFromTitles( $pages ); } @@ -166,47 +173,48 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase { } public function getAllowedParams() { - return array( + return [ 'prefix' => null, 'title' => null, - 'continue' => array( + 'continue' => [ ApiBase::PARAM_HELP_MSG => 'api-help-param-continue', - ), - 'limit' => array( + ], + 'limit' => [ ApiBase::PARAM_DFLT => 10, ApiBase::PARAM_TYPE => 'limit', ApiBase::PARAM_MIN => 1, ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1, ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2 - ), - 'prop' => array( + ], + 'prop' => [ ApiBase::PARAM_ISMULTI => true, ApiBase::PARAM_DFLT => '', - ApiBase::PARAM_TYPE => array( + ApiBase::PARAM_TYPE => [ 'iwprefix', 'iwtitle', - ), - ), - 'dir' => array( + ], + ApiBase::PARAM_HELP_MSG_PER_VALUE => [], + ], + 'dir' => [ ApiBase::PARAM_DFLT => 'ascending', - ApiBase::PARAM_TYPE => array( + ApiBase::PARAM_TYPE => [ 'ascending', 'descending' - ) - ), - ); + ] + ], + ]; } protected function getExamplesMessages() { - return array( + return [ 'action=query&list=iwbacklinks&iwbltitle=Test&iwblprefix=wikibooks' => 'apihelp-query+iwbacklinks-example-simple', 'action=query&generator=iwbacklinks&giwbltitle=Test&giwblprefix=wikibooks&prop=info' => 'apihelp-query+iwbacklinks-example-generator', - ); + ]; } public function getHelpUrls() { - return 'https://www.mediawiki.org/wiki/API:Iwbacklinks'; + return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Iwbacklinks'; } }