TinyPortal

Development => Bugs/Errors => Feedback => Fixed Bugs => Topic started by: @rjen on February 23, 2019, 08:06:04 AM

Title: Theme switcher always redirects to 'forum'
Post by: @rjen on February 23, 2019, 08:06:04 AM
Just looking at this report: https://www.simplemachines.org/community/index.php?topic=27642.msg4007889#msg4007889

It seems a bit funny indeed, that changing a theme 'exits' to the forumindex page. Seems more logical that it keeps you on the page you are on... especially if the 'theme switcher' is not showing on all pages...

Digging through the code, we are setting the destination to be 'forum' if this variable is not set: $context['TPortal']['querystring'])
Unfortunately it seems to be never set (?).

I guess this is a question for tino: any way we can always redirect the them switcher to the current page?

It's in this code in TPsubs.template.php:

// TPortal themebox
function TPortal_themebox()
{
global $context, $settings, $scripturl, $txt, $smcFunc, $forum_version;

$what = explode(',', $context['TPortal']['themeboxbody']);
$temaid = array();
$temanavn = array();
$temapaths = array();
foreach($what as $wh => $wht)
{
$all = explode('|', $wht);
if($all[0] > -1)
{
$temaid[] = $all[0];
$temanavn[] = isset($all[1]) ? $all[1] : '';
$temapaths[] = isset($all[2]) ? $all[2] : '';
}
}

if(isset($context['TPortal']['querystring']))
$tp_where = $smcFunc['htmlspecialchars'](strip_tags($context['TPortal']['querystring']));
else
$tp_where = 'action=forum';

if($tp_where != '')
$tp_where .= ';';

// remove multiple theme=x in the string.
$tp_where=preg_replace("'theme=[^>]*?;'si", "", $tp_where);

if(is_countable($temaid) && count($temaid) > 0){
        echo '
<form name="jumpurl1" onsubmit="return jumpit()" class="middletext" action="" style="padding: 0; margin: 0; text-align: center;">
<select style="width: 100%; margin: 5px 0px 5px 0px;" size="1" name="jumpurl2" onchange="check(this.value)">';
         for($a=0 ; $a<(count($temaid)); $a++)
{
                echo '
<option value="'.$temaid[$a].'" ', $settings['theme_id'] == $temaid[$a] ? 'selected="selected"' : '' ,'>'.substr($temanavn[$a],0,20).'</option>';
         }
echo '
</select><br>' , $context['user']['is_logged'] ?
'<input type="checkbox" value=";permanent" onclick="realtheme()" /> '. $txt['tp-permanent']. '<br>' : '' , '<br>
<input class="button_submit" type="button" value="'.$txt['tp-changetheme'].'" onclick="jumpit()" /><br><br>
<input type="hidden" value="'.$smcFunc['htmlspecialchars']($scripturl . '?'.$tp_where.'theme='.$settings['theme_id']).'" name="jumpurl3" />
<div style="text-align: center; width: 95%; overflow: hidden;">';



Title: Re: Theme switcher always redirects to 'forum'
Post by: @rjen on February 23, 2019, 08:18:33 AM
Somehow the querystring is not set in TPortal_init()


// TinyPortal init
function TPortal_init()
{
global $context, $txt, $user_info, $settings, $boarddir, $sourcedir, $modSettings, $forum_version;

// has init been run before? if so return!
if(isset($context['TPortal']['redirectforum']))
return;

if(loadLanguage('TPortal') == false)
loadLanguage('TPortal', 'english');

$context['TPortal'] = array();
$context['TPortal']['querystring'] = $_SERVER['QUERY_STRING'];


:hmm:
Title: Re: Theme switcher always redirects to 'forum'
Post by: tino on February 23, 2019, 08:32:51 AM
I'll look into it later. Inkling would be the server string is empty or similar when assigning.
Title: Re: Theme switcher always redirects to 'forum'
Post by: @rjen on February 23, 2019, 08:57:46 AM
Thats my guess too. I read somewhere that this is dependent on server setup, and that a GET command may be needed...
Title: Re: Theme switcher always redirects to 'forum'
Post by: lurkalot on February 23, 2019, 09:00:01 AM
Quote from: @rjen on February 23, 2019, 08:06:04 AM

Seems more logical that it keeps you on the page you are on...


Good call, this is slightly annoying now it's been brought to attention. Can't confirm if this happened with older versions such as TP1.0

There was I'm sure something else that took you to a different page after hitting submit, but can't for the life of me remember what it was, perhaps while I was messing around with the downloads sys the other day.  I'll have to see if I can find it, I know at the time it made me think, WTF. lol..
Title: Re: Theme switcher always redirects to 'forum'
Post by: tino on February 23, 2019, 12:01:14 PM
Just commited the fix for this into the master branch.
Title: Re: Theme switcher always redirects to 'forum'
Post by: @rjen on February 23, 2019, 12:30:45 PM
Did setupTPsettings wipe the setting? I did not see that. What statement caused that?
Title: Re: Theme switcher always redirects to 'forum'
Post by: tino on February 23, 2019, 12:44:35 PM
Quote from: @rjen on February 23, 2019, 12:30:45 PM
Did setupTPsettings wipe the setting? I did not see that. What statement caused that?

That line..

if (($context['TPortal'] = cache_get_data('tpSettings', 90)) == null)