Added Tasks to KH

This commit is contained in:
Deon George
2011-08-16 12:27:19 +10:00
parent f272bc254d
commit 4c9b214ff7
53 changed files with 773 additions and 170 deletions

View File

@@ -0,0 +1,95 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class is for rendering HTML sub body blocks.
*
* It will provide a header, body and footer.
*
* @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_Block_Sub extends HTMLRender {
protected static $_data = array();
protected static $_spacer = '<table><tr class="spacer"><td>&nbsp;</td></tr></table>';
protected static $_required_keys = array('body','position');
/**
* Add a block to be rendered
*
* @param array Block attributes
*/
public static function add($block,$prepend=FALSE) {
parent::add($block);
// Detect any style sheets.
if (! empty($block['style']) && is_array($block['style']))
foreach ($block['style'] as $data=>$media)
Style::add(array(
'type'=>'file',
'data'=>$data,
'media'=>$media,
));
}
/**
* Return an instance of this class
*
* @return Block
*/
public static function factory() {
return new Block_Sub;
}
/**
* Render this block
*
* @see HTMLRender::render()
*/
protected function render() {
$output = '';
$o = array();
$i = 0;
$x = $y = 0;
Sort::MAsort(static::$_data,'order,position,title,subtitle');
foreach (static::$_data as $value) {
$i = (! isset($value['order'])) ? $i+1 : $value['order'];
// Work out our dimentions
if ($value['position'] > $y)
$y = $value['position'];
if ($i > $x)
$x = $i;
// @todo Alert if a sub block has already been defined.
$o[$i][$value['position']] = '<table class="subblock" border="0">';
if (! empty($value['title']))
$o[$i][$value['position']] .= sprintf('<tr class="title"><td>%s</td></tr>',$value['title']);
if (! empty($value['subtitle']))
$o[$i][$value['position']] .= sprintf('<tr class="subtitle"><td>%s</td></tr>',$value['subtitle']);
$o[$i][$value['position']] .= sprintf('<tr class="body"><td>%s</td></tr>',$value['body']);
if (! empty($value['footer']))
$o[$i][$value['position']] .= sprintf('<tr class="footer"><td>%s</td></tr>',$value['footer']);
$o[$i][$value['position']] .= '</table>';
}
// Render our output.
$output .= '<table class="subblockhead">';
foreach ($o as $k => $v)
$output .= sprintf('<tr><td style="width: %s%%;">%s</td></tr>',round(100/$y,0),implode('</td><td>',$v));
$output .= '</table>';
return $output;
}
}
?>

View File

@@ -84,6 +84,20 @@ abstract class lnApp_Config extends Kohana_Config {
return date(Kohana::config('config.date_format'),$date);
}
/**
* Show a date using a site configured format
*/
public static function time($date) {
return date(Kohana::config('config.time_format'),$date);
}
/**
* Show a date using a site configured format
*/
public static function datetime($date) {
return date(Kohana::config('config.date_format').' '.Kohana::config('config.time_format'),$date);
}
/**
* See if our emails for the template should be sent to configured admin(s)
*

View File

@@ -77,9 +77,7 @@ abstract class lnApp_HTMLRender {
// Display the exception message
catch (Exception $e) {
Kohana::exception_handler($e);
return '';
Kohana_Exception::handler($e);
}
}

View 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;
}
}
?>