]> git.mxchange.org Git - friendica.git/blobdiff - mod/admin.php
Catch HTTPExceptions in App::runFrontend()
[friendica.git] / mod / admin.php
index 89514397f0da0fea80fe51703b13cf7a41599b8b..9b8a054c423e4cb391d76aef7a08e7c35173f2bc 100644 (file)
@@ -33,9 +33,22 @@ use Friendica\Util\Network;
 use Friendica\Util\Strings;
 use Friendica\Util\Temporal;
 
-require_once 'include/enotify.php';
-require_once 'include/text.php';
-require_once 'include/items.php';
+/**
+ * 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
@@ -93,31 +106,18 @@ function admin_post(App $a)
 
                                $theme = $a->argv[2];
                                if (is_file("view/theme/$theme/config.php")) {
-                                       $orig_theme = Renderer::$theme;
-                                       $orig_page = $a->page;
-                                       $orig_session_theme = $_SESSION['theme'];
-                                       require_once "view/theme/$theme/theme.php";
                                        require_once "view/theme/$theme/config.php";
-                                       $_SESSION['theme'] = $theme;
 
-                                       $init = $theme . '_init';
-                                       if (function_exists($init)) {
-                                               $init($a);
-                                       }
                                        if (function_exists('theme_admin_post')) {
                                                theme_admin_post($a);
                                        }
-
-                                       $_SESSION['theme'] = $orig_session_theme;
-                                       Renderer::$theme = $orig_theme;
-                                       $a->page = $orig_page;
                                }
 
                                info(L10n::t('Theme settings updated.'));
                                if ($a->isAjax()) {
                                        return;
                                }
-                               $return_path = 'admin/themes/' . $theme;
+                               $return_path = 'admin/themes/' . $theme . (!empty($_GET['mode']) ? '?mode=' . $_GET['mode'] : '');
                                break;
                        case 'tos':
                                admin_page_tos_post($a);
@@ -1444,9 +1444,7 @@ function admin_page_site(App $a)
                $banner = '<a href="https://friendi.ca"><img id="logo-img" src="images/friendica-32.png" alt="logo" /></a><span id="logo-text"><a href="https://friendi.ca">Friendica</a></span>';
        }
 
-       $banner = htmlspecialchars($banner);
        $info = Config::get('config', 'info');
-       $info = htmlspecialchars($info);
 
        // Automatically create temporary paths
        get_temppath();
@@ -1764,7 +1762,7 @@ function admin_page_users_post(App $a)
                        Thank you and welcome to %4$s.'));
 
                $preamble = sprintf($preamble, $user['username'], Config::get('config', 'sitename'));
-               $body = sprintf($body, System::baseUrl(), $user['email'], $result['password'], Config::get('config', 'sitename'));
+               $body = sprintf($body, System::baseUrl(), $user['nickname'], $result['password'], Config::get('config', 'sitename'));
 
                notification([
                        'type'     => SYSTEM_EMAIL,
@@ -2318,25 +2316,11 @@ function admin_page_themes(App $a)
 
                $admin_form = '';
                if (is_file("view/theme/$theme/config.php")) {
-                       $orig_theme = Renderer::$theme;
-                       $orig_page = $a->page;
-                       $orig_session_theme = $_SESSION['theme'];
-                       require_once "view/theme/$theme/theme.php";
                        require_once "view/theme/$theme/config.php";
-                       $_SESSION['theme'] = $theme;
-
-                       $init = $theme . "_init";
-                       if (function_exists($init)) {
-                               $init($a);
-                       }
 
                        if (function_exists('theme_admin')) {
                                $admin_form = theme_admin($a);
                        }
-
-                       $_SESSION['theme'] = $orig_session_theme;
-                       Renderer::$theme = $orig_theme;
-                       $a->page = $orig_page;
                }
 
                $screenshot = [Theme::getScreenshot($theme), L10n::t('Screenshot')];
@@ -2351,7 +2335,7 @@ function admin_page_themes(App $a)
                        '$toggle' => L10n::t('Toggle'),
                        '$settings' => L10n::t('Settings'),
                        '$baseurl' => System::baseUrl(true),
-                       '$addon' => $theme,
+                       '$addon' => $theme . (!empty($_GET['mode']) ? '?mode=' . $_GET['mode'] : ''),
                        '$status' => $status,
                        '$action' => $action,
                        '$info' => Theme::getInfo($theme),