summaryrefslogtreecommitdiffstats
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rw-r--r--inc/dictionary.inc.php11
-rw-r--r--inc/render.inc.php4
-rw-r--r--inc/util.inc.php5
3 files changed, 13 insertions, 7 deletions
diff --git a/inc/dictionary.inc.php b/inc/dictionary.inc.php
index fcbfdfb8..935d1f4e 100644
--- a/inc/dictionary.inc.php
+++ b/inc/dictionary.inc.php
@@ -30,10 +30,15 @@ class Dictionary
if ($lang !== false && in_array($lang, self::$languages)) {
setcookie('lang', $lang, time() + 60 * 60 * 24 * 30 * 12);
$url = Request::get('url');
- if ($url === false && isset($_SERVER['HTTP_REFERER']))
+ if ($url === false && isset($_SERVER['HTTP_REFERER'])) {
$url = $_SERVER['HTTP_REFERER'];
- if ($url === false)
- $url = '?do=Main';
+ }
+ $parts = parse_url($url);
+ if ($url === false || $parts === false || empty($parts['query'])) {
+ $url = '?do=main';
+ } else {
+ $url = '?' . $parts['query'];
+ }
Util::redirect($url);
}
diff --git a/inc/render.inc.php b/inc/render.inc.php
index 4b1d3643..4da0567e 100644
--- a/inc/render.inc.php
+++ b/inc/render.inc.php
@@ -213,7 +213,7 @@ class Render
* @param string $module name of module to load template from; defaults to currently active module
* @return string Rendered template
*/
- public static function parse($template, $params = false, $module = false)
+ public static function parse($template, $params = false, $module = false, $lang = false)
{
if ($module === false && class_exists('Page')) {
$module = Page::getModule()->getIdentifier();
@@ -228,7 +228,7 @@ class Render
}
// Now find all language tags in this array
if (preg_match_all('/{{\s*(lang_.+?)\s*}}/', $html, $out) > 0) {
- $dictionary = Dictionary::getArray($module, 'template-tags');
+ $dictionary = Dictionary::getArray($module, 'template-tags', $lang);
$fallback = false;
foreach ($out[1] as $tag) {
if ($fallback === false && empty($dictionary[$tag])) {
diff --git a/inc/util.inc.php b/inc/util.inc.php
index 1a5cbefe..e459cc46 100644
--- a/inc/util.inc.php
+++ b/inc/util.inc.php
@@ -234,9 +234,10 @@ SADFACE;
*
* @param float|int $bytes numeric value of the filesize to make readable
* @param int $decimals number of decimals to show, -1 for automatic
+ * @param int $shift how many units to skip, i.e. if you pass in KiB or MiB
* @return string human readable string representing the given file size
*/
- public static function readableFileSize($bytes, $decimals = -1)
+ public static function readableFileSize($bytes, $decimals = -1, $shift = 0)
{
$bytes = round($bytes);
static $sz = array('Byte', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB');
@@ -249,7 +250,7 @@ SADFACE;
$decimals = 2 - floor(strlen((int)$bytes) - 1);
}
}
- return sprintf("%.{$decimals}f", $bytes) . "\xe2\x80\x89" . $sz[$factor];
+ return sprintf("%.{$decimals}f", $bytes) . "\xe2\x80\x89" . $sz[$factor + $shift];
}
public static function sanitizeFilename($name)