1
0
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:
Awilum
2013-03-05 23:15:28 +02:00
parent a464d2bff5
commit 7433dbd24c
6 changed files with 86 additions and 68 deletions

View File

@@ -124,7 +124,7 @@ class ClassLoader
* Set an alias for a class.
*
* <code>
* ClassLoader::registerNamespace('ClassNameAlias', 'ClassName');
* ClassLoader::alias('ClassNameAlias', 'ClassName');
* </code>
*
* @access public
@@ -222,4 +222,15 @@ class ClassLoader
return false;
}
/**
* Register the Gelato ClassLoader to the SPL autoload stack.
*
* @return void
*/
public static function register()
{
spl_autoload_register('ClassLoader::load', true, true);
}
}

View File

@@ -18,6 +18,25 @@
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.
*
@@ -194,7 +213,7 @@ class ErrorHandler
if (isset($entry['file'])) {
$location['file'] = $entry['file'];
$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
if ($exception instanceof ErrorException) {
$error['type'] = 'ErrorException: ';
$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';
$error['type'] .= in_array($error['code'], array_keys(ErrorHandler::$levels)) ? ErrorHandler::$levels[$error['code']] : 'Unknown Error';
} else {
$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'] = static::formatBacktrace($error['backtrace']);
$error['highlighted'] = static::highlightCode($error['file'], $error['line']);
$error['backtrace'] = self::formatBacktrace($error['backtrace']);
$error['highlighted'] = self::highlightCode($error['file'], $error['line']);
Response::status(500);
include 'Resources/Views/Errors/exception.php';

View File

@@ -11,6 +11,16 @@
font-size:14px;
font-family:Verdana, Arial, Helvetica, "Nimbus Sans", FreeSans, Malayalam, sans-serif;
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 {
@@ -31,6 +41,13 @@
font-size:24px;
font-weight:700;
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 {

View File

@@ -18,7 +18,14 @@
/**
* 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 ?
@@ -28,10 +35,10 @@ if ( ! defined('GELATO_DEVELOPMENT')) {
}
/**
* Use Gelato Autoloader or not ?
* Use Gelato Class Loader or not ?
*/
if ( ! defined('GELATO_AUTOLOADER')) {
define('GELATO_AUTOLOADER', true);
if ( ! defined('GELATO_CLASS_LOADER')) {
define('GELATO_CLASS_LOADER', true);
}
/**
@@ -110,8 +117,8 @@ ClassLoader::mapClasses(array(
));
/**
* Register Gelato Autoloader
* Register Gelato Class Loader
*/
if (GELATO_AUTOLOADER) {
spl_autoload_register('ClassLoader::load');
if (GELATO_CLASS_LOADER) {
ClassLoader::register();
}

View File

@@ -24,38 +24,7 @@ class Log
* @var string
*/
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.
*
@@ -66,6 +35,13 @@ class Log
// Nothing here
}
/**
* Configure Log
*
* @access public
* @param string $setting The setting
* @param string $value The value
*/
public static function configure($setting, $value)
{
if (property_exists("log", $setting)) Log::$$setting = $value;
@@ -76,15 +52,12 @@ class Log
*
* @access public
* @param string $message The message to write to the log
* @param int $type (optional) Message type
* @return boolean
*/
public static function write($message, $type = Log::ERROR)
public static function write($message)
{
$file = rtrim(Log::$path, '/') . '/' . gmdate('Y_m_d') . '.log';
$message = '[' . gmdate('d-M-Y H:i:s') . '] ' . $message . PHP_EOL;
return (bool) file_put_contents($file, $message, FILE_APPEND);
return (bool) file_put_contents(rtrim(Log::$path, '/') . '/' . gmdate('Y_m_d') . '.log',
'[' . gmdate('d-M-Y H:i:s') . '] ' . $message . PHP_EOL,
FILE_APPEND);
}
}

View File

@@ -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
------------------------
- Initial release