summaryrefslogtreecommitdiffstats
path: root/inc/render.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2016-04-29 17:43:58 +0200
committerSimon Rettberg2016-04-29 17:43:58 +0200
commitf8189f4f0bdc79a83e084c56e93e8a2ca073e4c0 (patch)
tree13c41f05ef5920eb13c76be05f749de9a9a809fa /inc/render.inc.php
parentImplemented new menu, added logic for defining dependencies, move translation... (diff)
downloadslx-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/render.inc.php')
-rw-r--r--inc/render.inc.php43
1 files changed, 27 insertions, 16 deletions
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);
}
/**