r78568 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78567‎ | r78568 | r78569 >
Date:16:46, 18 December 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
More detailed info about the target wikis state
Modified paths:
  • /trunk/extensions/Push/Push.i18n.php (modified) (history)
  • /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.i18n.php
@@ -56,6 +56,7 @@
5757 'push-tab-err-filepush' => 'File push failed: $1',
5858 'push-tab-embedded-files' => '(Embedded files: $1)', // JS message, if you want to add plural, then fix the JS first.
5959 'push-tab-no-embedded-files' => '(No files are embedded in this page.)',
 60+ 'push-tab-included-override' => 'One or more included templates or files will be overriden.',
6061
6162 // Special page
6263 'special-push' => 'Push pages',
Index: trunk/extensions/Push/Push.php
@@ -91,7 +91,8 @@
9292 'push-tab-err-filepush',
9393 'push-tab-err-filepush-unknown',
9494 'push-tab-embedded-files',
95 - 'push-tab-no-embedded-files'
 95+ 'push-tab-no-embedded-files',
 96+ 'push-tab-included-override'
9697 );
9798
9899 // For backward compatibility with MW < 1.17.
Index: trunk/extensions/Push/includes/Push_Tab.php
@@ -248,6 +248,13 @@
249249 Html::element(
250250 'div',
251251 array(
 252+ 'id' => 'targetconflicts' . $targetId,
 253+ 'style' => 'display:none; color:darkgray'
 254+ )
 255+ ) .
 256+ Html::element(
 257+ 'div',
 258+ array(
252259 'id' => 'targeterrors' . $targetId,
253260 'style' => 'display:none; color:darkred'
254261 )
Index: trunk/extensions/Push/includes/ext.push.tab.js
@@ -24,6 +24,7 @@
2525 }
2626
2727 var pages;
 28+ var targetData = [];
2829
2930 $.each($(".push-button"), function(i,v) {
3031 getRemoteArticleInfo( $(v).attr( 'targetid' ), $(v).attr( 'pushtarget' ) );
@@ -80,8 +81,13 @@
8182
8283 $('#divIncTemplates').click(function() {
8384 setIncludeFilesText();
 85+ displayTargetsConflictStatus();
8486 });
8587
 88+ $('#divIncFiles').click(function() {
 89+ displayTargetsConflictStatus();
 90+ });
 91+
8692 $('#divIncFiles').hover(
8793 function() {
8894 var isHidden = $('#txtFileList').css( 'opacity' ) == 0;
@@ -118,6 +124,8 @@
119125 }
120126
121127 function getRemoteArticleInfo( targetId, targetUrl ) {
 128+ var pageName = $('#pageName').attr('value');
 129+
122130 $.getJSON(
123131 targetUrl + '/api.php?callback=?',
124132 {
@@ -125,22 +133,36 @@
126134 'format': 'json',
127135 'prop': 'revisions',
128136 'rvprop': 'timestamp|user|comment',
129 - 'titles': $('#pageName').attr('value'),
 137+ 'titles': [pageName]
 138+ .concat( window.wgPushTemplates )
 139+ .concat( window.wgPushPageFiles )
 140+ .concat( window.wgPushTemplateFiles )
 141+ .join( '|' ),
130142 },
131143 function( data ) {
132144 if ( data.query ) {
133145 var infoDiv = $( '#targetinfo' + targetId );
 146+
 147+ var existingPages = [];
 148+ var remotePage = false;
134149
135 - for ( first in data.query.pages ) break;
 150+ for ( remotePageId in data.query.pages ) {
 151+ if ( remotePageId > 0 ) {
 152+ if ( data.query.pages[remotePageId].title == pageName ) {
 153+ remotePage = data.query.pages[remotePageId];
 154+ }
 155+ else {
 156+ existingPages.push( data.query.pages[remotePageId] );
 157+ }
 158+ }
 159+ }
136160
137 - if ( first == '-1' ) {
138 - $( '#targetlink' + targetId ).attr( {'class': 'new'} );
139 - var message = mediaWiki.msg( 'push-tab-not-created' );
140 - }
141 - else {
 161+ targetData[targetId] = { 'existingPages': existingPages };
 162+
 163+ if ( remotePage ) {
142164 $( '#targetlink' + targetId ).attr( {'class': ''} );
143165
144 - var revision = data.query.pages[first].revisions[0];
 166+ var revision = remotePage.revisions[0];
145167 var dateTime = revision.timestamp.split( 'T' );
146168
147169 var message = mediaWiki.msg(
@@ -148,16 +170,55 @@
149171 revision.user,
150172 dateTime[0],
151173 dateTime[1].replace( 'Z', '' )
152 - );
 174+ );
153175 }
 176+ else {
 177+ $( '#targetlink' + targetId ).attr( {'class': 'new'} );
 178+ var message = mediaWiki.msg( 'push-tab-not-created' );
 179+ }
154180
155181 infoDiv.text( message );
156182 infoDiv.fadeIn( 'slow' );
 183+
 184+ displayTargetConflictStatus( targetId );
157185 }
158186 }
159187 );
160188 }
161189
 190+ function displayTargetsConflictStatus() {
 191+ $.each($(".push-button"), function(i,v) {
 192+ displayTargetConflictStatus( $(v).attr( 'targetid' ) );
 193+ });
 194+ }
 195+
 196+ function displayTargetConflictStatus( targetId ) {
 197+ var nsToCheck = [];
 198+
 199+ if ( $('#checkIncTemplates').attr('checked') ) {
 200+ nsToCheck.push( 10 );
 201+ }
 202+
 203+ if ( $('#checkIncFiles').length != 0 && $('#checkIncFiles').attr('checked') ) {
 204+ nsToCheck.push( 6 );
 205+ }
 206+
 207+ var hasConflict = false;
 208+
 209+ for ( remotePageId in targetData[targetId].existingPages ) {
 210+ if ( $.inArray( targetData[targetId].existingPages[remotePageId].ns, nsToCheck ) ) {
 211+ hasConflict = true;
 212+ }
 213+ }
 214+
 215+ if ( hasConflict ) {
 216+ $( '#targetconflicts' + targetId ).text( mediaWiki.msg( 'push-tab-included-override' ) ).fadeIn( 'slow' );
 217+ }
 218+ else {
 219+ $( '#targetconflicts' + targetId ).fadeOut( 'slow' );
 220+ }
 221+ }
 222+
162223 function initiatePush( sender, pages, targetUrl, targetName ) {
163224 $.getJSON(
164225 wgScriptPath + '/api.php',

Follow-up revisions

RevisionCommit summaryAuthorDate
r78569Follow up to r78568jeroendedauw16:54, 18 December 2010

Status & tagging log