From 5608d46e6cd7d822a7f71294c1a927dfd7f19fe4 Mon Sep 17 00:00:00 2001 From: Max Pozdeev Date: Thu, 10 Sep 2020 12:23:16 +0300 Subject: [PATCH] * 'list' query param redirect to hash route --- src/index.php | 27 +++++++++++++++++++++++++++ src/themes/default/index.php | 1 - 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/index.php b/src/index.php index 2fae7a5..3d7745d 100644 --- a/src/index.php +++ b/src/index.php @@ -7,6 +7,18 @@ require_once('./init.php'); +//Parse query string +if ( isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != '' ) +{ + parse_str($_SERVER['QUERY_STRING'], $q); + if (isset($q['list'])) { + $hash = ($q['list'] == 'alltasks') ? ['alltasks'] : ['list', (int)$q['list']]; + unset($q['list']); + redirectWithHashRoute($q, $hash); + } +} + + $lang = Lang::instance(); if ($lang->rtl()) { @@ -24,3 +36,18 @@ if ( isset($_GET['mobile']) || isset($_GET['pda'])) { define('TEMPLATEPATH', MTTPATH. 'themes/'. Config::get('template'). '/'); require(TEMPLATEPATH. 'index.php'); + +// end + +function redirectWithHashRoute(array $q, array $hash) +{ + $url = url_dir(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $_SERVER['SCRIPT_NAME']); + $query = http_build_query($q); + if ($query != '') $url .= "?$query"; + if (count($hash) > 0) { + $encodedHash = implode("/", array_map("rawurlencode", $hash)); + $url .= "#$encodedHash"; + } + header("Location: ". $url); + exit; +} \ No newline at end of file diff --git a/src/themes/default/index.php b/src/themes/default/index.php index 62dbf3e..19c96bf 100644 --- a/src/themes/default/index.php +++ b/src/themes/default/index.php @@ -37,7 +37,6 @@ $().ready(function(){ firstdayofweek: , calendarIcon: 'images/calendar.svg', autotag: - }).loadListsAtStart(); });