Ejemplo n.º 1
0
<?php

Dispatcher::main();
class Dispatcher
{
    private static $controller;
    public static function main()
    {
        $time_start = microtime(true);
        require_once 'lib/functions.php';
        session_start();
        header('Content-Type: text/html; charset=UTF-8');
        if (!function_exists('apache_request_headers')) {
            exit('Apache server is required. (PHP function "apache_request_headers" not found)');
        }
        $request_headers = apache_request_headers();
        //get headers for AJAX detection
        define('BASEDIR', dirname(__FILE__));
        define('IS_AJAX', (empty($request_headers['X-Requested-With']) or $request_headers['X-Requested-With'] != 'XMLHttpRequest') ? false : true);
        self::$controller = new Controller();
        self::$controller->View = new View(self::$controller);
        $action = 'index';
        if (!empty($_GET['url'])) {
            $params = explode("/", $_GET['url']);
            $action = preg_replace('/[^a-zA-Z0-9]/', '', $params[0]);
            if (substr($action, 0, 1) == '_') {
                exit("Failure to load pseudo-protected controller action {$action}");
            }
            if (!method_exists('Controller', $action)) {
                exit("Failure to load Controller action <b>{$action}</b>");
            }
Ejemplo n.º 2
0
 function test_PagedDisplay()
 {
     $PAGE_SIZE = 3;
     bibtexbrowser_configure('BIBTEXBROWSER_DEFAULT_DISPLAY', 'PagedDisplay');
     bibtexbrowser_configure('PAGE_SIZE', $PAGE_SIZE);
     $_GET['bib'] = 'bibacid-utf8.bib';
     $_GET['all'] = 1;
     $d = new Dispatcher();
     ob_start();
     $d->main();
     $content = "<div>" . ob_get_flush() . "</div>";
     $xml = new SimpleXMLElement($content);
     $result = $xml->xpath('//td[@class=\'bibref\']');
     $this->assertEquals($PAGE_SIZE, count($result));
 }