summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2018-02-13 12:20:45 +0100
committerSimon Rettberg2018-02-13 12:20:45 +0100
commitec9061579d77a11acc61cdd2436b037e6af6f857 (patch)
treeeab511fe829a0db9e80592f7ee43512b4110d37b
parent[eventlog] Use Util::prettyTime for timestamp formatting (diff)
downloadslx-admin-ec9061579d77a11acc61cdd2436b037e6af6f857.tar.gz
slx-admin-ec9061579d77a11acc61cdd2436b037e6af6f857.tar.xz
slx-admin-ec9061579d77a11acc61cdd2436b037e6af6f857.zip
[translation] Add support for global translation plugins
Until now, modules could only supply extensions for translating module-related additional dictionaries. Now a module can provide a 'translation-global.inc.php' that will add additional translation sections to any module.
-rw-r--r--modules-available/translation/page.inc.php29
1 files changed, 24 insertions, 5 deletions
diff --git a/modules-available/translation/page.inc.php b/modules-available/translation/page.inc.php
index a5cdebed..e41d4786 100644
--- a/modules-available/translation/page.inc.php
+++ b/modules-available/translation/page.inc.php
@@ -53,11 +53,30 @@ class Page_Translation extends Page
private function loadCustomHandler($moduleName)
{
$path = 'modules/' . $moduleName . '/hooks/translation.inc.php';
- if (!file_exists($path))
- return false;
$HANDLER = array();
- require $path;
- return $HANDLER;
+ if (file_exists($path)) {
+ require $path;
+ }
+ $backup = $HANDLER;
+ foreach (glob('modules/*/hooks/translation-global.inc.php', GLOB_NOSORT) as $path) {
+ $HANDLER = array();
+ require $path;
+ if (empty($HANDLER['subsections']))
+ continue;
+ foreach ($HANDLER['subsections'] as $sub) {
+ $suf = '';
+ while (isset($backup['subsections']) && in_array($sub . $suf, $backup['subsections'])) {
+ $suf = mt_rand();
+ }
+ $backup['subsections'][] = $sub . $suf;
+ if (isset($HANDLER['grep_' . $sub])) {
+ $backup['grep_' . $sub . $suf] = $HANDLER['grep_' . $sub];
+ }
+ }
+ }
+ if (empty($backup))
+ return false;
+ return $backup;
}
/**
@@ -81,7 +100,7 @@ class Page_Translation extends Page
{
User::load();
- if (!User::hasPermission('superadmin')) {
+ if (!User::isLoggedIn()) {
Message::addError('main.no-permission');
Util::redirect('?do=Main');
}