Add admin/themes/{theme}/embed module
- This module allows editing the site settings for a theme with a different user theme
This commit is contained in:
parent
d6a5274bb9
commit
a5da0fd98f
|
@ -133,6 +133,7 @@ class Router
|
||||||
$collector->addRoute(['GET'] , '/queue[/deferred]' , Module\Admin\Queue::class);
|
$collector->addRoute(['GET'] , '/queue[/deferred]' , Module\Admin\Queue::class);
|
||||||
|
|
||||||
$collector->addRoute(['GET', 'POST'], '/themes' , Module\Admin\Themes\Index::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);
|
$collector->addRoute(['GET', 'POST'], '/tos' , Module\Admin\Tos::class);
|
||||||
|
|
||||||
|
|
92
src/Module/Admin/Themes/Embed.php
Normal file
92
src/Module/Admin/Themes/Embed.php
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Friendica\Module\Admin\Themes;
|
||||||
|
|
||||||
|
use Friendica\Core\L10n;
|
||||||
|
use Friendica\Core\Renderer;
|
||||||
|
use Friendica\Core\System;
|
||||||
|
use Friendica\Core\Theme;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$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 '';
|
||||||
|
}
|
||||||
|
}
|
5
view/templates/admin/addons/embed.tpl
Normal file
5
view/templates/admin/addons/embed.tpl
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
<form method="post" action="{{$action}}">
|
||||||
|
<input type="hidden" name="form_security_token" value="{{$form_security_token}}">
|
||||||
|
{{$form nofilter}}
|
||||||
|
</form>
|
Loading…
Reference in a new issue