Index: trunk/extensions/ShortUrl/ShortUrl.functions.php |
— | — | @@ -14,35 +14,35 @@ |
15 | 15 | } |
16 | 16 | |
17 | 17 | /* stolen from http://www.php.net/manual/en/function.base64-encode.php#63543 */ |
18 | | -function urlsafe_b64encode($string) { |
19 | | - $data = base64_encode($string); |
20 | | - $data = str_replace(array('+','/','='),array('-','_',''),$data); |
21 | | - return $data; |
| 18 | +function urlsafe_b64encode( $string ) { |
| 19 | + $data = base64_encode( $string ); |
| 20 | + $data = str_replace( array( '+', '/', '=' ), array( '-', '_', '' ), $data ); |
| 21 | + return $data; |
22 | 22 | } |
23 | 23 | |
24 | 24 | /* stolen from http://www.php.net/manual/en/function.base64-encode.php#63543 */ |
25 | | -function urlsafe_b64decode($string) { |
26 | | - $data = str_replace(array('-','_'),array('+','/'),$string); |
27 | | - $mod4 = strlen($data) % 4; |
28 | | - if ($mod4) { |
29 | | - $data .= substr('====', $mod4); |
30 | | - } |
31 | | - return base64_decode($data); |
| 25 | +function urlsafe_b64decode( $string ) { |
| 26 | + $data = str_replace( array( '-', '_' ), array( '+', '/' ), $string ); |
| 27 | + $mod4 = strlen( $data ) % 4; |
| 28 | + if ( $mod4 ) { |
| 29 | + $data .= substr( '====', $mod4 ); |
| 30 | + } |
| 31 | + return base64_decode( $data ); |
32 | 32 | } |
33 | 33 | |
34 | 34 | function shorturlEncode ( $title ) { |
35 | 35 | global $wgMemc; |
36 | 36 | |
37 | | - $id = null; |
| 37 | + $id = null; |
38 | 38 | $id = $wgMemc->get( wfMemcKey( 'shorturls', 'title', $title->getFullText() ) ); |
39 | | - if( !$id ) { |
| 39 | + if ( !$id ) { |
40 | 40 | $dbr = wfGetDB( DB_SLAVE ); |
41 | 41 | $query = $dbr->select( |
42 | 42 | 'shorturls', |
43 | 43 | array( 'su_id' ), |
44 | 44 | array( 'su_namespace' => $title->getNamespace(), 'su_title' => $title->getText() ), |
45 | | - __METHOD__); |
46 | | - if( $dbr->numRows( $query ) > 0 ) { |
| 45 | + __METHOD__ ); |
| 46 | + if ( $dbr->numRows( $query ) > 0 ) { |
47 | 47 | $entry = $dbr->fetchRow( $query ); |
48 | 48 | $id = $entry['su_id']; |
49 | 49 | } else { |
— | — | @@ -53,18 +53,18 @@ |
54 | 54 | 'su_title' => $title->getText() |
55 | 55 | ); |
56 | 56 | $dbw->insert( 'shorturls', $row_data ); |
57 | | - $id = $dbw->insertId(); |
| 57 | + $id = $dbw->insertId(); |
58 | 58 | } |
59 | 59 | $wgMemc->set( wfMemcKey( 'shorturls', 'title', $title->getFullText() ), $id, 0 ); |
60 | | - } |
| 60 | + } |
61 | 61 | return urlsafe_b64encode( $id ); |
62 | 62 | } |
63 | 63 | |
64 | 64 | function shorturlDecode ( $data ) { |
65 | 65 | global $wgMemc; |
66 | 66 | |
67 | | - $id = intval(urlsafe_b64decode ( $data )); |
68 | | - $entry = $wgMemc->get( wfMemcKey( 'shorturls', 'id', $id) ); |
| 67 | + $id = intval( urlsafe_b64decode ( $data ) ); |
| 68 | + $entry = $wgMemc->get( wfMemcKey( 'shorturls', 'id', $id ) ); |
69 | 69 | if ( !$entry ) { |
70 | 70 | $dbr = wfGetDB( DB_SLAVE ); |
71 | 71 | $query = $dbr->select( |
— | — | @@ -74,7 +74,7 @@ |
75 | 75 | __METHOD__ |
76 | 76 | ); |
77 | 77 | |
78 | | - $entry = $dbr->fetchRow($query); |
| 78 | + $entry = $dbr->fetchRow( $query ); |
79 | 79 | $wgMemc->set( wfMemcKey( 'shorturls', 'id', $id ), $entry, 0 ); |
80 | 80 | } |
81 | 81 | return Title::makeTitle( $entry['su_namespace'], $entry['su_title'] ); |
Index: trunk/extensions/ShortUrl/ShortUrl.i18n.php |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | * @ingroup Extensions |
8 | 8 | * @author Yuvi Panda, yuvi.in |
9 | 9 | * @copyright © Yuvaraj Pandian <yuvipanda@yuvi.in> |
10 | | - * @license Modified BSD License |
| 10 | + * @license Modified BSD License |
11 | 11 | */ |
12 | 12 | |
13 | 13 | $messages = array(); |
Index: trunk/extensions/ShortUrl/ShortUrl.php |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * Setup for ShortUrl extension, a special page that provides redirects to articles |
| 4 | + * Setup for ShortUrl extension, a special page that provides redirects to articles |
5 | 5 | * via their page IDs |
6 | 6 | * |
7 | 7 | * @file |
— | — | @@ -10,7 +10,7 @@ |
11 | 11 | * @licence Modified BSD License |
12 | 12 | */ |
13 | 13 | |
14 | | -if( !defined( 'MEDIAWIKI' ) ) { |
| 14 | +if ( !defined( 'MEDIAWIKI' ) ) { |
15 | 15 | echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" ); |
16 | 16 | die( 1 ); |
17 | 17 | } |
Index: trunk/extensions/ShortUrl/SpecialShortUrl.php |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * Setup for ShortUrl extension, a special page that provides redirects to articles |
| 4 | + * Setup for ShortUrl extension, a special page that provides redirects to articles |
5 | 5 | * via their page IDs |
6 | 6 | * |
7 | 7 | * @file |
— | — | @@ -10,7 +10,7 @@ |
11 | 11 | * @licence Modified BSD License |
12 | 12 | */ |
13 | 13 | |
14 | | -if( !defined( 'MEDIAWIKI' ) ) { |
| 14 | +if ( !defined( 'MEDIAWIKI' ) ) { |
15 | 15 | echo( "not a valid entry point.\n" ); |
16 | 16 | die( 1 ); |
17 | 17 | } |
— | — | @@ -37,7 +37,7 @@ |
38 | 38 | */ |
39 | 39 | public function execute( $par ) { |
40 | 40 | global $wgOut, $wgRequest; |
41 | | - |
| 41 | + |
42 | 42 | $title = shorturlDecode( $par ); |
43 | 43 | if ( $title ) { |
44 | 44 | $wgOut->redirect( $title->getFullURL(), '301' ); |
Index: trunk/extensions/ShortUrl/ShortUrl.hooks.php |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | $shortId = shorturlEncode( $title ); |
25 | 25 | $shortURL = $wgShortUrlPrefix . $shortId; |
26 | 26 | $html = Html::rawElement( 'li', array( 'id' => 't-shorturl' ), |
27 | | - Html::Element( 'a', array( 'href' => $shortURL, 'title' => wfMsg( 'shorturl-toolbox-title') ), wfMsg ( 'shorturl-toolbox-text' ) ) |
| 27 | + Html::Element( 'a', array( 'href' => $shortURL, 'title' => wfMsg( 'shorturl-toolbox-title' ) ), wfMsg ( 'shorturl-toolbox-text' ) ) |
28 | 28 | ); |
29 | 29 | |
30 | 30 | echo $html; |
— | — | @@ -33,7 +33,7 @@ |
34 | 34 | |
35 | 35 | public static function SetupSchema( DatabaseUpdater $du ) { |
36 | 36 | $base = dirname( __FILE__ ) . '/schemas'; |
37 | | - $du->addExtensionTable( "shorturls", "$base/shorturls.sql"); |
| 37 | + $du->addExtensionTable( "shorturls", "$base/shorturls.sql" ); |
38 | 38 | return true; |
39 | 39 | } |
40 | 40 | |