r48894 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48893‎ | r48894 | r48895 >
Date:20:01, 26 March 2009
Author:demon
Status:deferred
Tags:
Comment:
Code cleanup:
* Spaces -> tabs
* Remove trailing ?>
* Use $out->mBodytext directly, no need for an extra variable
Modified paths:
  • /trunk/extensions/LocalFileLink/LocalFileLink.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LocalFileLink/LocalFileLink.php
@@ -9,37 +9,29 @@
1010 'description' => 'Allows the usage of local file links with FCKEditor',
1111 );
1212
13 -function lflAddLocalFileLinks(&$out) {
14 -
15 - $text = $out->mBodytext;
16 -
17 - $search = '/\[(file\:\/{2,5}[a-zA-Z]{0,1}[\:]{0,1}\S*)\s*([^\]]*)\]/';
18 - $replace = '<a href="$1" class="link-ftp">$2</a>';
 13+function lflAddLocalFileLinks( &$out ) {
1914
20 - $text = preg_replace($search, $replace, $text);
21 -
22 - $out->mBodytext = $text;
 15+ $search = '/\[(file\:\/{2,5}[a-zA-Z]{0,1}[\:]{0,1}\S*)\s*([^\]]*)\]/';
 16+ $replace = '<a href="$1" class="link-ftp">$2</a>';
2317
24 - return true;
 18+ $out->mBodytext = preg_replace( $search, $replace, $out->mBodytext );
 19+
 20+ return true;
2521 }
2622
27 -function lflAjaxAddLocalFileLinks(&$parser, &$text) {
28 -
29 - $search = '/\[(file\:\/{2,5}[a-zA-Z]{0,1}[\:]{0,1}\S*)\s*([^\]]*)\]/';
30 - $replace = '<a href="$1" class="link-ftp">$2</a>';
 23+function lflAjaxAddLocalFileLinks( &$parser, &$text ) {
3124
32 - $text = preg_replace($search, $replace, $text);
33 -
34 - return true;
35 -}
 25+ $search = '/\[(file\:\/{2,5}[a-zA-Z]{0,1}[\:]{0,1}\S*)\s*([^\]]*)\]/';
 26+ $replace = '<a href="$1" class="link-ftp">$2</a>';
3627
 28+ $text = preg_replace($search, $replace, $text);
3729
 30+ return true;
 31+}
3832
3933 if ( isset($_REQUEST['rs']) ) {
40 - $wgHooks['ParserBeforeTidy'][] = 'lflAjaxAddLocalFileLinks';
 34+ $wgHooks['ParserBeforeTidy'][] = 'lflAjaxAddLocalFileLinks';
4135 }
4236 else {
43 - $wgHooks['BeforePageDisplay'][] = 'lflAddLocalFileLinks';
 37+ $wgHooks['BeforePageDisplay'][] = 'lflAddLocalFileLinks';
4438 }
45 -
46 -?>

Status & tagging log