summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/Translate/specials/SpecialManageTranslatorSandbox.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/Translate/specials/SpecialManageTranslatorSandbox.php')
-rw-r--r--www/wiki/extensions/Translate/specials/SpecialManageTranslatorSandbox.php43
1 files changed, 28 insertions, 15 deletions
diff --git a/www/wiki/extensions/Translate/specials/SpecialManageTranslatorSandbox.php b/www/wiki/extensions/Translate/specials/SpecialManageTranslatorSandbox.php
index c729c121..28311452 100644
--- a/www/wiki/extensions/Translate/specials/SpecialManageTranslatorSandbox.php
+++ b/www/wiki/extensions/Translate/specials/SpecialManageTranslatorSandbox.php
@@ -5,7 +5,7 @@
* @file
* @author Niklas Laxström
* @author Amir E. Aharoni
- * @license GPL-2.0+
+ * @license GPL-2.0-or-later
*/
/**
@@ -38,6 +38,11 @@ class SpecialManageTranslatorSandbox extends SpecialPage {
$this->setHeaders();
$this->checkPermissions();
$out = $this->getOutput();
+ $out->addModuleStyles( [
+ 'ext.translate.special.managetranslatorsandbox.styles',
+ 'mediawiki.ui.button',
+ 'jquery.uls.grid'
+ ] );
$out->addModules( 'ext.translate.special.managetranslatorsandbox' );
$this->stash = new TranslationStashStorage( wfGetDB( DB_MASTER ) );
@@ -85,8 +90,8 @@ class SpecialManageTranslatorSandbox extends SpecialPage {
// to ensure the number of users is what the tests expect
$this->emptySandbox();
- $textUsernamePrefixes = array( 'Pupu', 'Orava' );
- $testLanguages = array( 'fi', 'uk', 'nl', 'he', 'bn' );
+ $textUsernamePrefixes = [ 'Pupu', 'Orava' ];
+ $testLanguages = [ 'fi', 'uk', 'nl', 'he', 'bn' ];
$testLanguagesCount = count( $testLanguages );
foreach ( $textUsernamePrefixes as $prefix ) {
@@ -101,13 +106,13 @@ class SpecialManageTranslatorSandbox extends SpecialPage {
$user = TranslateSandbox::addUser( $name, "$name@blackhole.io", 'porkkana' );
$user->setOption(
'translate-sandbox',
- FormatJson::encode( array(
- 'languages' => array( $testLanguages[$i] ),
+ FormatJson::encode( [
+ 'languages' => [ $testLanguages[$i] ],
'comment' => '',
- ) )
+ ] )
);
- $reminders = array();
+ $reminders = [];
for ( $reminderIndex = 0; $reminderIndex < $i; $reminderIndex++ ) {
$reminders[] = wfTimestamp() - $reminderIndex * $i * 10000;
}
@@ -138,10 +143,10 @@ class SpecialManageTranslatorSandbox extends SpecialPage {
$polyglotUser = TranslateSandbox::addUser( 'Kissa', 'kissa@blackhole.io', 'porkkana' );
$polyglotUser->setOption(
'translate-sandbox',
- FormatJson::encode( array(
+ FormatJson::encode( [
'languages' => $testLanguages,
'comment' => "I know some languages, and I'm a developer.",
- ) )
+ ] )
);
$polyglotUser->saveSettings();
for ( $polyglotLang = 0; $polyglotLang < $testLanguagesCount; $polyglotLang++ ) {
@@ -175,6 +180,14 @@ class SpecialManageTranslatorSandbox extends SpecialPage {
*/
protected function showPage() {
$out = $this->getOutput();
+
+ $nojs = Html::element(
+ 'div',
+ [ 'class' => 'tux-nojs errorbox' ],
+ $this->msg( 'tux-nojs' )->plain()
+ );
+ $out->addHTML( $nojs );
+
$out->addHTML( <<<HTML
<div class="grid">
<div class="row">
@@ -212,14 +225,14 @@ HTML;
}
protected function makeList() {
- $items = array();
- $requests = array();
+ $items = [];
+ $requests = [];
$users = TranslateSandbox::getUsers();
/** @var User $user */
foreach ( $users as $user ) {
$reminders = $user->getOption( 'translate-sandbox-reminders' );
- $reminders = $reminders ? explode( '|', $reminders ) : array();
+ $reminders = $reminders ? explode( '|', $reminders ) : [];
$remindersCount = count( $reminders );
if ( $remindersCount ) {
$lastReminderTimestamp = new MWTimestamp( end( $reminders ) );
@@ -230,7 +243,7 @@ HTML;
$lastReminderAgo = '';
}
- $requests[] = array(
+ $requests[] = [
'username' => $user->getName(),
'email' => $user->getEmail(),
'gender' => $user->getOption( 'gender' ),
@@ -240,11 +253,11 @@ HTML;
'userid' => $user->getId(),
'reminderscount' => $remindersCount,
'lastreminder' => $lastReminderAgo,
- );
+ ];
}
// Sort the requests based on translations and registration date
- usort( $requests, array( __CLASS__, 'translatorRequestSort' ) );
+ usort( $requests, [ __CLASS__, 'translatorRequestSort' ] );
foreach ( $requests as $request ) {
$items[] = $this->makeRequestItem( $request );