diff --git a/components/Avatar/Avatar.php b/components/Avatar/Avatar.php index 0a97374d3c..0dd49f9ba6 100644 --- a/components/Avatar/Avatar.php +++ b/components/Avatar/Avatar.php @@ -25,10 +25,12 @@ use App\Core\Event; use App\Core\GSFile; use App\Core\Modules\Component; use App\Util\Common; +use Component\Avatar\Controller as C; use Component\Avatar\Exception\NoAvatarException; use Exception; use Symfony\Component\Asset\Package; use Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy; +use Symfony\Component\HttpFoundation\Request; class Avatar extends Component { @@ -39,7 +41,18 @@ class Avatar extends Component return Event::next; } - public function onEndTwigPopulateVars(array &$vars) + public function onPopulateProfileSettingsTabs(Request $request, &$tabs) + { + // TODO avatar template shouldn't be on settings folder + $tabs[] = ['title' => 'Avatar', + 'desc' => 'Change your avatar.', + 'controller' => C\Avatar::settings_avatar($request), + ]; + + return Event::next; + } + + public function onStartTwigPopulateVars(array &$vars) { if (Common::user() != null) { $vars['user_avatar'] = self::getAvatarUrl(); diff --git a/components/Avatar/Controller/Avatar.php b/components/Avatar/Controller/Avatar.php index 432f269a5e..5d81b7fce5 100644 --- a/components/Avatar/Controller/Avatar.php +++ b/components/Avatar/Controller/Avatar.php @@ -59,13 +59,13 @@ class Avatar extends Controller /** * Local user avatar panel */ - public function settings_avatar(Request $request) + public static function settings_avatar(Request $request) { $form = Form::create([ - ['avatar', FileType::class, ['label' => _m('Avatar'), 'help' => _m('You can upload your personal avatar. The maximum file size is 2MB.'), 'multiple' => false, 'required' => false]], + ['avatar', FileType::class, ['label' => _m('Avatar'), 'help' => _m('You can upload your personal avatar. The maximum file size is 2MB.'), 'multiple' => false, 'required' => false]], ['remove', CheckboxType::class, ['label' => _m('Remove avatar'), 'help' => _m('Remove your avatar and use the default one'), 'required' => false, 'value' => false]], - ['hidden', HiddenType::class, []], - ['save', SubmitType::class, ['label' => _m('Submit')]], + ['hidden', HiddenType::class, []], + ['save', SubmitType::class, ['label' => _m('Submit')]], ]); $form->handleRequest($request); diff --git a/plugins/Cover/Controller/Cover.php b/plugins/Cover/Controller/Cover.php index a9dbe90c11..4ef037df75 100644 --- a/plugins/Cover/Controller/Cover.php +++ b/plugins/Cover/Controller/Cover.php @@ -61,14 +61,14 @@ class Cover * * @return array template */ - public function coverSettings(Request $request) + public static function coverSettings(Request $request) { $user = Common::user(); $actor_id = $user->getId(); $form = Form::create([ - ['cover', FileType::class, ['label' => _m('Cover'), 'help' => _m('You can upload your personal cover. The maximum file size is 2MB.'), - 'constraints' => [ + ['cover', FileType::class, ['label' => _m('Cover'), 'help' => _m('You can upload your personal cover. The maximum file size is 2MB.'), + 'constraints' => [ new F([ 'maxSize' => '2048k', 'mimeTypes' => [ diff --git a/plugins/Cover/Cover.php b/plugins/Cover/Cover.php index 20703fe4c8..d380b343fe 100644 --- a/plugins/Cover/Cover.php +++ b/plugins/Cover/Cover.php @@ -25,6 +25,8 @@ use App\Core\Event; use App\Core\Modules\Plugin; use App\Core\Router\RouteLoader; use App\Util\Common; +use Plugin\Cover\Controller as C; +use Symfony\Component\HttpFoundation\Request; /** * Cover plugin main class @@ -52,6 +54,17 @@ class Cover extends Plugin return Event::next; } + public function onPopulateProfileSettingsTabs(Request $request, &$tabs) + { + $tabs[] = [ + 'title' => 'Cover', + 'desc' => 'Change your cover.', + 'controller' => C\Cover::coverSettings($request), + ]; + + return Event::next; + } + /** * Populate twig vars * @@ -61,18 +74,14 @@ class Cover extends Plugin */ public function onStartTwigPopulateVars(array &$vars): bool { - $vars['profile_tabs'][] = ['title' => 'Cover', - 'route' => 'settings_profile_cover', - ]; - - if (Common::user() != null) { + /*if (Common::user() != null) { $cover = DB::find('cover', ['gsactor_id' => Common::user()->getId()]); if ($cover != null) { $vars['profile_extras'][] = ['name' => 'cover', 'vars' => ['img' => '/cover']]; } else { $vars['profile_extras'][] = ['name' => 'cover', 'vars' => []]; } - } + }*/ return Event::next; } diff --git a/plugins/ProfileColor/Controller/ProfileColor.php b/plugins/ProfileColor/Controller/ProfileColor.php index dcc7118cf4..0011d154ca 100644 --- a/plugins/ProfileColor/Controller/ProfileColor.php +++ b/plugins/ProfileColor/Controller/ProfileColor.php @@ -53,7 +53,7 @@ class ProfileColor * * @return array template */ - public function profileColorSettings(Request $request) + public static function profileColorSettings(Request $request) { $user = Common::user(); $actor_id = $user->getId(); diff --git a/plugins/ProfileColor/ProfileColor.php b/plugins/ProfileColor/ProfileColor.php index 077de90a2c..8a3069e5b2 100644 --- a/plugins/ProfileColor/ProfileColor.php +++ b/plugins/ProfileColor/ProfileColor.php @@ -25,6 +25,8 @@ use App\Core\Event; use App\Core\Modules\Plugin; use App\Core\Router\RouteLoader; use App\Util\Common; +use Plugin\ProfileColor\Controller as C; +use Symfony\Component\HttpFoundation\Request; /** * Profile Color plugin main class @@ -51,6 +53,18 @@ class ProfileColor extends Plugin return Event::next; } + public function onPopulateProfileSettingsTabs(Request $request, &$tabs) + { + // TODO avatar template shouldn't be on settings folder + $tabs[] = [ + 'title' => 'Color', + 'desc' => 'Change your profile color.', + 'controller' => C\ProfileColor::profileColorSettings($request), + ]; + + return Event::next; + } + /** * Populate twig vars * @@ -60,9 +74,11 @@ class ProfileColor extends Plugin */ public function onStartTwigPopulateVars(array &$vars): bool { - $vars['profile_tabs'][] = ['title' => 'Color', - 'route' => 'settings_profile_color', - ]; + /*$vars['profile_tabs'][] = [ + 'title' => 'Color', + 'desc' => 'Change your profile color.', + 'path' => 'profilecolor/profilecolor.html.twig', + ];*/ if (Common::user() != null) { $color = DB::find('profile_color', ['gsactor_id' => Common::user()->getId()]); if ($color != null) { diff --git a/templates/cover/cover.html.twig b/templates/cover/cover.html.twig index ef062ea42a..ca64c39e69 100644 --- a/templates/cover/cover.html.twig +++ b/templates/cover/cover.html.twig @@ -1,19 +1,9 @@ -{% extends 'settings/profile.html.twig' %} +