예제 #1
0
파일: handler.php 프로젝트: ortodesign/cms
 public function action_index()
 {
     $id = (int) $this->request->param('id');
     Observer::notify('handler_requested', $id);
     $widget = Widget_Manager::load($id);
     if ($widget === NULL or !$widget->is_handler()) {
         $this->go_home();
     }
     $widget->run();
 }
예제 #2
0
파일: widget.php 프로젝트: ortodesign/cms
 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);
 }
예제 #3
0
 /**
  * 
  * @param array $row
  * @param integr $fid
  * @param integer $recurse
  * @return array
  */
 protected static function _fetch_related_widget($widget, $row, $fid, $recurse, $key = 'ids', $fetch = FALSE)
 {
     $widget_id = Arr::get($widget->doc_fetched_widgets, $fid);
     if (empty($widget_id)) {
         return NULL;
     }
     $widget = Context::instance()->get_widget($widget_id);
     if (!$widget) {
         $widget = Widget_Manager::load($widget_id);
     }
     if ($widget === NULL) {
         return array();
     }
     $widget->{$key} = $row[$fid];
     if ($fetch === FALSE) {
         return $widget->get_document($row[$fid], $recurse - 1);
     } else {
         return $widget->fetch_data();
     }
 }
예제 #4
0
 /**
  * 
  * @param array $ids
  * @return \KodiCMS_Sitemap
  */
 public function fetch_widgets(array $ids)
 {
     if (empty($ids)) {
         return $this;
     }
     $widget_ids = array_unique(array_values($ids));
     $widgets = array();
     foreach ($widget_ids as $id) {
         $widgets[$id] = Widget_Manager::load($id);
     }
     foreach ($ids as $id => $widget_id) {
         if (empty($widgets[$widget_id])) {
             unset($ids[$id]);
             continue;
         }
         $ids[$id] = $widgets[$widget_id];
     }
     $array = $this->_array;
     $this->_fetch_widgets($array, $ids);
     $this->_array = $array;
     unset($array);
     return $this;
 }
예제 #5
0
 public function action_template()
 {
     $id = (int) $this->request->param('id');
     $widget = Widget_Manager::load($id);
     if (!$widget) {
         Messages::errors(__('Widget not found!'));
         $this->go_back();
     }
     Assets::package('ace');
     $template = $widget->default_template();
     $data = file_get_contents($template);
     $this->template->content = View::factory('widgets/default_template', array('data' => $data));
 }
예제 #6
0
 /**
  * 
  * @param integer $ds_id
  * @return array
  */
 public static function clear_cache($ds_id, array $widget_types = array())
 {
     $objects = Widget_Manager::get_widgets($widget_types);
     $cleared_ids = array();
     foreach ($objects as $id => $data) {
         $widget = Widget_Manager::load($id);
         if ($widget->ds_id == $ds_id) {
             $cleared_ids[] = $widget->id;
             $widget->clear_cache();
         }
     }
     return $cleared_ids;
 }