public function action_add() { // check if trying to save if (Request::current()->method() == Request::POST) { return $this->_add(); } $this->set_title(__('Create widget')); $this->template->content = View::factory('widgets/add', array('types' => Widget_Manager::map())); }
public function type() { $widget_types = Widget_Manager::map(); $type = $this->type; foreach ($widget_types as $group => $types) { if (isset($types[$type])) { $type = $types[$type]; } } return $type; }
public function get_widget_list() { $widget_settings = Model_User_Meta::get(Dashboard::WIDGET_SETTINGS_KEY, array()); $types = Widget_Manager::map('dashboard_widgets'); $attached_types = array(); foreach ($widget_settings as $widget) { $attached_types[$widget->type()] = $widget->is_multiple(); } foreach ($types as $key => $data) { if (Arr::get($attached_types, $key) === FALSE) { unset($types[$key]); } } $this->json = (string) View::factory('dashboard/widgets', array('types' => $types)); }
/** * * @return string */ public function type($as_key = TRUE) { if ($as_key === TRUE) { return $this->_type; } $widget_types = Widget_Manager::map(); $type = $this->_type; foreach ($widget_types as $group => $types) { if (isset($types[$type])) { $type = $types[$type]; } } return $type; }