Skip to content

Commit

Permalink
compile library
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcus Lunzenauer committed Oct 29, 2009
1 parent 4505196 commit cb2f835
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 24 deletions.
40 changes: 17 additions & 23 deletions lib/trails-unabridged.php
Expand Up @@ -113,8 +113,8 @@ function __construct($trails_root,
*/
function dispatch($uri) {

$old_handler =
set_error_handler(array($this, 'error_handler'), E_ALL);
# E_USER_ERROR|E_USER_WARNING|E_USER_NOTICE|E_RECOVERABLE_ERROR = 5888
$old_handler = set_error_handler(array($this, 'error_handler'), 5888);

ob_start();
$level = ob_get_level();
Expand Down Expand Up @@ -223,7 +223,6 @@ function clean_request_uri($uri) {
* @return type <description>
*/
function parse($unconsumed, $controller = NULL) {

list($head, $tail) = $this->split_on_first_slash($unconsumed);

if (!preg_match('/^\w+$/', $head)) {
Expand All @@ -243,11 +242,8 @@ function parse($unconsumed, $controller = NULL) {
}

function split_on_first_slash($str) {
$pos = strpos($str, '/');
if ($pos !== FALSE) {
return array(substr($str, 0, $pos), substr($str, $pos + 1));
}
return array($str, '');
preg_match(":([^/]*)(/+)?(.*):", $str, $matches);
return array($matches[1], $matches[3]);
}

function file_exists($path) {
Expand All @@ -274,23 +270,21 @@ function load_controller($controller) {


/**
* <MethodDescription>
* # TODO (mlunzena) add description
* This method transforms E_USER_* and E_RECOVERABLE_ERROR to
* Trails_Exceptions.
*
* @param type <description>
* @param integer the level of the error raised
* @param string the error message
* @param string the filename that the error was raised in
* @param integer the line number the error was raised at
* @param array an array of every variable that existed in the scope the
* error was triggered in
*
* @return type <description>
* @throws Trails_Exception
*
* @return void
*/
function error_handler($errno, $string, $file, $line, $context) {

if (!($errno & error_reporting())) {
return;
}

if ($errno == E_NOTICE || $errno == E_WARNING || $errno == E_STRICT) {
return FALSE;
}

$e = new Trails_Exception(500, $string);
$e->line = $line;
$e->file = $file;
Expand Down Expand Up @@ -449,7 +443,7 @@ function output() {
*
* @param string the HTTP header
* @param bool optional; TRUE if previously sent header should be
* replaced FALSE otherwise (default)
* replaced - FALSE otherwise (default)
* @param integer optional; the HTTP response code
*
* @return void
Expand Down Expand Up @@ -866,7 +860,7 @@ function set_content_type($type) {
* @return object a response object
*/
function rescue($exception) {
return ($this->response = $this->dispatcher->trails_error($exception));
return $this->dispatcher->trails_error($exception);
}
}

Expand Down

0 comments on commit cb2f835

Please sign in to comment.