Created new file system/base.php with low-level functions, moved __() to base.php, moved environment setup to bootstrap.php, and updated index.php accordingly
This commit is contained in:
parent
c3aaae8491
commit
100f8a7abd
|
@ -1,21 +1,41 @@
|
||||||
<?php defined('SYSPATH') or die('No direct script access.');
|
<?php defined('SYSPATH') or die('No direct script access.');
|
||||||
|
|
||||||
/**
|
//-- Environment setup --------------------------------------------------------
|
||||||
* Initialize Kohana
|
|
||||||
*/
|
|
||||||
Kohana::init(array('charset' => 'utf-8', 'base_url' => '/ko3/'));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable modules.
|
* Enable the Kohana auto-loader.
|
||||||
|
*/
|
||||||
|
spl_autoload_register(array('Kohana', 'auto_load'));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable Kohana exception handling, adds stack traces and error source.
|
||||||
|
*/
|
||||||
|
set_exception_handler(array('Kohana', 'exception_handler'));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable Kohana error handling, converts all PHP errors to exceptions.
|
||||||
|
*/
|
||||||
|
set_error_handler(array('Kohana', 'error_handler'));
|
||||||
|
|
||||||
|
//-- Kohana configuration -----------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize Kohana, setting the default options.
|
||||||
|
*/
|
||||||
|
Kohana::init(array('charset' => 'utf-8', 'base_url' => '/ko3/index.php/'));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable modules. Modules are referenced by a relative or absolute path.
|
||||||
*/
|
*/
|
||||||
Kohana::modules(array(
|
Kohana::modules(array(
|
||||||
// 'orm' => MODPATH.'orm',
|
// 'orm' => MODPATH.'orm',
|
||||||
// 'database' => MODPATH.'database',
|
'database' => MODPATH.'database',
|
||||||
'todoist' => MODPATH.'todoist',
|
'todoist' => MODPATH.'todoist',
|
||||||
));
|
));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log all messages to files
|
* Attach the file write to logging. Any Kohana_Log object can be attached,
|
||||||
|
* and multiple writers are supported.
|
||||||
*/
|
*/
|
||||||
Kohana::$log->attach(new Kohana_Log_File(APPPATH.'logs'));
|
Kohana::$log->attach(new Kohana_Log_File(APPPATH.'logs'));
|
||||||
|
|
||||||
|
@ -24,6 +44,8 @@ Kohana::$log->attach(new Kohana_Log_File(APPPATH.'logs'));
|
||||||
*/
|
*/
|
||||||
i18n::$lang = 'en_US';
|
i18n::$lang = 'en_US';
|
||||||
|
|
||||||
|
//-- Routing and execution ----------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the routes.
|
* Set the routes.
|
||||||
*/
|
*/
|
||||||
|
@ -40,5 +62,12 @@ Route::set('default', '(<controller>(/<action>(/<id>)))')
|
||||||
'action' => 'index',
|
'action' => 'index',
|
||||||
'id' => NULL));
|
'id' => NULL));
|
||||||
|
|
||||||
// Execute the main request
|
/**
|
||||||
Request::instance($_SERVER['PATH_INFO'])->execute(FALSE);
|
* Execute the main request using PATH_INFO. If no URI source is specified,
|
||||||
|
* the URI will be automatically detected.
|
||||||
|
*
|
||||||
|
* To return the output of the request instead of displaying it, specify
|
||||||
|
* TRUE for execute().
|
||||||
|
*/
|
||||||
|
Request::instance($_SERVER['PATH_INFO'])
|
||||||
|
->execute(FALSE);
|
||||||
|
|
24
index.php
24
index.php
|
@ -73,32 +73,14 @@ if (file_exists('install'.EXT))
|
||||||
return include 'install'.EXT;
|
return include 'install'.EXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// i18n translation function
|
|
||||||
function __($string, array $values = NULL)
|
|
||||||
{
|
|
||||||
if (i18n::$lang !== i18n::$default_lang)
|
|
||||||
{
|
|
||||||
// Get the translation for this string
|
|
||||||
$string = i18n::get($string);
|
|
||||||
}
|
|
||||||
|
|
||||||
return empty($values) ? $string : strtr($string, $values);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define the start time of the application
|
// Define the start time of the application
|
||||||
define('KOHANA_START_TIME', microtime(TRUE));
|
define('KOHANA_START_TIME', microtime(TRUE));
|
||||||
|
|
||||||
|
// Load the base, low-level functions
|
||||||
|
require SYSPATH.'base'.EXT;
|
||||||
|
|
||||||
// Load the main Kohana class
|
// Load the main Kohana class
|
||||||
require SYSPATH.'classes/kohana'.EXT;
|
require SYSPATH.'classes/kohana'.EXT;
|
||||||
|
|
||||||
// Enable auto-loading of classes
|
|
||||||
spl_autoload_register(array('Kohana', 'auto_load'));
|
|
||||||
|
|
||||||
// Enable the exception handler
|
|
||||||
set_exception_handler(array('Kohana', 'exception_handler'));
|
|
||||||
|
|
||||||
// Enable the error-to-exception handler
|
|
||||||
set_error_handler(array('Kohana', 'error_handler'));
|
|
||||||
|
|
||||||
// Bootstrap the application
|
// Bootstrap the application
|
||||||
require APPPATH.'bootstrap'.EXT;
|
require APPPATH.'bootstrap'.EXT;
|
||||||
|
|
21
system/base.php
Normal file
21
system/base.php
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<?php defined('SYSPATH') or die('No direct script access.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kohana translation/internationalization function.
|
||||||
|
*
|
||||||
|
* __('Welcome back, :user', array(':user' => $username));
|
||||||
|
*
|
||||||
|
* @param string text to translate
|
||||||
|
* @param array values to replace in the translated text
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function __($string, array $values = NULL)
|
||||||
|
{
|
||||||
|
if (i18n::$lang !== i18n::$default_lang)
|
||||||
|
{
|
||||||
|
// Get the translation for this string
|
||||||
|
$string = i18n::get($string);
|
||||||
|
}
|
||||||
|
|
||||||
|
return empty($values) ? $string : strtr($string, $values);
|
||||||
|
}
|
Loading…
Reference in a new issue