-<?php\r
-\r
-namespace Friendica\Module\Admin\Themes;\r
-\r
-use Friendica\Core\L10n;\r
-use Friendica\Core\Renderer;\r
-use Friendica\Module\BaseAdminModule;\r
-use Friendica\Util\Strings;\r
-\r
-class Embed extends BaseAdminModule\r
-{\r
- public static function init()\r
- {\r
- $a = self::getApp();\r
-\r
- if ($a->argc > 2) {\r
- // @TODO: Replace with parameter from router\r
- $theme = $a->argv[2];\r
- $theme = Strings::sanitizeFilePathItem($theme);\r
- if (is_file("view/theme/$theme/config.php")) {\r
- $a->setCurrentTheme($theme);\r
- }\r
- }\r
- }\r
-\r
- public static function post()\r
- {\r
- parent::post();\r
-\r
- $a = self::getApp();\r
-\r
- if ($a->argc > 2) {\r
- // @TODO: Replace with parameter from router\r
- $theme = $a->argv[2];\r
- $theme = Strings::sanitizeFilePathItem($theme);\r
- if (is_file("view/theme/$theme/config.php")) {\r
- self::checkFormSecurityTokenRedirectOnError('/admin/themes/' . $theme . '/embed?mode=minimal', 'admin_theme_settings');\r
-\r
- require_once "view/theme/$theme/config.php";\r
-\r
- if (function_exists('theme_admin_post')) {\r
- theme_admin_post($a);\r
- }\r
- }\r
-\r
- info(L10n::t('Theme settings updated.'));\r
-\r
- if ($a->isAjax()) {\r
- return;\r
- }\r
-\r
- $a->internalRedirect('admin/themes/' . $theme . '/embed?mode=minimal');\r
- }\r
- }\r
-\r
- public static function content()\r
- {\r
- parent::content();\r
-\r
- $a = self::getApp();\r
-\r
- if ($a->argc > 2) {\r
- // @TODO: Replace with parameter from router\r
- $theme = $a->argv[2];\r
- $theme = Strings::sanitizeFilePathItem($theme);\r
- if (!is_dir("view/theme/$theme")) {\r
- notice(L10n::t('Unknown theme.'));\r
- return '';\r
- }\r
-\r
- $admin_form = '';\r
- if (is_file("view/theme/$theme/config.php")) {\r
- require_once "view/theme/$theme/config.php";\r
-\r
- if (function_exists('theme_admin')) {\r
- $admin_form = theme_admin($a);\r
- }\r
- }\r
-\r
- $t = Renderer::getMarkupTemplate('admin/addons/embed.tpl');\r
- return Renderer::replaceMacros($t, [\r
- '$action' => '/admin/themes/' . $theme . '/embed?mode=minimal',\r
- '$form' => $admin_form,\r
- '$form_security_token' => parent::getFormSecurityToken("admin_theme_settings"),\r
- ]);\r
- }\r
-\r
- return '';\r
- }\r
-}
\ No newline at end of file
+<?php
+
+namespace Friendica\Module\Admin\Themes;
+
+use Friendica\Core\L10n;
+use Friendica\Core\Renderer;
+use Friendica\Module\BaseAdminModule;
+use Friendica\Util\Strings;
+
+class Embed extends BaseAdminModule
+{
+ public static function init()
+ {
+ $a = self::getApp();
+
+ if ($a->argc > 2) {
+ // @TODO: Replace with parameter from router
+ $theme = $a->argv[2];
+ $theme = Strings::sanitizeFilePathItem($theme);
+ if (is_file("view/theme/$theme/config.php")) {
+ $a->setCurrentTheme($theme);
+ }
+ }
+ }
+
+ public static function post()
+ {
+ parent::post();
+
+ $a = self::getApp();
+
+ if ($a->argc > 2) {
+ // @TODO: Replace with parameter from router
+ $theme = $a->argv[2];
+ $theme = Strings::sanitizeFilePathItem($theme);
+ if (is_file("view/theme/$theme/config.php")) {
+ self::checkFormSecurityTokenRedirectOnError('/admin/themes/' . $theme . '/embed?mode=minimal', 'admin_theme_settings');
+
+ require_once "view/theme/$theme/config.php";
+
+ if (function_exists('theme_admin_post')) {
+ theme_admin_post($a);
+ }
+ }
+
+ info(L10n::t('Theme settings updated.'));
+
+ if ($a->isAjax()) {
+ return;
+ }
+
+ $a->internalRedirect('admin/themes/' . $theme . '/embed?mode=minimal');
+ }
+ }
+
+ public static function content()
+ {
+ parent::content();
+
+ $a = self::getApp();
+
+ if ($a->argc > 2) {
+ // @TODO: Replace with parameter from router
+ $theme = $a->argv[2];
+ $theme = Strings::sanitizeFilePathItem($theme);
+ if (!is_dir("view/theme/$theme")) {
+ notice(L10n::t('Unknown theme.'));
+ return '';
+ }
+
+ $admin_form = '';
+ if (is_file("view/theme/$theme/config.php")) {
+ require_once "view/theme/$theme/config.php";
+
+ if (function_exists('theme_admin')) {
+ $admin_form = theme_admin($a);
+ }
+ }
+
+ // Overrides normal theme style include to strip user param to show embedded theme settings
+ Renderer::$theme['stylesheet'] = 'view/theme/' . $theme . '/style.pcss';
+
+ $t = Renderer::getMarkupTemplate('admin/addons/embed.tpl');
+ return Renderer::replaceMacros($t, [
+ '$action' => '/admin/themes/' . $theme . '/embed?mode=minimal',
+ '$form' => $admin_form,
+ '$form_security_token' => parent::getFormSecurityToken("admin_theme_settings"),
+ ]);
+ }
+
+ return '';
+ }
+}