Index: trunk/extensions/Push/Push.i18n.php |
— | — | @@ -56,6 +56,7 @@ |
57 | 57 | 'push-tab-err-filepush' => 'File push failed: $1', |
58 | 58 | 'push-tab-embedded-files' => '(Embedded files: $1)', // JS message, if you want to add plural, then fix the JS first. |
59 | 59 | '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.', |
60 | 61 | |
61 | 62 | // Special page |
62 | 63 | 'special-push' => 'Push pages', |
Index: trunk/extensions/Push/Push.php |
— | — | @@ -91,7 +91,8 @@ |
92 | 92 | 'push-tab-err-filepush', |
93 | 93 | 'push-tab-err-filepush-unknown', |
94 | 94 | 'push-tab-embedded-files', |
95 | | - 'push-tab-no-embedded-files' |
| 95 | + 'push-tab-no-embedded-files', |
| 96 | + 'push-tab-included-override' |
96 | 97 | ); |
97 | 98 | |
98 | 99 | // For backward compatibility with MW < 1.17. |
Index: trunk/extensions/Push/includes/Push_Tab.php |
— | — | @@ -248,6 +248,13 @@ |
249 | 249 | Html::element( |
250 | 250 | 'div', |
251 | 251 | array( |
| 252 | + 'id' => 'targetconflicts' . $targetId, |
| 253 | + 'style' => 'display:none; color:darkgray' |
| 254 | + ) |
| 255 | + ) . |
| 256 | + Html::element( |
| 257 | + 'div', |
| 258 | + array( |
252 | 259 | 'id' => 'targeterrors' . $targetId, |
253 | 260 | 'style' => 'display:none; color:darkred' |
254 | 261 | ) |
Index: trunk/extensions/Push/includes/ext.push.tab.js |
— | — | @@ -24,6 +24,7 @@ |
25 | 25 | } |
26 | 26 | |
27 | 27 | var pages; |
| 28 | + var targetData = []; |
28 | 29 | |
29 | 30 | $.each($(".push-button"), function(i,v) { |
30 | 31 | getRemoteArticleInfo( $(v).attr( 'targetid' ), $(v).attr( 'pushtarget' ) ); |
— | — | @@ -80,8 +81,13 @@ |
81 | 82 | |
82 | 83 | $('#divIncTemplates').click(function() { |
83 | 84 | setIncludeFilesText(); |
| 85 | + displayTargetsConflictStatus(); |
84 | 86 | }); |
85 | 87 | |
| 88 | + $('#divIncFiles').click(function() { |
| 89 | + displayTargetsConflictStatus(); |
| 90 | + }); |
| 91 | + |
86 | 92 | $('#divIncFiles').hover( |
87 | 93 | function() { |
88 | 94 | var isHidden = $('#txtFileList').css( 'opacity' ) == 0; |
— | — | @@ -118,6 +124,8 @@ |
119 | 125 | } |
120 | 126 | |
121 | 127 | function getRemoteArticleInfo( targetId, targetUrl ) { |
| 128 | + var pageName = $('#pageName').attr('value'); |
| 129 | + |
122 | 130 | $.getJSON( |
123 | 131 | targetUrl + '/api.php?callback=?', |
124 | 132 | { |
— | — | @@ -125,22 +133,36 @@ |
126 | 134 | 'format': 'json', |
127 | 135 | 'prop': 'revisions', |
128 | 136 | '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( '|' ), |
130 | 142 | }, |
131 | 143 | function( data ) { |
132 | 144 | if ( data.query ) { |
133 | 145 | var infoDiv = $( '#targetinfo' + targetId ); |
| 146 | + |
| 147 | + var existingPages = []; |
| 148 | + var remotePage = false; |
134 | 149 | |
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 | + } |
136 | 160 | |
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 ) { |
142 | 164 | $( '#targetlink' + targetId ).attr( {'class': ''} ); |
143 | 165 | |
144 | | - var revision = data.query.pages[first].revisions[0]; |
| 166 | + var revision = remotePage.revisions[0]; |
145 | 167 | var dateTime = revision.timestamp.split( 'T' ); |
146 | 168 | |
147 | 169 | var message = mediaWiki.msg( |
— | — | @@ -148,16 +170,55 @@ |
149 | 171 | revision.user, |
150 | 172 | dateTime[0], |
151 | 173 | dateTime[1].replace( 'Z', '' ) |
152 | | - ); |
| 174 | + ); |
153 | 175 | } |
| 176 | + else { |
| 177 | + $( '#targetlink' + targetId ).attr( {'class': 'new'} ); |
| 178 | + var message = mediaWiki.msg( 'push-tab-not-created' ); |
| 179 | + } |
154 | 180 | |
155 | 181 | infoDiv.text( message ); |
156 | 182 | infoDiv.fadeIn( 'slow' ); |
| 183 | + |
| 184 | + displayTargetConflictStatus( targetId ); |
157 | 185 | } |
158 | 186 | } |
159 | 187 | ); |
160 | 188 | } |
161 | 189 | |
| 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 | + |
162 | 223 | function initiatePush( sender, pages, targetUrl, targetName ) { |
163 | 224 | $.getJSON( |
164 | 225 | wgScriptPath + '/api.php', |