Extension:Edit Section Link Transform
From MediaWiki.org
|
Edit Section Link Transform Release status: stable |
|
|---|---|
| Implementation | User interface |
| Description | Changes "[edit]" edit section links in to an icon link. |
| Author(s) | Tim Laqua |
| Version | 1.0 (08-05-2007) |
| MediaWiki | 1.5+ |
| Download | see below |
| Hooks used | |
This extension replaces the boring "[edit]" links with a pretty icon (of your choosing).
Contents |
[edit] Installation
- Copy the source code (below) to a file named EditSectionLinkTransform.php
- Create a new folder (directory) in the following location:
wiki-install-folder/extensions/EditSectionLinkTransform - Copy EditSectionLinkTransform.php in to the new EditSectionLinkTransform folder
- Add the following code to your LocalSettings.php at the bottom
//Path to YOUR "[edit]" link icon! $wgEditSectionIcon = "$wgScriptPath/extensions/EditSectionLinkTransform/EditSectionIcon.png"; require_once("$IP/extensions/EditSectionLinkTransform/EditSectionLinkTransform.php");
[edit] Source Code
[edit] EditSectionLinkTransform.php
<?php if ( !defined( 'MEDIAWIKI' ) ) { die( 'This file is a MediaWiki extension, it is not a valid entry point' ); } $wgExtensionCredits['parserhook'][] = array( 'name'=>'Edit Section Link Transform', 'url'=>'http://www.mediawiki.org/wiki/Extension:Edit_Section_Link_Transform', 'author'=>'Tim Laqua, t.laqua at gmail dot com', 'description'=>'Replaces the [edit] EditSection link in articles with an icon.', 'version'=>'1.0' ); $wgHooks['ParserAfterTidy'][] = 'wfEditSectionLinkTransform'; function wfEditSectionLinkTransform(&$parser, &$text) { global $wgEditSectionIcon; $text = preg_replace("/<span class=\"editsection\">\[<a href=\"(.+)\" title=\"(.+)\">".wfMsg('editsection')."<\/a>\]<\/span>/i", "<span class=\"editsection\"><a href=\"$1\" title=\"$2\"><img src=\"$wgEditSectionIcon\" width=\"16px\" height=\"16px\" border=\"0\" alt=\"$2\"></a></span>",$text); return false; } return true;
[edit] Usage
- Follow Installation Instructions
- Ensure that your $wgEditSectionIcon is a valid path to a valid image!
There comes an error on Mediawiki 1.11. This can be fix by adding "return false;" in the end of the funtion. Comment by user Tweaked it. Tuvok[Talk/en.wp] 22:24, 4 January 2008 (UTC)

