Index: branches/js2-work/phase3/includes/OutputPage.php |
— | — | @@ -183,7 +183,8 @@ |
184 | 184 | if( $this->mJQueryDone ) |
185 | 185 | return ; |
186 | 186 | $this->mJQueryDone = true; |
187 | | - // @todo We should deprecate wikibits in favor of some mwEmbed pieces and jQuery |
| 187 | + |
| 188 | + // Set core Classes |
188 | 189 | $coreClasses = array( 'window.jQuery', 'mwEmbed', 'wikibits' ); |
189 | 190 | |
190 | 191 | //make sure scripts are on top: |
— | — | @@ -280,7 +281,7 @@ |
281 | 282 | */ |
282 | 283 | function getURIDparam( $classAry = array() ) { |
283 | 284 | global $wgDebugJavaScript, $wgStyleVersion, $IP, $wgScriptModifiedFileCheck; |
284 | | - global $wgLang, $wgScriptModifiedMsgCheck; |
| 285 | + global $wgLang, $wgUser, $wgScriptModifiedMsgCheck; |
285 | 286 | |
286 | 287 | //Always the language key param to keep urls distinct per language |
287 | 288 | $uriParam = 'uselang=' . $wgLang->getCode(); |
— | — | @@ -292,18 +293,24 @@ |
293 | 294 | if( gettype( $classAry) == 'string' ){ |
294 | 295 | $classAry = array( $classAry ); |
295 | 296 | } |
296 | | - $ftime = $frev = 0; |
| 297 | + $ftime = $currentTitleRev = 0; |
297 | 298 | foreach( $classAry as $class ) { |
298 | 299 | // Add the latest revision ID if the class set includes a WT (wiki title) |
299 | 300 | if( substr($class, 0, 3) == 'WT:'){ |
300 | | - $title_str = substr($class, 3); |
301 | | - $t = Title::newFromText( $title_str ); |
302 | | - if( $t && $t->exists() ) { |
303 | | - if( $t->getLatestRevID() > $frev ) |
304 | | - $frev = $t->getLatestRevID(); |
| 301 | + $titleString = substr($class, 3); |
| 302 | + |
| 303 | + //Check for special case of generated js |
| 304 | + if( $titleString[0] == '-' ){ |
| 305 | + $currentTitleRev = self::getLatestTitleRev( $currentTitleRev, 'MediaWiki:Common.js' ); |
| 306 | + // Also check MediaWiki:{skinName}.js |
| 307 | + $sk = $wgUser->getSkin(); |
| 308 | + $currentTitleRev = self::getLatestTitleRev( $currentTitleRev, |
| 309 | + 'MediaWiki:' . ucfirst( $sk->getSkinName() ) . '.js' ); |
| 310 | + } else { |
| 311 | + $currentTitleRev = self::getLatestTitleRev( $currentTitleRev, $titleString ); |
305 | 312 | } |
306 | 313 | }else{ |
307 | | - //check for file modified time: |
| 314 | + // Check for file modified time: |
308 | 315 | if( $wgScriptModifiedFileCheck ) { |
309 | 316 | $jsPath = jsScriptLoader::getJsPathFromClass( $class ); |
310 | 317 | if( $jsPath ) { |
— | — | @@ -314,18 +321,18 @@ |
315 | 322 | } |
316 | 323 | } |
317 | 324 | } |
318 | | - //build the actual unique request id: |
| 325 | + // uild the actual unique request id: |
319 | 326 | $uriParam .= "&urid={$wgStyleVersion}"; |
320 | 327 | |
321 | 328 | // Add the file modification time if set |
322 | 329 | if( $ftime != 0 ) |
323 | 330 | $uriParam .= "_" . $ftime; |
324 | 331 | |
325 | | - //add the wiki rev id if set |
326 | | - if( $frev != 0 ) |
327 | | - $uriParam.= "_" . $frev; |
| 332 | + // Add the wiki rev id if set |
| 333 | + if( $currentTitleRev != 0 ) |
| 334 | + $uriParam.= "_" . $currentTitleRev; |
328 | 335 | |
329 | | - //add the latest msg rev id if $wgScriptModifiedMsgCheck is enabled: |
| 336 | + // Add the latest msg rev id if $wgScriptModifiedMsgCheck is enabled: |
330 | 337 | if( $wgScriptModifiedMsgCheck ){ |
331 | 338 | $dbr = wfGetDB( DB_SLAVE ); |
332 | 339 | // Grab the latest mediaWiki msg rev id: |
— | — | @@ -343,12 +350,27 @@ |
344 | 351 | $uriParam.= '_' . $rc->rc_id; |
345 | 352 | } |
346 | 353 | } |
347 | | - //@@todo we could otherwise use the the SVN version if not already covered by $wgStyleVersion above |
348 | 354 | } |
349 | 355 | return $uriParam; |
350 | 356 | } |
351 | 357 | } |
352 | 358 | /** |
| 359 | + * Get the latest title revision from a title |
| 360 | + * update the tRev if larger than the current |
| 361 | + * @param {Number} $currentTitleRev Current latest revision |
| 362 | + * @param {String} $titleString String of title to check |
| 363 | + * @return {Number} Latest revision number |
| 364 | + */ |
| 365 | + public static function getLatestTitleRev( $titleRev, $titleString ){ |
| 366 | + $t = Title::newFromText( $titleString ); |
| 367 | + if( $t && $t->exists() ) { |
| 368 | + if( $t->getLatestRevID() > $titleRev ){ |
| 369 | + return $t->getLatestRevID(); |
| 370 | + } |
| 371 | + } |
| 372 | + return $titleRev; |
| 373 | + } |
| 374 | + /** |
353 | 375 | * Given a script path, get the JS class name, or false if no such path is registered. |
354 | 376 | * @param $path string |
355 | 377 | */ |