summaryrefslogtreecommitdiffstats
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rw-r--r--inc/render.inc.php6
-rw-r--r--inc/util.inc.php13
2 files changed, 14 insertions, 5 deletions
diff --git a/inc/render.inc.php b/inc/render.inc.php
index 13262c1d..d09b2a8e 100644
--- a/inc/render.inc.php
+++ b/inc/render.inc.php
@@ -224,15 +224,15 @@ class Render
$params = array();
}
// Now find all language tags in this array
- if (preg_match_all('/{{(lang_.+?)}}/', $html, $out) > 0) {
+ if (preg_match_all('/{{\s*(lang_.+?)\s*}}/', $html, $out) > 0) {
$dictionary = Dictionary::getArray($module, 'template-tags');
$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
+ $fallback = true; // Fallback to general dictionary of main module
$dictionary = $dictionary + Dictionary::getArray('main', 'global-tags');
}
+ // Add untranslated strings to the dictionary, so their tag is seen in the rendered page
if (empty($dictionary[$tag])) {
$dictionary[$tag] = '{{' . $tag . '}}';
}
diff --git a/inc/util.inc.php b/inc/util.inc.php
index 963b3416..ace879f4 100644
--- a/inc/util.inc.php
+++ b/inc/util.inc.php
@@ -150,15 +150,21 @@ SADFACE;
* Redirects the user via a '302 Moved' header.
* An active session will be saved, any messages that haven't
* been displayed yet will be appended to the redirect.
- * @param string $location Location to redirect to. "false" to redirect to same URL (useful after POSTs)
+ * @param string|false $location Location to redirect to. "false" to redirect to same URL (useful after POSTs)
+ * @param bool $preferRedirectPost if true, use the value from $_POST['redirect'] instead of $location
*/
- public static function redirect($location = false)
+ public static function redirect($location = false, $preferRedirectPost = false)
{
if ($location === false) {
$location = preg_replace('/(&|\?)message\[\]\=[^&]*/', '\1', $_SERVER['REQUEST_URI']);
}
Session::save();
$messages = Message::toRequest();
+ if ($preferRedirectPost
+ && ($redirect = Request::post('redirect', false, 'string')) !== false
+ && !preg_match(',^(\w+\:|//),', $redirect) /* no uri scheme, no server */) {
+ $location = $redirect;
+ }
if (!empty($messages)) {
if (strpos($location, '?') === false) {
$location .= '?' . $messages;
@@ -470,6 +476,9 @@ SADFACE;
*/
public static function prettyTime($ts)
{
+ settype($ts, 'int');
+ if ($ts === 0)
+ return '???';
static $TODAY = false, $ETODAY = false, $YESTERDAY = false, $YEAR = false;
if (!$ETODAY) $ETODAY = strtotime('today 23:59:59');
if ($ts > $ETODAY) // TODO: Do we need strings for future too?