Source for file data.ledgertable.php
Documentation is available at data.ledgertable.php
* @author KainX <mej@kainx.org>
* @subpackage plugins_data
* @copyright Copyright (c) 2004, bitweaver.org
* All Rights Reserved. See below for details and a complete list of authors.
* @license Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details.
define( 'PLUGIN_GUID_DATALEDGERTABLE', 'dataledgertable' );
'auto_activate' => FALSE,
'load_function' => 'data_ledgertable',
'title' => 'Ledger Table',
'help_page' => 'DataPluginLedgertable',
'description' => tra("This Plugin creates a ledger-like table with even/odd row colors, optional top- or left-placed headers, and support for row/column spans."),
'help_function' => 'data_ledgertable_help',
'syntax' => "{LEDGERTABLE loc= head= }",
'<table class="data help">'
. '<th>' . tra( "Key" ) . '</th>'
. '<th>' . tra( "Type" ) . '</th>'
. '<th>' . tra( "Comments" ) . '</th>'
. '<td>' . tra( "string") . '<br />' . tra("(optional)") . '</td>'
. '<td>' . tra( "Where to display row/column headers (\"left\" or \"top\", default <strong>top</strong>).")
. '<td>' . tra( "string") . '<br />' . tra("(optional)") . '</td>'
. '<td>' . tra( "Header(s) separated by \"~|~\", default <strong>none</strong>")
. tra("LedgerTable: ") . "{LEDGERTABLE loc=>left head=>Row1~|~Row2~|~Row3}<br />"
. tra("This will display")
. data_ledgertable('Example', array('loc' => 'left', 'head' => 'Row1~|~Row2~|~Row3'));
return "<!-- Error: No data passed to LEDGERTABLE plugin. -->";
if (substr($data, 0, 1) == "\n") {
if (isset ($params['loc'])) {
$ret .= "<!-- Header row set to $params[loc]. -->";
$plugdata_loc = $params['loc'];
$ret .= "<!-- Defaulting header row to top. -->";
if (isset ($params['head'])) {
$ret .= "<!-- Got headers. -->";
$plugdata_head = $params['head'];
$ret .= "<!-- No headers specified. -->";
if (isset ($params['width'])) {
$ret .= "<!-- Got width $params[width]. -->";
$plugdata_width = " style=\"width: " . $params['width'] . '"';
$ret .= "<table class=\"ledgertable\"$plugdata_width>";
if (isset ($plugdata_head)) {
$headers = explode('~|~', $plugdata_head);
if ($plugdata_loc == 'top') {
$ret .= " <!-- Placing header row on top. -->";
$ret .= " <tr class=\"ledgertable header row\">";
foreach ($headers as $hdr) {
$ret .= " <th class=\"header highlight\">$hdr</td>";
$lines = split("\n", $data);
foreach ($lines as $line) {
$ret .= " <!-- Displaying row $line_count. -->";
$ret .= " <tr class=\"" . (($line_count % 2) ? ("odd") : ("even")) . "\">";
if (isset ($plugdata_head) && ($plugdata_loc == "left")) {
$ret .= " <!-- Placing header on left. -->";
$ret .= " <th class=\"header highlight\"";
if (preg_match("/^~(row|col)span:(\d+)~(.*)$/", $header, $matches)) {
$ret .= " $matches[1]span=\"$matches[2]\"";
foreach ($cells as $col) {
$ret .= " <td class=\"" . (($line_count % 2) ? ("odd") : ("even")) . "\"";
if (!strcmp($col, "~blank~")) {
} else if (preg_match("/^~(row|col)span:(\d+)~(.*)$/", $col, $matches)) {
$ret .= " $matches[1]span=\"$matches[2]\"";
|