示例#1
0
 /**
  * More feature-rich caching using the optional cache library if available. The default
  * Kohana cache doesn't support all the use cases below as expected. The default cache checks lifetime 
  * when getting based on the file modified time.
  * 
  * Simplified usage for both internal Kohana cache and cache module:
  * - cache() - Get/set.
  * - cache(true, 60) - Get/set.
  * - cache(true, 0) - Delete.
  * - cache(false) - Refresh.
  * - cache(false, 60) - Refresh.
  * - cache(false, 0) - Delete.
  * 
  * Specific usage for cache module:
  * - cache() - Get or set cache. Get cache. If empty, set cache using default lifetime.
  * - cache(true, 60) - Get or set cache. Same as above cache() but using specified lifetime.
  * - cache(true, 0) - Delete cache. Check and return cache if it exists, but also delete cache. 
  * 	  	for this query. If a cached result doesn't exist, then same effect as not using cache().
  * - cache(false) - Refresh cache. Don't check cache, but cache the new results using the default lifetime.
  * - cache(false, 60) - Refresh cache. Same as above cache(false) but using specified lifetime.
  * - cache(false, 0) - Delete cache. Don't check cache and delete cache for this query if it was previously cached.
  *
  * Specific usage if no cache module. Note that lifetime is meaningless when setting cache:
  * - cache() - 	1) Get cache. If cache exists and is younger than default lifetime, then get cache. 
  * 					If older than default time, delete cache.
  * 				2) Else set cache. Lifetime not used when setting.
  * - cache(true, 60) - 	Same as above cache(), but use specified lifetime instead of default lifetime.
  * - cache(true, 0) - Delete cache. Doesn't get or set cache.
  * - cache(false) - Refresh cache. Don't check cache, but cache the new results ignoring lifetime.
  * - cache(false, 60) - Refresh cache. Same as above cache(false).
  * - cache(false, 0) - Delete cache. Same as cache(true, 0);
  * 
  * @param boolean $check [optional] Check cache and return cached result if available.
  * @param integer $specific_lifetime [optional] Set cache lifetime. If null, use default. If "0", delete.
  * @param string $type [optional] Cache type name if using cache module. If null use default.
  * @return object $this
  */
 public function cache($check = TRUE, $specific_lifetime = NULL, $type = NULL)
 {
     if (!isset($this->_cache)) {
         // TODO: is this the best way to check for the "cache" module?
         $modules = Kohana::modules();
         if (isset($modules['cache'])) {
             // Use the "unofficial" Kohana cache module.
             $this->_cache = Cache::instance($type);
         } else {
             // Default internal Kohana cache.
             $this->_cache = true;
         }
     }
     if ($specific_lifetime === NULL) {
         if (is_object($this->_cache)) {
             // Use the default internal Kohana cache lifetime which is 60 seconds.
             $this->_cache_lifetime = 60;
         } else {
             // Use the default lifetime from the Cache module.
             $this->_cache_lifetime = Kohana::config('cache.default-expire');
         }
     } else {
         $this->_cache_lifetime = $specific_lifetime;
     }
     $this->_cache_check = $check;
     return $this;
 }
示例#2
0
 public function setUp()
 {
     parent::setUp();
     $this->environment()->backup_and_set(array('Request::$client_ip' => '127.0.0.1', 'Request::$user_agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.162 Safari/535.19', 'functest.modules' => array('functest', 'test'), 'functest.apptests' => FALSE));
     $this->modpath = Arr::get(Kohana::modules(), 'functest');
     $this->test_folder = 'tests' . DIRECTORY_SEPARATOR . 'test_data' . DIRECTORY_SEPARATOR . 'test_folder' . DIRECTORY_SEPARATOR;
 }
示例#3
0
 /**
  * Application initialization
  *     - Loads the plugins
  *     - Sets the cookie configuration
  */
 public static function init()
 {
     // Set defaule cache configuration
     Cache::$default = Kohana::$config->load('site')->get('default_cache');
     try {
         $cache = Cache::instance()->get('dummy' . rand(0, 99));
     } catch (Exception $e) {
         // Use the dummy driver
         Cache::$default = 'dummy';
     }
     // Load the plugins
     Swiftriver_Plugins::load();
     // Add the current default theme to the list of modules
     $theme = Swiftriver::get_setting('site_theme');
     if (isset($theme) and $theme != "default") {
         Kohana::modules(array_merge(array('themes/' . $theme->value => THEMEPATH . $theme->value), Kohana::modules()));
     }
     // Clean up
     unset($active_plugins, $theme);
     // Load the cookie configuration
     $cookie_config = Kohana::$config->load('cookie');
     Cookie::$httponly = TRUE;
     Cookie::$salt = $cookie_config->get('salt', Swiftriver::DEFAULT_COOKIE_SALT);
     Cookie::$domain = $cookie_config->get('domain') or '';
     Cookie::$secure = $cookie_config->get('secure') or FALSE;
     Cookie::$expiration = $cookie_config->get('expiration') or 0;
     // Set the default site locale
     I18n::$lang = Swiftriver::get_setting('site_locale');
 }
示例#4
0
 /**
  * @return Kohana_Twig
  */
 public static function instance()
 {
     if (!static::$instance) {
         static::$instance = new self();
         // Load Twig configuration
         static::$instance->config = Kohana::$config->load('twig');
         // Array of template locations in cascading filesystem
         $templatesDir = static::$instance->config->templates_dir;
         $templatePaths = [APPPATH . $templatesDir];
         foreach (Kohana::modules() as $modulePath) {
             $tempPath = $modulePath . $templatesDir;
             if (is_dir($tempPath)) {
                 $templatePaths[] = $tempPath;
             }
         }
         // Create the the loader
         $loader = new Twig_Loader_Filesystem($templatePaths);
         // Set up Twig
         static::$instance->twig = new Twig_Environment($loader, static::$instance->config->environment);
         foreach (static::config('extensions', []) as $extension) {
             // Load extensions
             static::$instance->twig->addExtension(new $extension());
         }
     }
     return static::$instance;
 }
 public function before()
 {
     // We need to load all theme modules
     foreach (scandir(MODPATH) as $modulePath) {
         if (substr($modulePath, 0, 5) == 'theme') {
             Kohana::modules(array($modulePath => MODPATH . $modulePath) + Kohana::modules());
         }
     }
 }
示例#6
0
 private static function _fetch_controllers()
 {
     $paths = Kohana::modules() + array(APPPATH);
     $paths = array_values($paths);
     foreach ($paths as $index => $path) {
         $paths[$index] = rtrim($path, '/') . '/';
     }
     $paths = Kohana::list_files('classes/controller', $paths);
     return self::_path_to_controller($paths);
 }
示例#7
0
 /**
  * Инициализация модуля.
  * 
  * При инициализации активированные плагины подключаются через
  * Kohana::modules
  * 
  */
 public static function init()
 {
     self::$_activated = self::_load_from_db();
     $plugins = array();
     foreach (self::$_activated as $plugin_id => $tmp) {
         if (is_dir(PLUGPATH . $plugin_id)) {
             $plugins['plugin_' . $plugin_id] = PLUGPATH . $plugin_id;
         }
     }
     Kohana::modules($plugins + Kohana::modules());
 }
示例#8
0
 public static function get_modules()
 {
     if (self::$modules === null) {
         foreach (Kohana::modules() as $module => $path) {
             if (stripos($module, 'cms_') === 0) {
                 self::$modules[$module] = $path;
             }
         }
     }
     return self::$modules;
 }
 protected function _execute(array $options)
 {
     $db = $this->db_params(Kohana::TESTING);
     Minion_Task::factory(array('task' => 'db:structure:load', 'database' => Kohana::TESTING, 'force' => NULL, 'file' => NULL))->execute();
     $structure_files = array_filter(array_map(function ($dir) use($db) {
         $file = $dir . 'tests' . DIRECTORY_SEPARATOR . 'database' . DIRECTORY_SEPARATOR . 'structure' . DIRECTORY_SEPARATOR . strtolower($db['type']) . '.sql';
         return is_file($file) ? $file : NULL;
     }, Kohana::modules()));
     foreach ($structure_files as $schema) {
         Minion_Task::factory(array('task' => 'db:structure:load', 'database' => Kohana::TESTING, 'force' => NULL, 'file' => $schema))->execute();
     }
 }
示例#10
0
 public function __toString()
 {
     // $attr = $this->_html_attr;
     // $attr['class'] = $this->css_class();
     // $attr['type'] = $this->field_type();
     // return Form::checkbox($this->name(), null, (bool)$this->value(), $attr);
     if (array_key_exists('recaptcha', Kohana::modules())) {
         $recap = Recaptcha::instance();
         return $recap->get_html();
     } else {
         return "";
     }
 }
示例#11
0
 public static function on($name)
 {
     if (isset(self::$modules[$name])) {
         return;
     }
     foreach (self::$paths as $path) {
         if (is_dir($path . $name)) {
             self::$modules[$name] = $path . DS . $name;
             Kohana::modules(self::$modules);
             break;
         }
     }
 }
示例#12
0
 private function generateJS($cacheFileName = 'leaflet-package.js')
 {
     $modulePath = Arr::get(Kohana::modules(), 'kohana-leaflet');
     $dir = $modulePath . 'media/js/';
     $jsContent = '/* Created :' . date('Y-m-d H:i:s') . ' */';
     foreach ($this->_jsFiles as $jsFile) {
         $fJSFile = $modulePath . $jsFile;
         if (file_exists($fJSFile)) {
             $jsFileContent = preg_replace('/\\s+/', ' ', file_get_contents($fJSFile));
             $jsContent .= "\n\n" . '/* JS from: ' . basename($fJSFile) . ' */' . "\n" . $jsFileContent;
         }
     }
     file_put_contents($dir . $cacheFileName, $jsContent);
 }
示例#13
0
 /**
  * Run Plugin Installer Script if Available
  *
  * @param   string   plugin namespace
  * @return  bool
  */
 public static function install($plugin)
 {
     // Dynamically load the new module into the system
     Kohana::modules(array_merge(array(PLUGINPATH . $plugin), Kohana::modules()));
     // Does the plugin have an installer script?
     if (isset(self::$_installers[$plugin])) {
         try {
             call_user_func(self::$_installers[$plugin]);
             return TRUE;
         } catch (Exception $e) {
             Kohana::$log->add(Log::ERROR, "Could not execute plugin installer callback function :callback", array(':callback' => self::$_installers[$plugin]));
             return FALSE;
         }
     }
     return FALSE;
 }
示例#14
0
    protected function _execute(array $options)
    {
        $module_name = $options['module'];
        $module_dir = Arr::get(Kohana::modules(), $module_name);
        $author = $options['author'];
        switch ($options['type']) {
            case 'number':
                $parent = 'Stats_Widget_Number';
                break;
            case 'chart':
                $parent = 'Stats_Widget_Chart';
                break;
            default:
                $parent = 'Stats_Widget';
        }
        $name = $options['name'];
        $title = Jam::capitalize_class_name(str_replace('_', ' ', $name));
        $path = str_replace('_', DIRECTORY_SEPARATOR, $title);
        $dir = $module_dir . 'classes' . DIRECTORY_SEPARATOR . 'Stats' . DIRECTORY_SEPARATOR . 'Widget';
        $file = $dir . DIRECTORY_SEPARATOR . $path . EXT;
        $class = 'Stats_Widget_' . str_replace(' ', '_', $title);
        if (!is_dir(dirname($file))) {
            mkdir(dirname($file), 0777, TRUE);
        }
        $widget_content = <<<WIDGET
<?php defined('SYSPATH') OR die('No direct script access.');

/**
 * Stats Widget: {$title}
 *
 * @package {$module_name}
 * @author {$author}
 * @copyright  (c) 2011-2013 Despark Ltd.
 */
class {$class} extends {$parent} {

\tprotected \$_title = '{$title}';

\tpublic function retrieve(\$start_date, \$end_date)
\t{
\t\t// return 0;
\t}
}
WIDGET;
        Minion_Jam_Generate::modify_file($file, $widget_content, $options['force'] !== FALSE);
    }
示例#15
0
 /**
  * Sets active theme if none supplied or uses the supplied one 
  *
  * @param  boolean|string  $theme  Theme name [Optional]
  */
 public static function set_theme($theme = FALSE)
 {
     if (!empty($theme)) {
         Theme::$active = $theme;
     }
     $modules = Kohana::modules();
     // Check if the active theme is not loaded already
     if (!empty(Theme::$active) and !in_array(Theme::$active, array_keys($modules))) {
         // Make sure the theme is available
         if ($theme = self::getTheme()) {
             //set absolute theme path and load the request theme as kohana module
             Kohana::modules(array('theme' => $theme->path) + $modules);
         } else {
             Log::error('Missing site theme: :theme', array(':theme' => Theme::$active));
         }
     }
     unset($modules);
 }
示例#16
0
 /**
  * Load all active plugins into the Kohana system
  *
  * @return	void
  */
 public static function load()
 {
     if (!($plugin_entries = Cache::instance()->get('site_plugin_entries', FALSE))) {
         $plugin_entries = array();
         $active_plugins = ORM::factory("plugin")->where("plugin_enabled", "=", 1)->find_all();
         foreach ($active_plugins as $plugin) {
             $plugin_path = PLUGINPATH . $plugin->plugin_path;
             if (!is_dir(realpath($plugin_path . DIRECTORY_SEPARATOR))) {
                 // Plugin no longer exists. Delete.
                 $plugin->delete();
                 continue;
             }
             $plugin_entries[$plugin->plugin_path] = $plugin_path;
         }
         Cache::instance()->set('site_plugin_entries', $plugin_entries, 86400 + rand(0, 86400));
     }
     // Add the plugin entries to the list of Kohana modules
     Kohana::modules(Kohana::modules() + $plugin_entries);
 }
示例#17
0
 /**
  * Loads a plugin
  *
  * @param mixed $plugin
  * @return bool - if plugin was successfully loaded
  */
 public static function load($plugin = NULL)
 {
     if (!$plugin instanceof ORM) {
         if (is_string($plugin)) {
             $plugin = ORM::factory('plugin')->where('name', '=', $plugin)->find();
         }
         if (is_int($pluigin)) {
             $plugin = ORM::factory('plugin', $plugin)->find();
         }
     }
     if (!$plugin->loaded()) {
         return FALSE;
     }
     self::$_models[$plugin->name] = $plugin;
     Kohana::modules(array_merge(Kohana::modules(), array($plugin->name => DOCROOT . 'plugins/' . $plugin->path)));
     $check = Kohana::modules();
     if (!isset($check[$plugin->name])) {
         unset(self::$_models[$plugin->name]);
         return FALSE;
     }
     return TRUE;
 }
示例#18
0
 * - boolean  profile     enable or disable internal profiling               TRUE
 * - boolean  caching     enable or disable internal caching                 FALSE
 */
Kohana::init(array('base_url' => '/', 'index_file' => ''));
/**
 * Attach the file write to logging. Multiple writers are supported.
 */
Kohana::$log->attach(new Kohana_Log_File(APPPATH . 'logs'));
/**
 * Attach a file reader to config. Multiple readers are supported.
 */
Kohana::$config->attach(new Kohana_Config_File());
/**
 * Enable modules. Modules are referenced by a relative or absolute path.
 */
Kohana::modules(array());
/**
 * Set the routes. Each route must have a minimum of a name, a URI and a set of
 * defaults for the URI.
 */
// if ( ! Route::cache())
// {
Route::set('cron', 'cron/injest')->defaults(array('controller' => 'cron', 'action' => 'injest'));
Route::set('default', '(<controller>(/<action>(/<id>)))')->defaults(array('controller' => 'front', 'action' => 'index'));
// Save the routes to cache
Route::cache(TRUE);
// }
/**
 * Execute the main request. A source of the URI can be passed, eg: $_SERVER['PATH_INFO'].
 * If no source is specified, the URI will be automatically detected.
 */
示例#19
0
 * - boolean  errors      enable or disable error handling                   TRUE
 * - boolean  profile     enable or disable internal profiling               TRUE
 * - boolean  caching     enable or disable internal caching                 FALSE
 * - boolean  autolocale  enable or disable autodetect locale                TRUE
 */
Kohana::init(array('base_url' => '/', 'index_file' => FALSE, 'caching' => Kohana::$environment === Kohana::PRODUCTION, 'profile' => Kohana::$environment !== Kohana::PRODUCTION));
/**
 * Attach a file reader to config. Multiple readers are supported.
 */
Kohana::$config->attach(new Config_File());
/**
 * Enable modules.
 *
 * Modules are referenced by a relative or absolute path.
 */
Kohana::modules(array('user' => MODPATH . 'user', 'database' => MODPATH . 'database', 'image' => MODPATH . 'image', 'captcha' => MODPATH . 'captcha', 'minion' => MODPATH . 'minion'));
/**
 * Attach the file write to logging.
 * Multiple writers are supported.
 */
if (Kohana::$environment !== Kohana::DEVELOPMENT and Kohana::$environment !== Kohana::STAGING) {
    Kohana::$log->attach(new Log_File(APPPATH . 'logs'), LOG_INFO);
} else {
    Kohana::$log->attach(new Log_File(APPPATH . 'logs'));
}
/**
 * Default path for uploads directory.
 * Path are referenced by a relative or absolute path.
 */
Upload::$default_directory = APPPATH . 'uploads';
/**
示例#20
0
 /**
  * Load All Plugins Into System
  */
 public static function load()
 {
     if (!defined('PLUGINPATH') or !is_dir(PLUGINPATH)) {
         return;
     }
     // Load Plugins
     $results = scandir(PLUGINPATH);
     foreach ($results as $result) {
         if ($result === '.' or $result === '..') {
             continue;
         }
         if (is_dir(PLUGINPATH . $result)) {
             Kohana::modules(array($result => PLUGINPATH . $result) + Kohana::modules());
         }
     }
 }
示例#21
0
 */
Kohana::$log->attach(new Log_File(APPPATH . 'logs'));
/**
 * Attach a file reader to config. Multiple readers are supported.
 */
Kohana::$config->attach(new Config_File());
// preload configs
Kohana::$config->load('constants');
Kohana::$config->load('app');
Kohana::$config->load('install');
Kohana::$config->load('database');
/**
 * Enable modules. Modules are referenced by a relative or absolute path.
 */
Cookie::$salt = 'jg2389h1sank5n1238asdw';
Kohana::modules(array('auth' => MODPATH . 'auth', 'profilertoolbar' => MODPATH . 'profilertoolbar', 'database' => MODPATH . 'database', 'orm' => MODPATH . 'orm'));
/**
 * Set the routes. Each route must have a minimum of a name, a URI and a set of
 * defaults for the URI.
 */
Helper::set_language();
if (!Route::cache()) {
    Route::set('error', 'system/error(/<message>)', array('message' => '.+'))->defaults(array('directory' => 'system', 'controller' => 'error', 'action' => 'index'));
    // Системные контроллеры
    //		Route::set( 'system', '<directory>-<controller>-<action>(/<id>)', array(
    //				'directory' => '(ajax|action)',
    //				'controller' => '[A-Za-z\_]+',
    //				'action' => '[A-Za-z\_]+',
    //				'id' => '.+',
    //		) )->defaults( array(
    //				'directory' => 'action',
示例#22
0
文件: tests.php 项目: azuya/Wi3
 /**
  * Works out the whitelist from the config
  * Used only on the CLI
  *
  * @returns array Array of directories to whitelist
  */
 protected static function get_config_whitelist()
 {
     $config = Kohana::config('unittest');
     $directories = array();
     if ($config->whitelist['app']) {
         $directories['k_app'] = APPPATH;
     }
     if ($modules = $config->whitelist['modules']) {
         $k_modules = Kohana::modules();
         // Have to do this because kohana merges config...
         // If you want to include all modules & override defaults then TRUE must be the first
         // value in the modules array of your app/config/unittest file
         if (array_search(TRUE, $modules, TRUE) === count($modules) - 1) {
             $modules = $k_modules;
         } elseif (array_search(FALSE, $modules, TRUE) === FALSE) {
             $modules = array_intersect_key($k_modules, array_combine($modules, $modules));
         } else {
             // modules are disabled
             $modules = array();
         }
         $directories += $modules;
     }
     if ($config->whitelist['system']) {
         $directories['k_sys'] = SYSPATH;
     }
     return $directories;
 }
示例#23
0
 */
Kohana::init(array('base_url' => '/kohana/'));
/**
 * Attach the file write to logging. Multiple writers are supported.
 */
Kohana::$log->attach(new Log_File(APPPATH . 'logs'));
/**
 * Attach a file reader to config. Multiple readers are supported.
 */
Kohana::$config->attach(new Config_File());
Cookie::$salt = 'vFkdZeP74127asfNT';
// Please don't change this option at the work site
Cookie::$expiration = 1209600;
// 1209600 - 2 weeks
/**
 * Enable modules. Modules are referenced by a relative or absolute path.
 */
Kohana::modules(array('parsers' => MODPATH . 'parsers'));
/**
 * Cookie Salt
 * @see  http://kohanaframework.org/3.3/guide/kohana/cookies
 * 
 * If you have not defined a cookie salt in your Cookie class then
 * uncomment the line below and define a preferrably long salt.
 */
// Cookie::$salt = NULL;
/**
 * Set the routes. Each route must have a minimum of a name, a URI and a set of
 * defaults for the URI.
 */
Route::set('default', '(<controller>(/<action>(/<id>)))')->defaults(array('controller' => 'welcome', 'action' => 'index'));
示例#24
0
 * - string   cache_dir   set the internal cache directory                   APPPATH/cache
 * - boolean  errors      enable or disable error handling                   TRUE
 * - boolean  profile     enable or disable internal profiling               TRUE
 * - boolean  caching     enable or disable internal caching                 FALSE
 */
Kohana::init(array('base_url' => '/', 'index_file' => FALSE, 'charset' => 'utf-8'));
/**
 * Attach the file write to logging. Multiple writers are supported.
 */
Kohana::$log->attach(new Kohana_Log_File(APPPATH . 'logs'));
/**
 * Attach a file reader to config. Multiple readers are supported.
 */
Kohana::$config->attach(new Kohana_Config_File());
/**
 * Enable modules. Modules are referenced by a relative or absolute path.
 */
Kohana::modules(array('database' => MODPATH . 'database', 'image' => MODPATH . 'image', 'orm' => MODPATH . 'orm', 'pagination' => MODPATH . 'pagination'));
/**
 * Set the routes. Each route must have a minimum of a name, a URI and a set of
 * defaults for the URI.
 */
Route::set('admin', 'admin(/<action>(/<id>))')->defaults(array('controller' => 'admin', 'action' => 'index'));
Route::set('captcha', 'captcha(/<action>)')->defaults(array('controller' => 'captcha', 'action' => 'default'));
Route::set('bg', 'background')->defaults(array('controller' => 'page', 'action' => 'background'));
Route::set('default', '(<page>(/<id>))')->defaults(array('controller' => 'page', 'action' => 'showpage'));
/**
 * Execute the main request. A source of the URI can be passed, eg: $_SERVER['PATH_INFO'].
 * If no source is specified, the URI will be automatically detected.
 */
echo Request::instance()->execute()->send_headers()->response;
示例#25
0
<?php

spl_autoload_register(function ($class) {
    $file = __DIR__ . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . str_replace('_', '/', $class) . '.php';
    if (is_file($file)) {
        require_once $file;
    }
});
require_once __DIR__ . '/../vendor/autoload.php';
Kohana::modules(array('database' => MODPATH . 'database', 'jam' => __DIR__ . '/../modules/jam', 'jam-closuretable' => __DIR__ . '/../modules/jam-closuretable', 'template-module' => __DIR__ . '/..'));
Kohana::$config->load('database')->set('default', array('type' => 'PDO', 'connection' => array('dsn' => 'mysql:dbname=test-jam-locations;host=127.0.0.1', 'username' => 'root', 'password' => '', 'persistent' => TRUE), 'table_prefix' => '', 'charset' => 'utf8', 'caching' => FALSE));
Kohana::$environment = Kohana::TESTING;
示例#26
0
 public static function teardownAfterClass()
 {
     Kohana::modules(self::$old_modules);
 }
示例#27
0
/**
 * Initialize Kohana, setting the default options.
 *
 * The following options are available:
 *
 * - string   base_url    path, and optionally domain, of your application   NULL
 * - string   index_file  name of your index file, usually "index.php"       index.php
 * - string   charset     internal character set used for input and output   utf-8
 * - string   cache_dir   set the internal cache directory                   APPPATH/cache
 * - boolean  errors      enable or disable error handling                   TRUE
 * - boolean  profile     enable or disable internal profiling               TRUE
 * - boolean  caching     enable or disable internal caching                 FALSE
 */
Kohana::init(array('base_url' => '/'));
/**
 * Attach the file write to logging. Multiple writers are supported.
 */
Kohana::$log->attach(new Log_File(APPPATH . 'logs'));
/**
 * Attach a file reader to config. Multiple readers are supported.
 */
Kohana::$config->attach(new Config_File());
/**
 * Enable modules. Modules are referenced by a relative or absolute path.
 */
Kohana::modules(array('database' => MODPATH . 'database', 'orm' => MODPATH . 'orm', 'userguide' => MODPATH . 'userguide'));
/**
 * Set the routes. Each route must have a minimum of a name, a URI and a set of
 * defaults for the URI.
 */
Route::set('default', '(<controller>(/<action>(/<id>)))')->defaults(array('controller' => 'welcome', 'action' => 'index'));
<?php

include_once 'bootstrap.php';
// Enable all modules we can find
$modules_iterator = new DirectoryIterator(MODPATH);
$modules = array();
foreach ($modules_iterator as $module) {
    if ($module->isDir() and !$module->isDot()) {
        $modules[$module->getFilename()] = MODPATH . $module->getFilename();
    }
}
Kohana::modules(Kohana::modules() + $modules);
unset($modules_iterator, $modules, $module);
示例#29
0
<?php

defined('SYSPATH') or die('No direct script access.');
$modules = Kohana::modules();
Route::set('lwrte-media', 'lwrte/media(/<file>)', array('file' => '.+'))->defaults(array('controller' => 'lwrte', 'action' => 'media', 'file' => NULL));
Route::set('lwrte-upload', 'lwrte/upload')->defaults(array('controller' => 'lwrte', 'action' => 'upload'));
示例#30
0
 */
Kohana::init(array('base_url' => '/kohana/'));
/**
 * Attach the file write to logging. Multiple writers are supported.
 */
// Disabled the default file writer FirePHP so we can filter out FirePHP
// A custom file writer is included with this module
//Kohana::$log->attach(new Kohana_Log_File(APPPATH.'logs'));
/**
 * Attach a file reader to config. Multiple readers are supported.
 */
Kohana::$config->attach(new Kohana_Config_File());
/**
 * Enable modules. Modules are referenced by a relative or absolute path.
 */
Kohana::modules(array('firephp' => MODPATH . 'firephp', 'auth' => MODPATH . 'auth', 'database' => MODPATH . 'database'));
/**
 * Attach FirePHP to logging. be sure to enable firephp module
 */
// Exclude all FirePHP console logs from the file log...
Kohana::$log->attach(new FirePHP_Log_File(APPPATH . 'logs'));
Kohana::$log->attach(new FirePHP_Log_Console());
Kohana::$log->add('FirePHP::INFO', 'FirePHP Initialized...')->write();
/**
 *  Examples of using the KO3 log class with FirePHP
 */
Kohana::$log->add('FirePHP::GROUP_START', 'Kohana FirePHP Demos...');
Kohana::$log->add('FirePHP::LOG', 'FirePHP Log...');
Kohana::$log->add('FirePHP::INFO', 'FirePHP Info...');
Kohana::$log->add('FirePHP::WARN', 'FirePHP Warn...');
Kohana::$log->add('FirePHP::ERROR', 'FirePHP Error...');