Esempio n. 1
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;
 }
Esempio n. 2
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();
Esempio n. 3
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)');
});