Merge pull request #574 from fermionic/20130103-always-load-theme-in-mod_init

Finalize theme decision in a module's _init function
This commit is contained in:
friendica 2013-01-04 14:36:47 -08:00
commit c0fd572fec
25 changed files with 228 additions and 174 deletions

View file

@ -1107,6 +1107,10 @@ if(! function_exists('get_max_import_size')) {
* Profile information is placed in the App structure for later retrieval.
* Honours the owner's chosen theme for display.
*
* IMPORTANT: Should only be run in the _init() functions of a module. That ensures that
* the theme is chosen before the _init() function of a theme is run, which will usually
* load a lot of theme-specific content
*
*/
if(! function_exists('profile_load')) {
@ -1166,7 +1170,7 @@ if(! function_exists('profile_load')) {
if(! $r[0]['is-default']) {
$x = q("select `pub_keywords` from `profile` where uid = %d and `is-default` = 1 limit 1",
intval($profile_uid)
intval($r[0]['profile_uid'])
);
if($x && count($x))
$r[0]['pub_keywords'] = $x[0]['pub_keywords'];
@ -1174,7 +1178,7 @@ if(! function_exists('profile_load')) {
$a->profile = $r[0];
$a->profile['mobile-theme'] = get_pconfig($profile_uid, 'system', 'mobile_theme');
$a->profile['mobile-theme'] = get_pconfig($a->profile['profile_uid'], 'system', 'mobile_theme');
$a->page['title'] = $a->profile['name'] . " @ " . $a->config['sitename'];
@ -1185,6 +1189,8 @@ if(! function_exists('profile_load')) {
* load/reload current theme info
*/
set_template_engine($a); // reset the template engine to the default in case the user's theme doesn't specify one
$theme_info_file = "view/theme/".current_theme()."/theme.php";
if (file_exists($theme_info_file)){
require_once($theme_info_file);
@ -1611,7 +1617,7 @@ if(! function_exists('current_theme')) {
// $mobile_detect = new Mobile_Detect();
// $is_mobile = $mobile_detect->isMobile() || $mobile_detect->isTablet();
$is_mobile = $a->is_mobile || $a->is_tablet;
if($is_mobile) {
if(isset($_SESSION['show-mobile']) && !$_SESSION['show-mobile']) {
$system_theme = '';