3 namespace Friendica\Module\Admin\Themes;
5 use Friendica\Core\L10n;
6 use Friendica\Core\Renderer;
8 use Friendica\Module\BaseAdminModule;
9 use Friendica\Util\Strings;
11 class Embed extends BaseAdminModule
13 public static function init(array $parameters = [])
18 // @TODO: Replace with parameter from router
20 $theme = Strings::sanitizeFilePathItem($theme);
21 if (is_file("view/theme/$theme/config.php")) {
22 $a->setCurrentTheme($theme);
27 public static function post(array $parameters = [])
29 parent::post($parameters);
34 // @TODO: Replace with parameter from router
36 $theme = Strings::sanitizeFilePathItem($theme);
37 if (is_file("view/theme/$theme/config.php")) {
38 self::checkFormSecurityTokenRedirectOnError('/admin/themes/' . $theme . '/embed?mode=minimal', 'admin_theme_settings');
40 require_once "view/theme/$theme/config.php";
42 if (function_exists('theme_admin_post')) {
47 info(L10n::t('Theme settings updated.'));
53 $a->internalRedirect('admin/themes/' . $theme . '/embed?mode=minimal');
57 public static function content(array $parameters = [])
59 parent::content($parameters);
64 // @TODO: Replace with parameter from router
66 $theme = Strings::sanitizeFilePathItem($theme);
67 if (!is_dir("view/theme/$theme")) {
68 notice(L10n::t('Unknown theme.'));
73 if (is_file("view/theme/$theme/config.php")) {
74 require_once "view/theme/$theme/config.php";
76 if (function_exists('theme_admin')) {
77 $admin_form = theme_admin($a);
81 // Overrides normal theme style include to strip user param to show embedded theme settings
82 Renderer::$theme['stylesheet'] = 'view/theme/' . $theme . '/style.pcss';
84 $t = Renderer::getMarkupTemplate('admin/addons/embed.tpl');
85 return Renderer::replaceMacros($t, [
86 '$action' => '/admin/themes/' . $theme . '/embed?mode=minimal',
87 '$form' => $admin_form,
88 '$form_security_token' => parent::getFormSecurityToken("admin_theme_settings"),