'; 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']] = ''; if (! empty($value['title'])) $o[$i][$value['position']] .= sprintf('',$value['title']); if (! empty($value['subtitle'])) $o[$i][$value['position']] .= sprintf('',$value['subtitle']); $o[$i][$value['position']] .= sprintf('',$value['body']); if (! empty($value['footer'])) $o[$i][$value['position']] .= sprintf('',$value['footer']); $o[$i][$value['position']] .= '
%s
%s
%s
'; } // Render our output. $output .= ''; foreach ($o as $k => $v) $output .= sprintf('',$x=round(100/$y,0),implode(sprintf('
%s
',$x),$v)); $output .= '
'; return $output; } } ?>