diff --git a/plugins/Cover/Controller/Cover.php b/plugins/Cover/Controller/Cover.php
index bc5cafbbf5..5e7ba28343 100644
--- a/plugins/Cover/Controller/Cover.php
+++ b/plugins/Cover/Controller/Cover.php
@@ -133,7 +133,7 @@ class Cover
}
$removeForm = $form2->createView();
}
- return ['_template' => 'cover/cover.html.twig', 'form' => $form->createView(), 'remove_form' => $removeForm];
+ return ['_template' => 'cover/cover.html.twig', 'cover' => $form->createView(), 'cover_remove_form' => $removeForm];
}
/**
diff --git a/plugins/Cover/templates/cover/cover.html.twig b/plugins/Cover/templates/cover/cover.html.twig
index ca64c39e69..ab94148ef5 100644
--- a/plugins/Cover/templates/cover/cover.html.twig
+++ b/plugins/Cover/templates/cover/cover.html.twig
@@ -1,9 +1,9 @@
- {{ form(form) }}
+ {{ form(cover) }}
-{% if remove_form is not null %}
+{% if cover_remove_form is not null %}
- {{ form(remove_form) }}
+ {{ form(cover_remove_form) }}
{% endif %}
\ No newline at end of file
diff --git a/plugins/ProfileColor/Controller/ProfileColor.php b/plugins/ProfileColor/Controller/ProfileColor.php
index 1ee8ca1930..5d7cd35668 100644
--- a/plugins/ProfileColor/Controller/ProfileColor.php
+++ b/plugins/ProfileColor/Controller/ProfileColor.php
@@ -23,6 +23,7 @@ namespace Plugin\ProfileColor\Controller;
use App\Core\DB\DB;
use App\Core\Form;
+use App\Util\Exception\ServerException;
use function App\Core\I18n\_m;
use App\Util\Common;
use App\Util\Exception\RedirectException;
@@ -39,51 +40,54 @@ use Symfony\Component\HttpFoundation\Request;
* @category ProfileColor
*
* @author Daniel Brandao
+ * @author Eliseu Amaro
* @copyright 2020 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class ProfileColor
{
+
/**
- * Add/change profile color
- *
+ * Change Profile color background
* @param Request $request
- *
+ * @return array
* @throws RedirectException
- *
- * @return array template
+ * @throws ServerException
*/
public static function profileColorSettings(Request $request)
{
- $user = Common::user();
- $actor_id = $user->getId();
- $pcolor = DB::find('profile_color', ['actor_id' => $actor_id]);
- $color = '#000000';
- if ($pcolor != null) {
- $color = $pcolor;
- }
+ $user = Common::user();
+ $actor_id = $user->getId();
+ $pcolor = DB::findOneBy('profile_color', ['actor_id' => $actor_id]);
$form = Form::create([
- ['color', ColorType::class, ['data' => $color, 'label' => _m('Profile Color'), 'help' => _m('Choose your Profile Color')] ],
+ ['color', ColorType::class, [
+ 'html5' => true,
+ 'data' => "#000000",
+ 'label' => _m('Profile Color'),
+ 'help' => _m('Choose your Profile Color')]
+ ],
['hidden', HiddenType::class, []],
['save_profile_color', SubmitType::class, ['label' => _m('Submit')]],
]);
$form->handleRequest($request);
+
if ($form->isSubmitted() && $form->isValid()) {
- $data = $form->getData();
if ($pcolor !== null) {
DB::remove($pcolor);
DB::flush();
}
- $pcolor = Entity\ProfileColor::create(['actor_id' => $actor_id, 'profile_color' => $data['color']]);
+ $data = $form->getData();
+ $pcolor = Entity\ProfileColor::create(['actor_id' => $actor_id, 'color' => $data['color']]);
DB::persist($pcolor);
DB::flush();
+
throw new RedirectException();
}
- return ['_template' => 'profileColor/profileColorSettings.html.twig', 'form' => $form->createView()];
+ return ['_template' => 'profileColor/profileColorSettings.html.twig', 'profile_color' => $form->createView()];
}
}
diff --git a/plugins/ProfileColor/ProfileColor.php b/plugins/ProfileColor/ProfileColor.php
index f13b1245a7..f5f20f40a0 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 App\Util\Exception\RedirectException;
+use App\Util\Exception\ServerException;
use App\Util\Formatting;
use Plugin\ProfileColor\Controller as C;
use Symfony\Component\HttpFoundation\Request;
@@ -50,10 +52,17 @@ class ProfileColor extends Plugin
*/
public function onAddRoute(RouteLoader $r): bool
{
- $r->connect('settings_profile_color', 'settings/color', [Controller\ProfileColor::class, 'profilecolorsettings']);
+ $r->connect('settings_profile_color', 'settings/color', [Controller\ProfileColor::class, 'profileColorSettings']);
return Event::next;
}
+ /**
+ * @param Request $request
+ * @param $tabs
+ * @return bool
+ * @throws RedirectException
+ * @throws ServerException
+ */
public function onPopulateProfileSettingsTabs(Request $request, &$tabs)
{
// TODO avatar template shouldn't be on settings folder
@@ -74,15 +83,15 @@ class ProfileColor extends Plugin
* @param $res
* @return bool
*/
- public function onAppendCardProfile(&$res): bool
+ public function onAppendCardProfile($vars, &$res): bool
{
- $user = Common::user();
- if ($user !== null) {
- $actor_id = $user->getId();
+ $actor = $vars['actor'];
+ if ($actor !== null) {
+ $actor_id = $actor->getId();
$color = DB::find('profile_color', ['actor_id' => $actor_id]);
if ($color !== null) {
- $res[] = Formatting::twigRenderFile('/profileColor/profileColorView.html.twig', ['profile' => $color]);
+ $res[] = Formatting::twigRenderFile('/profileColor/profileColorView.html.twig', ['profile_color' => $color, 'actor' => $actor_id]);
}
}
diff --git a/plugins/ProfileColor/templates/profileColor/profileColorSettings.html.twig b/plugins/ProfileColor/templates/profileColor/profileColorSettings.html.twig
index ca9a027941..3000e82545 100644
--- a/plugins/ProfileColor/templates/profileColor/profileColorSettings.html.twig
+++ b/plugins/ProfileColor/templates/profileColor/profileColorSettings.html.twig
@@ -1,3 +1,3 @@
- {{ form(form) }}
+ {{ form(profile_color) }}
\ No newline at end of file
diff --git a/plugins/ProfileColor/templates/profileColor/profileColorView.html.twig b/plugins/ProfileColor/templates/profileColor/profileColorView.html.twig
index ea62f678ac..97bb4be198 100644
--- a/plugins/ProfileColor/templates/profileColor/profileColorView.html.twig
+++ b/plugins/ProfileColor/templates/profileColor/profileColorView.html.twig
@@ -1,7 +1,7 @@
{% block stylesheets %}
{% endblock stylesheets %}
\ No newline at end of file
diff --git a/templates/cards/profile/view.html.twig b/templates/cards/profile/view.html.twig
index 2b300b084c..ad207ac3e4 100644
--- a/templates/cards/profile/view.html.twig
+++ b/templates/cards/profile/view.html.twig
@@ -4,7 +4,7 @@
{% set actor_bio = actor.getBio() %}
{% block profile_view %}
-