Extension:FileLinkCorrection

From MediaWiki.org

Jump to: navigation, search
Manual on MediaWiki Extensions
List of MediaWiki Extensions
FileLinkCorrection

Release status: beta

Implementation Page action
Description Using file:// links with linktext with MediaWiki+FCKeditor
Author(s) Johannes Perl (Jperl Talk)
Version 0.1
MediaWiki 1.10.2
Download no link
Hooks used

OutputPageBeforeHTML

Contents

[edit] What can this extension do?

This extension corrects file:// links with description which are destroyed by the FCKeditor.

[edit] Usage

[edit] Download instructions

Please cut and paste the code found below and place it in $IP/extensions/FileLinkCorrection.php. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.

[edit] Installation

To install this extension, add the following to LocalSettings.php:

#to correct file:// links destroyed by FCKeditor
include("extensions/FileLinkCorrection.php");

[edit] Code

<?php
# FileLinkCorrection MediaWiki Extention
# Created by Johannes Perl
#
#
# When using file:// links with MediaWiki+FCKeditor, file links of the form 
# [file://path/to/file/file.txt filename] are destroyed.
# This extension parses the html output and corrects destroyed tags. 
 
$wgExtensionCredits['parserhook'][] = array(
        'name' => 'FileLinkCorrection',
        'author' => 'Johannes Perl',
        'url' => 'http://www.mediawiki.org/wiki/User:Jperl',
        'description' => 'This extension helps to be able to use file:// links with description MediaWiki+FCKeditor.',
        'version'=>'0.1'
);
 
$wgHooks['OutputPageBeforeHTML'][] = 'fileLinkCorrection';
 
function fileLinkCorrection(&$out, &$parseroutput)
{
        $mBodytext = $out->mBodytext;
        //preview of text     
        if($mBodytext != "")
                $out->mBodytext = preg_replace('/\[(<a[^>]*\>)([^(bearbeiten)].*)<\/a>(.*)\]/U', "$1$3</a>", $mBodytext);
        else
                $parseroutput = preg_replace('/\[(<a[^>]*\>)([^(bearbeiten)].*)<\/a>(.*)\]/U', "$1$3</a>", $parseroutput);
 
        return true;
}
?>

[edit] See also

Personal tools