Themeing work based on bootstrap

This commit is contained in:
Deon George
2013-04-25 10:22:36 +10:00
parent b310cdb125
commit 74a9c291e4
184 changed files with 37653 additions and 8903 deletions

View File

@@ -11,118 +11,79 @@
*/
abstract class lnApp_SystemMessage extends HTMLRender {
protected static $_data = array();
protected static $_spacer = '<table><tr class="spacer"><td>&nbsp;</td></tr></table>';
protected static $_spacer = '';
protected static $_c = 0;
protected $_items = array('body','title','type');
protected static $_required_keys = array('title','body','type');
public function __call($name,$args=NULL) {
parent::__call($name,$args);
Session::instance()->set('sessionmsgs',static::$_data);
return $this;
}
/**
* Add a system message to be rendered
*
* @param array System Message attributes
* @deprecated
*/
public static function add($msg,$prepend=FALSE) {
if ($msgs = Session::instance()->get('sessionmsgs')) {
if ($msgs = Session::instance()->get_once('sessionmsgs'))
static::$_data = $msgs;
}
parent::add($msg);
// Add a gribber popup
Style::add(array(
'type'=>'file',
'data'=>'css/jquery.gritter.css',
'media'=>'screen',
));
Script::add(array(
'type'=>'file',
'data'=>'js/jquery.gritter-1.5.js',
));
Script::add(array(
'type'=>'stdin',
'data'=>sprintf(
'$(document).ready(function() {
$.extend($.gritter.options, {
fade_in_speed: "medium",
fade_out_speed: 2000,
time: "3000",
sticky: false,
});
$.gritter.add({
title: "%s",
text: "%s",
image: "%s",
});});',$msg['title'],$msg['body'],URL::site().static::image($msg['type'],true))));
static::$_c = count(static::$_data);
// Save our messages in our session, so that we get them for redirects
Session::instance()->set('sessionmsgs',static::$_data);
}
/**
* Return an instance of this class
*
* @return SystemMessage
*/
public static function factory() {
return new SystemMessage;
}
/**
* Render an image for the System Message
*/
public static function image($type,$raw=false,$big=false,$alt='') {
$mediapath = Route::get(static::$_media_path);
switch ($type) {
case 'error':
$file = sprintf('img/dialog-error%s.png',$big ? '-big' : '');
break;
case 'info':
$file = sprintf('img/dialog-information%s.png',$big ? '-big' : '');
break;
case 'warning':
$file = sprintf('img/dialog-warning%s.png',$big ? '-big' : '');
break;
case 'debug':
$file = sprintf('img/dialog-question%s.png',$big ? '-big' : '');
break;
default:
throw new Kohana_Exception('Unknown system message type :type',array(':type'=>$value['type']));
}
if ($raw)
return $mediapath->uri(array('file'=>$file));
else
return HTML::image($mediapath->uri(array('file'=>$file)),array('alt'=>$alt ? $alt : '','class'=>'sysicon'));
}
/**
* Render this system message
*
* @see HTMLRender::render()
*/
protected function render() {
$record = static::$_data[$this->_x];
$output = '';
$mediapath = Route::get(static::$_media_path);
// Reload our message from the session
if ($msgs = Session::instance()->get('sessionmsgs')) {
Session::instance()->delete('sessionmsgs');
static::$_data = $msgs;
$output .= sprintf('<div class="alert %s">',empty($record['type']) ? '' : 'alert-'.$record['type']);
$output .= '<button type="button" class="close" data-dismiss="alert">&times;</button>';
switch ($record['type']) {
case 'error':
$output .= '<i class="icon-ban-circle"></i>';
break;
case 'success':
$output .= '<i class="icon-check"></i>';
break;
case 'warning':
$output .= '<i class="icon-warning-sign"></i>';
break;
case 'info':
default:
$output .= '<i class="icon-info-sign"></i>';
}
$i = 0;
foreach (static::$_data as $value) {
if ($i++)
$output .= static::$_spacer;
$output .= '<table><tr>';
$output .= sprintf('<td class="icon" rowspan="2">%s</td>',static::image($value['type'],false,false,isset($value['alt']) ? $value['alt'] : ''));
$output .= sprintf('<td class="head">%s</td>',$value['title']);
$output .= '</tr><tr>';
$output .= sprintf('<td class="body">%s</td>',$value['body']);
$output .= '</tr></table>';
}
$output .= sprintf(' <strong>%s</strong>: %s',$record['title'],$record['body']);
$output .= '</div> <!-- /alert -->';
return $output;
}
/**
* Render all of these items
*/
public static function render_all() {
// Reload our message from the session
if ($msgs = Session::instance()->get_once('sessionmsgs'))
static::$_data = $msgs;
return parent::render_all();
}
}
?>