ElkArte Community

Elk Development => Bug Reports => Exterminated Bugs => Topic started by: Joshua Dickerson on May 13, 2013, 01:04:26 am

Title: $context -> loadTheme() setupThemeContext()
Post by: Joshua Dickerson on May 13, 2013, 01:04:26 am
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).
Title: Re: $context -> loadTheme() setupThemeContext()
Post by: TestMonkey on May 13, 2013, 05:28:11 am
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.
Title: Re: $context -> loadTheme() setupThemeContext()
Post by: emanuele on January 11, 2014, 11:27:10 am
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:-)
Title: Re: $context -> loadTheme() setupThemeContext()
Post by: Spuds on January 11, 2014, 12:28:23 pm
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). 
Title: Re: $context -> loadTheme() setupThemeContext()
Post by: emanuele on January 11, 2014, 01:42:48 pm
https://github.com/emanuele45/Dialogo/commit/66062fb44014b9b5a01848f4bf8fda23467eb90e