00001 <?php
00002
00003
00004
00005
00006
00007
00008 class WidgetBlock implements IWidget {
00009
00010
00011
00012
00013
00014 public $position;
00015
00016
00017
00018
00019
00020 public $page_data;
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 public static function retrieve($name, $page_data, $route_id = '', $position = false, $weight = false, $more_params = array()) {
00031 $params = array(
00032 'name' => $name,
00033 'route_id' => $route_id
00034 );
00035 $params = array_merge($more_params, $params);
00036
00037 $result = array();
00038 EventSource::Instance()->invoke_event('block', $params, $result);
00039
00040 if ($page_data) {
00041 foreach($result as $block) {
00042 $page_data->add_block($block, $position, $weight);
00043 }
00044 }
00045 return $result;
00046 }
00047
00048 public static function render_blocks($arr_blocks, $position = false) {
00049 $view = ViewFactory::create_view(IViewFactory::MESSAGE, 'widgets/blocks');
00050 $view->assign('blocks', $arr_blocks);
00051 $view->assign('position', $position);
00052 return $view->render();
00053 }
00054
00055
00056
00057
00058
00059
00060
00061
00062 public static function output($page_data, $position = '') {
00063 $w = new WidgetBlock($page_data, $position);
00064 return $w->render();
00065 }
00066
00067 public function __construct($page_data, $position) {
00068 $this->position = $position;
00069 $this->page_data = $page_data;
00070 }
00071
00072 public function render($policy = self::NONE) {
00073 $this->page_data->sort_blocks();
00074 $arr_blocks = $this->page_data->get_blocks($this->position);
00075 return self::render_blocks($arr_blocks, $this->position);
00076 }
00077 }