Extension:Alternate
From MediaWiki.org
|
Release status: experimental |
|||
|---|---|---|---|
| Implementation | Tag | ||
| Description | give you the oportunity to alternate how the model look | ||
| Author(s) | Thierry G. Veilleux (KronoxtTalk) | ||
| Last Version | 0.1 (15:31, 9 May 2009 (UTC)) | ||
| MediaWiki | 1.13+ didn't check other | ||
| License | not specified | ||
| Download | see below | ||
|
|||
|
check usage (experimental) |
|||
Contents |
[edit] Description
This is an choose-the-text tag... It's the continuity of the Extension:NumerAlpha which counts how many tags there are in the source... Well this one chose one text from two. If the tag is not even... It chooses the text1 if it is... it chooses the text2.
[edit] License
License not specified... you can use it, modify it, distribute it, etc.
[edit] Status
experimental
[edit] Why this extension?
Well I use it to list characters so the pictures can be one on the left, the other on the right... etc. You can reset it using the parameter reset, and restart the count with the parameter begin
[edit] usage
example: from one model I use...
{{#tag:alt
|
|text1="
<table width='100%' cellspacing='3px;' border='0'>
<tr>
<td width='15px' style='border:1px solid #000; background:#AAA;'>$nbsp;
</td><td style='border:1px solid #000; background:#CCC;'>{{{1|personnages}}}
</td></tr><tr><td colspan='2' style='border:1px solid #000; background:#EEE; text-align:justify'>
[[file:{{{name|no_pic}}}.jpg|thumb|right]]{{{2|description}}}
</td></tr></table>"
|text2="
<table width='100%' cellspacing='5px;' border='0'>
<tr>
<td style='border:1px solid #000; background:#CCC;'>{{{1|personnages}}}
</td><td width='15px' style='border:1px solid #000; background:#AAA;'>
</td></tr><tr><td colspan='2' style='border:1px solid #000; background:#EEE; text-align:justify'>
[[file:{{{name|no_pic}}}.jpg|thumb|right]]{{{2|description}}}
</td></tr></table>"
}}
[edit] installation
You can install it by
- copying the following php code:
- save it with the Alternate.php filename.
- copy it into your extensions directory
- and add the inclusion in your [localsettings.php] file. → require_once("$IP/extensions/Alternate.php");
<?php //KroNoxt extension free to use modify or anything if you want to give me credits you're free to do so. //we don't need array and class file because it's only numbers... $wgExtensionCredits['parserhook'][] = array( 'name' => 'Alternate', 'author' => 'KroNoxt', 'description' => 'to alternate the way of model, table, etc.', 'url' => 'http://www.mediawiki.org/wiki/Extension:Alternate' ); $wgExtAlt = new ExtAlt(); $wgExtensionFunctions[] = array( &$wgExtAlt, 'setup' ); class ExtAlt { const VERSION = '0.1'; private static $NumAltCnt = 1; //when you want to reset... you put the reset parameters to "1" //this for abc incremential... public function setup() { global $wgParser; $wgParser->setHook( 'alt', array( &$this, 'altRender' ) ); } function altRender($text,$argv,&$parser){ if (isset($argv['reset']) && $argv['reset'] = "yes" OR isset($argv['reset']) && $argv['reset'] = "1") {self::$NumAltCnt = 1;} if (isset($argv['begin']) && $argv['begin'] != "") {self::$NumAltCnt = $argv['begin'];} $num = self::$NumAltCnt++; $num = intval($num); if (isset($argv['text1'])) {$t1 = $argv['text1'];}else{$t1 = "The parameter \"text1\" is not defined";} if (isset($argv['text2'])) {$t2 = $argv['text2'];}else{$t2 = "The parameter \"text2\" is not defined";} if ($num%2 == 0) {$output = $parser->recursiveTagParse( $t2 );} else{$output = $parser->recursiveTagParse( $t1 );} return $output; }}