Extension:GalleryTable
This extension stores its source code on a wiki page. Please be aware that this code may be unreviewed or maliciously altered. They may contain security holes, outdated interfaces that are no longer compatible etc. Note: No localisation updates are provided for this extension by translatewiki.net . |
This extension is incompatible with MediaWiki 1.39 or any later release! You are advised against using this extension on a live site.
|
This extension is currently not actively maintained! Although it may still work, any bug reports or feature requests will more than likely be ignored. |
GalleryTable Release status: unmaintained |
|
---|---|
Implementation | Tag |
Description | Displays a table-gallery |
Author(s) | RUNA (Runa_cgtalk) |
Latest version | 0.1 (March 2010) |
MediaWiki | tested on 1.10.2, 1.15.1 |
License | GPL |
Download | See the section labeled code below |
Displays a table, divided by the specified number of columns. Table Cells are separated by a newline. The contents of the cell - wikitext.
Installation edit
To install this extension
- Create file in your /extension directory: GalleryTable.php (see #Code section)
- Add the following to LocalSettings.php :
require_once("$IP/extensions/GalleryTable.php");
Syntax edit
<gal cols="column number (default = 3)"> gallery cell 1 gallery cell 2 gallery cell 3 ... gallery cell n </gal>
Code edit
<?php
//Avoid unstubbing $wgParser on setHook() too early on modern (1.12+) MW versions, as per r35980
if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
$wgHooks['ParserFirstCallInit'][] = 'wfGalleryTable';
} else { // Otherwise do things the old fashioned way
$wgExtensionFunctions[] = 'wfGalleryTable';
}
function wfGalleryTable() {
global $wgParser;
$wgParser->setHook( "gal", "GalleryTable" );
return true;
}
function GalleryTable( $input, $argv, $parser, $frame ) {
global $wgScriptPath;
$cols = 3;
if (isset($argv['cols'])) {$cols = $argv['cols'];}
$cwidth = floor(100/$cols);
$output = "<table>";
$tdcontent = explode(chr(10), $input);
$count = count($tdcontent);
for ($i=1; $i<$count-1; $i++) {
if ($i % $cols == 1) {$output .= chr(10)."<tr>";}
$content = $parser->recursiveTagParse($tdcontent[$i]);
$output .= "<td width=\"".$cwidth."%\">".$content."</td>";
if ($i % $cols == 0) {$output .= "</tr>";}
}
if (($count-2) % $cols > 0) {
$output .= "<td colspan=\"".($cols - (($count-2) % $cols))."\"> </td></tr>"; }
$output .= "</table>";
return $output;
}
?>