X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryLangBacklinks.php;h=8d5b5f3ea6a2c6c511a1c7c76a1863ea20cec4e3;hb=2b7d97e6a49c46eeb0e1018dd51ae5e79b2f373e;hp=9f77b84a4710b3312a82f16d77ae78561cf8f4c5;hpb=27808a526c6afb22c1a56e98bc6c177c82c27f96;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryLangBacklinks.php b/includes/api/ApiQueryLangBacklinks.php index 9f77b84a47..8d5b5f3ea6 100644 --- a/includes/api/ApiQueryLangBacklinks.php +++ b/includes/api/ApiQueryLangBacklinks.php @@ -51,7 +51,14 @@ class ApiQueryLangBacklinks extends ApiQueryGeneratorBase { $params = $this->extractRequestParams(); if ( isset( $params['title'] ) && !isset( $params['lang'] ) ) { - $this->dieUsageMsg( array( 'missingparam', 'lang' ) ); + $this->dieWithError( + [ + 'apierror-invalidparammix-mustusewith', + $this->encodeParamName( 'title' ), + $this->encodeParamName( 'lang' ) + ], + 'nolang' + ); } if ( !is_null( $params['continue'] ) ) { @@ -76,11 +83,11 @@ class ApiQueryLangBacklinks extends ApiQueryGeneratorBase { $lllang = isset( $prop['lllang'] ); $lltitle = isset( $prop['lltitle'] ); - $this->addTables( array( 'langlinks', 'page' ) ); + $this->addTables( [ 'langlinks', 'page' ] ); $this->addWhere( 'll_from = page_id' ); - $this->addFields( array( 'page_id', 'page_title', 'page_namespace', 'page_is_redirect', - 'll_from', 'll_lang', 'll_title' ) ); + $this->addFields( [ 'page_id', 'page_title', 'page_namespace', 'page_is_redirect', + 'll_from', 'll_lang', 'll_title' ] ); $sort = ( $params['dir'] == 'descending' ? ' DESC' : '' ); if ( isset( $params['lang'] ) ) { @@ -89,24 +96,24 @@ class ApiQueryLangBacklinks extends ApiQueryGeneratorBase { $this->addWhereFld( 'll_title', $params['title'] ); $this->addOption( 'ORDER BY', 'll_from' . $sort ); } else { - $this->addOption( 'ORDER BY', array( + $this->addOption( 'ORDER BY', [ 'll_title' . $sort, 'll_from' . $sort - ) ); + ] ); } } else { - $this->addOption( 'ORDER BY', array( + $this->addOption( 'ORDER BY', [ 'll_lang' . $sort, 'll_title' . $sort, 'll_from' . $sort - ) ); + ] ); } $this->addOption( 'LIMIT', $params['limit'] + 1 ); $res = $this->select( __METHOD__ ); - $pages = array(); + $pages = []; $count = 0; $result = $this->getResult(); @@ -125,7 +132,7 @@ class ApiQueryLangBacklinks 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 ); @@ -142,7 +149,7 @@ class ApiQueryLangBacklinks extends ApiQueryGeneratorBase { $entry['lltitle'] = $row->ll_title; } - $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $entry ); + $fit = $result->addValue( [ 'query', $this->getModuleName() ], null, $entry ); if ( !$fit ) { $this->setContinueEnumParameter( 'continue', @@ -154,7 +161,7 @@ class ApiQueryLangBacklinks extends ApiQueryGeneratorBase { } if ( is_null( $resultPageSet ) ) { - $result->addIndexedTagName( array( 'query', $this->getModuleName() ), 'll' ); + $result->addIndexedTagName( [ 'query', $this->getModuleName() ], 'll' ); } else { $resultPageSet->populateFromTitles( $pages ); } @@ -165,45 +172,45 @@ class ApiQueryLangBacklinks extends ApiQueryGeneratorBase { } public function getAllowedParams() { - return array( + return [ 'lang' => 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 => [ 'lllang', 'lltitle', - ), - ApiBase::PARAM_HELP_MSG_PER_VALUE => array(), - ), - '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=langbacklinks&lbltitle=Test&lbllang=fr' => 'apihelp-query+langbacklinks-example-simple', 'action=query&generator=langbacklinks&glbltitle=Test&glbllang=fr&prop=info' => 'apihelp-query+langbacklinks-example-generator', - ); + ]; } public function getHelpUrls() {