diff --git a/src/Controller/AdminConfigController.php b/src/Controller/AdminPanel.php similarity index 83% rename from src/Controller/AdminConfigController.php rename to src/Controller/AdminPanel.php index 6d107e69a6..50632d6f98 100644 --- a/src/Controller/AdminConfigController.php +++ b/src/Controller/AdminPanel.php @@ -42,7 +42,7 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\HttpFoundation\Request; -class AdminConfigController extends Controller +class AdminPanel extends Controller { public function handle(Request $request) { @@ -55,9 +55,11 @@ class AdminConfigController extends Controller } } - $form = Form::create([[_m('Setting'), ChoiceType::class, ['choices' => $options]], + $form = Form::create([ + [_m('Setting'), ChoiceType::class, ['choices' => $options]], [_m('Value'), TextType::class], - ['save', SubmitType::class, ['label' => _m('Set site setting')]], ]); + ['save', SubmitType::class, ['label' => _m('Set site setting')]], + ]); $form->handleRequest($request); if ($form->isSubmitted()) { @@ -66,17 +68,19 @@ class AdminConfigController extends Controller list($section, $setting) = explode(':', $data[_m('Setting')]); $value = $data[_m('Value')]; $default = $defaults[$section][$setting]; + // Sanity check if (gettype($default) === gettype($value)) { $conf = DB::find('config', ['section' => $section, 'setting' => $setting]); - $old_value = $conf->getValue(); + $old_value = unserialize($conf->getValue()); $conf->setValue(serialize($value)); DB::flush(); + return [ + '_template' => 'config/admin.html.twig', + 'form' => $form->createView(), + 'old_value' => $old_value, + 'default' => $default, + ]; } - return $this->render('config/admin.html.twig', [ - 'form' => $form->createView(), - 'old_value' => unserialize($old_value), - 'default' => $default, - ]); } else { // TODO Display error } diff --git a/src/Controller/SecurityController.php b/src/Controller/Security.php similarity index 69% rename from src/Controller/SecurityController.php rename to src/Controller/Security.php index 7e84a0669b..c3772e7bb1 100644 --- a/src/Controller/SecurityController.php +++ b/src/Controller/Security.php @@ -2,11 +2,11 @@ namespace App\Controller; -use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use App\Core\Controller; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Security\Http\Authentication\AuthenticationUtils; -class SecurityController extends AbstractController +class Security extends Controller { public function login(AuthenticationUtils $authenticationUtils): Response { @@ -17,9 +17,9 @@ class SecurityController extends AbstractController // get the login error if there is one $error = $authenticationUtils->getLastAuthenticationError(); // last username entered by the user - $lastUsername = $authenticationUtils->getLastUsername(); + $last_username = $authenticationUtils->getLastUsername(); - return $this->render('security/login.html.twig', ['last_username' => $lastUsername, 'error' => $error]); + return ['_template' => 'security/login.html.twig', 'last_username' => $last_username, 'error' => $error]; } public function logout() diff --git a/src/Controller/UserPanel.php b/src/Controller/UserPanel.php index 94f488a101..c80b052654 100644 --- a/src/Controller/UserPanel.php +++ b/src/Controller/UserPanel.php @@ -31,8 +31,6 @@ namespace App\Controller; -// use App\Core\Event; -// use App\Util\Common; use App\Core\DB\DB; use App\Core\Form; use function App\Core\I18n\_m; @@ -72,9 +70,7 @@ class UserPanel extends AbstractController } } - return $this->render('settings/profile.html.twig', [ - 'prof' => $prof->createView(), - ]); + return ['_template' => 'settings/profile.html.twig', 'prof' => $prof->createView()]; } public function account(Request $request) @@ -89,9 +85,7 @@ class UserPanel extends AbstractController [_m('emailnotifyfav'), CheckboxType::class, ['help' => 'Send me email when someone adds my notice as a favorite.', 'label_format' => 'Notify favorites']], ['save', SubmitType::class, ['label' => _m('Save')]], ]); - return $this->render('settings/account.html.twig', [ - 'acc' => $acc->createView(), - ]); + return ['_template' => 'settings/account.html.twig', 'acc' => $acc->createView()]; } public function avatar(Request $request) @@ -100,9 +94,7 @@ class UserPanel extends AbstractController [_m('avatar'), FileType::class, ['help' => 'You can upload your personal avatar. The maximum file size is 64MB.', 'label_format' => 'Avatar']], ['save', SubmitType::class, ['label' => _m('Submit')]], ]); - return $this->render('settings/avatar.html.twig', [ - 'avatar' => $avatar->createView(), - ]); + return ['_template' => 'settings/avatar.html.twig', 'avatar' => $avatar->createView()]; } public function misc(Request $request) @@ -114,8 +106,6 @@ class UserPanel extends AbstractController [_m('posts_by_followed'), CheckboxType::class, ['help' => 'Send me notices.', 'label_format' => 'Notices']], ['save', SubmitType::class, ['label' => _m('Save')]], ]); - return $this->render('settings/misc.html.twig', [ - 'misc' => $misc->createView(), - ]); + return ['_template' => 'settings/misc.html.twig', 'misc' => $misc->createView()]; } -} \ No newline at end of file +} diff --git a/src/Routes/Main.php b/src/Routes/Main.php index 98c056556b..0764826bba 100644 --- a/src/Routes/Main.php +++ b/src/Routes/Main.php @@ -1,6 +1,7 @@ . + // }}} /** @@ -40,10 +42,10 @@ abstract class Main public static function load(RouteLoader $r): void { $r->connect('main_all', '/main/all', C\NetworkPublic::class); - $r->connect('admin_config', '/admin/config', C\AdminConfigController::class); + $r->connect('admin_config', '/admin/config', C\AdminPanel::class); - $r->connect('login', '/login', [C\SecurityController::class, 'login']); - $r->connect('logout', '/logout', [C\SecurityController::class, 'logout']); + $r->connect('login', '/login', [C\Security::class, 'login']); + $r->connect('logout', '/logout', [C\Security::class, 'logout']); // FAQ static pages foreach (['faq', 'contact', 'tags', 'groups', 'openid'] as $s) {