Ejemplo n.º 1
0
 public function before()
 {
     $page = strtolower(substr(get_class($this), 11));
     Model_Navigation::init(Kohana::$config->load('sitemap')->as_array());
     parent::before();
     $navigation = Model_Navigation::get();
     $this->page = Model_Navigation::$current;
     if ($this->auto_render !== TRUE) {
         return;
     }
     $this->template->set_global(array('page_body_id' => $this->get_path(), 'page_name' => $page, 'page' => $this->page));
     if ($this->request->is_iframe()) {
         $navigation = NULL;
         $this->template->footer = NULL;
         $this->template->breadcrumbs = NULL;
         Config::set('site', 'profiling', 'no');
         $this->query_params = array('type' => 'iframe');
     } else {
         $this->template->breadcrumbs = Config::get('site', 'breadcrumbs') == Config::YES ? $this->breadcrumbs : NULL;
         $this->template->footer = View::factory('system/blocks/footer');
     }
     $this->template->theme = 'theme-' . Model_User_Meta::get('admin_theme', Config::get('global', 'default_theme'));
     $this->template->bind_global('navigation', $navigation);
     Observer::notify('controller_before_' . $this->get_path());
 }
Ejemplo n.º 2
0
 public static function get_root_section()
 {
     if (self::$_root_section === NULL) {
         self::$_root_section = new Model_Navigation_Section(array('name' => 'root'));
     }
     return self::$_root_section;
 }
Ejemplo n.º 3
0
 /**
  * Добавление раздела в меню Backend
  * 
  * @param Datasource_Section $section
  * @param Model_Navigation_Section $parent_section
  * return Model_Navigation_Section;
  */
 public static function add_section_to_menu(Datasource_Section $section, Model_Navigation_Section $parent_section = NULL)
 {
     if ($parent_section === NULL) {
         $parent_section = Model_Navigation::get_root_section();
     }
     if (!$section->has_access_view()) {
         return $parent_section;
     }
     return $parent_section->add_page(new Model_Navigation_Page(array('name' => $section->name, 'url' => Route::get('datasources')->uri(array('controller' => 'data', 'directory' => 'datasources')) . URL::query(array('ds_id' => $section->id())), 'icon' => $section->icon(), 'permissions' => 'ds_id.' . $section->id() . '.section.view')), 999);
 }
Ejemplo n.º 4
0
 public function action_settings()
 {
     $this->set_title(__('Settings'));
     Assets::package('ace');
     $site_pages = array();
     foreach (Model_Navigation::get()->sections() as $section) {
         foreach ($section->get_pages() as $item) {
             $url = trim(str_replace(ADMIN_DIR_NAME, '', $item->url()), '/');
             $site_pages[$section->name()][$url] = $item->name();
         }
     }
     $this->template->content = View::factory('system/settings', array('filters' => Arr::merge(array('--none--'), WYSIWYG::findAll()), 'dates' => Date::formats(), 'site_pages' => $site_pages, 'default_status_id' => array(Model_Page::STATUS_DRAFT => __('Draft'), Model_Page::STATUS_PUBLISHED => __('Published'))));
 }
Ejemplo n.º 5
0
 /**
  * 
  * @param array $pages
  * @return \Model_Navigation_Section
  */
 public function add_pages(array $pages)
 {
     foreach ($pages as $page) {
         if (isset($page['children'])) {
             $section = Model_Navigation::get_section($page['name'], $this);
             if (isset($page['icon'])) {
                 $section->icon = $page['icon'];
             }
             if (count($page['children']) > 0) {
                 $section->add_pages($page['children']);
             }
         } else {
             $page = new Model_Navigation_Page($page);
             $this->add_page($page);
         }
     }
     return $this;
 }
Ejemplo n.º 6
0
        }
        foreach ($folders as $folder_id => $folder) {
            if (empty($folder['sections'])) {
                continue;
            }
            $folder_section = Model_Navigation::get_section($folder['name'], $ds_section);
            foreach ($folder['sections'] as $id => $section) {
                $section->add_to_menu($folder_section);
            }
        }
        foreach ($sections_list as $type => $sections) {
            foreach ($sections as $id => $section) {
                $section->add_to_menu($ds_section);
            }
        }
        $_create_section = Model_Navigation::get_section(__('Create section'), $ds_section, 999);
        foreach ($types as $id => $type) {
            $_create_section->add_page(new Model_Navigation_Page(array('name' => $type, 'url' => Route::get('datasources')->uri(array('controller' => 'section', 'directory' => 'datasources', 'action' => 'create', 'id' => $id)), 'permissions' => $id . '.section.create')));
        }
        unset($sections_list, $folders, $root_section);
    } catch (Exception $ex) {
    }
});
Observer::observe('update_search_index', function () {
    $ds_ids = Datasource_Data_Manager::get_all();
    foreach ($ds_ids as $ds_id => $data) {
        $ds = Datasource_Data_Manager::load($ds_id);
        if (!$ds->loaded()) {
            continue;
        }
        $ds->update_index();
Ejemplo n.º 7
0
<?php

defined('SYSPATH') or die('No direct script access.');
Route::set('archive', ADMIN_DIR_NAME . '/archive/<id>', array('id' => '[0-9]+', 'controller' => 'archive', 'action' => 'index'))->defaults(array('controller' => 'archive', 'action' => 'index'));
$behaviors = array();
foreach (Kohana::$config->load('behaviors') as $key => $behavior) {
    if (isset($behavior['link'])) {
        $behaviors[] = $key;
    }
}
if (empty($behaviors)) {
    return;
}
if (ACL::check('page.index')) {
    $pages = DB::select()->from('pages')->where('behavior_id', 'in', $behaviors)->cache_key('archive_section')->cached()->as_object()->execute();
    $root_section = Model_Navigation::get_section('Archive', Model_Navigation::get_section('Content'));
    $root_section->icon = 'archive';
    foreach ($pages as $page) {
        $root_section->add_page(new Model_Navigation_Page(array('name' => $page->title, 'url' => Route::get('archive')->uri(array('controller' => 'archive', 'id' => $page->id)), 'permissions' => 'page.index')), 999);
    }
}
Observer::observe(array('page_delete', 'page_edit_after_save'), function () {
    Cache::instance()->delete('Database::cache(archive_section)');
});