$collector->addRoute(['GET'] , '/queue[/deferred]' , Module\Admin\Queue::class);
$collector->addRoute(['GET', 'POST'], '/themes' , Module\Admin\Themes\Index::class);
+ $collector->addRoute(['GET', 'POST'], '/themes/{theme}/embed' , Module\Admin\Themes\Embed::class);
$collector->addRoute(['GET', 'POST'], '/tos' , Module\Admin\Tos::class);
--- /dev/null
+<?php\r
+\r
+namespace Friendica\Module\Admin\Themes;\r
+\r
+use Friendica\Core\L10n;\r
+use Friendica\Core\Renderer;\r
+use Friendica\Core\System;\r
+use Friendica\Core\Theme;\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