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:
@@ -4,57 +4,52 @@ if (isset($heading))
|
||||
echo $heading;
|
||||
else
|
||||
echo '<h2>'.__('Contacts',true).'</h2>';
|
||||
?>
|
||||
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
$headers_manual = array('Id', 'Last Name', 'First Name', 'Company', 'Comment');
|
||||
if (isset($paginator)) {
|
||||
echo $paginator->counter(array(
|
||||
'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
|
||||
|
||||
<?php
|
||||
{
|
||||
if (isset($paginator)) {
|
||||
echo $paginator->counter(array(
|
||||
'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
|
||||
|
||||
$rows = array($paginator->sort('id'),
|
||||
$headers = array($paginator->sort('id'),
|
||||
$paginator->sort('last_name'),
|
||||
$paginator->sort('first_name'),
|
||||
$paginator->sort('company_name'),
|
||||
//$paginator->sort('unit_id'),
|
||||
$paginator->sort('comment'));
|
||||
} else {
|
||||
$rows = array('Id', 'Last Name', 'First Name', 'Company', 'Comment');
|
||||
}
|
||||
echo $html->tableHeaders($rows);
|
||||
} else {
|
||||
$headers = $headers_manual;
|
||||
}
|
||||
|
||||
$rows = array();
|
||||
foreach ($contacts as $contact) {
|
||||
$rows[] = array($html->link($contact['Contact']['id'],
|
||||
array('controller' => 'contacts',
|
||||
'action' => 'view',
|
||||
$contact['Contact']['id'])),
|
||||
$html->link($contact['Contact']['last_name'],
|
||||
array('controller' => 'contacts',
|
||||
'action' => 'view',
|
||||
$contact['Contact']['id'])),
|
||||
$html->link($contact['Contact']['first_name'],
|
||||
array('controller' => 'contacts',
|
||||
'action' => 'view',
|
||||
$contact['Contact']['id'])),
|
||||
$contact['Contact']['company_name'],
|
||||
$contact['Contact']['comment']);
|
||||
}
|
||||
echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
$rows = array();
|
||||
foreach ($contacts as $contact) {
|
||||
$rows[] = array($html->link($contact['Contact']['id'],
|
||||
array('controller' => 'contacts',
|
||||
'action' => 'view',
|
||||
$contact['Contact']['id'])),
|
||||
$html->link($contact['Contact']['last_name'],
|
||||
array('controller' => 'contacts',
|
||||
'action' => 'view',
|
||||
$contact['Contact']['id'])),
|
||||
$html->link($contact['Contact']['first_name'],
|
||||
array('controller' => 'contacts',
|
||||
'action' => 'view',
|
||||
$contact['Contact']['id'])),
|
||||
$contact['Contact']['company_name'],
|
||||
$contact['Contact']['comment']);
|
||||
}
|
||||
|
||||
<?php
|
||||
if (isset($paginator)) {
|
||||
echo('<div class="paging">' . "\n");
|
||||
echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));
|
||||
echo(' | ');
|
||||
echo $paginator->numbers();
|
||||
echo(' | ');
|
||||
echo $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));
|
||||
echo('</div>' . "\n");
|
||||
}
|
||||
?>
|
||||
echo $this->element('table',
|
||||
array('class' => 'item contact list',
|
||||
'headers' => $headers,
|
||||
'rows' => $rows,
|
||||
'column_class' => $headers_manual));
|
||||
|
||||
if (isset($paginator)) {
|
||||
echo('<div class="paging">' . "\n");
|
||||
echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));
|
||||
echo(' | ');
|
||||
echo $paginator->numbers();
|
||||
echo(' | ');
|
||||
echo $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));
|
||||
echo('</div>' . "\n");
|
||||
}
|
||||
|
||||
@@ -4,55 +4,50 @@ if (isset($heading))
|
||||
echo $heading;
|
||||
else
|
||||
echo '<h2>'.__('Maps',true).'</h2>';
|
||||
?>
|
||||
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
$headers_manual = array('Id', 'Name', 'Area', 'Width', 'Depth', 'Comment');
|
||||
if (isset($paginator)) {
|
||||
echo $paginator->counter(array(
|
||||
'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
|
||||
|
||||
<?php
|
||||
{
|
||||
if (isset($paginator)) {
|
||||
echo $paginator->counter(array(
|
||||
'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
|
||||
|
||||
$rows = array($paginator->sort('id'),
|
||||
$headers = array($paginator->sort('id'),
|
||||
$paginator->sort('name'),
|
||||
$paginator->sort('site_area_id'),
|
||||
$paginator->sort('width'),
|
||||
$paginator->sort('depth'),
|
||||
$paginator->sort('comment'));
|
||||
} else {
|
||||
$rows = array('Id', 'Name', 'Area', 'Width', 'Depth', 'Comment');
|
||||
}
|
||||
echo $html->tableHeaders($rows);
|
||||
} else {
|
||||
$headers = $headers_manual;
|
||||
}
|
||||
|
||||
$rows = array();
|
||||
foreach ($maps as $map) {
|
||||
$rows[] = array($html->link($map['Map']['id'],
|
||||
array('controller' => 'maps',
|
||||
'action' => 'view',
|
||||
$map['Map']['id'])),
|
||||
$html->link($map['Map']['name'],
|
||||
array('controller' => 'maps',
|
||||
'action' => 'view',
|
||||
$map['Map']['id'])),
|
||||
$map['SiteArea']['name'],
|
||||
$map['Map']['width'] / 12,
|
||||
$map['Map']['depth'] / 12,
|
||||
$map['Map']['comment']);
|
||||
}
|
||||
echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
$rows = array();
|
||||
foreach ($maps as $map) {
|
||||
$rows[] = array($html->link($map['Map']['id'],
|
||||
array('controller' => 'maps',
|
||||
'action' => 'view',
|
||||
$map['Map']['id'])),
|
||||
$html->link($map['Map']['name'],
|
||||
array('controller' => 'maps',
|
||||
'action' => 'view',
|
||||
$map['Map']['id'])),
|
||||
$map['SiteArea']['name'],
|
||||
$map['Map']['width'] / 12,
|
||||
$map['Map']['depth'] / 12,
|
||||
$map['Map']['comment']);
|
||||
}
|
||||
|
||||
<?php
|
||||
if (isset($paginator)) {
|
||||
echo('<div class="paging">' . "\n");
|
||||
echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));
|
||||
echo(' | ');
|
||||
echo $paginator->numbers();
|
||||
echo(' | ');
|
||||
echo $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));
|
||||
echo('</div>' . "\n");
|
||||
}
|
||||
?>
|
||||
echo $this->element('table',
|
||||
array('class' => 'item map list',
|
||||
'headers' => $headers,
|
||||
'rows' => $rows,
|
||||
'column_class' => $headers_manual));
|
||||
|
||||
if (isset($paginator)) {
|
||||
echo('<div class="paging">' . "\n");
|
||||
echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));
|
||||
echo(' | ');
|
||||
echo $paginator->numbers();
|
||||
echo(' | ');
|
||||
echo $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));
|
||||
echo('</div>' . "\n");
|
||||
}
|
||||
|
||||
59
site/views/elements/table.ctp
Normal file
59
site/views/elements/table.ctp
Normal 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");
|
||||
}
|
||||
@@ -4,53 +4,48 @@ if (isset($heading))
|
||||
echo $heading;
|
||||
else
|
||||
echo '<h2>'.__('Units',true).'</h2>';
|
||||
?>
|
||||
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
$headers_manual = array('Id', 'Unit', 'Size', 'Status', 'Comment');
|
||||
if (isset($paginator)) {
|
||||
echo $paginator->counter(array(
|
||||
'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
|
||||
|
||||
<?php
|
||||
{
|
||||
if (isset($paginator)) {
|
||||
echo $paginator->counter(array(
|
||||
'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
|
||||
|
||||
$rows = array($paginator->sort('id'),
|
||||
$headers = array($paginator->sort('id'),
|
||||
$paginator->sort('Unit', 'name'),
|
||||
$paginator->sort('unit_size_id'),
|
||||
$paginator->sort('status'),
|
||||
$paginator->sort('comment'));
|
||||
} else {
|
||||
$rows = array('Id', 'Unit', 'Size', 'Status', 'Comment');
|
||||
}
|
||||
echo $html->tableHeaders($rows);
|
||||
} else {
|
||||
$headers = $headers_manual;
|
||||
}
|
||||
|
||||
$rows = array();
|
||||
foreach ($units as $unit) {
|
||||
$rows[] = array($html->link($unit['Unit']['id'],
|
||||
array('controller' => 'units',
|
||||
'action' => 'view',
|
||||
$unit['Unit']['id'])),
|
||||
$html->link($unit['Unit']['name'],
|
||||
array('controller' => 'units',
|
||||
'action' => 'view',
|
||||
$unit['Unit']['id'])),
|
||||
$unit['UnitSize']['name'],
|
||||
$unit['Unit']['status'],
|
||||
$unit['Unit']['comment']);
|
||||
}
|
||||
echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
$rows = array();
|
||||
foreach ($units as $unit) {
|
||||
$rows[] = array($html->link($unit['Unit']['id'],
|
||||
array('controller' => 'units',
|
||||
'action' => 'view',
|
||||
$unit['Unit']['id'])),
|
||||
$html->link($unit['Unit']['name'],
|
||||
array('controller' => 'units',
|
||||
'action' => 'view',
|
||||
$unit['Unit']['id'])),
|
||||
$unit['UnitSize']['name'],
|
||||
$unit['Unit']['status'],
|
||||
$unit['Unit']['comment']);
|
||||
}
|
||||
|
||||
<?php
|
||||
if (isset($paginator)) {
|
||||
echo('<div class="paging">' . "\n");
|
||||
echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));
|
||||
echo(' | ');
|
||||
echo $paginator->numbers();
|
||||
echo(' | ');
|
||||
echo $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));
|
||||
echo('</div>' . "\n");
|
||||
}
|
||||
?>
|
||||
echo $this->element('table',
|
||||
array('class' => 'item unit list',
|
||||
'headers' => $headers,
|
||||
'rows' => $rows,
|
||||
'column_class' => $headers_manual));
|
||||
|
||||
if (isset($paginator)) {
|
||||
echo('<div class="paging">' . "\n");
|
||||
echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));
|
||||
echo(' | ');
|
||||
echo $paginator->numbers();
|
||||
echo(' | ');
|
||||
echo $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));
|
||||
echo('</div>' . "\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user