From f8189f4f0bdc79a83e084c56e93e8a2ca073e4c0 Mon Sep 17 00:00:00 2001
From: Simon Rettberg
Date: Fri, 29 Apr 2016 17:43:58 +0200
Subject: More Progress; Merged changes from ufpr up to
775cdbd29f5d0f70946d1d5ff09c091e6189c9e9
---
inc/render.inc.php | 43 +++++++++++++++++++++++++++----------------
1 file changed, 27 insertions(+), 16 deletions(-)
(limited to 'inc/render.inc.php')
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
'
- ', RENDER_DEFAULT_TITLE, self::$title, '
+ ', self::$title, RENDER_DEFAULT_TITLE, '
@@ -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 'Template ' . htmlspecialchars($template) . '
' . nl2br(htmlspecialchars(print_r($params, true))) . '
';
}
- // 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);
}
/**
--
cgit v1.2.3-55-g7522