[PLUGINS][MediaFeed] Fixed template path typos

This commit is contained in:
Eliseu Amaro 2021-12-23 18:12:49 +00:00 committed by Diogo Peralta Cordeiro
parent 1e7a285ded
commit f10b3bb05c
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0
2 changed files with 18 additions and 14 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
declare(strict_types=1); declare(strict_types = 1);
// {{{ License // {{{ License
// This file is part of GNU social - https://www.gnu.org/software/social // This file is part of GNU social - https://www.gnu.org/software/social
@ -23,6 +23,7 @@ declare(strict_types=1);
* *
* @package GNUsocial * @package GNUsocial
* @category Plugin * @category Plugin
*
* @author Phablulo <phablulo@gmail.com> * @author Phablulo <phablulo@gmail.com>
* @copyright 2018-2019, 2021 Free Software Foundation, Inc http://www.fsf.org * @copyright 2018-2019, 2021 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
@ -31,11 +32,11 @@ declare(strict_types=1);
namespace Plugin\MediaFeed; namespace Plugin\MediaFeed;
use App\Core\Event; use App\Core\Event;
use App\Entity\Note;
use Functional as F;
use App\Entity\Actor;
use App\Util\Formatting;
use App\Core\Modules\Plugin; use App\Core\Modules\Plugin;
use App\Entity\Actor;
use App\Entity\Note;
use App\Util\Formatting;
use Functional as F;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
class MediaFeed extends Plugin class MediaFeed extends Plugin
@ -47,38 +48,41 @@ class MediaFeed extends Plugin
} }
return Event::next; return Event::next;
} }
/** /**
* Draw the media feed navigation. * Draw the media feed navigation.
* @return bool hook value; true means continue processing, false means stop. *
* @return bool hook value; true means continue processing, false means stop
*/ */
public function onBeforeFeed(Request $request, &$res): bool public function onBeforeFeed(Request $request, &$res): bool
{ {
$isMediaActive = $request->get('filter-type') === 'media'; $isMediaActive = $request->get('filter-type') === 'media';
// we need two urls: one with filter-type=media and without it. // we need two urls: one with filter-type=media and without it.
$query = strpos($request->getRequestUri(), '?'); $query = mb_strpos($request->getRequestUri(), '?');
$mediaURL = $request->getRequestUri() . ($query !== false ? '&' : '?') . 'filter-type=media'; $mediaURL = $request->getRequestUri() . ($query !== false ? '&' : '?') . 'filter-type=media';
$allURL = $request->getPathInfo(); $allURL = $request->getPathInfo();
if ($query !== false) { if ($query !== false) {
$params = explode('&', substr($request->getRequestUri(), $query + 1)); $params = explode('&', mb_substr($request->getRequestUri(), $query + 1));
$params = array_filter($params, fn ($s) => $s !== 'filter-type=media'); $params = array_filter($params, fn ($s) => $s !== 'filter-type=media');
$params = implode('&', $params); $params = implode('&', $params);
if ($params) { if ($params) {
$allURL .= '?' . $params; $allURL .= '?' . $params;
} }
} }
$res[] = Formatting::twigRenderFile('mediaFeeed/tabs.html.twig', [ $res[] = Formatting::twigRenderFile('mediaFeed/tabs.html.twig', [
'main' => [ 'main' => [
'active' => !$isMediaActive, 'active' => !$isMediaActive,
'url' => $isMediaActive ? $allURL : '', 'url' => $isMediaActive ? $allURL : '',
], ],
'media' => [ 'media' => [
'active' => $isMediaActive, 'active' => $isMediaActive,
'url' => $isMediaActive ? '' : $mediaURL, 'url' => $isMediaActive ? '' : $mediaURL,
] ],
]); ]);
return Event::next; return Event::next;
} }
/** /**
* Output our dedicated stylesheet * Output our dedicated stylesheet
* *