Skip to content

Commit

Permalink
make plugin usable at site level
Browse files Browse the repository at this point in the history
  • Loading branch information
edelm authored and asmecher committed May 10, 2024
1 parent 067c627 commit 13aee73
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CustomLocaleHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CustomLocaleHandler extends Handler {
function printCustomLocaleChanges($args, $request) {
$context = $request->getContext();

$contextFileManager = new ContextFileManager($context->getId());
$contextFileManager = new ContextFileManager($context ? $context->getId() : CONTEXT_SITE);
$customLocaleDir = $contextFileManager->getBasePath() . 'customLocale';
if (!file_exists($customLocaleDir) || !is_dir($customLocaleDir)) throw new Exception("Path \"$customLocaleDir\" does not exist!");

Expand Down
4 changes: 2 additions & 2 deletions CustomLocalePlugin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function register($category, $path, $mainContextId = null) {
$context = $request->getContext();

import('lib.pkp.classes.file.ContextFileManager');
$contextFileManager = new ContextFileManager($context->getId());
$contextFileManager = new ContextFileManager($context ? $context->getId() : CONTEXT_SITE);
$customLocalePathBase = $contextFileManager->getBasePath() . "customLocale/$locale/";

import('lib.pkp.classes.file.FileManager');
Expand Down Expand Up @@ -144,7 +144,7 @@ function addCustomLocale($hookName, $args) {
$request =& Registry::get('request');
$context = $request->getContext();

$contextFileManager = new ContextFileManager($context->getId());
$contextFileManager = new ContextFileManager($context ? $context->getId() : CONTEXT_SITE);
$customLocalePath = $contextFileManager->getBasePath() . "customLocale/$locale/$localeFilename";

if ($contextFileManager->fileExists($customLocalePath)) {
Expand Down
4 changes: 2 additions & 2 deletions controllers/grid/CustomLocaleGridHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function authorize($request, &$args, $roleAssignments) {
*/
function updateLocale($args, $request) {
$context = $request->getContext();
$contextId = $context->getId();
$contextId = $context ? $context->getId() : CONTEXT_SITE;
$locale = $args['locale'];
$filename = $args['key'];

Expand All @@ -68,7 +68,7 @@ function updateLocale($args, $request) {
$changes = (array) $args['changes'];
if (!empty($changes)) {
import('lib.pkp.classes.file.ContextFileManager');
$contextFileManager = new ContextFileManager($context->getId());
$contextFileManager = new ContextFileManager($context ? $context->getId() : CONTEXT_SITE);
$customFilesDir = $contextFileManager->getBasePath() . "customLocale/$locale/";
$customFilePath = "$customFilesDir/$filename";

Expand Down

0 comments on commit 13aee73

Please sign in to comment.