* 'list' query param redirect to hash route

This commit is contained in:
Max Pozdeev 2020-09-10 12:23:16 +03:00
parent 1a6a480f15
commit 5608d46e6c
2 changed files with 27 additions and 1 deletions

View file

@ -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;
}

View file

@ -37,7 +37,6 @@ $().ready(function(){
firstdayofweek: <?php echo (int) Config::get('firstdayofweek'); ?>,
calendarIcon: '<?php mttinfo('template_url'); ?>images/calendar.svg',
autotag: <?php echo Config::get('autotag') ? "true" : "false"; ?>
<?php if(isset($_GET['list'])) echo ",openList: ". (int)$_GET['list']; ?>
<?php if(Config::get('mobile')) echo ", touchDevice: true"; ?>
}).loadListsAtStart();
});