Example #1
0
    ctx_log_start("Loading themelets");
    foreach (_get_themelet_files(get_theme()) as $themelet) {
        require_once $themelet;
    }
    ctx_log_endok();
    _load_extensions();
    // start the page generation waterfall
    $page = class_exists("CustomPage") ? new CustomPage() : new Page();
    $user = _get_user();
    send_event(new InitExtEvent());
    if (!is_cli()) {
        // web request
        send_event(new PageRequestEvent(@$_GET["q"]));
        $page->display();
    } else {
        // command line request
        send_event(new CommandEvent($argv));
    }
    // saving cache data and profiling data to disk can happen later
    if (function_exists("fastcgi_finish_request")) {
        fastcgi_finish_request();
    }
    $database->commit();
    ctx_log_endok();
} catch (Exception $e) {
    if ($database) {
        $database->rollback();
    }
    _fatal_error($e);
    ctx_log_ender();
}
Example #2
0
/**
 * Send an event to all registered Extensions
 */
function send_event(Event $event)
{
    global $_event_listeners, $_event_count;
    ctx_log_start(get_class($event));
    $my_event_listeners = $_event_listeners;
    // http://bugs.php.net/bug.php?id=35106
    ksort($my_event_listeners);
    foreach ($my_event_listeners as $listener) {
        ctx_log_start(get_class($listener));
        $listener->receive_event($event);
        ctx_log_endok();
    }
    $_event_count++;
    ctx_log_endok();
}
Example #3
0
function _load_extensions()
{
    global $_event_listeners;
    ctx_log_start("Loading extensions");
    if (COMPILE_ELS && file_exists("data/cache/event_listeners.php")) {
        require_once "data/cache/event_listeners.php";
    } else {
        _set_event_listeners(get_declared_classes());
        if (COMPILE_ELS) {
            _dump_event_listeners($_event_listeners, data_path("cache/event_listeners.php"));
        }
    }
    ctx_log_endok();
}
Example #4
0
/**
 * Send an event to all registered Extensions.
 *
 * @param Event $event
 */
function send_event(Event $event)
{
    global $_shm_event_listeners, $_shm_event_count;
    if (!isset($_shm_event_listeners[get_class($event)])) {
        return;
    }
    $method_name = "on" . str_replace("Event", "", get_class($event));
    // send_event() is performance sensitive, and with the number
    // of times context gets called the time starts to add up
    $ctx = constant('CONTEXT');
    if ($ctx) {
        ctx_log_start(get_class($event));
    }
    // SHIT: http://bugs.php.net/bug.php?id=35106
    $my_event_listeners = $_shm_event_listeners[get_class($event)];
    ksort($my_event_listeners);
    foreach ($my_event_listeners as $listener) {
        if ($ctx) {
            ctx_log_start(get_class($listener));
        }
        if (method_exists($listener, $method_name)) {
            $listener->{$method_name}($event);
        }
        if ($ctx) {
            ctx_log_endok();
        }
    }
    $_shm_event_count++;
    if ($ctx) {
        ctx_log_endok();
    }
}