http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88818
Revision: 88818
Author: yuvipanda
Date: 2011-05-25 19:26:10 +0000 (Wed, 25 May 2011)
Log Message:
-----------
Spacing fixes for ShortUrl
Modified Paths:
--------------
trunk/extensions/ShortUrl/ShortUrl.functions.php
trunk/extensions/ShortUrl/ShortUrl.hooks.php
trunk/extensions/ShortUrl/ShortUrl.i18n.php
trunk/extensions/ShortUrl/ShortUrl.php
trunk/extensions/ShortUrl/SpecialShortUrl.php
Modified: trunk/extensions/ShortUrl/ShortUrl.functions.php
===================================================================
--- trunk/extensions/ShortUrl/ShortUrl.functions.php 2011-05-25 19:00:18 UTC
(rev 88817)
+++ trunk/extensions/ShortUrl/ShortUrl.functions.php 2011-05-25 19:26:10 UTC
(rev 88818)
@@ -14,35 +14,35 @@
}
/* stolen from http://www.php.net/manual/en/function.base64-encode.php#63543 */
-function urlsafe_b64encode($string) {
- $data = base64_encode($string);
- $data =
str_replace(array('+','/','='),array('-','_',''),$data);
- return $data;
+function urlsafe_b64encode( $string ) {
+ $data = base64_encode( $string );
+ $data = str_replace( array( '+', '/', '=' ), array( '-', '_', '' ), $data
);
+ return $data;
}
/* stolen from http://www.php.net/manual/en/function.base64-encode.php#63543 */
-function urlsafe_b64decode($string) {
- $data = str_replace(array('-','_'),array('+','/'),$string);
- $mod4 = strlen($data) % 4;
- if ($mod4) {
- $data .= substr('====', $mod4);
- }
- return base64_decode($data);
+function urlsafe_b64decode( $string ) {
+ $data = str_replace( array( '-', '_' ), array( '+', '/' ), $string );
+ $mod4 = strlen( $data ) % 4;
+ if ( $mod4 ) {
+ $data .= substr( '====', $mod4 );
+ }
+ return base64_decode( $data );
}
function shorturlEncode ( $title ) {
global $wgMemc;
- $id = null;
+ $id = null;
$id = $wgMemc->get( wfMemcKey( 'shorturls', 'title', $title->getFullText()
) );
- if( !$id ) {
+ if ( !$id ) {
$dbr = wfGetDB( DB_SLAVE );
$query = $dbr->select(
'shorturls',
array( 'su_id' ),
array( 'su_namespace' => $title->getNamespace(), 'su_title' =>
$title->getText() ),
- __METHOD__);
- if( $dbr->numRows( $query ) > 0 ) {
+ __METHOD__ );
+ if ( $dbr->numRows( $query ) > 0 ) {
$entry = $dbr->fetchRow( $query );
$id = $entry['su_id'];
} else {
@@ -53,18 +53,18 @@
'su_title' => $title->getText()
);
$dbw->insert( 'shorturls', $row_data );
- $id = $dbw->insertId();
+ $id = $dbw->insertId();
}
$wgMemc->set( wfMemcKey( 'shorturls', 'title', $title->getFullText()
), $id, 0 );
- }
+ }
return urlsafe_b64encode( $id );
}
function shorturlDecode ( $data ) {
global $wgMemc;
- $id = intval(urlsafe_b64decode ( $data ));
- $entry = $wgMemc->get( wfMemcKey( 'shorturls', 'id', $id) );
+ $id = intval( urlsafe_b64decode ( $data ) );
+ $entry = $wgMemc->get( wfMemcKey( 'shorturls', 'id', $id ) );
if ( !$entry ) {
$dbr = wfGetDB( DB_SLAVE );
$query = $dbr->select(
@@ -74,7 +74,7 @@
__METHOD__
);
- $entry = $dbr->fetchRow($query);
+ $entry = $dbr->fetchRow( $query );
$wgMemc->set( wfMemcKey( 'shorturls', 'id', $id ), $entry, 0 );
}
return Title::makeTitle( $entry['su_namespace'], $entry['su_title'] );
Modified: trunk/extensions/ShortUrl/ShortUrl.hooks.php
===================================================================
--- trunk/extensions/ShortUrl/ShortUrl.hooks.php 2011-05-25 19:00:18 UTC
(rev 88817)
+++ trunk/extensions/ShortUrl/ShortUrl.hooks.php 2011-05-25 19:26:10 UTC
(rev 88818)
@@ -23,7 +23,7 @@
$shortId = shorturlEncode( $title );
$shortURL = $wgShortUrlPrefix . $shortId;
$html = Html::rawElement( 'li', array( 'id' =>
't-shorturl' ),
- Html::Element( 'a', array( 'href' => $shortURL,
'title' => wfMsg( 'shorturl-toolbox-title') ), wfMsg ( 'shorturl-toolbox-text'
) )
+ Html::Element( 'a', array( 'href' => $shortURL,
'title' => wfMsg( 'shorturl-toolbox-title' ) ), wfMsg ( 'shorturl-toolbox-text'
) )
);
echo $html;
@@ -33,7 +33,7 @@
public static function SetupSchema( DatabaseUpdater $du ) {
$base = dirname( __FILE__ ) . '/schemas';
- $du->addExtensionTable( "shorturls", "$base/shorturls.sql");
+ $du->addExtensionTable( "shorturls", "$base/shorturls.sql" );
return true;
}
Modified: trunk/extensions/ShortUrl/ShortUrl.i18n.php
===================================================================
--- trunk/extensions/ShortUrl/ShortUrl.i18n.php 2011-05-25 19:00:18 UTC (rev
88817)
+++ trunk/extensions/ShortUrl/ShortUrl.i18n.php 2011-05-25 19:26:10 UTC (rev
88818)
@@ -6,7 +6,7 @@
* @ingroup Extensions
* @author Yuvi Panda, yuvi.in
* @copyright © Yuvaraj Pandian <[email protected]>
- * @license Modified BSD License
+ * @license Modified BSD License
*/
$messages = array();
Modified: trunk/extensions/ShortUrl/ShortUrl.php
===================================================================
--- trunk/extensions/ShortUrl/ShortUrl.php 2011-05-25 19:00:18 UTC (rev
88817)
+++ trunk/extensions/ShortUrl/ShortUrl.php 2011-05-25 19:26:10 UTC (rev
88818)
@@ -1,6 +1,6 @@
<?php
/**
- * Setup for ShortUrl extension, a special page that provides redirects to
articles
+ * Setup for ShortUrl extension, a special page that provides redirects to
articles
* via their page IDs
*
* @file
@@ -10,7 +10,7 @@
* @licence Modified BSD License
*/
-if( !defined( 'MEDIAWIKI' ) ) {
+if ( !defined( 'MEDIAWIKI' ) ) {
echo( "This file is an extension to the MediaWiki software and cannot
be used standalone.\n" );
die( 1 );
}
Modified: trunk/extensions/ShortUrl/SpecialShortUrl.php
===================================================================
--- trunk/extensions/ShortUrl/SpecialShortUrl.php 2011-05-25 19:00:18 UTC
(rev 88817)
+++ trunk/extensions/ShortUrl/SpecialShortUrl.php 2011-05-25 19:26:10 UTC
(rev 88818)
@@ -1,6 +1,6 @@
<?php
/**
- * Setup for ShortUrl extension, a special page that provides redirects to
articles
+ * Setup for ShortUrl extension, a special page that provides redirects to
articles
* via their page IDs
*
* @file
@@ -10,7 +10,7 @@
* @licence Modified BSD License
*/
-if( !defined( 'MEDIAWIKI' ) ) {
+if ( !defined( 'MEDIAWIKI' ) ) {
echo( "not a valid entry point.\n" );
die( 1 );
}
@@ -37,7 +37,7 @@
*/
public function execute( $par ) {
global $wgOut, $wgRequest;
-
+
$title = shorturlDecode( $par );
if ( $title ) {
$wgOut->redirect( $title->getFullURL(), '301' );
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs