00001 <?php
00002
00003
00004
00005
00006
00007
00008 class WidgetFilter implements IWidget {
00009 const DONT_INDEX_FILTERED = 2048;
00010 const DONT_CHANGE_TITLE = 4096;
00011
00012 public $data;
00013
00014 public static function output($data, $policy = self::NONE) {
00015 $w = new WidgetFilter($data);
00016 return $w->render($policy);
00017 }
00018
00019 public function __construct($data) {
00020 $this->data = $data;
00021 }
00022
00023 public function render($policy = self::NONE) {
00024 $builder = Arr::get_item($this->data, 'filter_url_builder', false);
00025 $page_data = Arr::get_item($this->data, 'page_data', false);
00026 if (empty($builder) || empty($page_data)) {
00027 return '';
00028 }
00029
00030 $groups = Arr::force(Arr::get_item($this->data, 'filter_groups', array()));
00031 $ret = '';
00032 foreach($groups as $group) {
00033 $view = ViewFactory::create_view(IViewFactory::MESSAGE, 'core::widgets/filter.meta');
00034 $view->assign('filter_group', $group);
00035 $view->assign('page_data', $page_data);
00036 $view->assign('policy', $policy);
00037 $view->render();
00038
00039 $view = ViewFactory::create_view(IViewFactory::MESSAGE, 'core::widgets/filter');
00040 $view->assign('filter_group', $group);
00041 $view->assign('filter_url_builder', $builder);
00042 $view->assign('page_data', $page_data);
00043 $view->assign('policy', $policy);
00044 $ret .= $view->render();
00045 }
00046 if ($ret) {
00047 $ret = html::div($ret, 'filter_groups');
00048 }
00049 return $ret;
00050 }
00051 }