r89019 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89018‎ | r89019 | r89020 >
Date:04:14, 28 May 2011
Author:yuvipanda
Status:ok (Comments)
Tags:
Comment:
Adds proper default $wgShortUrlPrefix
Modified paths:
  • /trunk/extensions/ShortUrl/README (modified) (history)
  • /trunk/extensions/ShortUrl/ShortUrl.hooks.php (modified) (history)
  • /trunk/extensions/ShortUrl/ShortUrl.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ShortUrl/ShortUrl.php
@@ -45,4 +45,4 @@
4646 );
4747
4848 // Configuration
49 -$wgShortUrlPrefix = '/wiki/Special:ShortUrl/';
 49+$wgShortUrlPrefix = NULL;
Index: trunk/extensions/ShortUrl/ShortUrl.hooks.php
@@ -22,10 +22,16 @@
2323 */
2424 public static function AddToolboxLink( &$tpl ) {
2525 global $wgOut, $wgShortUrlPrefix;
 26+ if ( $wgShortUrlPrefix == NULL) {
 27+ $urlPrefix = SpecialPage::getTitleFor( 'ShortUrl' )->getFullURL() . '/';
 28+ } else {
 29+ $urlPrefix = $wgShortUrlPrefix;
 30+ }
 31+
2632 $title = $wgOut->getTitle();
2733 if ( needsShortUrl( $title ) ) {
2834 $shortId = shorturlEncode( $title );
29 - $shortURL = $wgShortUrlPrefix . $shortId;
 35+ $shortURL = $urlPrefix . $shortId;
3036 $html = Html::rawElement( 'li', array( 'id' => 't-shorturl' ),
3137 Html::Element( 'a', array(
3238 'href' => $shortURL,
@@ -35,7 +41,6 @@
3642 );
3743
3844 echo $html;
39 - // echo '<script type="text/javascript">mediaWiki.loader.load( "ext.shortUrl" );</script>';
4045 }
4146 return true;
4247 }
Index: trunk/extensions/ShortUrl/README
@@ -4,11 +4,6 @@
55 Licenses: GNU General Public Licence (GPL)
66 --------------------------------------------------------------------------
77
8 -The ShortUrl extension implements a URL Shortener
9 -creates a special page Special:Contact, which is similar to
10 -Special:Emailuser, but it has a fixed recipient, and can be used
11 -anonymously.
12 -
138 <http://mediawiki.org/wiki/Extension:ShortUrl>
149
1510 == Installing ==
@@ -21,4 +16,6 @@
2217
2318 == Configuration ==
2419
25 -There are no configuration options available as of now.
 20+$wgShortUrlPrefix specifies the prefix to use before the shorturl.
 21+Defaults to using the longer form (with Special:ShortUrl). Can be
 22+condensed down to use anything else, via mod_rewrite rules

Comments

#Comment by 😂 (talk | contribs)   21:55, 22 July 2011

Coding conventions are to write NULL as null, but otherwise this is ok.

Status & tagging log