<?php defined('SYSPATH') or die('No direct access allowed.'); /** * This class is for rendering HTML blocks or widget. * * It will provide a title and body for the content. * * @package lnApp * @category lnApp/Helpers * @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(); protected static $_spacer = ''; protected static $_c = 0; protected $_items = array('body','title','title_icon','type'); protected static $_required_keys = array('body'); /** * Add a block to be rendered * * @param array Block attributes * @deprecated */ 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, )); } /** * Render this Block */ protected function render() { $record = static::$_data[$this->_x]; $output = ''; $output .= '<div class="row">'; $output .= sprintf('<div class="%s">',empty($record['span']) ? 'span12' : $record['span']); $output .= '<div class="widget stacked">'; if (! empty($record['title'])) $output .= sprintf('<div class="widget-header">%s<h3>%s</h3></div>',empty($record['title_icon']) ? '' : sprintf(' <i class="%s"></i>',$record['title_icon']),$record['title']); $output .= '<div class="widget-content">'; if (! empty($record['type'])) switch ($record['type']) { case 'form-horizontal': $output .= Form::open(NULL,array('class'=>'form-horizontal')); $output .= (string)$record['body']; $output .= Form::close(); break; default: $output .= (string)$record['body']; } else $output .= (string)$record['body']; $output .= '</div> <!-- /widget-content -->'; $output .= '</div> <!-- /widget-stacked -->'; $output .= '</div> <!-- /span -->'; $output .= '</div> <!-- /row -->'; return $output; } } ?>