Index: trunk/extensions/ShortUrl/ShortUrl.functions.php |
— | — | @@ -13,14 +13,22 @@ |
14 | 14 | exit( 1 ); |
15 | 15 | } |
16 | 16 | |
17 | | -/* stolen from http://www.php.net/manual/en/function.base64-encode.php#63543 */ |
| 17 | +/** |
| 18 | + * stolen from http://www.php.net/manual/en/function.base64-encode.php#63543 |
| 19 | + * |
| 20 | + * @param $string string |
| 21 | + */ |
18 | 22 | function urlsafe_b64encode( $string ) { |
19 | 23 | $data = base64_encode( $string ); |
20 | 24 | $data = str_replace( array( '+', '/', '=' ), array( '-', '_', '' ), $data ); |
21 | 25 | return $data; |
22 | 26 | } |
23 | 27 | |
24 | | -/* stolen from http://www.php.net/manual/en/function.base64-encode.php#63543 */ |
| 28 | +/** |
| 29 | + * stolen from http://www.php.net/manual/en/function.base64-encode.php#63543 |
| 30 | + * |
| 31 | + * @param $string string |
| 32 | + */ |
25 | 33 | function urlsafe_b64decode( $string ) { |
26 | 34 | $data = str_replace( array( '-', '_' ), array( '+', '/' ), $string ); |
27 | 35 | $mod4 = strlen( $data ) % 4; |
— | — | @@ -30,6 +38,10 @@ |
31 | 39 | return base64_decode( $data ); |
32 | 40 | } |
33 | 41 | |
| 42 | +/** |
| 43 | + * @param $title Title |
| 44 | + * @return mixed|string |
| 45 | + */ |
34 | 46 | function shorturlEncode ( $title ) { |
35 | 47 | global $wgMemc; |
36 | 48 | |
— | — | @@ -59,6 +71,10 @@ |
60 | 72 | return urlsafe_b64encode( $id ); |
61 | 73 | } |
62 | 74 | |
| 75 | +/** |
| 76 | + * @param $data string |
| 77 | + * @return Title |
| 78 | + */ |
63 | 79 | function shorturlDecode ( $data ) { |
64 | 80 | global $wgMemc; |
65 | 81 | |
Index: trunk/extensions/ShortUrl/ShortUrl.php |
— | — | @@ -28,7 +28,6 @@ |
29 | 29 | $dir = dirname( __FILE__ ) . '/'; |
30 | 30 | $wgExtensionMessagesFiles['ShortUrl'] = $dir . 'ShortUrl.i18n.php'; |
31 | 31 | |
32 | | - |
33 | 32 | $wgAutoloadClasses['ShortUrlHooks'] = $dir . 'ShortUrl.hooks.php'; |
34 | 33 | $wgAutoloadClasses['SpecialShortUrl'] = $dir . 'SpecialShortUrl.php'; |
35 | 34 | $wgSpecialPages['ShortUrl'] = 'SpecialShortUrl'; |
Index: trunk/extensions/ShortUrl/ShortUrl.hooks.php |
— | — | @@ -16,6 +16,10 @@ |
17 | 17 | require_once "ShortUrl.functions.php"; |
18 | 18 | |
19 | 19 | class ShortUrlHooks { |
| 20 | + /** |
| 21 | + * @param $tpl |
| 22 | + * @return bool |
| 23 | + */ |
20 | 24 | public static function AddToolboxLink( &$tpl ) { |
21 | 25 | global $wgOut, $wgShortUrlPrefix; |
22 | 26 | if ( ! $wgOut->getTitle()->equals( Title::newMainPage() ) ) { |
— | — | @@ -23,7 +27,11 @@ |
24 | 28 | $shortId = shorturlEncode( $title ); |
25 | 29 | $shortURL = $wgShortUrlPrefix . $shortId; |
26 | 30 | $html = Html::rawElement( 'li', array( 'id' => 't-shorturl' ), |
27 | | - Html::Element( 'a', array( 'href' => $shortURL, 'title' => wfMsg( 'shorturl-toolbox-title' ) ), wfMsg ( 'shorturl-toolbox-text' ) ) |
| 31 | + Html::Element( 'a', array( |
| 32 | + 'href' => $shortURL, |
| 33 | + 'title' => wfMsg( 'shorturl-toolbox-title' ) |
| 34 | + ), |
| 35 | + wfMsg ( 'shorturl-toolbox-text' ) ) |
28 | 36 | ); |
29 | 37 | |
30 | 38 | echo $html; |
— | — | @@ -31,6 +39,10 @@ |
32 | 40 | return true; |
33 | 41 | } |
34 | 42 | |
| 43 | + /** |
| 44 | + * @param $du DatabaseUpdater |
| 45 | + * @return bool |
| 46 | + */ |
35 | 47 | public static function SetupSchema( DatabaseUpdater $du ) { |
36 | 48 | $base = dirname( __FILE__ ) . '/schemas'; |
37 | 49 | $du->addExtensionTable( "shorturls", "$base/shorturls.sql" ); |