Extension:WikiPagesTag
<translate> This extension stores its source code on a wiki page.</translate> <translate> Please be aware that this code may be unreviewed or maliciously altered.</translate> <translate> They may contain security holes, outdated interfaces that are no longer compatible etc.</translate> <translate> Note:</translate> <translate> No [[<tvar name=localisation>Special:MyLanguage/Localisation#Translation resources</tvar>|localisation]] updates are provided for this extension by <tvar name=twn>translatewiki.net </tvar>.</translate> |
This extension is incompatible with MediaWiki 1.39 or any later release! You are advised against using this extension on a live site.
|
<translate> This extension is currently not actively maintained!</translate> <translate> Although it may still work, any bug reports or feature requests will more than likely be ignored.</translate> |
WikiPagesTag Release status: unmaintained |
|
---|---|
Implementation | Tag |
Description | Allows to have a list enclosed in <WikiPages> </WikiPages> tag that auto links to internal links whether or not is exists. |
Author(s) | Rajinder Uppal (owngeektalk) |
Latest version | 1.0 (2010-01-27) |
MediaWiki | |
Database changes | No |
License | Freeware just give me credit if you use it. |
Download | No link |
|
|
Quarterly downloads | Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin'). |
Public wikis using | Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin'). |
What can this extension do?
This extension was made because there was no way other than using auto-link to create internal links to documents or articles using a tag. But auto-link is very intensive one resources etc. Also I wanted the ability to have a list of words separated by a carriage return and have those words automatically link to internal pages whether or not those pages exist.
So if you had a list of words like:
billy bob
jane austin
mike duck
super man
And you want to create internal links for those documents, you would have to place [[ and ]] around those words. If there is a lot of words, that is a lot of manual editing. This will allow you to auto link all of those words without manually adding the brackets.
Usage
<WikiPages> list list list </WikiPages>
Will do the equivalent of:
[[list]] [[list]] [[list]] [[list]]
Thanks and if you have questions email me at owngeek@gmail.com
Download instructions
Please cut and paste the code found below. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds $IP/extensions/WikiPages.php
LocalSettings.php.
Installation
To install this extension, add the following to LocalSettings.php:
#add configuration parameters here
#setup user rights here
require_once("$IP/extensions/WikiPages.php");
Code
This is the version 1.0 It includes the ability to add css styling to the output. Also you can specify if you want the UL or LI per line.
<?php
if (!defined('MEDIAWIKI')) die();
$wgExtensionCredits['validextensionclass'][] = array(
'name' => 'WikiPagesTag',
'author' =>'Rajinder Uppal',
'url' => 'https://www.mediawiki.org/wiki/Extension:WikiPagesTag',
'description' => 'Allows you to automatically add [[ ]] around a list of words in a wiki to auto link them'
);
//Avoid unstubbing $wgParser on setHook() too early on modern (1.12+) MW versions, as per r35980
if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
$wgHooks['ParserFirstCallInit'][] = 'wfWikiPages';
} else { // Otherwise do things the old fashioned way
$wgExtensionFunctions[] = 'wfWikiPages';
}
function wfWikiPages( $data ) {
global $wgParser;
$wgParser->setHook( 'WikiPages', 'wfWikiPagesTagParser' );
return true;
}
function wfWikiPagesTagParser( $data,$args,&$parser) {
global $wgParser;
// Declare Variables
$cols = 4;
// Check arguments are passed.
if (array_key_exists('cols', $argv)) {$cols = trim($argv['type']);}
if (array_key_exists('class', $argv)) {$class = trim($argv['type']);}
$table = "<table class=\"$class\" style=\"text-align: center;\">";
$tr_field='<tr>';
$td_field='<td>';
// $before_list_line_insert='<ul><li>[[';
// $after_list_lineInsert=']] </li></ul>';
$before_list_line_insert='[[';
$after_list_lineInsert=']]';
$output= $table;
# return $parser->recursiveTagParse( "[[" . implode( "]]<br /> \n[[",
# array_map( 'wfWikiPagesString',
# explode( "\n", trim( $data ) ) ) ) . "]]<br />\n");
$index=1;
$array = array_map( 'wfWikiPagesString',explode( "\n", trim( $data )));
$output .= $tr_field;
for ( $x=0; $x < 4; $x++ ) {
$output .= $td_field;
for ($y=$x; $y < count($array); $y+=4) {
$val = $before_list_line_insert . $array[$y] . $after_list_lineInsert;
$output .= $val;
}
$output .= "</td>";
}
$output .= "</tr></table>";
return $parser->recursiveTagParse( $output); }
function wfWikiPagesString( $text ) {
return strtr(
wfWikiPagesDisplay( $text ),
array(
"\\" => "\\\\",
"\"" => "\\\"",
"'" => "'",
"\r\n" => "\\n",
"\r" => "\\n",
"\n" => "\\n",
) );
}
function wfWikiPagesDisplay( $text ) {
static $invisibles = array( ' ', ' ' );
static $visibles = array( '&nbsp;', '&#160;' );
return Sanitizer::decodeCharReferences(
str_replace( $invisibles, $visibles, $text ) );
}
- Pages with script errors
- Pages with broken file links
- Extensions which host their code in-wiki
- Extensions incompatible with 1.39
- Unmaintained extensions
- Extensions without an image
- Tag extensions
- Extensions without a compatibility policy
- Extensions without MediaWiki version
- Extensions with unknown license
- ParserFirstCallInit extensions
- All extensions
- Extensions not in ExtensionJson