mirror of
https://github.com/monstra-cms/monstra.git
synced 2025-07-31 02:10:37 +02:00
Core Improvements: Next Round
This commit is contained in:
@@ -114,9 +114,9 @@ class Core
|
||||
|
||||
// Init ORM
|
||||
if (defined('MONSTRA_DB_DSN')) {
|
||||
ORM::configure(MONSTRA_DB_DSN);
|
||||
ORM::configure('username', MONSTRA_DB_USER);
|
||||
ORM::configure('password', MONSTRA_DB_PASSWORD);
|
||||
Orm::configure(MONSTRA_DB_DSN);
|
||||
Orm::configure('username', MONSTRA_DB_USER);
|
||||
Orm::configure('password', MONSTRA_DB_PASSWORD);
|
||||
}
|
||||
|
||||
// Auto cleanup if MONSTRA_DEBUG is true
|
||||
@@ -129,6 +129,12 @@ class Core
|
||||
if (count($namespaces = Dir::scan(CACHE)) > 0) foreach ($namespaces as $namespace) Dir::delete(CACHE . DS . $namespace);
|
||||
}
|
||||
|
||||
// Set cache dir
|
||||
Cache::configure('cache_dir', CACHE);
|
||||
|
||||
// Load URI module
|
||||
require_once(ROOT . '/libraries/engine/Security.php');
|
||||
|
||||
// Load URI module
|
||||
require_once(ROOT . '/libraries/engine/Uri.php');
|
||||
|
||||
|
@@ -20,7 +20,7 @@ class Cache
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $cache_dir = CACHE;
|
||||
public static $cache_dir = '';
|
||||
|
||||
/**
|
||||
* Cache file ext
|
||||
|
85
libraries/monstra/Config.php
Normal file
85
libraries/monstra/Config.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
class Config
|
||||
{
|
||||
|
||||
private static $path = '';
|
||||
|
||||
|
||||
/**
|
||||
* Config array.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
|
||||
protected static $config;
|
||||
|
||||
|
||||
/**
|
||||
* Protected constructor since this is a static class.
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
|
||||
protected function __construct()
|
||||
{
|
||||
// Nothing here
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the location where to save the config file.
|
||||
*
|
||||
* @return SpoonLog
|
||||
* @param string[optional] $path The path where you want to store the logfile. If null it will be saved in 'spoon/log/*'.
|
||||
*/
|
||||
public static function setPath($path)
|
||||
{
|
||||
Config::$path = $path;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the path to the configuration file.
|
||||
*
|
||||
* @access protected
|
||||
* @param string $file File name
|
||||
* @return string
|
||||
*/
|
||||
|
||||
protected static function file($file)
|
||||
{
|
||||
|
||||
//$path = MONSTRA_LIBRARIES_PATH.'/'.Config::$path.'/'.$file.'.php';
|
||||
|
||||
if (file_exists(Config::$path.'/'.$file.'.php')) {
|
||||
return Config::$path.'/'.$file.'.php';
|
||||
}
|
||||
|
||||
throw new RuntimeException(vsprintf("%s(): The '%s' config file does not exist.", array(__METHOD__, $file)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns config value or entire config array from a file.
|
||||
*
|
||||
* @access public
|
||||
* @param string $key Config key
|
||||
* @param mixed $default (optional) Default value to return if config value doesn't exist
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
public static function get($key, $default = null)
|
||||
{
|
||||
$keys = explode('.', $key, 2);
|
||||
|
||||
if (!isset(static::$config[$keys[0]])) {
|
||||
static::$config[$keys[0]] = include(static::file($keys[0]));
|
||||
}
|
||||
|
||||
if (!isset($keys[1])) {
|
||||
return static::$config[$keys[0]];
|
||||
} else {
|
||||
return Arr::get(static::$config[$keys[0]], $keys[1], $default);
|
||||
}
|
||||
}
|
||||
}
|
@@ -36,13 +36,13 @@ class Date
|
||||
* @param string $format Date format
|
||||
* @return integer
|
||||
*/
|
||||
public static function format($date, $format = '')
|
||||
public static function format($date, $format = 'j.n.Y')
|
||||
{
|
||||
// Redefine vars
|
||||
$format = (string) $format;
|
||||
$date = (int) $date;
|
||||
|
||||
if ($format != '') { return date($format, $date); } else { return date(MONSTRA_DATE_FORMAT, $date); }
|
||||
return date($format, $date);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -13,9 +13,6 @@
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Dir class
|
||||
*/
|
||||
class Dir
|
||||
{
|
||||
/**
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Monstra Library
|
||||
*
|
||||
|
@@ -13,12 +13,12 @@
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
/*
|
||||
/**
|
||||
* Version number for the current version of the Monstra Library.
|
||||
*/
|
||||
define('MONSTRA_LIBRARY_VERSION', '1.0.0');
|
||||
|
||||
/*
|
||||
/**
|
||||
* Should we use the Monstra Autoloader to ensure the dependancies are automatically
|
||||
* loaded?
|
||||
*/
|
||||
@@ -26,7 +26,9 @@ if ( ! defined('MONSTRA_LIBRARY_AUTOLOADER')) {
|
||||
define('MONSTRA_LIBRARY_AUTOLOADER', true);
|
||||
}
|
||||
|
||||
// Register autoload function
|
||||
/**
|
||||
* Register autoload function
|
||||
*/
|
||||
if (MONSTRA_LIBRARY_AUTOLOADER) {
|
||||
spl_autoload_register(array('Monstra', 'autoload'));
|
||||
}
|
||||
@@ -43,7 +45,6 @@ class Monstra
|
||||
* @var array
|
||||
*/
|
||||
private static $registry = array();
|
||||
|
||||
|
||||
/**
|
||||
* Autload
|
||||
|
Reference in New Issue
Block a user