public function action_index() { Assets::package('jquery-ui'); $cur_ds_id = (int) Arr::get($this->request->query(), 'ds_id', Cookie::get('ds_id')); $tree = Datasource_Data_Manager::get_tree(); $cur_ds_id = Datasource_Data_Manager::exists($cur_ds_id) ? $cur_ds_id : Datasource_Data_Manager::$first_section; $ds = $this->section($cur_ds_id); $this->template->content = View::factory('datasource/content', array('content' => View::factory('datasource/data/index'), 'menu' => View::factory('datasource/data/menu', array('tree' => $tree, 'folders' => Datasource_Folder::get_all())))); $this->template->footer = NULL; $this->template->breadcrumbs = NULL; if ($ds instanceof Datasource_Section) { $this->set_title($ds->name); $limit = (int) Arr::get($this->request->query(), 'limit', Cookie::get('limit')); Cookie::set('ds_id', $cur_ds_id); $keyword = $this->request->query('keyword'); if (!empty($limit)) { Cookie::set('limit', $limit); $this->section()->headline()->limit($limit); } $this->template->content->content->headline = $this->section()->headline()->render(); $this->template->content->content->toolbar = View::factory('datasource/' . $ds->type() . '/toolbar', array('keyword' => $keyword)); $this->template->set_global(array('datasource' => $ds)); $this->template_js_params['DS_ID'] = $this->_section->id(); $this->template_js_params['DS_TYPE'] = $this->_section->type(); } else { $this->template->content->content = NULL; } }
public function get_menu() { $ds_id = (int) $this->param('ds_id', NULL); $tree = Datasource_Data_Manager::get_tree(); $menu = View::factory('datasource/data/menu', array('tree' => $tree, 'folders' => Datasource_Folder::get_all(), 'datasource' => DataSource_Section::load($ds_id))); $this->response((string) $menu); }
defined('SYSPATH') or die('No direct access allowed.'); if (IS_BACKEND) { Route::set('datasources', ADMIN_DIR_NAME . '/<directory>(/<controller>(/<action>(/<id>)))', array('directory' => '(datasources|' . implode('|', array_keys(Datasource_Data_Manager::types())) . ')'))->defaults(array('directory' => 'datasources', 'controller' => 'data', 'action' => 'index')); } Observer::observe('modules::after_load', function () { if (!IS_BACKEND or !Auth::is_logged_in()) { return; } $types = Datasource_Data_Manager::types(); if (empty($types)) { return; } try { $ds_section = Model_Navigation::get_section('Datasources'); $ds_section->icon = 'tasks'; $sections_list = Datasource_Data_Manager::get_tree(array_keys($types)); $datasource_is_empty = empty($sections_list); $folders = Datasource_Folder::get_all(); $root_sections = array(); foreach ($sections_list as $type => $sections) { foreach ($sections as $id => $section) { if ($section->show_in_root_menu()) { $root_sections[] = $section; unset($sections_list[$type][$id]); continue; } if (array_key_exists($section->folder_id(), $folders)) { $folders[$section->folder_id()]['sections'][] = $section; unset($sections_list[$type][$id]); } }
protected function _get_sections() { $map = Datasource_Data_Manager::get_tree(); $hds = Datasource_Data_Manager::get_all('hybrid'); $sections = array(); foreach (Datasource_Data_Manager::types() as $key => $value) { if ($key != 'hybrid' and !empty($map[$key])) { foreach ($map[$key] as $id => $section) { $sections[$key][$id] = $section->name; } } else { foreach ($hds as $id => $section) { $sections[$key][$id] = $section->name; } } } return $sections; }