%PDF-1.7 GIF89;
| Server IP : 104.20.45.2 / Your IP : 172.16.20.3 Web Server : Apache/2.4.25 (Debian) System : Linux f64a392e70de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : application ( 1000) PHP Version : 5.6.40 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /app/plugins/generic/customLocale/ |
Upload File : |
<?php
/**
* @file plugins/generic/customLocale/CustomLocalePlugin.inc.php
*
* Copyright (c) 2013-2019 Simon Fraser University
* Copyright (c) 2003-2019 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class CustomLocalePlugin
*
* @brief This plugin enables customization of locale strings.
*/
define('CUSTOM_LOCALE_DIR', 'customLocale');
import('lib.pkp.classes.plugins.GenericPlugin');
class CustomLocalePlugin extends GenericPlugin {
function register($category, $path) {
if (parent::register($category, $path)) {
if ($this->getEnabled()) {
// Add custom locale data for already registered locale files.
$locale = AppLocale::getLocale();
$localeFiles = AppLocale::getLocaleFiles($locale);
$journal = Request::getJournal();
$journalId = $journal->getId();
$publicFilesDir = Config::getVar('files', 'public_files_dir');
$customLocalePathBase = $publicFilesDir . DIRECTORY_SEPARATOR . 'journals' . DIRECTORY_SEPARATOR . $journalId . DIRECTORY_SEPARATOR . CUSTOM_LOCALE_DIR . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR;
import('lib.pkp.classes.file.FileManager');
$fileManager = new FileManager();
foreach ($localeFiles as $localeFile) {
$customLocalePath = $customLocalePathBase . $localeFile->getFilename();
if ($fileManager->fileExists($customLocalePath)) {
AppLocale::registerLocaleFile($locale, $customLocalePath, true);
}
}
// Add custom locale data for all locale files registered after this plugin
HookRegistry::register('PKPLocale::registerLocaleFile', array(&$this, 'addCustomLocale'));
}
return true;
}
return false;
}
function addCustomLocale($hookName, $args) {
$locale =& $args[0];
$localeFilename =& $args[1];
$journal = Request::getJournal();
$journalId = $journal->getId();
$publicFilesDir = Config::getVar('files', 'public_files_dir');
$customLocalePath = $publicFilesDir . DIRECTORY_SEPARATOR . 'journals' . DIRECTORY_SEPARATOR . $journalId . DIRECTORY_SEPARATOR . CUSTOM_LOCALE_DIR . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . $localeFilename;
import('lib.pkp.classes.file.FileManager');
$fileManager = new FileManager();
if ($fileManager->fileExists($customLocalePath)) {
AppLocale::registerLocaleFile($locale, $customLocalePath, false);
}
return true;
}
function getDisplayName() {
return __('plugins.generic.customLocale.name');
}
function getDescription() {
return __('plugins.generic.customLocale.description');
}
function smartyPluginUrl($params, &$smarty) {
$path = array($this->getCategory(), $this->getName());
if (is_array($params['path'])) {
$params['path'] = array_merge($path, $params['path']);
} elseif (!empty($params['path'])) {
$params['path'] = array_merge($path, array($params['path']));
} else {
$params['path'] = $path;
}
if (!empty($params['key'])) {
$params['path'] = array_merge($params['path'], array($params['key']));
unset($params['key']);
}
if (!empty($params['file'])) {
$params['path'] = array_merge($params['path'], array($params['file']));
unset($params['file']);
}
return $smarty->smartyUrl($params, $smarty);
}
function getManagementVerbs() {
$verbs = array();
if ($this->getEnabled()) {
$verbs[] = array('index', __('plugins.generic.customLocale.customize'));
}
return parent::getManagementVerbs($verbs);
}
/**
* Execute a management verb on this plugin
* @param $verb string
* @param $args array
* @param $message string Result status message
* @param $messageParams array Parameters for the message key
* @return boolean
*/
function manage($verb, $args, &$message, &$messageParams) {
if (!parent::manage($verb, $args, $message, $messageParams)) return false;
$this->import('CustomLocaleHandler');
$customLocaleHandler = new CustomLocaleHandler($this->getName());
switch ($verb) {
case 'edit':
$customLocaleHandler->edit($args);
return true;
case 'saveLocaleChanges':
$customLocaleHandler->saveLocaleChanges($args);
return true;
case 'editLocaleFile':
$customLocaleHandler->editLocaleFile($args);
return true;
case 'saveLocaleFile':
$customLocaleHandler->saveLocaleFile($args);
return true;
default:
$customLocaleHandler->index();
return true;
}
}
}
?>