mirror of
https://github.com/slawkens/myaac.git
synced 2025-06-13 08:14:31 +02:00
* Environment is now configurable ('prod' for production, 'dev' for development)
Significantly better load times with 'prod' !!!
This commit is contained in:
parent
510459b046
commit
550b664a61
10
config.php
10
config.php
@ -20,6 +20,16 @@ $config = array(
|
|||||||
// directories & files
|
// directories & files
|
||||||
'server_path' => '', // path to the server directory (same directory where config file is located)
|
'server_path' => '', // path to the server directory (same directory where config file is located)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Environment Setting
|
||||||
|
*
|
||||||
|
* if you use this script on your live server - set to 'prod' (production)
|
||||||
|
* if you want to test and debug the script locally, or develop plugins, set to 'dev' (development)
|
||||||
|
* WARNING: on 'dev' cache is disabled, so site will be significantly slower !!!
|
||||||
|
* Recommended: 'prod' cause of speed (page load time is better)
|
||||||
|
*/
|
||||||
|
'env' => 'prod', // 'prod' for production and 'dev' for development
|
||||||
|
|
||||||
'template' => 'kathrine', // template used by website (kathrine, tibiacom)
|
'template' => 'kathrine', // template used by website (kathrine, tibiacom)
|
||||||
'template_allow_change' => true, // allow users to choose their own template while browsing website?
|
'template_allow_change' => true, // allow users to choose their own template while browsing website?
|
||||||
|
|
||||||
|
@ -17,6 +17,10 @@ if(!$error) {
|
|||||||
$content .= PHP_EOL;
|
$content .= PHP_EOL;
|
||||||
$content .= '$config[\'installed\'] = true;';
|
$content .= '$config[\'installed\'] = true;';
|
||||||
$content .= PHP_EOL;
|
$content .= PHP_EOL;
|
||||||
|
// by default, set env to prod
|
||||||
|
// user can disable when he wants
|
||||||
|
$content .= '$config[\'env\'] = \'prod\'; // dev or prod';
|
||||||
|
$content .= PHP_EOL;
|
||||||
$content .= '$config[\'mail_enabled\'] = true;';
|
$content .= '$config[\'mail_enabled\'] = true;';
|
||||||
$content .= PHP_EOL;
|
$content .= PHP_EOL;
|
||||||
foreach($_SESSION as $key => $value)
|
foreach($_SESSION as $key => $value)
|
||||||
|
@ -39,12 +39,17 @@ class Twig_Autoloader
|
|||||||
*/
|
*/
|
||||||
public static function autoload($class)
|
public static function autoload($class)
|
||||||
{
|
{
|
||||||
if (0 !== strpos($class, 'Twig')) {
|
if (0 !== strpos($class, 'Twig')) {// || !isset($class[0])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_file($file = dirname(__FILE__).'/../'.str_replace(array('_', "\0"), array('/', ''), $class).'.php')) {
|
$file = __DIR__.'/../'.str_replace(array('_', "\0"), array('/', ''), $class).'.php';
|
||||||
require $file;
|
|
||||||
|
$dev_mode = (config('env') === 'dev');
|
||||||
|
if($dev_mode && !is_file($file)) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
require $file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,10 @@ class Cache
|
|||||||
|
|
||||||
static public function getInstance($engine = '', $prefix = '')
|
static public function getInstance($engine = '', $prefix = '')
|
||||||
{
|
{
|
||||||
|
if(config('env') === 'dev') {
|
||||||
|
return new self();
|
||||||
|
}
|
||||||
|
|
||||||
if(!self::$instance) {
|
if(!self::$instance) {
|
||||||
switch(strtolower($engine)) {
|
switch(strtolower($engine)) {
|
||||||
case 'apc':
|
case 'apc':
|
||||||
|
@ -3,12 +3,14 @@
|
|||||||
require_once LIBS . 'Twig/Autoloader.php';
|
require_once LIBS . 'Twig/Autoloader.php';
|
||||||
Twig_Autoloader::register();
|
Twig_Autoloader::register();
|
||||||
|
|
||||||
|
$dev_mode = (config('env') === 'dev');
|
||||||
$twig_loader = new Twig_Loader_Filesystem(SYSTEM . 'templates');
|
$twig_loader = new Twig_Loader_Filesystem(SYSTEM . 'templates');
|
||||||
$twig = new Twig_Environment($twig_loader, array(
|
$twig = new Twig_Environment($twig_loader, array(
|
||||||
'cache' => CACHE . 'twig/',
|
'cache' => CACHE . 'twig/',
|
||||||
'auto_reload' => true,
|
'auto_reload' => $dev_mode,
|
||||||
//'debug' => true
|
'debug' => $dev_mode
|
||||||
));
|
));
|
||||||
|
unset($dev_mode);
|
||||||
|
|
||||||
$function = new Twig_SimpleFunction('getStyle', function ($i) {
|
$function = new Twig_SimpleFunction('getStyle', function ($i) {
|
||||||
return getStyle($i);
|
return getStyle($i);
|
||||||
@ -34,4 +36,5 @@ $twig->addFunction($function);
|
|||||||
$filter = new Twig_SimpleFilter('urlencode', function ($s) {
|
$filter = new Twig_SimpleFilter('urlencode', function ($s) {
|
||||||
return urlencode($s);
|
return urlencode($s);
|
||||||
});
|
});
|
||||||
$twig->addFilter($filter);
|
$twig->addFilter($filter);
|
||||||
|
unset($function, $filter);
|
Loading…
x
Reference in New Issue
Block a user