Extension:FileLinkCorrection

From mediawiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
OOjs UI icon advanced.svg
FileLinkCorrection
Release status: unmaintained
Implementation Page action
Description Using file:// links with linktext with MediaWiki+FCKeditor
Author(s) Johannes Perl (Jperltalk)
Latest version 0.1.0 (2008-02-28)
MediaWiki 1.10.2+
MediaWiki 1.36 Not formally tested
MediaWiki 1.34 Not formally tested
MediaWiki 1.32 Not formally tested
License No license specified
Download see below

Check usage and version matrix.

What can this extension do?[edit]

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

This extension should have become obsolete for new mediawiki versions as FCKeditor has been improved now. Go to Extension:FCKeditor_(by_FCKeditor_and_Wikia) for details.

Usage[edit]

Download instructions[edit]

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 .

Installation[edit]

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

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

Code[edit]

<?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.0'
);

$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;
}
?>