示例#1
0
 /**
  * Create the test locale file.
  */
 function execute()
 {
     AppLocale::initialize();
     $localeFiles = AppLocale::makeComponentMap($this->inLocale);
     foreach ($localeFiles as $localeFilePath) {
         $localeFile = basename($localeFilePath);
         $outFile = dirname(dirname($localeFilePath)) . '/' . $this->outLocale . '/' . $localeFile;
         $this->generateLocaleFile($localeFile, $localeFilePath, $outFile);
     }
 }
 function CommandLineTool($argv = array())
 {
     // Initialize the a request object with a page router
     $application =& PKPApplication::getApplication();
     $request =& $application->getRequest();
     // FIXME: Write and use a CLIRouter here (see classdoc)
     import('classes.core.PageRouter');
     $router = new PageRouter();
     $router->setApplication($application);
     $request->setRouter($router);
     // Initialize the locale and load generic plugins.
     AppLocale::initialize();
     PluginRegistry::loadCategory('generic');
     $this->argv = isset($argv) && is_array($argv) ? $argv : array();
     if (isset($_SERVER['SERVER_NAME'])) {
         die('This script can only be executed from the command-line');
     }
     $this->scriptName = isset($this->argv[0]) ? array_shift($this->argv) : '';
     if (isset($this->argv[0]) && $this->argv[0] == '-h') {
         $this->usage();
         exit(0);
     }
 }
示例#3
0
 /**
  * Determine the correct router for this request. Then
  * let the router dispatch the request to the appropriate
  * handler method.
  * @param $request PKPRequest
  */
 function dispatch($request)
 {
     // Make sure that we have at least one router configured
     $routerNames = $this->getRouterNames();
     assert(count($routerNames) > 0);
     // Go through all configured routers by priority
     // and find out whether one supports the incoming request
     foreach ($routerNames as $shortcut => $routerCandidateName) {
         $routerCandidate =& $this->_instantiateRouter($routerCandidateName, $shortcut);
         // Does this router support the current request?
         if ($routerCandidate->supports($request)) {
             // Inject router and dispatcher into request
             $request->setRouter($routerCandidate);
             $request->setDispatcher($this);
             // We've found our router and can go on
             // to handle the request.
             $router =& $routerCandidate;
             $this->_router =& $router;
             break;
         }
     }
     // None of the router handles this request? This is a development-time
     // configuration error.
     if (is_null($router)) {
         fatalError('None of the configured routers supports this request.');
     }
     // Can we serve a cached response?
     if ($router->isCacheable($request)) {
         $this->_requestCallbackHack =& $request;
         if (Config::getVar('cache', 'web_cache')) {
             if ($this->_displayCached($router, $request)) {
                 exit;
             }
             // Success
             ob_start(array($this, '_cacheContent'));
         }
     } else {
         if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') {
             header('HTTP/1.0 403 Forbidden');
             echo '403: Forbidden<br><br>Pre-fetching not allowed.';
             exit;
         }
     }
     AppLocale::initialize($request);
     PluginRegistry::loadCategory('generic', true);
     $router->route($request);
 }