Extension:PropertyTable/PropertyTable.php

<?php // PropertyTable MediaWiki Extension. // Outputs a table with keys and values.

// Copyright (C) 2007, Benner Sistemas. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA

$PropertyTableVersion = '1.1.0';


 * 1)    Internationalized messages
 * 1)    Internationalized messages

$wgPropertyTablePrefix = "propertytable_"; $wgPropertyTableMessages = array;

// English $wgPropertyTableMessages['en'] = array(   $wgPropertyTablePrefix . 'tag' => 'properties',    );

// Polish (PL) $wgPropertyTableMessages['pl'] = array(   $wgPropertyTablePrefix . 'tag' => 'wlasciwosci', );

// Portuguese (Brazilian) $wgPropertyTableMessages['pt-br'] = array(   $wgPropertyTablePrefix . 'tag' => 'propriedades', );


 * 1)    Extension initialization
 * 1)    Extension initialization

// HTML attributes of the table tag $wgPropertyTableAttributes = 'class="property_table" border="0" cellpadding="2" cellspacing="4"'; // HTML attributes of key cells $wgPropertyTableKeyAttributes = 'class="property_key_cell" valign="top" bgcolor="#E8F3FF" style="font-weight: bold"'; // HTML attributes of value cells $wgPropertyTableValueAttributes = 'class="property_value_cell" valign="top" bgcolor="#F3F3F3"';

// credits $wgExtensionCredits['parserhook'][] = array(   'name'=>'PropertyTable',    'version'=>$PropertyTableVersion,    'author'=>'Fernando Correia',    'url'=>'http://www.mediawiki.org/wiki/Extension:PropertyTable',    'description' => 'Outputs a table with keys and values'    );

// extension initialization $wgExtensionFunctions[] = "fnPropertyTableExtension";

// Registers the extension with the WikiText parser. function fnPropertyTableExtension { // register messages global $wgMessageCache, $wgPropertyTableMessages; foreach( $wgPropertyTableMessages as $sLang => $aMsgs ) { $wgMessageCache->addMessages( $aMsgs, $sLang ); }          // register the extension with the WikiText parser global $wgParser; $wgParser->setHook( wfMsg('propertytable_tag'), "fnPropertyTableTag" ); }


 * 1)    Event handlers
 * 1)    Event handlers

// Processes the tag. function fnPropertyTableTag($input, $argv, &$parser) { // initialize $sequence = 0; // parse input $properties = array; $tok = strtok($input, "\n"); while ($tok !== false) { $line = explode("=", $tok); if (count($line) == 2) { $properties[] = $line; }       $tok = strtok("\n"); }   // produce output if (count($properties) == 0) return ''; global $wgPropertyTableAttributes, $wgPropertyTableKeyAttributes, $wgPropertyTableValueAttributes; $result = " "; return $result; }

?>