r106907 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106906‎ | r106907 | r106908 >
Date:00:45, 21 December 2011
Author:preilly
Status:deferred (Comments)
Tags:mobile 
Comment:
skeleton for extension
Modified paths:
  • /trunk/extensions/ZeroRatedMobileAccess/ZeroRatedMobileAccess.i18n.php (added) (history)
  • /trunk/extensions/ZeroRatedMobileAccess/ZeroRatedMobileAccess.php (added) (history)

Diff [purge]

Index: trunk/extensions/ZeroRatedMobileAccess/ZeroRatedMobileAccess.php
@@ -0,0 +1,56 @@
 2+<?php
 3+/**
 4+ * Extension ZeroRatedMobileAccess — Zero Rated Mobile Access
 5+ *
 6+ * @file
 7+ * @ingroup Extensions
 8+ * @author Patrick Reilly
 9+ * @copyright © 2011 Patrick Reilly
 10+ * @licence GNU General Public Licence 2.0 or later
 11+ */
 12+
 13+// Needs to be called within MediaWiki; not standalone
 14+if ( !defined( 'MEDIAWIKI' ) ) {
 15+ echo( "This is an extension to the MediaWiki package and cannot be run standalone.\n" );
 16+ die( -1 );
 17+}
 18+
 19+// Extension credits that will show up on Special:Version
 20+$wgExtensionCredits['other'][] = array(
 21+ 'path' => __FILE__,
 22+ 'name' => 'ZeroRatedMobileAccess',
 23+ 'version' => ExtZeroRatedMobileAccess::VERSION,
 24+ 'author' => '[http://www.mediawiki.org/wiki/User:Preilly Preilly]',
 25+ 'descriptionmsg' => 'zero-rated-mobile-access-desc',
 26+ 'url' => 'https://www.mediawiki.org/wiki/Extension:ZeroRatedMobileAccess',
 27+);
 28+
 29+$cwd = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
 30+$wgExtensionMessagesFiles['ZeroRatedMobileAccess'] = $cwd . 'ZeroRatedMobileAccess.i18n.php';
 31+
 32+$wgExtZeroRatedMobileAccess = new ExtZeroRatedMobileAccess();
 33+
 34+$wgHooks['BeforePageDisplay'][] = array( &$wgExtZeroRatedMobileAccess, 'beforePageDisplayHTML' );
 35+
 36+class ExtZeroRatedMobileAccess {
 37+ const VERSION = '0.0.1';
 38+
 39+ public static $renderZeroRatedLandingPage;
 40+
 41+ /**
 42+ * @param $out OutputPage
 43+ * @param $text String
 44+ * @return bool
 45+ */
 46+ public function beforePageDisplayHTML( &$out, &$text ) {
 47+ global $wgRequest;
 48+ wfProfileIn( __METHOD__ );
 49+ self::$renderZeroRatedLandingPage = $wgRequest->getInt( 'renderZeroRatedLandingPage' );
 50+ if ( self::$renderZeroRatedLandingPage === 1 ) {
 51+ echo wfMsg( 'zero-rated-mobile-access-desc' );
 52+ exit();
 53+ }
 54+ wfProfileOut( __METHOD__ );
 55+ return true;
 56+ }
 57+}
\ No newline at end of file
Property changes on: trunk/extensions/ZeroRatedMobileAccess/ZeroRatedMobileAccess.php
___________________________________________________________________
Added: svn:eol-style
158 + native
Index: trunk/extensions/ZeroRatedMobileAccess/ZeroRatedMobileAccess.i18n.php
@@ -0,0 +1,21 @@
 2+<?php
 3+/**
 4+ * Internationalisation file for the extension ZeroRatedMobileAccess
 5+ *
 6+ * @file
 7+ * @ingroup Extensions
 8+ * @author Patrick Reilly
 9+ * @copyright © 2011 Patrick Reilly
 10+ * @licence GNU General Public Licence 2.0 or later
 11+ */
 12+
 13+$messages = array();
 14+
 15+// en translation
 16+$messages['en'] = array (
 17+ 'zero-rated-mobile-access-desc' => 'Zero Rated Mobile Access',
 18+);
 19+
 20+$messages['qqq'] = array(
 21+ 'zero-rated-mobile-access-desc' => '{{Identical|Show}}',
 22+);
\ No newline at end of file
Property changes on: trunk/extensions/ZeroRatedMobileAccess/ZeroRatedMobileAccess.i18n.php
___________________________________________________________________
Added: svn:eol-style
123 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r1085711.18wmf1: MFT r106907 - r108532preilly00:07, 11 January 2012

Comments

#Comment by Raymond (talk | contribs)   19:52, 21 December 2011

Could the description message

'zero-rated-mobile-access-desc' => 'Zero Rated Mobile Access',

a bit more descriptive please? At least I have no idea what this means, therefore the quality of translations would be bad.

#Comment by 😂 (talk | contribs)   15:56, 24 December 2011

ExtZeroRatedMobileAccess's design confuses me. You're constructing an object seemingly just for the callbacks? If you intend to use this class in a static manner (which I'm thinking the case, given $renderZeroRatedLandingPage), why don't you just skip construction and make the hook callbacks static? If the state of the object matters, then shouldn't $renderZeroRatedLandingPage be non-static?

Status & tagging log