Added Tasks to KH
This commit is contained in:
63
application/classes/lnapp/table.php
Normal file
63
application/classes/lnapp/table.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class is for rendering a table of data.
|
||||
*
|
||||
* @package lnApp
|
||||
* @subpackage Page
|
||||
* @category Helpers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2010 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
* @uses Style
|
||||
*/
|
||||
class lnApp_Table {
|
||||
public static function limit($data,$rows,array $cols,$other) {
|
||||
if (! (array)$data)
|
||||
return '';
|
||||
|
||||
$output = '';
|
||||
|
||||
$other = $i = 0;
|
||||
$output = '<table border="0">';
|
||||
$output .= '<tr><th>'.implode('</th><th>',array_keys($cols)).'</th></tr>';
|
||||
foreach ($data as $do) {
|
||||
if ($i++ < $rows) {
|
||||
$output .= '<tr>';
|
||||
|
||||
foreach (array_values($cols) as $col) {
|
||||
if (is_array($do) AND isset($do[$col]))
|
||||
$x = $do[$col];
|
||||
// If the col is a method, we need to eval it
|
||||
elseif (preg_match('/\(/',$col))
|
||||
eval("\$x = \$do->$col;");
|
||||
else
|
||||
$x = $do->{$col};
|
||||
|
||||
$output .= sprintf('<td>%s</td>',$x);
|
||||
}
|
||||
|
||||
$output .= '</tr>';
|
||||
|
||||
} else {
|
||||
if (is_array($do) AND isset($do[$col]))
|
||||
$x = $do[$col];
|
||||
// If the col is a method, we need to eval it
|
||||
elseif (preg_match('/\(/',$col))
|
||||
eval("\$x = \$do->$col;");
|
||||
else
|
||||
$x = $do->{$col};
|
||||
|
||||
$other += $x;
|
||||
}
|
||||
}
|
||||
|
||||
if ($other)
|
||||
$output .= sprintf('<tr><td>Other</td><td colspan="%s">(%s) %s</td></tr>',count($cols)-1,$i-$rows,$other);
|
||||
|
||||
$output .= '</table>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user