Exemple #1
0
 /**
  * Усмтановка виджета из массива
  * 
  * array(
  *		'type' => [Widget type],
  *		'data' => array (
  *			[KEY] => [VALUE]
  *			.....
  *		),
  *		'blocks' => array (
  *			[PAGE_ID] => [BLOCK NAME]
  *		)
  *	)
  * 
  * @param array $widget_array
  * @return integer $id
  */
 public static function install(array $widget_array)
 {
     if (empty($widget_array['type']) or empty($widget_array['data']) or empty($widget_array['data']['name'])) {
         return;
     }
     $widget = Widget_Manager::factory($widget_array['type']);
     try {
         $widget->name = $widget_array['data']['name'];
         $widget->description = Arr::get($widget_array, 'description');
         $widget->set_values($widget_array['data']);
         $widget->set_cache_settings($widget_array['data']);
         $id = Widget_Manager::create($widget);
     } catch (Exception $e) {
         return FALSE;
     }
     $blocks = array();
     foreach (Arr::get($widget_array, 'blocks', array()) as $page_id => $block_name) {
         $blocks[$page_id] = array('name' => $block_name, 'position' => 500);
     }
     Widget_Manager::set_location($id, $blocks);
     return $id;
 }
Exemple #2
0
 protected function _add_location($widget)
 {
     $data = $this->request->post();
     Widget_Manager::set_location($widget->id, Arr::get($data, 'blocks', array()));
     $this->go_back();
 }