3 namespace Friendica\Module\Admin\Themes;
5 use Friendica\Core\L10n;
6 use Friendica\Core\Renderer;
7 use Friendica\Module\BaseAdminModule;
8 use Friendica\Util\Strings;
10 class Embed extends BaseAdminModule
12 public static function init($parameters)
17 // @TODO: Replace with parameter from router
19 $theme = Strings::sanitizeFilePathItem($theme);
20 if (is_file("view/theme/$theme/config.php")) {
21 $a->setCurrentTheme($theme);
26 public static function post($parameters)
28 parent::post($parameters);
33 // @TODO: Replace with parameter from router
35 $theme = Strings::sanitizeFilePathItem($theme);
36 if (is_file("view/theme/$theme/config.php")) {
37 self::checkFormSecurityTokenRedirectOnError('/admin/themes/' . $theme . '/embed?mode=minimal', 'admin_theme_settings');
39 require_once "view/theme/$theme/config.php";
41 if (function_exists('theme_admin_post')) {
46 info(L10n::t('Theme settings updated.'));
52 $a->internalRedirect('admin/themes/' . $theme . '/embed?mode=minimal');
56 public static function content($parameters)
58 parent::content($parameters);
63 // @TODO: Replace with parameter from router
65 $theme = Strings::sanitizeFilePathItem($theme);
66 if (!is_dir("view/theme/$theme")) {
67 notice(L10n::t('Unknown theme.'));
72 if (is_file("view/theme/$theme/config.php")) {
73 require_once "view/theme/$theme/config.php";
75 if (function_exists('theme_admin')) {
76 $admin_form = theme_admin($a);
80 // Overrides normal theme style include to strip user param to show embedded theme settings
81 Renderer::$theme['stylesheet'] = 'view/theme/' . $theme . '/style.pcss';
83 $t = Renderer::getMarkupTemplate('admin/addons/embed.tpl');
84 return Renderer::replaceMacros($t, [
85 '$action' => '/admin/themes/' . $theme . '/embed?mode=minimal',
86 '$form' => $admin_form,
87 '$form_security_token' => parent::getFormSecurityToken("admin_theme_settings"),