/** * Create the test locale file. */ function execute() { Locale::initialize(); $localeFiles =& Locale::getLocaleFiles(); $localeFile = array_shift($localeFiles[$this->inLocale]); $localeData = LocaleFile::load($localeFile->filename); if (!isset($localeData)) { printf('Invalid locale \'%s\'', $this->inLocale); exit(1); } $outFile = sprintf('locale/%s/locale.xml', $this->outLocale); $fp = fopen($outFile, 'wb'); if (!$fp) { printf('Failed to write to \'%s\'', $outFile); exit(1); } fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" . "<!DOCTYPE locale SYSTEM \"../locale.dtd\">\n\n" . "<!--\n" . " * locale.xml\n" . " *\n" . " * Copyright (c) 2003-2007 John Willinsky\n" . " * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.\n" . " *\n" . sprintf(" * Localization strings for the %s (%s) locale.\n", $this->outLocale, DEFAULT_OUT_LOCALE_NAME) . " *\n" . " * \$Id\$\n" . " -->\n\n" . sprintf("<locale name=\"%s\" full_name=\"%s\">\n", $this->outLocale, DEFAULT_OUT_LOCALE_NAME)); foreach ($localeData as $key => $message) { $outMessage = $this->fancifyString($message); if (strstr($outMessage, '<') || strstr($outMessage, '>')) { $outMessage = '<![CDATA[' . $outMessage . ']]>'; } fwrite($fp, sprintf("\t<message key=\"%s\">%s</message>\n", $key, $outMessage)); } fwrite($fp, "</locale>\n"); fclose($fp); }
/** * Create the test locale file. */ function execute() { Locale::initialize(); $localeFiles = Locale::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. Locale::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); } }
/** * 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 into request $request->setRouter($routerCandidate); $router =& $routerCandidate; $this->_router =& $router; // We've found our router and can go on // to handle the request. 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)) { 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; } } Locale::initialize(); PluginRegistry::loadCategory('generic'); $router->route($request); }
if (basename($_SERVER['SCRIPT_FILENAME'], ".php") == "rfiles") { $baseDir = dirname($baseDir); } define('INDEX_FILE_LOCATION', $baseDir . '/index.php'); // Load and execute initialization code chdir($baseDir); require $baseDir . '/lib/pkp/includes/bootstrap.inc.php'; // Manually set up a context router to get access // to the application context (required by Locale). $application =& PKPApplication::getApplication(); $request =& $application->getRequest(); import('core.PKPRouter'); $router = new PKPRouter(); $router->setApplication($application); $request->setRouter($router); Locale::initialize(); // Load user variables $sessionManager =& SessionManager::getManager(); $userSession =& $sessionManager->getUserSession(); $user =& $userSession->getUser(); // Insert system variables into associative array to be used by iBrowser $init['publicDir'] = Config::getVar('files', 'public_files_dir'); if (isset($user)) { // User is logged in $init['user'] = $user->getUsername(); //$init['lang'] = String::substr(Locale::getLocale(), 0, 2); $init['lang'] = 'en'; $init['baseUrl'] = Config::getVar('general', 'base_url'); $init['baseDir'] = $baseDir; $application = PKPApplication::getApplication(); $contextDepth = $application->getContextDepth();