r77942 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77941‎ | r77942 | r77943 >
Date:01:13, 7 December 2010
Author:jeroendedauw
Status:deferred (Comments)
Tags:
Comment:
Adding support for mw 1.16
Modified paths:
  • /trunk/extensions/Push/Push.php (modified) (history)
  • /trunk/extensions/Push/includes/Push_Tab.php (modified) (history)
  • /trunk/extensions/Push/includes/ext.push.tab.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Push/Push.php
@@ -54,27 +54,45 @@
5555 $wgAvailableRights[] = 'pushadmin';
5656 $wgGroupPermissions['sysop']['pushadmin'] = true;
5757
58 -$moduleTemplate = array(
59 - 'localBasePath' => dirname( __FILE__ ),
60 - 'remoteBasePath' => $egPushScriptPath,
61 - 'group' => 'ext.push'
 58+$egPushJSMessages = array(
 59+ 'push-button-pushing',
 60+ 'push-button-completed',
 61+ 'push-button-failed',
 62+ 'push-import-revision-message',
6263 );
6364
64 -$wgResourceModules['ext.push.tab'] = $moduleTemplate + array(
65 - 'scripts' => 'includes/ext.push.tab.js',
66 - 'dependencies' => array(),
67 - 'messages' => array(
68 - 'push-button-pushing',
69 - 'push-button-completed',
70 - 'push-button-failed',
71 - 'push-import-revision-message',
72 - )
73 -);
 65+// For backward compatibility with MW < 1.17.
 66+if ( is_callable( array( 'OutputPage', 'addModules' ) ) ) {
 67+ $moduleTemplate = array(
 68+ 'localBasePath' => dirname( __FILE__ ),
 69+ 'remoteBasePath' => $egPushScriptPath,
 70+ 'group' => 'ext.push'
 71+ );
 72+
 73+ $wgResourceModules['ext.push.tab'] = $moduleTemplate + array(
 74+ 'scripts' => 'includes/ext.push.tab.js',
 75+ 'dependencies' => array(),
 76+ 'messages' => $egPushJSMessages
 77+ );
 78+}
7479
75 -// This function has been deprecated in 1.16, but needed for earlier versions.
76 -// It's present in 1.16 as a stub, but lets check if it exists in case it gets removed at some point.
77 -if ( function_exists( 'wfLoadExtensionMessages' ) ) {
78 - wfLoadExtensionMessages( 'Push' );
 80+function efPushAddJSLocalisation( $parser = false ) {
 81+ global $egPushJSMessages;
 82+
 83+ $data = array();
 84+
 85+ foreach ( $egPushJSMessages as $msg ) {
 86+ $data[$msg] = wfMsgNoTrans( $msg );
 87+ }
 88+
 89+ $js = 'var wgPushMessages = ' . json_encode( $data ) . ';';
 90+
 91+ if ( $parser ) {
 92+ $parser->getOutput()->addHeadItem( Html::inlineScript( $js ) );
 93+ } else {
 94+ global $wgOut;
 95+ $wgOut->addInlineScript( $js );
 96+ }
7997 }
8098
8199 require_once 'Push_Settings.php';
Index: trunk/extensions/Push/includes/Push_Tab.php
@@ -62,20 +62,49 @@
6363 }
6464
6565 /**
 66+ * Loads the needed JavaScript.
 67+ * Takes care of non-RL compatibility.
 68+ *
 69+ * @since 0.1
 70+ */
 71+ protected static function loadJs() {
 72+ global $wgOut;
 73+
 74+ // For backward compatibility with MW < 1.17.
 75+ if ( is_callable( array( $wgOut, 'addModules' ) ) ) {
 76+ $wgOut->addModules( 'ext.push.tab' );
 77+ }
 78+ else {
 79+ global $egPushScriptPath;
 80+
 81+ efPushAddJSLocalisation();
 82+
 83+ // TODO: jquery
 84+
 85+ $wgOut->addHeadItem(
 86+ 'ext.push.tab',
 87+ Html::linkedScript( $egPushScriptPath . '/includes/ext.push.tab.js' )
 88+ );
 89+ }
 90+ }
 91+
 92+ /**
6693 * The function called if we're in index.php (as opposed to one of the
6794 * special pages)
 95+ *
 96+ * @since 0.1
6897 */
6998 public static function displayPushPage( Article $article ) {
7099 global $wgOut, $wgUser, $wgTitle;
71100
72101 $wgOut->setPageTitle( wfMsgExt( 'push-tab-title', 'parsemag', $article->getTitle()->getText() ) );
73102
 103+ self::loadJs();
 104+
74105 $wgOut->addHTML(
75106 Html::hidden( 'pageName', $wgTitle->getFullText(), array( 'id' => 'pageName' ) )
76107 );
77108
78 - $wgOut->addModules( 'ext.push.tab' );
79 -
80109 if ( $wgUser->isAllowed( 'push' ) ) {
81110 self::displayPushList();
82111 }
@@ -88,6 +117,11 @@
89118 return false;
90119 }
91120
 121+ /**
 122+ * Displays a list with all targets to which can be pushed.
 123+ *
 124+ * @since 0.1
 125+ */
92126 protected static function displayPushList() {
93127 global $wgOut, $egPushTargets;
94128
@@ -120,6 +154,16 @@
121155 );
122156 }
123157
 158+ /**
 159+ * Returns the HTML for a single push target.
 160+ *
 161+ * @since 0.1
 162+ *
 163+ * @param string $name
 164+ * @param string $url
 165+ *
 166+ * @return string
 167+ */
124168 protected static function getPushItem( $name, $url ) {
125169 return Html::rawElement(
126170 'tr',
@@ -146,6 +190,11 @@
147191 // TODO: add edit and delete stuff
148192 }
149193
 194+ /**
 195+ * Displays a form via which a new psuh item can be added.
 196+ *
 197+ * @since 0.1
 198+ */
150199 protected static function displayNewPushItem() {
151200 global $wgOut;
152201
Index: trunk/extensions/Push/includes/ext.push.tab.js
@@ -7,6 +7,8 @@
88
99 $( document ).ready( function() {
1010
 11+ // TODO: message b/c
 12+
1113 $('.push-button').click(function() {
1214 this.disabled = true;
1315 this.innerHTML = mediaWiki.msg( 'push-button-pushing' );

Follow-up revisions

RevisionCommit summaryAuthorDate
r77945Follow up to r77942jeroendedauw01:27, 7 December 2010

Comments

#Comment by Nikerabbit (talk | contribs)   07:34, 7 December 2010

+ * Displays a form via which a new psuh item can be added.

Status & tagging log