phpldapadmin/application/classes/pla/block.php

82 lines
1.9 KiB
PHP
Raw Normal View History

2012-06-05 03:50:21 +00:00
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class is for rendering HTML body blocks (left, center, right).
*
* It will provide a header, body and footer.
*
* @package PLA
* @subpackage Page
* @category Helpers
* @author Deon George
* @copyright (c) phpLDAPadmin Development Team
* @license http://dev.phpldapadmin.org/license.html
* @uses Style
*/
abstract class PLA_Block extends HTMLRender {
protected static $_data = array();
protected static $_spacer = '<table><tr class="spacer"><td>&nbsp;</td></tr></table>';
protected static $_required_keys = array('body');
/**
* 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;
}
/**
* Render this block
*
* @see HTMLRender::render()
*/
protected function render() {
$output = '';
$styles = array();
$i = 0;
foreach (static::$_data as $value) {
if ($i++)
$output .= static::$_spacer;
$output .= '<table class="block" border="0">';
if (! empty($value['title']))
$output .= sprintf('<tr class="title"><td>%s</td></tr>',$value['title']);
if (! empty($value['subtitle']))
$output .= sprintf('<tr class="subtitle"><td>%s</td></tr>',$value['subtitle']);
$output .= sprintf('<tr class="body"><td>%s</td></tr>',$value['body']);
if (! empty($value['footer']))
$output .= sprintf('<tr class="footer"><td>%s</td></tr>',$value['footer']);
$output .= '</table>';
}
return $output;
}
}
?>