Skip to main content
Topic: $context -> loadTheme() setupThemeContext() (Read 4595 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

$context -> loadTheme() setupThemeContext()

There is so much mixing with $context on where to load it.

I think all of this base $context that doesn't rely on individual actions should be moved to loadThemeContext() and then be called from loadTheme().

Thoughts?

Before you say that setupThemeContext() isn't used by all themes, well, then... I say it (loadThemeContext) should be in the init template (along with a bunch of other things that are theme dependent).

Re: $context -> loadTheme() setupThemeContext()

Reply #1

loadTheme() does indeed (still, I think) too much. Speaking off-hand at the moment, I think it does user related stuff which would be better elsewhere... Could try some ways to make it into more manageable chunks. Not sure atm about setupThemeContext(), will need to look.
The best moment for testing your PR is right after you merge it. Can't miss with that one.

 

Re: $context -> loadTheme() setupThemeContext()

Reply #2

A couple of things I think loadTheme is doing and do not belong there:
Code: [Select]
if (isset($_SERVER['HTTP_HOST']) || isset($_SERVER['SERVER_NAME']))
if (isset($detected_url) && $detected_url != $boardurl)
if ($context['user']['is_guest'] && empty($context['user']['name']))
if ((!empty($modSettings['mail_next_send']) && $modSettings['mail_next_send'] < time() && empty($modSettings['mail_queue_use_cron'])) || empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time())

Do we still need that one?
Code: [Select]
context['character_set'] = 'UTF-8';
Probably for "compatibility"?
I'd say let's put a @deprecated tag and let's start to phase it out. O:-)
Bugs creator.
Features destroyer.
Template killer.

Re: $context -> loadTheme() setupThemeContext()

Reply #3

Don't think those belong there, but we need to make sure they were moved to the right areas at some point (I think they were)

Code: [Select]
context['character_set'] = 'UTF-8';
Should not be used really, I'd vote to just remove it now (and looks like there were a couple missed  O:-)  in our forms, those should just be replaced).