78       assert(is_array($this->_routerNames) && is_string($routerName));
 
   79       $this->_routerNames[$shortcut] = $routerName;
 
   91       assert(
count($routerNames) > 0);
 
   95       foreach($routerNames as $shortcut => $routerCandidateName) {
 
   99          if ($routerCandidate->supports($request)) {
 
  101             $request->setRouter($routerCandidate);
 
  102             $request->setDispatcher($this);
 
  106             $router =& $routerCandidate;
 
  107             $this->_router =& $router;
 
  114       if (is_null($router)) 
fatalError(
'None of the configured routers supports this request.');
 
  117       if ($router->isCacheable($request)) {
 
  118          $this->_requestCallbackHack =& $request;
 
  121             ob_start(array($this, 
'_cacheContent'));
 
  124          if (isset($_SERVER[
'HTTP_X_MOZ']) && $_SERVER[
'HTTP_X_MOZ'] == 
'prefetch') {
 
  125             header(
'HTTP/1.0 403 Forbidden');
 
  126             echo 
'403: Forbidden<br><br>Pre-fetching not allowed.';
 
  139       import(
'classes.core.Services');
 
  140       $contextSchema = 
\Services::get(
'schema')->get(SCHEMA_CONTEXT, 
true);
 
  141       $request->getRouter()->getContext($request, 1, 
true);
 
  143       $router->route($request);
 
  159    function url($request, $shortcut, $newContext = 
null, $handler = 
null, 
$op = 
null, $path = 
null,
 
  160             $params = 
null, $anchor = 
null, $escape = 
false) {
 
  162       assert(isset($this->_routerNames[$shortcut]));
 
  163       $routerName = $this->_routerNames[$shortcut];
 
  166       return $router->url($request, $newContext, $handler, 
$op, $path, $params, $anchor, $escape);
 
  179       if (!isset($this->_routerInstances[$shortcut])) {
 
  182          $allowedRouterPackages = array(
 
  184             'lib.pkp.classes.core' 
  188          $router =& 
instantiate($routerName, 
'PKPRouter', $allowedRouterPackages);
 
  189          if (!is_object($router)) {
 
  190             fatalError(
'Cannot instantiate requested router. Routers must belong to the core package and be of type "PKPRouter".');
 
  192          $router->setApplication($this->_application);
 
  193          $router->setDispatcher($this);
 
  196          $this->_routerInstances[$shortcut] =& $router;
 
  199       return $this->_routerInstances[$shortcut];
 
  207       $filename = $router->getCacheFilename($request);
 
  208       if (!file_exists($filename)) 
return false;
 
  211       $ifModifiedSince = $request->getIfModifiedSince();
 
  212       if ($ifModifiedSince !== 
null && $ifModifiedSince >= filemtime($filename)) {
 
  213          header(
'HTTP/1.1 304 Not Modified');
 
  217       $fp = fopen($filename, 
'r');
 
  218       $data = fread($fp, filesize($filename));
 
  221       $i = strpos($data, 
':');
 
  222       $time = substr($data, 0, $i);
 
  223       $contents = substr($data, $i+1);
 
  225       if (mktime() > $time + 
Config::getVar(
'cache', 
'web_cache_hours') * 60 * 60) 
return false;
 
  227       header(
'Content-Type: text/html; charset=' . 
Config::getVar(
'i18n', 
'client_charset'));
 
  239       assert(is_a($this->_router, 
'PKPRouter'));
 
  240       if ($contents == 
'') 
return $contents; 
 
  241       $filename = $this->_router->getCacheFilename($this->_requestCallbackHack);
 
  242       $fp = fopen($filename, 
'w');
 
  244          fwrite($fp, mktime() . 
':' . $contents);
 
  254       header(
'HTTP/1.0 404 Not Found');