r89017 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89016‎ | r89017 | r89018 >
Date:03:53, 28 May 2011
Author:yuvipanda
Status:ok
Tags:
Comment:
Fixed resourceloader issues
Modified paths:
  • /trunk/extensions/ShortUrl/ShortUrl.functions.php (modified) (history)
  • /trunk/extensions/ShortUrl/ShortUrl.hooks.php (modified) (history)
  • /trunk/extensions/ShortUrl/ShortUrl.php (modified) (history)
  • /trunk/extensions/ShortUrl/css/ext.shortUrl.css (modified) (history)

Diff [purge]

Index: trunk/extensions/ShortUrl/ShortUrl.functions.php
@@ -69,3 +69,11 @@
7070 }
7171 return Title::makeTitle( $entry['su_namespace'], $entry['su_title'] );
7272 }
 73+
 74+/**
 75+ * @param $title Title
 76+ * @return True if a shorturl needs to be displayed
 77+ */
 78+function needsShortUrl( $title ) {
 79+ return $title->exists() && ! $title->equals( Title::newMainPage() );
 80+}
Index: trunk/extensions/ShortUrl/ShortUrl.php
@@ -34,8 +34,9 @@
3535
3636 $wgHooks['SkinTemplateToolboxEnd'][] = 'ShortUrlHooks::AddToolboxLink';
3737 $wgHooks['LoadExtensionSchemaUpdates'][] = 'ShortUrlHooks::SetupSchema';
 38+$wgHooks['OutputPageBeforeHTML'][] = 'ShortUrlHooks::OutputPageBeforeHTML';
3839
39 -$wgResourceModules['ext.ShortUrl'] = array(
 40+$wgResourceModules['ext.shortUrl'] = array(
4041 'scripts' => 'js/ext.shortUrl.js',
4142 'styles' => 'css/ext.shortUrl.css',
4243 'dependencies' => array( 'jquery' ),
Index: trunk/extensions/ShortUrl/css/ext.shortUrl.css
@@ -1,4 +1,4 @@
2 -.title-shorturl {
 2+.title-shortlink {
33 font-size: small;
44 font-family: monospace;
55 }
Index: trunk/extensions/ShortUrl/ShortUrl.hooks.php
@@ -23,7 +23,7 @@
2424 public static function AddToolboxLink( &$tpl ) {
2525 global $wgOut, $wgShortUrlPrefix;
2626 $title = $wgOut->getTitle();
27 - if ( $title->exists() && ! $title->equals( Title::newMainPage() ) ) {
 27+ if ( needsShortUrl( $title ) ) {
2828 $shortId = shorturlEncode( $title );
2929 $shortURL = $wgShortUrlPrefix . $shortId;
3030 $html = Html::rawElement( 'li', array( 'id' => 't-shorturl' ),
@@ -35,12 +35,25 @@
3636 );
3737
3838 echo $html;
39 - $wgOut->addModules( 'ext.ShortUrl' );
 39+ // echo '<script type="text/javascript">mediaWiki.loader.load( "ext.shortUrl" );</script>';
4040 }
4141 return true;
4242 }
4343
4444 /**
 45+ * @param $out OutputPage
 46+ * @param $text the HTML text to be added
 47+ */
 48+ public static function OutputPageBeforeHTML( &$out, &$text ) {
 49+ global $wgOut;
 50+ $title = $wgOut->getTitle();
 51+ if ( needsShortUrl( $title ) ) {
 52+ $wgOut->addModules( 'ext.shortUrl' );
 53+ }
 54+ return true;
 55+ }
 56+
 57+ /**
4558 * @param $du DatabaseUpdater
4659 * @return bool
4760 */

Status & tagging log