/** This method is the main controller */ public static function serveWeb() { if (Config::get('PROFILING_ENABLED')) { Profiling::start('index'); } $url = $_SERVER['REQUEST_URI']; $hash = md5($url); if (!@(include 'cache/' . $hash)) { Router::setUrl($url); switch (Router::$node->getProperty('type')) { case 'page': case 'root': ControllerPage::compile(); break; case 'php': ControllerPhp::compile(); break; } } if (Config::get('PROFILING_ENABLED')) { Profiling::end(); } }
function render404() { Router::setUrl(time()); }
echo "Language does not match\n"; } // Print Router::print_r(); return $pass; }; $tests['Get parametrized'] = function () { $pass = true; // Prepare Router::$root = $root = build_basic_hierarchy(); $a = $root->get('a'); $e = $root->get('a/e'); $e->remove(); $a->append('{parameter}', $e); // Run $router = Router::setUrl("/a/my-parameter/f"); // Check if (0 != count(Router::$parts)) { $pass = false; echo "All parts must be consumed\n"; } if (1 != count(Router::$parameters)) { $pass = false; echo "Must be 1 parameter\n"; } if (Router::$parameters['{parameter}'] !== 'my-parameter') { $pass = false; echo "parameters['{parameter}'] MUST BE 'my-parameter'\n"; } // Print $root->print_r();
<?php if (!Config::get('DOC_ENABLED')) { Router::setUrl(time()); return; } ?> <!DOCTYPE html> <html> <head> <title>Documentation</title> <script src="http://docuss.treeweb.es/docuss.js" type="text/javascript"></script> </head> <body> <h1>Index</h1> <ul> <?php $path = 'doc/'; $d = dir($path); $select = array(); while (false !== ($entry = $d->read())) { $entry = pathinfo($entry); if ('html' == $entry['extension']) { $select[$entry['filename']] = $entry['basename']; } } $d->close(); ksort($select); foreach ($select as $S => $s) { echo "<li><a href='/{$path}{$s}'>{$S}</a></li>"; }