summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2016-08-10 11:18:12 +0200
committerSimon Rettberg2016-08-10 11:18:12 +0200
commit5135886f2584631a414eb08e57d4ebdd2c48d611 (patch)
tree60a23166e7bdd4071d0d77d3687a3049815a28b2
parentMerge branch 'modularization' of git.openslx.org:openslx-ng/slx-admin into mo... (diff)
downloadslx-admin-5135886f2584631a414eb08e57d4ebdd2c48d611.tar.gz
slx-admin-5135886f2584631a414eb08e57d4ebdd2c48d611.tar.xz
slx-admin-5135886f2584631a414eb08e57d4ebdd2c48d611.zip
Add fallback feature to Dictionary functions
-rw-r--r--inc/dictionary.inc.php12
-rw-r--r--modules-available/baseconfig/page.inc.php2
-rw-r--r--modules-available/dozmod/page.inc.php8
-rw-r--r--modules-available/statistics/inc/filterset.inc.php2
-rw-r--r--modules-available/translation/page.inc.php2
5 files changed, 16 insertions, 10 deletions
diff --git a/inc/dictionary.inc.php b/inc/dictionary.inc.php
index cb23d0b2..634b1c3c 100644
--- a/inc/dictionary.inc.php
+++ b/inc/dictionary.inc.php
@@ -69,10 +69,13 @@ class Dictionary
return self::$stringCache[$file] = $json;
}
- public static function translateFileModule($moduleId, $path, $tag)
+ public static function translateFileModule($moduleId, $path, $tag, $returnTagOnMissing = false)
{
$strings = self::getArray($moduleId, $path);
if (!isset($strings[$tag])) {
+ if ($returnTagOnMissing) {
+ return '{{' . $tag . '}}';
+ }
return false;
}
return $strings[$tag];
@@ -85,12 +88,15 @@ class Dictionary
return self::translateFileModule(Page::getModule()->getIdentifier(), $path, $tag);
}
- public static function translate($tag)
+ public static function translate($tag, $returnTagOnMissing = false)
{
$string = self::translateFile('module', $tag);
if ($string !== false)
return $string;
- return self::translateFileModule('main', 'global-tags', $tag);
+ $string = self::translateFileModule('main', 'global-tags', $tag);
+ if ($string !== false || !$returnTagOnMissing)
+ return $string;
+ return '{{' . $tag . '}}';
}
public static function getMessage($module, $id)
diff --git a/modules-available/baseconfig/page.inc.php b/modules-available/baseconfig/page.inc.php
index 0995a369..9ff8c086 100644
--- a/modules-available/baseconfig/page.inc.php
+++ b/modules-available/baseconfig/page.inc.php
@@ -103,7 +103,7 @@ class Page_BaseConfig extends Page
foreach ($this->categories as $catid => $val) {
Dashboard::addSubmenu(
'#category_' . $catid,
- Dictionary::translateFileModule($this->categories[$catid]['module'], 'config-variable-categories', $catid)
+ Dictionary::translateFileModule($this->categories[$catid]['module'], 'config-variable-categories', $catid, true)
);
}
}
diff --git a/modules-available/dozmod/page.inc.php b/modules-available/dozmod/page.inc.php
index c1c19b15..31d4cce2 100644
--- a/modules-available/dozmod/page.inc.php
+++ b/modules-available/dozmod/page.inc.php
@@ -15,10 +15,10 @@ class Page_DozMod extends Page
}
/* add sub-menus */
- Dashboard::addSubmenu('?do=dozmod&section=mailconfig', Dictionary::translate('submenu_mailconfig'));
- Dashboard::addSubmenu('?do=dozmod&section=templates', Dictionary::translate('submenu_templates'));
- Dashboard::addSubmenu('?do=dozmod&section=runtimeconfig', Dictionary::translate('submenu_runtime'));
- Dashboard::addSubmenu('?do=dozmod&section=users', Dictionary::translate('submenu_users'));
+ Dashboard::addSubmenu('?do=dozmod&section=mailconfig', Dictionary::translate('submenu_mailconfig', true));
+ Dashboard::addSubmenu('?do=dozmod&section=templates', Dictionary::translate('submenu_templates', true));
+ Dashboard::addSubmenu('?do=dozmod&section=runtimeconfig', Dictionary::translate('submenu_runtime', true));
+ Dashboard::addSubmenu('?do=dozmod&section=users', Dictionary::translate('submenu_users', true));
/* instantiate sub pages */
$this->mail_templates = new Page_mail_templates();
diff --git a/modules-available/statistics/inc/filterset.inc.php b/modules-available/statistics/inc/filterset.inc.php
index 7cc075c3..ea25d9b1 100644
--- a/modules-available/statistics/inc/filterset.inc.php
+++ b/modules-available/statistics/inc/filterset.inc.php
@@ -15,7 +15,7 @@ class FilterSet
{
$this->sortDirection = $direction === 'DESC' ? 'DESC' : 'ASC';
- if (array_key_exists($col, Page_Statistics::$columns)) {
+ if (is_string($col) && array_key_exists($col, Page_Statistics::$columns)) {
$isMapped = array_key_exists('map_sort', Page_Statistics::$columns[$col]);
$this->sortColumn = $isMapped ? Page_Statistics::$columns[$col]['map_sort'] : $col;
} else {
diff --git a/modules-available/translation/page.inc.php b/modules-available/translation/page.inc.php
index 563ffae0..93616cd1 100644
--- a/modules-available/translation/page.inc.php
+++ b/modules-available/translation/page.inc.php
@@ -474,7 +474,7 @@ class Page_Translation extends Page
if ($module === false) {
$module = $this->module;
}
- $tags = $this->loadTagsFromPhp('/Dictionary\s*::\s*translate\s*\(\s*[\'"](?<tag>[^\'"\.]*)[\'"]\s*\)/i',
+ $tags = $this->loadTagsFromPhp('/Dictionary\s*::\s*translate\s*\(\s*[\'"](?<tag>[^\'"\.]*)[\'"]\s*[\),]/i',
$this->getModulePhpFiles($module));
foreach ($tags as &$tag) {
$tag = true;