Jack Phoenix has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/311991

Change subject: Slightly modernize NewTalkGlobal in preparation for archiving it
......................................................................

Slightly modernize NewTalkGlobal in preparation for archiving it

MW 1.25+ is now required as the main entry point changed from PHP to JSON;
ditto for i18n stuff.

Bug: T146242
Change-Id: Ic8e66c7a8d7f0446149b32e2c9f9e00a7d2a4479
---
M NewTalkGlobal.body.php
D NewTalkGlobal.i18n.php
D NewTalkGlobal.php
A extension.json
A i18n/en.json
A i18n/ka.json
A i18n/qqq.json
A i18n/vi.json
8 files changed, 76 insertions(+), 70 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/NewTalkGlobal 
refs/changes/91/311991/1

diff --git a/NewTalkGlobal.body.php b/NewTalkGlobal.body.php
index be4333d..fe56307 100644
--- a/NewTalkGlobal.body.php
+++ b/NewTalkGlobal.body.php
@@ -3,35 +3,33 @@
 class NewTalkGlobal {
 
        public static function onGetNewMessagesAlert( &$ntl, array $newtalks, 
User $user, OutputPage $out ) {
+               global $newTalkGlobalDatabases;
 
                $ntl = '';
 
-               global $newTalkGlobalDatabases;
-
                $msgs = array();
 
-               foreach( $newTalkGlobalDatabases as $wiki => $data ){
+               foreach ( $newTalkGlobalDatabases as $wiki => $data ) {
                        $dbr = wfGetDB( DB_SLAVE, array(), $data['db'] );
 
-                       if( $user->isAnon() ){
-                               $res = $dbr->select(
-                                               "user_newtalk",
-                                               "user_last_timestamp",
-                                               array( "user_ip" => $user -> 
getName() )
-                               );
+                       if ( $user->isAnon() ) {
+                               $where = array( 'user_ip' => $user->getName() );
                        } else {
-                               $res = $dbr->select(
-                                               "user_newtalk",
-                                               "user_last_timestamp",
-                                               array( "user_id" => $user -> 
getId() )
-                               );
+                               $where = array( 'user_id' => $user->getId() );
                        }
 
-                       if( $res->numRows() != 0 ) {
+                       $res = $dbr->select(
+                               'user_newtalk',
+                               'user_last_timestamp',
+                               $where,
+                               __METHOD__
+                       );
+
+                       if ( $res->numRows() != 0 ) {
                                $msgs[] = Xml::element(
-                                               'a',
-                                               array( 'href' => 
"{$data['url']}User_talk:$user" ),
-                                               $data['name']
+                                       'a',
+                                       array( 'href' => 
"{$data['url']}User_talk:$user" ),
+                                       $data['name']
                                );
                        }
                }
@@ -39,9 +37,10 @@
                $sep = str_replace( '_', ' ', wfMessage( 'newtalkseparator' 
)->escaped() );
                $parts = implode( $sep, $msgs );
 
-               if( count( $msgs ) ) {
+               if ( count( $msgs ) ) {
                        $ntl = wfMessage( 'youhavenewmessagesmulti' 
)->rawParams( $parts )->escaped();
                }
+
                return true;
        }
 }
\ No newline at end of file
diff --git a/NewTalkGlobal.i18n.php b/NewTalkGlobal.i18n.php
deleted file mode 100644
index 0df53df..0000000
--- a/NewTalkGlobal.i18n.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-
-$messages = array();
-
-/** English (English)
- * @author UltrasonicNXT
- */
-$messages[ 'en' ] = array(
-       'newtalkglobal' => 'newtalkglobal', 
-       'newtalkglobal-desc' => 'Shows talk page messages received on any 
project of a wikifarm',
-);
-
-/** Georgian (ქართული)
- * @author ToaMeiko
- */
-$messages['ka'] = array(
-       'newtalkglobal' => 'თოქ გლობალურ',
-       'newtalkglobal-desc' => 'მონიტორები გაიგო გვერდი შეტყობინებები მიღებული 
ნებისმიერი პროექტის ვიკი ფერმაში',
-);
-
-/** Message documentation (Message documentation)
- * @author UltrasonicNXT
- */
-$messages[ 'qqq' ] = array(
-       'newtalkglobal' => 'The name of the extension',
-       'newtalkglobal-desc' => '{{desc}}',
-);
-
-/** Vietnamese (Việt)
- * @author Codyn329
- */
-$messages['vi'] = array(
-       'newtalkglobal' => 'nói chuyện mới toàn cầu',
-       'newtalkglobal-desc' => 'Hiển thị các thông trang thảo luận nhận được 
trên bất kỳ dự án của một trang trại wiki',
-);
diff --git a/NewTalkGlobal.php b/NewTalkGlobal.php
deleted file mode 100644
index d28b9b1..0000000
--- a/NewTalkGlobal.php
+++ /dev/null
@@ -1,16 +0,0 @@
-<?php
-
-$wgExtensionCredits['other'][] = array(
-               'path' => __FILE__,
-               'name' => 'NewTalkGlobal',
-               'author' => 'Adam Carter',
-               'url' => '//github.com/Brickimedia/NewTalkGlobal',
-               'descriptionmsg' => 'newtalkglobal-desc',
-               'version'  => 1.0,
-);
-
-$wgAutoloadClasses['NewTalkGlobal'] = __DIR__ . '/NewTalkGlobal.body.php';
-
-$wgHooks['GetNewMessagesAlert'][] = 'NewTalkGlobal::onGetNewMessagesAlert';
-
-$wgExtensionMessagesFiles['NewTalkGlobal'] = __DIR__ . 
'/NewTalkGlobal.i18n.php';
\ No newline at end of file
diff --git a/extension.json b/extension.json
new file mode 100644
index 0000000..9088f4c
--- /dev/null
+++ b/extension.json
@@ -0,0 +1,22 @@
+{
+       "name": "NewTalkGlobal",
+       "version": "1.0",
+       "author": "Adam Carter",
+       "url": "https://www.mediawiki.org/wiki/Extension:NewTalkGlobal";,
+       "descriptionmsg": "newtalkglobal-desc",
+       "type": "other",
+       "MessagesDirs": {
+               "NewTalkGlobal": [
+                       "i18n"
+               ]
+       },
+       "AutoloadClasses": {
+               "NewTalkGlobal": "NewTalkGlobal.body.php"
+       },
+       "Hooks": {
+               "GetNewMessagesAlert": [
+                       "NewTalkGlobal::onGetNewMessagesAlert"
+               ]
+       },
+       "manifest_version": 1
+}
diff --git a/i18n/en.json b/i18n/en.json
new file mode 100644
index 0000000..7b3cf83
--- /dev/null
+++ b/i18n/en.json
@@ -0,0 +1,9 @@
+{
+       "@metadata": {
+               "authors": [
+                       "UltrasonicNXT"
+               ]
+       },
+       "newtalkglobal": "newtalkglobal",
+       "newtalkglobal-desc": "Shows talk page messages received on any project 
of a wikifarm"
+}
diff --git a/i18n/ka.json b/i18n/ka.json
new file mode 100644
index 0000000..be6ef78
--- /dev/null
+++ b/i18n/ka.json
@@ -0,0 +1,9 @@
+{
+       "@metadata": {
+               "authors": [
+                       "ToaMeiko"
+               ]
+       },
+       "newtalkglobal": "თოქ გლობალურ",
+       "newtalkglobal-desc": "მონიტორები გაიგო გვერდი შეტყობინებები მიღებული 
ნებისმიერი პროექტის ვიკი ფერმაში"
+}
diff --git a/i18n/qqq.json b/i18n/qqq.json
new file mode 100644
index 0000000..d1ec4f4
--- /dev/null
+++ b/i18n/qqq.json
@@ -0,0 +1,9 @@
+{
+       "@metadata": {
+               "authors": [
+                       "UltrasonicNXT"
+               ]
+       },
+       "newtalkglobal": "The name of the extension",
+       "newtalkglobal-desc": "{{desc}}"
+}
diff --git a/i18n/vi.json b/i18n/vi.json
new file mode 100644
index 0000000..59f9543
--- /dev/null
+++ b/i18n/vi.json
@@ -0,0 +1,9 @@
+{
+       "@metadata": {
+               "authors": [
+                       "Codyn329"
+               ]
+       },
+       "newtalkglobal": "nói chuyện mới toàn cầu",
+       "newtalkglobal-desc": "Hiển thị các thông trang thảo luận nhận được 
trên bất kỳ dự án của một trang trại wiki"
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/311991
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic8e66c7a8d7f0446149b32e2c9f9e00a7d2a4479
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/NewTalkGlobal
Gerrit-Branch: master
Gerrit-Owner: Jack Phoenix <j...@countervandalism.net>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to