Index: trunk/extensions/LocalFileLink/LocalFileLink.php |
— | — | @@ -9,37 +9,29 @@ |
10 | 10 | 'description' => 'Allows the usage of local file links with FCKEditor', |
11 | 11 | ); |
12 | 12 | |
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 ) { |
19 | 14 | |
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>'; |
23 | 17 | |
24 | | - return true; |
| 18 | + $out->mBodytext = preg_replace( $search, $replace, $out->mBodytext ); |
| 19 | + |
| 20 | + return true; |
25 | 21 | } |
26 | 22 | |
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 ) { |
31 | 24 | |
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>'; |
36 | 27 | |
| 28 | + $text = preg_replace($search, $replace, $text); |
37 | 29 | |
| 30 | + return true; |
| 31 | +} |
38 | 32 | |
39 | 33 | if ( isset($_REQUEST['rs']) ) { |
40 | | - $wgHooks['ParserBeforeTidy'][] = 'lflAjaxAddLocalFileLinks'; |
| 34 | + $wgHooks['ParserBeforeTidy'][] = 'lflAjaxAddLocalFileLinks'; |
41 | 35 | } |
42 | 36 | else { |
43 | | - $wgHooks['BeforePageDisplay'][] = 'lflAddLocalFileLinks'; |
| 37 | + $wgHooks['BeforePageDisplay'][] = 'lflAddLocalFileLinks'; |
44 | 38 | } |
45 | | - |
46 | | -?> |