3 * @copyright Copyright (C) 2020, Friendica
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Module\Admin\Themes;
24 use Friendica\Core\Renderer;
26 use Friendica\Module\BaseAdmin;
27 use Friendica\Util\Strings;
29 class Embed extends BaseAdmin
31 public static function init(array $parameters = [])
36 // @TODO: Replace with parameter from router
38 $theme = Strings::sanitizeFilePathItem($theme);
39 if (is_file("view/theme/$theme/config.php")) {
40 $a->setCurrentTheme($theme);
45 public static function post(array $parameters = [])
47 parent::post($parameters);
52 // @TODO: Replace with parameter from router
54 $theme = Strings::sanitizeFilePathItem($theme);
55 if (is_file("view/theme/$theme/config.php")) {
56 self::checkFormSecurityTokenRedirectOnError('/admin/themes/' . $theme . '/embed?mode=minimal', 'admin_theme_settings');
58 require_once "view/theme/$theme/config.php";
60 if (function_exists('theme_admin_post')) {
65 info(DI::l10n()->t('Theme settings updated.'));
67 if (DI::mode()->isAjax()) {
71 DI::baseUrl()->redirect('admin/themes/' . $theme . '/embed?mode=minimal');
75 public static function content(array $parameters = [])
77 parent::content($parameters);
82 // @TODO: Replace with parameter from router
84 $theme = Strings::sanitizeFilePathItem($theme);
85 if (!is_dir("view/theme/$theme")) {
86 notice(DI::l10n()->t('Unknown theme.'));
91 if (is_file("view/theme/$theme/config.php")) {
92 require_once "view/theme/$theme/config.php";
94 if (function_exists('theme_admin')) {
95 $admin_form = theme_admin($a);
99 // Overrides normal theme style include to strip user param to show embedded theme settings
100 Renderer::$theme['stylesheet'] = 'view/theme/' . $theme . '/style.pcss';
102 $t = Renderer::getMarkupTemplate('admin/addons/embed.tpl');
103 return Renderer::replaceMacros($t, [
104 '$action' => '/admin/themes/' . $theme . '/embed?mode=minimal',
105 '$form' => $admin_form,
106 '$form_security_token' => parent::getFormSecurityToken("admin_theme_settings"),