2013-04-22 05:50:28 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
2013-04-25 00:22:36 +00:00
|
|
|
* This class is for rendering HTML blocks or widget.
|
2013-04-22 05:50:28 +00:00
|
|
|
*
|
2013-04-25 00:22:36 +00:00
|
|
|
* It will provide a title and body for the content.
|
2013-04-22 05:50:28 +00:00
|
|
|
*
|
|
|
|
* @package lnApp
|
2013-10-08 23:24:11 +00:00
|
|
|
* @category Helpers
|
2013-04-22 05:50:28 +00:00
|
|
|
* @author Deon George
|
|
|
|
* @copyright (c) 2009-2013 Deon George
|
|
|
|
* @license http://dev.leenooks.net/license.html
|
|
|
|
* @uses Style
|
|
|
|
*/
|
|
|
|
abstract class lnApp_Block extends HTMLRender {
|
|
|
|
protected static $_data = array();
|
2013-04-25 00:22:36 +00:00
|
|
|
protected static $_spacer = '';
|
|
|
|
protected static $_c = 0;
|
2013-06-06 11:25:25 +00:00
|
|
|
protected $_items = array('body','id','scrollable','span','title','title_icon','type');
|
2013-04-25 00:22:36 +00:00
|
|
|
|
2013-04-22 05:50:28 +00:00
|
|
|
protected static $_required_keys = array('body');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a block to be rendered
|
|
|
|
*
|
|
|
|
* @param array Block attributes
|
2013-04-25 00:22:36 +00:00
|
|
|
* @deprecated
|
2013-04-22 05:50:28 +00:00
|
|
|
*/
|
|
|
|
public static function add($block,$prepend=FALSE) {
|
|
|
|
// Any body objects should be converted to a string, so that any calls to Style/Script are processed
|
|
|
|
if (isset($block['body']))
|
|
|
|
$block['body'] = (string)$block['body'];
|
|
|
|
|
|
|
|
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,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-04-25 00:22:36 +00:00
|
|
|
* Render this Block
|
2013-04-22 05:50:28 +00:00
|
|
|
*/
|
|
|
|
protected function render() {
|
2013-12-26 10:39:49 +00:00
|
|
|
$record = self::$_data[$this->_x];
|
2013-04-22 05:50:28 +00:00
|
|
|
|
2013-04-25 00:22:36 +00:00
|
|
|
$output = '';
|
2014-09-29 04:47:51 +00:00
|
|
|
$output .= sprintf('<div class="col-md-%s %s">',Arr::get($record,'span',12),Arr::get($record,'scrollable',''));
|
2013-04-25 00:22:36 +00:00
|
|
|
$output .= '<div class="widget stacked">';
|
2013-04-22 05:50:28 +00:00
|
|
|
|
2013-04-25 00:22:36 +00:00
|
|
|
if (! empty($record['title']))
|
2014-09-29 04:47:51 +00:00
|
|
|
$output .= sprintf('<div class="widget-header"><i class="fa %s"></i><h3>%s</h3></div>',Arr::get($record,'title_icon','fa-square'),Arr::get($record,'title','NO Title!'));
|
2013-04-22 05:50:28 +00:00
|
|
|
|
2013-04-25 00:22:36 +00:00
|
|
|
$output .= '<div class="widget-content">';
|
2013-04-22 05:50:28 +00:00
|
|
|
|
2013-04-25 00:22:36 +00:00
|
|
|
if (! empty($record['type']))
|
|
|
|
switch ($record['type']) {
|
2013-06-06 11:25:25 +00:00
|
|
|
case 'form': $output .= Form::open(NULL,(empty($record['id']) ? NULL : array('id'=>$record['id'])));
|
2013-05-29 11:09:14 +00:00
|
|
|
$output .= (string)$record['body'];
|
|
|
|
$output .= Form::close();
|
|
|
|
break;
|
|
|
|
|
2014-10-09 12:21:28 +00:00
|
|
|
case 'form-horizontal': $output .= Form::open(NULL,Arr::merge(array('class'=>'form-horizontal','role'=>'form','enctype'=>'multipart/form-data','data-toggle'=>'validator'),(empty($record['id']) ? array() : array('id'=>$record['id']))));
|
2013-04-25 00:22:36 +00:00
|
|
|
$output .= (string)$record['body'];
|
|
|
|
$output .= Form::close();
|
|
|
|
break;
|
2013-04-22 05:50:28 +00:00
|
|
|
|
2013-04-25 00:22:36 +00:00
|
|
|
default:
|
|
|
|
$output .= (string)$record['body'];
|
|
|
|
}
|
2013-04-22 05:50:28 +00:00
|
|
|
|
2013-04-25 00:22:36 +00:00
|
|
|
else
|
|
|
|
$output .= (string)$record['body'];
|
2013-04-22 05:50:28 +00:00
|
|
|
|
2013-04-25 00:22:36 +00:00
|
|
|
$output .= '</div> <!-- /widget-content -->';
|
|
|
|
$output .= '</div> <!-- /widget-stacked -->';
|
2014-09-08 13:42:05 +00:00
|
|
|
$output .= '</div> <!-- /col-md -->';
|
2013-04-22 05:50:28 +00:00
|
|
|
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|