示例#1
0
 public function action_forgot()
 {
     if ($this->request->method() == Request::POST) {
         $this->auto_render = FALSE;
         $widget = Widget_Manager::factory('User_Forgot');
         Context::instance()->set('email', Arr::path($this->request->post(), 'forgot.email'));
         $widget->set_values(array('next_url' => Route::get('user')->uri(array('action' => 'login'))))->on_page_load();
     }
     $this->set_title(__('Forgot password'));
     $this->template->content = View::factory('system/forgot');
 }
示例#2
0
 /**
  * 
  * @param string $type
  * @return Model_Widget_Decorator_Dashboard
  */
 public static function add_widget($type, array $data = NULL, $user_id = NULL)
 {
     $widget_settings = Model_User_Meta::get(self::WIDGET_SETTINGS_KEY, array(), $user_id);
     $widget = Widget_Manager::factory($type);
     $widget->id = uniqid();
     if ($data !== NULL) {
         $widget->set_values($data);
     }
     $widget_settings[$widget->id] = $widget;
     Model_User_Meta::set(self::WIDGET_SETTINGS_KEY, $widget_settings, $user_id);
     return $widget;
 }
示例#3
0
 protected function _add()
 {
     $data = $this->request->post();
     $widget = Widget_Manager::factory($data['type']);
     try {
         $widget->name = $data['name'];
         $widget->description = Arr::get($data, 'description');
         $id = Widget_Manager::create($widget);
         Observer::notify('widget_after_add', $id);
     } catch (ORM_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' => $id));
     }
 }
示例#4
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;
 }