public function post_set_template() { $widget_id = (int) $this->param('widget_id', NULL, TRUE); $template = $this->param('template', NULL); $widget = Widget_Manager::load($widget_id); if ($widget !== NULL) { $widget->template = empty($template) ? NULL : $template; Widget_Manager::update($widget); $this->message('Widget template changet to :name', array(':name' => $template)); $this->response(TRUE); return; } $this->response(FALSE); }
protected function _edit(Model_Widget_Decorator $widget) { $data = $this->request->post(); try { if (!ACL::check('widget.roles') and !empty($data['roles'])) { $data['roles'] = array(); } if (ACL::check('widgets.cache')) { $widget->set_cache_settings($data); } $widget->set_values($data); Widget_Manager::update($widget); Observer::notify('widget_after_edit', $widget->id); } catch (Validation_Exception $e) { Flash::set('post_data', $data); Messages::errors($e->errors('validation')); $this->go_back(); } // save and quit or save and continue editing? if ($this->request->post('commit') !== NULL) { $this->go(); } else { $this->go(array('controller' => 'widgets', 'action' => 'edit', 'id' => $widget->id)); } }
public function fetch_backend_content() { if ($this->ds_id > 0 and !Datasource_Data_Manager::exists($this->ds_id)) { $this->ds_id = 0; Widget_Manager::update($this); } return parent::fetch_backend_content(); }