Example #1
0
 public static function BootstrapAuthentication($config)
 {
     // Load the authentication system.
     $auth_module = BUGDAR_ROOT . '/includes/auth/auth_' . $config->{'auth.module'} . '.php';
     if (!file_exists($auth_module) || !is_readable($auth_module)) {
         throw new CoreException('Could not load authentication module ' . $config->{'auth.module'});
     }
     require $auth_module;
     $name = phalanx\base\UnderscoreToCamelCase($config->{'auth.module'});
     $class_name = 'Authentication' . $name;
     if (!class_exists($class_name)) {
         throw new CoreException('Could not find class ' . $class_name);
     }
     self::$auth = new $class_name($config->auth);
 }
Example #2
0
File: main.php Project: rsesek/nztv
use phalanx\tasks\CLIDispatcher;
use phalanx\tasks\CLIOutputHandler;
use phalanx\tasks\TaskPump;
require './init.php';
require_once PHALANX_ROOT . '/base/functions.php';
require_once PHALANX_ROOT . '/tasks/task_pump.php';
require_once PHALANX_ROOT . '/tasks/cli_dispatcher.php';
require_once PHALANX_ROOT . '/tasks/cli_output_handler.php';
require './tasks/internal/error.php';
require './tasks/internal/message.php';
$dispatcher = new CLIDispatcher($argv);
$dispatcher->set_task_loader(function ($name) {
    $name = str_replace('-', '_', $name);
    $path = "./tasks/{$name}.php";
    if (!file_exists($path)) {
        TaskPump::Pump()->RunTask(new ErrorTask('Could not load file for task ' . $name));
        return;
    }
    require_once $path;
    return '\\nztv\\' . \phalanx\base\UnderscoreToCamelCase($name) . 'Task';
});
$output_handler = new CLIOutputHandler();
TaskPump::Pump()->set_output_handler($output_handler);
if (!isset($argv[1])) {
    Fatal("Commands: add-show set-episode set-url remove-show update-records");
}
// Process the inital task.
$dispatcher->Start();
// Stop the pump now that all tasks have been run.
TaskPump::Pump()->StopPump();
Example #3
0
$pump->set_output_handler($view_handler);
// Events are named in reverse order to be more human readable. Rather than
// user_register, it's register_user. After reversing the components, events
// are loaded from the events/ directory. The class name is the CammelCase
// version of the underscored name, suffixed by the word 'Event'.
$dispatcher->set_event_loader(function ($name) {
    $name = preg_replace('/[^a-z0-9_\\-\\.]/i', '', $name);
    $parts = explode('_', $name);
    $parts = array_reverse($parts);
    $name = implode('_', $parts);
    $path = "./events/{$name}.php";
    if (!file_exists($path)) {
        phalanx\events\EventPump::Pump()->RaiseEvent(new StandardErrorEvent('Could not load event ' . $name));
    }
    require_once $path;
    return phalanx\base\UnderscoreToCamelCase($name) . 'Event';
});
// Register bypass rules.
$dispatcher->AddBypassRule('', 'home');
$dispatcher->AddBypassRule('list', 'list_bug');
$dispatcher->AddBypassRule('new', 'new_bug');
$dispatcher->AddBypassRule('view', 'view_bug');
$dispatcher->AddBypassRule('login', 'login_user');
$dispatcher->AddBypassRule('logout', 'logout_user');
// Transform the event name into a template name.
phalanx\views\View::set_template_path(dirname(__FILE__) . '/templates/%s.tpl');
phalanx\views\View::set_cache_path(dirname(__FILE__) . '/cache');
$view_handler->set_template_loader(function ($event_class) {
    $name = preg_replace('/Event$/', '', $event_class);
    return phalanx\base\CamelCaseToUnderscore($name);
});