mirror of
https://github.com/monstra-cms/monstra.git
synced 2025-08-05 04:37:51 +02:00
Update Gelato to 1.0.1
This commit is contained in:
@@ -124,7 +124,7 @@ class ClassLoader
|
|||||||
* Set an alias for a class.
|
* Set an alias for a class.
|
||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* ClassLoader::registerNamespace('ClassNameAlias', 'ClassName');
|
* ClassLoader::alias('ClassNameAlias', 'ClassName');
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
@@ -222,4 +222,15 @@ class ClassLoader
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the Gelato ClassLoader to the SPL autoload stack.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function register()
|
||||||
|
{
|
||||||
|
spl_autoload_register('ClassLoader::load', true, true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -18,6 +18,25 @@
|
|||||||
class ErrorHandler
|
class ErrorHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Error Levels
|
||||||
|
*/
|
||||||
|
public static $levels = array (
|
||||||
|
E_ERROR => 'Fatal Error',
|
||||||
|
E_PARSE => 'Parse Error',
|
||||||
|
E_COMPILE_ERROR => 'Compile Error',
|
||||||
|
E_COMPILE_WARNING => 'Compile Warning',
|
||||||
|
E_STRICT => 'Strict Mode Error',
|
||||||
|
E_NOTICE => 'Notice',
|
||||||
|
E_WARNING => 'Warning',
|
||||||
|
E_RECOVERABLE_ERROR => 'Recoverable Error',
|
||||||
|
E_USER_NOTICE => 'Notice',
|
||||||
|
E_USER_WARNING => 'Warning',
|
||||||
|
E_USER_ERROR => 'Error',
|
||||||
|
/*E_DEPRECATED => 'Deprecated',*/ /* PHP 5.3 only */
|
||||||
|
/*E_USER_DEPRECATED => 'Deprecated'*/ /* PHP 5.3 only */
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Protected constructor since this is a static class.
|
* Protected constructor since this is a static class.
|
||||||
*
|
*
|
||||||
@@ -194,7 +213,7 @@ class ErrorHandler
|
|||||||
if (isset($entry['file'])) {
|
if (isset($entry['file'])) {
|
||||||
$location['file'] = $entry['file'];
|
$location['file'] = $entry['file'];
|
||||||
$location['line'] = $entry['line'];
|
$location['line'] = $entry['line'];
|
||||||
$location['code'] = static::highlightCode($entry['file'], $entry['line']);
|
$location['code'] = self::highlightCode($entry['file'], $entry['line']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -247,24 +266,7 @@ class ErrorHandler
|
|||||||
// Determine error type
|
// Determine error type
|
||||||
if ($exception instanceof ErrorException) {
|
if ($exception instanceof ErrorException) {
|
||||||
$error['type'] = 'ErrorException: ';
|
$error['type'] = 'ErrorException: ';
|
||||||
|
$error['type'] .= in_array($error['code'], array_keys(ErrorHandler::$levels)) ? ErrorHandler::$levels[$error['code']] : 'Unknown Error';
|
||||||
$codes = array (
|
|
||||||
E_ERROR => 'Fatal Error',
|
|
||||||
E_PARSE => 'Parse Error',
|
|
||||||
E_COMPILE_ERROR => 'Compile Error',
|
|
||||||
E_COMPILE_WARNING => 'Compile Warning',
|
|
||||||
E_STRICT => 'Strict Mode Error',
|
|
||||||
E_NOTICE => 'Notice',
|
|
||||||
E_WARNING => 'Warning',
|
|
||||||
E_RECOVERABLE_ERROR => 'Recoverable Error',
|
|
||||||
/*E_DEPRECATED => 'Deprecated',*/
|
|
||||||
E_USER_NOTICE => 'Notice',
|
|
||||||
E_USER_WARNING => 'Warning',
|
|
||||||
E_USER_ERROR => 'Error',
|
|
||||||
/*E_USER_DEPRECATED => 'Deprecated'*/
|
|
||||||
);
|
|
||||||
|
|
||||||
$error['type'] .= in_array($error['code'], array_keys($codes)) ? $codes[$error['code']] : 'Unknown Error';
|
|
||||||
} else {
|
} else {
|
||||||
$error['type'] = get_class($exception);
|
$error['type'] = get_class($exception);
|
||||||
}
|
}
|
||||||
@@ -283,8 +285,8 @@ class ErrorHandler
|
|||||||
$error['backtrace'] = array_slice($error['backtrace'], 1); //Remove call to error handler from backtrace
|
$error['backtrace'] = array_slice($error['backtrace'], 1); //Remove call to error handler from backtrace
|
||||||
}
|
}
|
||||||
|
|
||||||
$error['backtrace'] = static::formatBacktrace($error['backtrace']);
|
$error['backtrace'] = self::formatBacktrace($error['backtrace']);
|
||||||
$error['highlighted'] = static::highlightCode($error['file'], $error['line']);
|
$error['highlighted'] = self::highlightCode($error['file'], $error['line']);
|
||||||
|
|
||||||
Response::status(500);
|
Response::status(500);
|
||||||
include 'Resources/Views/Errors/exception.php';
|
include 'Resources/Views/Errors/exception.php';
|
||||||
|
@@ -11,6 +11,16 @@
|
|||||||
font-size:14px;
|
font-size:14px;
|
||||||
font-family:Verdana, Arial, Helvetica, "Nimbus Sans", FreeSans, Malayalam, sans-serif;
|
font-family:Verdana, Arial, Helvetica, "Nimbus Sans", FreeSans, Malayalam, sans-serif;
|
||||||
margin:20px auto;
|
margin:20px auto;
|
||||||
|
|
||||||
|
-webkit-box-shadow: 1px 1px 18px rgba(50, 50, 50, 0.75);
|
||||||
|
-moz-box-shadow: 1px 1px 18px rgba(50, 50, 50, 0.75);
|
||||||
|
box-shadow: 1px 1px 18px rgba(50, 50, 50, 0.75);
|
||||||
|
|
||||||
|
-webkit-border-radius: 5px;
|
||||||
|
-moz-border-radius: 5px;
|
||||||
|
border-radius: 5px;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#gelato-error pre {
|
#gelato-error pre {
|
||||||
@@ -31,6 +41,13 @@
|
|||||||
font-size:24px;
|
font-size:24px;
|
||||||
font-weight:700;
|
font-weight:700;
|
||||||
padding:10px;
|
padding:10px;
|
||||||
|
|
||||||
|
-moz-border-radius-topleft: 5px;
|
||||||
|
-webkit-border-top-left-radius: 5px;
|
||||||
|
border-top-left-radius: 5px;
|
||||||
|
-moz-border-radius-topright: 5px;
|
||||||
|
-webkit-border-top-right-radius: 5px;
|
||||||
|
border-top-right-radius: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#gelato-error .body {
|
#gelato-error .body {
|
||||||
|
@@ -18,7 +18,14 @@
|
|||||||
/**
|
/**
|
||||||
* The version of Gelato
|
* The version of Gelato
|
||||||
*/
|
*/
|
||||||
define('GELATO_VERSION', '1.0.0');
|
define('GELATO_VERSION', '1.0.1');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define __DIR__ constant for PHP 5.2.x
|
||||||
|
*/
|
||||||
|
if ( ! defined('__DIR__')) {
|
||||||
|
define('__DIR__', dirname(__FILE__));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display Gelato Errors or not ?
|
* Display Gelato Errors or not ?
|
||||||
@@ -28,10 +35,10 @@ if ( ! defined('GELATO_DEVELOPMENT')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use Gelato Autoloader or not ?
|
* Use Gelato Class Loader or not ?
|
||||||
*/
|
*/
|
||||||
if ( ! defined('GELATO_AUTOLOADER')) {
|
if ( ! defined('GELATO_CLASS_LOADER')) {
|
||||||
define('GELATO_AUTOLOADER', true);
|
define('GELATO_CLASS_LOADER', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,8 +117,8 @@ ClassLoader::mapClasses(array(
|
|||||||
));
|
));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register Gelato Autoloader
|
* Register Gelato Class Loader
|
||||||
*/
|
*/
|
||||||
if (GELATO_AUTOLOADER) {
|
if (GELATO_CLASS_LOADER) {
|
||||||
spl_autoload_register('ClassLoader::load');
|
ClassLoader::register();
|
||||||
}
|
}
|
||||||
|
@@ -25,37 +25,6 @@ class Log
|
|||||||
*/
|
*/
|
||||||
protected static $path = '';
|
protected static $path = '';
|
||||||
|
|
||||||
/**
|
|
||||||
* Log levels.
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
const EMERGENCY = 1;
|
|
||||||
const ALERT = 2;
|
|
||||||
const CRITICAL = 3;
|
|
||||||
const ERROR = 4;
|
|
||||||
const WARNING = 5;
|
|
||||||
const NOTICE = 6;
|
|
||||||
const INFO = 7;
|
|
||||||
const DEBUG = 8;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Log types.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected static $types = array
|
|
||||||
(
|
|
||||||
Log::EMERGENCY => 'emergency',
|
|
||||||
Log::ALERT => 'alert',
|
|
||||||
Log::CRITICAL => 'critical',
|
|
||||||
Log::ERROR => 'error',
|
|
||||||
Log::WARNING => 'warning',
|
|
||||||
Log::NOTICE => 'notice',
|
|
||||||
Log::INFO => 'info',
|
|
||||||
Log::DEBUG => 'debug',
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Protected constructor since this is a static class.
|
* Protected constructor since this is a static class.
|
||||||
*
|
*
|
||||||
@@ -66,6 +35,13 @@ class Log
|
|||||||
// Nothing here
|
// Nothing here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure Log
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string $setting The setting
|
||||||
|
* @param string $value The value
|
||||||
|
*/
|
||||||
public static function configure($setting, $value)
|
public static function configure($setting, $value)
|
||||||
{
|
{
|
||||||
if (property_exists("log", $setting)) Log::$$setting = $value;
|
if (property_exists("log", $setting)) Log::$$setting = $value;
|
||||||
@@ -76,15 +52,12 @@ class Log
|
|||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $message The message to write to the log
|
* @param string $message The message to write to the log
|
||||||
* @param int $type (optional) Message type
|
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function write($message, $type = Log::ERROR)
|
public static function write($message)
|
||||||
{
|
{
|
||||||
$file = rtrim(Log::$path, '/') . '/' . gmdate('Y_m_d') . '.log';
|
return (bool) file_put_contents(rtrim(Log::$path, '/') . '/' . gmdate('Y_m_d') . '.log',
|
||||||
|
'[' . gmdate('d-M-Y H:i:s') . '] ' . $message . PHP_EOL,
|
||||||
$message = '[' . gmdate('d-M-Y H:i:s') . '] ' . $message . PHP_EOL;
|
FILE_APPEND);
|
||||||
|
|
||||||
return (bool) file_put_contents($file, $message, FILE_APPEND);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,3 +1,11 @@
|
|||||||
|
Gelato 1.0.1, 2013-03-05
|
||||||
|
------------------------
|
||||||
|
- New constant GELATO_CLASS_LOADER instead of GELATO_AUTOLOADER
|
||||||
|
- ErrorHanler Class Improvements.
|
||||||
|
- Log Class Improvements.
|
||||||
|
- ClassLoader: new method register() added.
|
||||||
|
- Define __DIR__ constant for PHP 5.2.x
|
||||||
|
|
||||||
Gelato 1.0.0, 2013-02-26
|
Gelato 1.0.0, 2013-02-26
|
||||||
------------------------
|
------------------------
|
||||||
- Initial release
|
- Initial release
|
||||||
|
Reference in New Issue
Block a user