summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/Translate/api/ApiQueryMessageTranslations.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/Translate/api/ApiQueryMessageTranslations.php')
-rw-r--r--www/wiki/extensions/Translate/api/ApiQueryMessageTranslations.php51
1 files changed, 24 insertions, 27 deletions
diff --git a/www/wiki/extensions/Translate/api/ApiQueryMessageTranslations.php b/www/wiki/extensions/Translate/api/ApiQueryMessageTranslations.php
index ccec4634..13eed8b6 100644
--- a/www/wiki/extensions/Translate/api/ApiQueryMessageTranslations.php
+++ b/www/wiki/extensions/Translate/api/ApiQueryMessageTranslations.php
@@ -4,7 +4,7 @@
*
* @file
* @author Niklas Laxström
- * @license GPL-2.0+
+ * @license GPL-2.0-or-later
*/
/**
@@ -31,28 +31,28 @@ class ApiQueryMessageTranslations extends ApiQueryBase {
$namespace = $handle->getTitle()->getNamespace();
$base = $handle->getKey();
- $dbr = wfGetDB( DB_SLAVE );
+ $dbr = wfGetDB( DB_REPLICA );
$res = $dbr->select( 'page',
- array( 'page_namespace', 'page_title' ),
- array(
+ [ 'page_namespace', 'page_title' ],
+ [
'page_namespace' => $namespace,
'page_title ' . $dbr->buildLike( "$base/", $dbr->anyString() ),
- ),
+ ],
__METHOD__,
- array(
+ [
'ORDER BY' => 'page_title',
'USE INDEX' => 'name_title',
- )
+ ]
);
- $titles = array();
+ $titles = [];
foreach ( $res as $row ) {
$titles[] = $row->page_title;
}
- if ( $titles === array() ) {
- return array();
+ if ( $titles === [] ) {
+ return [];
}
$pageInfo = TranslateUtils::getContents( $titles, $namespace );
@@ -65,15 +65,12 @@ class ApiQueryMessageTranslations extends ApiQueryBase {
$title = Title::newFromText( $params['title'] );
if ( !$title ) {
- $this->dieUsage( 'Invalid title', 'invalidtitle' );
+ $this->dieWithError( [ 'apierror-invalidtitle', wfEscapeWikiText( $params['title'] ) ] );
}
$handle = new MessageHandle( $title );
if ( !$handle->isValid() ) {
- $this->dieUsage(
- 'Title does not correspond to a translatable message',
- 'nomessagefortitle'
- );
+ $this->dieWithError( 'apierror-translate-nomessagefortitle', 'nomessagefortitle' );
}
$namespace = $title->getNamespace();
@@ -90,11 +87,11 @@ class ApiQueryMessageTranslations extends ApiQueryBase {
$tTitle = Title::makeTitle( $namespace, $key );
$tHandle = new MessageHandle( $tTitle );
- $data = array(
+ $data = [
'title' => $tTitle->getPrefixedText(),
'language' => $tHandle->getCode(),
'lasttranslator' => $info[1],
- );
+ ];
$fuzzy = MessageHandle::hasFuzzyString( $info[0] ) || $tHandle->isFuzzy();
@@ -105,34 +102,34 @@ class ApiQueryMessageTranslations extends ApiQueryBase {
$translation = str_replace( TRANSLATE_FUZZY, '', $info[0] );
ApiResult::setContentValue( $data, 'translation', $translation );
- $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $data );
+ $fit = $result->addValue( [ 'query', $this->getModuleName() ], null, $data );
if ( !$fit ) {
$this->setContinueEnumParameter( 'offset', $count );
break;
}
}
- $result->addIndexedTagName( array( 'query', $this->getModuleName() ), 'message' );
+ $result->addIndexedTagName( [ 'query', $this->getModuleName() ], 'message' );
}
public function getAllowedParams() {
- return array(
- 'title' => array(
+ return [
+ 'title' => [
ApiBase::PARAM_TYPE => 'string',
ApiBase::PARAM_REQUIRED => true,
- ),
- 'offset' => array(
+ ],
+ 'offset' => [
ApiBase::PARAM_DFLT => 0,
ApiBase::PARAM_TYPE => 'integer',
ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
- ),
- );
+ ],
+ ];
}
protected function getExamplesMessages() {
- return array(
+ return [
'action=query&meta=messagetranslations&mttitle=MediaWiki:January'
=> 'apihelp-query+messagetranslations-example-1',
- );
+ ];
}
}