diff options
author | Simon Rettberg | 2016-04-29 17:43:58 +0200 |
---|---|---|
committer | Simon Rettberg | 2016-04-29 17:43:58 +0200 |
commit | f8189f4f0bdc79a83e084c56e93e8a2ca073e4c0 (patch) | |
tree | 13c41f05ef5920eb13c76be05f749de9a9a809fa /inc | |
parent | Implemented new menu, added logic for defining dependencies, move translation... (diff) | |
download | slx-admin-f8189f4f0bdc79a83e084c56e93e8a2ca073e4c0.tar.gz slx-admin-f8189f4f0bdc79a83e084c56e93e8a2ca073e4c0.tar.xz slx-admin-f8189f4f0bdc79a83e084c56e93e8a2ca073e4c0.zip |
More Progress; Merged changes from ufpr up to 775cdbd29f5d0f70946d1d5ff09c091e6189c9e9
Diffstat (limited to 'inc')
-rw-r--r-- | inc/dictionary.inc.php | 2 | ||||
-rw-r--r-- | inc/module.inc.php | 14 | ||||
-rw-r--r-- | inc/render.inc.php | 43 |
3 files changed, 40 insertions, 19 deletions
diff --git a/inc/dictionary.inc.php b/inc/dictionary.inc.php index b56106cc..e8f51e24 100644 --- a/inc/dictionary.inc.php +++ b/inc/dictionary.inc.php @@ -104,7 +104,7 @@ class Dictionary } $string = self::translate($out[1], 'categories', $out[2]); if ($string === false) { - return $category; + return '!!' . $category . '!!'; } return $string; } diff --git a/inc/module.inc.php b/inc/module.inc.php index 9126cb32..73959471 100644 --- a/inc/module.inc.php +++ b/inc/module.inc.php @@ -27,6 +27,11 @@ class Module return self::resolveDeps(self::$modules[$name]); } + /** + * + * @param \Module $mod the module to check + * @return boolean true iff module deps are all found and enabled + */ private static function resolveDeps($mod) { if (!$mod->depsChecked) { @@ -34,7 +39,7 @@ class Module foreach ($mod->dependencies as $dep) { if (!self::resolveDepsByName($dep)) { if ($mod->enabled) { - error_log("Disabling module $name: Dependency $dep failed."); + error_log("Disabling module {$mod->name}: Dependency $dep failed."); } $mod->enabled = false; $mod->depsMissing = true; @@ -142,10 +147,15 @@ class Module { $string = Dictionary::translate($this->name, 'module', 'module_name'); if ($string === false) { - return $this->name; + return '!!' . $this->name . '!!'; } return $string; } + + public function getPageTitle() + { + return Dictionary::translate($this->name, 'module', 'page_title'); + } public function getCategory() { diff --git a/inc/render.inc.php b/inc/render.inc.php index 14d5a810..b8abaf71 100644 --- a/inc/render.inc.php +++ b/inc/render.inc.php @@ -45,7 +45,7 @@ class Render '<!DOCTYPE html> <html> <head> - <title>', RENDER_DEFAULT_TITLE, self::$title, '</title> + <title>', self::$title, RENDER_DEFAULT_TITLE, '</title> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> @@ -93,7 +93,7 @@ class Render */ public static function setTitle($title) { - self::$title = ' - ' . $title; + self::$title = $title . ' - '; } /** @@ -177,28 +177,39 @@ class Render if ($html === false) { return '<h3>Template ' . htmlspecialchars($template) . '</h3>' . nl2br(htmlspecialchars(print_r($params, true))) . '<hr>'; } - // Get all translated strings for this template - if($module === false){ - $module = strtolower(empty($_REQUEST['do']) ? 'main' : $_REQUEST['do']); + if($module === false) { + $module = Page::getModule()->getIdentifier(); + } + if (!is_array($params)) { + $params = array(); } - $dictionary = Dictionary::getArrayTemplate($template, $module); - // Now find all language tags in this array - preg_match_all('/{{(lang_.+?)}}/', $html, $out); - foreach ($out[1] as $tag) { - // Add untranslated strings to the dictionary, so their tag is seen in the rendered page - if (empty($dictionary[$tag])) - $dictionary[$tag] = '{{' . $tag . '}}'; + if (preg_match_all('/{{(lang_.+?)}}/', $html, $out) > 0) { + $dictionary = Dictionary::getArrayTemplate($template, $module); + $fallback = false; + foreach ($out[1] as $tag) { + // Add untranslated strings to the dictionary, so their tag is seen in the rendered page + if ($fallback === false && empty($dictionary[$tag])) { + $fallback = true; // Fallback to general dictionary of module + $dictionary = $dictionary + Dictionary::getArray($module, 'module'); + if ($module !== 'main') { + $dictionary = $dictionary + Dictionary::getArray('main', 'module'); + } + } + if (empty($dictionary[$tag])) { + $dictionary[$tag] = '{{' . $tag . '}}'; + } + } + $params = $params + $dictionary; } // Always add token to parameter list - if (is_array($params) || $params === false || is_null($params)) - $params['token'] = Session::get('token'); - // Likewise, add currently selected language ( its two letter code) to params + $params['token'] = Session::get('token'); + // Likewise, add currently selected language (its two letter code) to params $params['current_lang'] = LANG; // Add desired password field type $params['password_type'] = Property::getPasswordFieldType(); // Return rendered html - return self::$mustache->render($html, array_merge($dictionary,$params)); + return self::$mustache->render($html, $params); } /** |