Merge pull request #6473 from MrPetovan/bug/5092-redux
Move theme init after module init but before post/content
This commit is contained in:
commit
f018c23bd0
|
@ -33,6 +33,23 @@ use Friendica\Util\Network;
|
|||
use Friendica\Util\Strings;
|
||||
use Friendica\Util\Temporal;
|
||||
|
||||
/**
|
||||
* Sets the current theme for theme settings pages.
|
||||
*
|
||||
* This needs to be done before the post() or content() methods are called.
|
||||
*
|
||||
* @param App $a
|
||||
*/
|
||||
function admin_init(App $a)
|
||||
{
|
||||
if ($a->argc > 2 && $a->argv[1] == 'themes') {
|
||||
$theme = $a->argv[2];
|
||||
if (is_file("view/theme/$theme/config.php")) {
|
||||
$a->setCurrentTheme($theme);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Process send data from the admin panels subpages
|
||||
*
|
||||
|
@ -89,15 +106,8 @@ function admin_post(App $a)
|
|||
|
||||
$theme = $a->argv[2];
|
||||
if (is_file("view/theme/$theme/config.php")) {
|
||||
$a->setCurrentTheme($theme);
|
||||
|
||||
require_once "view/theme/$theme/theme.php";
|
||||
require_once "view/theme/$theme/config.php";
|
||||
|
||||
$init = $theme . '_init';
|
||||
if (function_exists($init)) {
|
||||
$init($a);
|
||||
}
|
||||
if (function_exists('theme_admin_post')) {
|
||||
theme_admin_post($a);
|
||||
}
|
||||
|
@ -2306,16 +2316,8 @@ function admin_page_themes(App $a)
|
|||
|
||||
$admin_form = '';
|
||||
if (is_file("view/theme/$theme/config.php")) {
|
||||
$a->setCurrentTheme($theme);
|
||||
|
||||
require_once "view/theme/$theme/theme.php";
|
||||
require_once "view/theme/$theme/config.php";
|
||||
|
||||
$init = $theme . "_init";
|
||||
if (function_exists($init)) {
|
||||
$init($a);
|
||||
}
|
||||
|
||||
if (function_exists('theme_admin')) {
|
||||
$admin_form = theme_admin($a);
|
||||
}
|
||||
|
|
16
src/App.php
16
src/App.php
|
@ -1720,13 +1720,7 @@ class App
|
|||
|
||||
$content = '';
|
||||
|
||||
// Load current theme info after module has been executed as theme could have been set in module
|
||||
$theme_info_file = 'view/theme/' . $this->getCurrentTheme() . '/theme.php';
|
||||
if (file_exists($theme_info_file)) {
|
||||
require_once $theme_info_file;
|
||||
}
|
||||
|
||||
// Call module functions
|
||||
// Initialize module that can set the current theme in the init() method, either directly or via App->profile_uid
|
||||
if ($this->module_loaded) {
|
||||
$this->page['page_title'] = $this->module;
|
||||
$placeholder = '';
|
||||
|
@ -1740,12 +1734,20 @@ class App
|
|||
if (!$this->error) {
|
||||
call_user_func([$this->module_class, 'rawContent']);
|
||||
}
|
||||
}
|
||||
|
||||
// Load current theme info after module has been initialized as theme could have been set in module
|
||||
$theme_info_file = 'view/theme/' . $this->getCurrentTheme() . '/theme.php';
|
||||
if (file_exists($theme_info_file)) {
|
||||
require_once $theme_info_file;
|
||||
}
|
||||
|
||||
if (function_exists(str_replace('-', '_', $this->getCurrentTheme()) . '_init')) {
|
||||
$func = str_replace('-', '_', $this->getCurrentTheme()) . '_init';
|
||||
$func($this);
|
||||
}
|
||||
|
||||
if ($this->module_loaded) {
|
||||
if (! $this->error && $_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
Core\Addon::callHooks($this->module . '_mod_post', $_POST);
|
||||
call_user_func([$this->module_class, 'post']);
|
||||
|
|
|
@ -22,26 +22,17 @@ use Friendica\Model;
|
|||
use Friendica\Module;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
$frio = 'view/theme/frio';
|
||||
|
||||
global $frio;
|
||||
|
||||
function frio_init(App $a)
|
||||
{
|
||||
global $frio;
|
||||
$frio = 'view/theme/frio';
|
||||
|
||||
// disable the events module link in the profile tab
|
||||
$a->theme_events_in_profile = false;
|
||||
$a->videowidth = 622;
|
||||
|
||||
Renderer::setActiveTemplateEngine('smarty3');
|
||||
|
||||
$baseurl = System::baseUrl();
|
||||
|
||||
$style = PConfig::get(local_user(), 'frio', 'style');
|
||||
|
||||
$frio = 'view/theme/frio';
|
||||
|
||||
global $frio;
|
||||
|
||||
// if the device is a mobile device set js is_mobile
|
||||
// variable so the js scripts can use this information
|
||||
if ($a->is_mobile || $a->is_tablet) {
|
||||
|
@ -51,10 +42,6 @@ function frio_init(App $a)
|
|||
</script>
|
||||
EOT;
|
||||
}
|
||||
|
||||
if ($style == '') {
|
||||
$style = Config::get('frio', 'style');
|
||||
}
|
||||
}
|
||||
|
||||
function frio_install()
|
||||
|
|
Loading…
Reference in New Issue
Block a user