[MediaWiki-commits] [Gerrit] mediawiki...ZeroBanner[wmf/1.28.0-wmf.22]: Revert "Convert ZeroBanner to extension registration"

2016-10-13 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Revert "Convert ZeroBanner to extension registration"
..


Revert "Convert ZeroBanner to extension registration"

This reverts commit 661408d9e24bbc3350bb3dcce1f910eda6e45420.

Change-Id: I0a5e29a9783b43b6d2eef51f4bc13894ceb579e5
---
M README
A ZeroBanner.i18n.php
M ZeroBanner.php
D extension.json
M includes/PageRenderingHooks.php
5 files changed, 238 insertions(+), 230 deletions(-)

Approvals:
  Reedy: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/README b/README
index 05a33c0..f4217d2 100644
--- a/README
+++ b/README
@@ -64,27 +64,6 @@
   $ vagrant enable-role zero
   $ vagrant provision
 
-=== Extension configuration ===
-All Zero-related wikis, including ZeroPortal, will get this configuration:
-
-$wgJsonConfigs['JsonZeroConfig'] = array(
-  'namespace' => NS_ZERO,
-  'nsName' => 'Zero',
-  'isLocal' => false, // shared cross-wiki
-  'cacheKey' => '1', // update when breaking json config structure - to 
simplify rollbacks
-);
-
-All wikis except for the portal need further customization. They need to know 
how to access
-remote zero configuration, using the given username and password.
-On the other hand, ZeroPortal on the other hand, will specify to use current 
wiki for storage.
-See JsonConfig extension documentation for more info.
-
-$wgJsonConfigs['JsonZeroConfig']['remote'] = array(
-  'url' => 'https://zero.wikimedia.org/w/api.php',
-  'username' => ...,
-  'password' => ...,
-);
-
 
 == Testing ==
 
diff --git a/ZeroBanner.i18n.php b/ZeroBanner.i18n.php
new file mode 100644
index 000..532393c
--- /dev/null
+++ b/ZeroBanner.i18n.php
@@ -0,0 +1,35 @@
+https://git.wikimedia.org/blob/mediawiki%2Fcore.git/HEAD/maintenance%2FgenerateJsonI18n.php
+ *
+ * Beginning with MediaWiki 1.23, translation strings are stored in json files,
+ * and the EXTENSION.i18n.php file only exists to provide compatibility with
+ * older releases of MediaWiki. For more information about this migration, see:
+ * https://www.mediawiki.org/wiki/Requests_for_comment/Localisation_format
+ *
+ * This shim maintains compatibility back to MediaWiki 1.17.
+ */
+$messages = array();
+if ( !function_exists( 'wfJsonI18nShim625f69e14aead689' ) ) {
+   function wfJsonI18nShim625f69e14aead689( $cache, $code, &$cachedData ) {
+   $codeSequence = array_merge( array( $code ), 
$cachedData['fallbackSequence'] );
+   foreach ( $codeSequence as $csCode ) {
+   $fileName = dirname( __FILE__ ) . "/i18n/$csCode.json";
+   if ( is_readable( $fileName ) ) {
+   $data = FormatJson::decode( file_get_contents( 
$fileName ), true );
+   foreach ( array_keys( $data ) as $key ) {
+   if ( $key === '' || $key[0] === '@' ) {
+   unset( $data[$key] );
+   }
+   }
+   $cachedData['messages'] = array_merge( $data, 
$cachedData['messages'] );
+   }
+
+   $cachedData['deps'][] = new FileDependency( $fileName );
+   }
+   return true;
+   }
+
+   $GLOBALS['wgHooks']['LocalisationCacheRecache'][] = 
'wfJsonI18nShim625f69e14aead689';
+}
diff --git a/ZeroBanner.php b/ZeroBanner.php
index 3fc6d50..ffdd7dc 100644
--- a/ZeroBanner.php
+++ b/ZeroBanner.php
@@ -1,18 +1,206 @@
 https://www.mediawiki.org/wiki/Extension_registration for 
more details.'
-   ); */
-   return;
-} else {
-   die( 'This version of the ZeroBanner extension requires MediaWiki 
1.28+' );
+// Needs to be called within MediaWiki; not standalone
+if ( !defined( 'MEDIAWIKI' ) ) {
+   echo( "This is a MediaWiki extension and cannot run standalone.\n" );
+   die( -1 );
 }
+
+// Extension credits that will show up on Special:Version
+$wgExtensionCredits['other'][] = array(
+   'path'  =>  __FILE__,
+   'name'  =>  'ZeroBanner',
+   'version'  =>  '1.0.0',
+   'author' => array( 'Patrick Reilly', 'Yuri Astrakhan' ),
+   'descriptionmsg'  =>  'zero-desc',
+   'url'  =>  'https://www.mediawiki.org/wiki/Extension:ZeroBanner',
+   'license-name'  =>  'GPL-2.0+',
+);
+
+$zbDir = __DIR__ . DIRECTORY_SEPARATOR;
+$wgMessagesDirs['ZeroBanner'] = $zbDir . 'i18n';
+$wgExtensionMessagesFiles['ZeroBanner'] = $zbDir . 'ZeroBanner.i18n.php';
+$wgExtensionMessagesFiles['ZeroBannerAlias'] = $zbDir . "ZeroBanner.alias.php";
+
+$wgSpecialPages['ZeroRatedMobileAccess'] = 'ZeroBanner\ZeroSpecialPage';
+$wgExtensionMessagesFiles['ZeroRatedMobileAccessAlias'] = $zbDir . 
"ZeroBanner.alias.php";
+
+$wgAutoloadClasses['GDText\\Box'] = $zbDir . 'vendor/stil/gd-text/src/Box.php';
+$wgAutoloadClasses['GDText\\Color'] = $zbDir . 

[MediaWiki-commits] [Gerrit] mediawiki...ZeroBanner[wmf/1.28.0-wmf.22]: Revert "Convert ZeroBanner to extension registration"

2016-10-13 Thread Reedy (Code Review)
Reedy has uploaded a new change for review.

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

Change subject: Revert "Convert ZeroBanner to extension registration"
..

Revert "Convert ZeroBanner to extension registration"

This reverts commit 661408d9e24bbc3350bb3dcce1f910eda6e45420.

Change-Id: I0a5e29a9783b43b6d2eef51f4bc13894ceb579e5
---
M README
A ZeroBanner.i18n.php
M ZeroBanner.php
D extension.json
M includes/PageRenderingHooks.php
5 files changed, 238 insertions(+), 230 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ZeroBanner 
refs/changes/68/315868/1

diff --git a/README b/README
index 05a33c0..f4217d2 100644
--- a/README
+++ b/README
@@ -64,27 +64,6 @@
   $ vagrant enable-role zero
   $ vagrant provision
 
-=== Extension configuration ===
-All Zero-related wikis, including ZeroPortal, will get this configuration:
-
-$wgJsonConfigs['JsonZeroConfig'] = array(
-  'namespace' => NS_ZERO,
-  'nsName' => 'Zero',
-  'isLocal' => false, // shared cross-wiki
-  'cacheKey' => '1', // update when breaking json config structure - to 
simplify rollbacks
-);
-
-All wikis except for the portal need further customization. They need to know 
how to access
-remote zero configuration, using the given username and password.
-On the other hand, ZeroPortal on the other hand, will specify to use current 
wiki for storage.
-See JsonConfig extension documentation for more info.
-
-$wgJsonConfigs['JsonZeroConfig']['remote'] = array(
-  'url' => 'https://zero.wikimedia.org/w/api.php',
-  'username' => ...,
-  'password' => ...,
-);
-
 
 == Testing ==
 
diff --git a/ZeroBanner.i18n.php b/ZeroBanner.i18n.php
new file mode 100644
index 000..532393c
--- /dev/null
+++ b/ZeroBanner.i18n.php
@@ -0,0 +1,35 @@
+https://git.wikimedia.org/blob/mediawiki%2Fcore.git/HEAD/maintenance%2FgenerateJsonI18n.php
+ *
+ * Beginning with MediaWiki 1.23, translation strings are stored in json files,
+ * and the EXTENSION.i18n.php file only exists to provide compatibility with
+ * older releases of MediaWiki. For more information about this migration, see:
+ * https://www.mediawiki.org/wiki/Requests_for_comment/Localisation_format
+ *
+ * This shim maintains compatibility back to MediaWiki 1.17.
+ */
+$messages = array();
+if ( !function_exists( 'wfJsonI18nShim625f69e14aead689' ) ) {
+   function wfJsonI18nShim625f69e14aead689( $cache, $code, &$cachedData ) {
+   $codeSequence = array_merge( array( $code ), 
$cachedData['fallbackSequence'] );
+   foreach ( $codeSequence as $csCode ) {
+   $fileName = dirname( __FILE__ ) . "/i18n/$csCode.json";
+   if ( is_readable( $fileName ) ) {
+   $data = FormatJson::decode( file_get_contents( 
$fileName ), true );
+   foreach ( array_keys( $data ) as $key ) {
+   if ( $key === '' || $key[0] === '@' ) {
+   unset( $data[$key] );
+   }
+   }
+   $cachedData['messages'] = array_merge( $data, 
$cachedData['messages'] );
+   }
+
+   $cachedData['deps'][] = new FileDependency( $fileName );
+   }
+   return true;
+   }
+
+   $GLOBALS['wgHooks']['LocalisationCacheRecache'][] = 
'wfJsonI18nShim625f69e14aead689';
+}
diff --git a/ZeroBanner.php b/ZeroBanner.php
index 3fc6d50..ffdd7dc 100644
--- a/ZeroBanner.php
+++ b/ZeroBanner.php
@@ -1,18 +1,206 @@
 https://www.mediawiki.org/wiki/Extension_registration for 
more details.'
-   ); */
-   return;
-} else {
-   die( 'This version of the ZeroBanner extension requires MediaWiki 
1.28+' );
+// Needs to be called within MediaWiki; not standalone
+if ( !defined( 'MEDIAWIKI' ) ) {
+   echo( "This is a MediaWiki extension and cannot run standalone.\n" );
+   die( -1 );
 }
+
+// Extension credits that will show up on Special:Version
+$wgExtensionCredits['other'][] = array(
+   'path'  =>  __FILE__,
+   'name'  =>  'ZeroBanner',
+   'version'  =>  '1.0.0',
+   'author' => array( 'Patrick Reilly', 'Yuri Astrakhan' ),
+   'descriptionmsg'  =>  'zero-desc',
+   'url'  =>  'https://www.mediawiki.org/wiki/Extension:ZeroBanner',
+   'license-name'  =>  'GPL-2.0+',
+);
+
+$zbDir = __DIR__ . DIRECTORY_SEPARATOR;
+$wgMessagesDirs['ZeroBanner'] = $zbDir . 'i18n';
+$wgExtensionMessagesFiles['ZeroBanner'] = $zbDir . 'ZeroBanner.i18n.php';
+$wgExtensionMessagesFiles['ZeroBannerAlias'] = $zbDir . "ZeroBanner.alias.php";
+
+$wgSpecialPages['ZeroRatedMobileAccess'] = 'ZeroBanner\ZeroSpecialPage';
+$wgExtensionMessagesFiles['ZeroRatedMobileAccessAlias'] = $zbDir . 
"ZeroBanner.alias.php";
+
+$wgAutoloadClasses['GDText\\Box'] = $zbDir . 'vendor/stil/gd-text/src/Box.php';