Changed how tables are layed out (since I was repeatedly duplicating code in many places) by adding a table element to be used wherever we need a table. This could probably have been a helper instead of an element, but it's not clear to me why one should be chosen over the other, and I already know how to quickly add an element (I think the real choice resides in whether you need a collection of helper functions, or you just want to drop in a chunk of html, i.e. a helper element). Also, a major revamp to the style sheets as well, although more work is clearly needed.

git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@42 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-05-30 15:56:41 +00:00
parent 2a4b8079fb
commit c041174b0c
10 changed files with 452 additions and 535 deletions

View File

@@ -0,0 +1,59 @@
<?php /* -*- mode:PHP -*- */
/* table.ctp */
/*
*
* @filesource
* @copyright Copyright 2009, Abijah Perkins
* @package pmgr
*/
if (isset($rows) && is_array($rows) && count($rows)) {
echo('<TABLE' . (isset($class) ? ' CLASS="'.$class.'"' : '') . '>' . "\n");
if (isset($caption))
echo(' <CAPTION>' . $caption . '</CAPTION>' . "\n");
if (isset($row_class) && is_array($row_class)) {
foreach ($row_class AS &$rc)
$rc = preg_replace("/ /", "-", strtolower($rc));
}
if (isset($column_class) && is_array($column_class)) {
foreach ($column_class AS &$cc)
$cc = preg_replace("/ /", "-", strtolower($cc));
}
/* if (isset($headers) && is_array($headers)) { */
/* foreach ($headers AS $i => $col) { */
/* if (!isset($column_class[$i])) */
/* continue; */
/* $headers[$i] = array($col, array('class' => $column_class[$i])); */
/* } */
/* } */
// Very kludgy.
// I want the row_class to affix to the <tr> tag.
// tableCells, however, does not have such ability :-/
foreach ($rows AS $r => &$row) {
foreach ($row AS $c => $col) {
$colclass = (isset($column_class) && is_array($column_class)) ? $column_class[$c] : '';;
$rowclass = (isset($row_class) && is_array($row_class)) ? $row_class[$r] : '';
$class = $rowclass . ($colclass ? " " . $colclass : '');
if (!$class)
continue;
$row[$c] = array($col, array('class' => $class));
}
}
echo("\n");
if (isset($headers) && is_array($headers))
echo $html->tableHeaders($headers);
echo("\n");
echo $html->tableCells($rows,
array('class' => "oddrow"),
array('class' => "evnrow"),
false, false);
echo("\n");
echo('</TABLE>' . "\n");
}