namespace Shaarli\Front;
use Shaarli\Container\ShaarliContainer;
-use Shaarli\Front\Exception\ShaarliException;
+use Shaarli\Front\Exception\ShaarliFrontException;
+use Shaarli\Front\Exception\UnauthorizedException;
use Slim\Http\Request;
use Slim\Http\Response;
{
try {
$response = $next($request, $response);
- } catch (ShaarliException $e) {
+ } catch (ShaarliFrontException $e) {
$this->container->pageBuilder->assign('message', $e->getMessage());
if ($this->container->conf->get('dev.debug', false)) {
$this->container->pageBuilder->assign(
$response = $response->withStatus($e->getCode());
$response = $response->write($this->container->pageBuilder->render('error'));
+ } catch (UnauthorizedException $e) {
+ return $response->withRedirect($request->getUri()->getBasePath() . '/login');
}
return $response;
declare(strict_types=1);
-namespace Shaarli\Front\Controller;
+namespace Shaarli\Front\Controller\Admin;
use Shaarli\Security\LoginManager;
use Slim\Http\Request;
*
* Slim controller used to logout the user.
* It invalidates page cache and terminate the user session. Then it redirects to the homepage.
- *
- * @package Front\Controller
*/
-class LogoutController extends ShaarliController
+class LogoutController extends ShaarliAdminController
{
public function index(Request $request, Response $response): Response
{
declare(strict_types=1);
-namespace Shaarli\Front\Controller;
+namespace Shaarli\Front\Controller\Admin;
use Shaarli\Bookmark\BookmarkFilter;
use Shaarli\Security\SessionManager;
* Class SessionFilterController
*
* Slim controller used to handle filters stored in the user session, such as visibility, links per page, etc.
- *
- * @package Shaarli\Front\Controller
*/
-class SessionFilterController extends ShaarliController
+class SessionFilterController extends ShaarliAdminController
{
/**
* GET /links-per-page: set the number of bookmarks to display per page in homepage
abs(intval($linksPerPage))
);
- return $this->redirectFromReferer($response, ['linksperpage'], ['nb']);
+ return $this->redirectFromReferer($request, $response, ['linksperpage'], ['nb']);
}
/**
public function visibility(Request $request, Response $response, array $args): Response
{
if (false === $this->container->loginManager->isLoggedIn()) {
- return $this->redirectFromReferer($response, ['visibility']);
+ return $this->redirectFromReferer($request, $response, ['visibility']);
}
$newVisibility = $args['visibility'] ?? null;
$this->container->sessionManager->deleteSessionParameter(SessionManager::KEY_VISIBILITY);
}
- return $this->redirectFromReferer($response, ['visibility']);
+ return $this->redirectFromReferer($request, $response, ['visibility']);
}
/**
empty($this->container->sessionManager->getSessionParameter(SessionManager::KEY_UNTAGGED_ONLY))
);
- return $this->redirectFromReferer($response, ['untaggedonly', 'untagged-only']);
+ return $this->redirectFromReferer($request, $response, ['untaggedonly', 'untagged-only']);
}
}
--- /dev/null
+<?php
+
+declare(strict_types=1);
+
+namespace Shaarli\Front\Controller\Admin;
+
+use Shaarli\Container\ShaarliContainer;
+use Shaarli\Front\Controller\Visitor\ShaarliVisitorController;
+use Shaarli\Front\Exception\UnauthorizedException;
+
+abstract class ShaarliAdminController extends ShaarliVisitorController
+{
+ public function __construct(ShaarliContainer $container)
+ {
+ parent::__construct($container);
+
+ if (true !== $this->container->loginManager->isLoggedIn()) {
+ throw new UnauthorizedException();
+ }
+ }
+}
declare(strict_types=1);
-namespace Shaarli\Front\Controller;
+namespace Shaarli\Front\Controller\Visitor;
use DateTime;
use DateTimeImmutable;
* Class DailyController
*
* Slim controller used to render the daily page.
- *
- * @package Front\Controller
*/
-class DailyController extends ShaarliController
+class DailyController extends ShaarliVisitorController
{
public static $DAILY_RSS_NB_DAYS = 8;
declare(strict_types=1);
-namespace Shaarli\Front\Controller;
+namespace Shaarli\Front\Controller\Visitor;
use Shaarli\Feed\FeedBuilder;
use Slim\Http\Request;
* Class FeedController
*
* Slim controller handling ATOM and RSS feed.
- *
- * @package Front\Controller
*/
-class FeedController extends ShaarliController
+class FeedController extends ShaarliVisitorController
{
public function atom(Request $request, Response $response): Response
{
declare(strict_types=1);
-namespace Shaarli\Front\Controller;
+namespace Shaarli\Front\Controller\Visitor;
use Shaarli\Front\Exception\LoginBannedException;
use Slim\Http\Request;
*
* The login page is not available if the user is banned
* or if open shaarli setting is enabled.
- *
- * @package Front\Controller
*/
-class LoginController extends ShaarliController
+class LoginController extends ShaarliVisitorController
{
public function index(Request $request, Response $response): Response
{
declare(strict_types=1);
-namespace Shaarli\Front\Controller;
+namespace Shaarli\Front\Controller\Visitor;
use Slim\Http\Request;
use Slim\Http\Response;
*
* Slim controller used to render open search template.
* This allows to add Shaarli as a search engine within the browser.
- *
- * @package front\controllers
*/
-class OpenSearchController extends ShaarliController
+class OpenSearchController extends ShaarliVisitorController
{
public function index(Request $request, Response $response): Response
{
declare(strict_types=1);
-namespace Shaarli\Front\Controller;
+namespace Shaarli\Front\Controller\Visitor;
use Shaarli\Front\Exception\ThumbnailsDisabledException;
use Shaarli\Thumbnailer;
*
* Slim controller used to render the pictures wall page.
* If thumbnails mode is set to NONE, we just render the template without any image.
- *
- * @package Front\Controller
*/
-class PictureWallController extends ShaarliController
+class PictureWallController extends ShaarliVisitorController
{
public function index(Request $request, Response $response): Response
{
declare(strict_types=1);
-namespace Shaarli\Front\Controller;
+namespace Shaarli\Front\Controller\Visitor;
use Shaarli\Bookmark\BookmarkFilter;
use Shaarli\Container\ShaarliContainer;
+use Slim\Http\Request;
use Slim\Http\Response;
-abstract class ShaarliController
+abstract class ShaarliVisitorController
{
/** @var ShaarliContainer */
protected $container;
* @param array $loopTerms Terms to remove from path and query string to prevent direction loop.
* @param array $clearParams List of parameter to remove from the query string of the referrer.
*/
- protected function redirectFromReferer(Response $response, array $loopTerms = [], array $clearParams = []): Response
- {
- $defaultPath = './';
+ protected function redirectFromReferer(
+ Request $request,
+ Response $response,
+ array $loopTerms = [],
+ array $clearParams = []
+ ): Response {
+ $defaultPath = $request->getUri()->getBasePath();
$referer = $this->container->environment['HTTP_REFERER'] ?? null;
if (null !== $referer) {
declare(strict_types=1);
-namespace Shaarli\Front\Controller;
+namespace Shaarli\Front\Controller\Visitor;
use Slim\Http\Request;
use Slim\Http\Response;
* Class TagCloud
*
* Slim controller used to render the tag cloud and tag list pages.
- *
- * @package Front\Controller
*/
-class TagCloudController extends ShaarliController
+class TagCloudController extends ShaarliVisitorController
{
protected const TYPE_CLOUD = 'cloud';
protected const TYPE_LIST = 'list';
declare(strict_types=1);
-namespace Shaarli\Front\Controller;
+namespace Shaarli\Front\Controller\Visitor;
use Slim\Http\Request;
use Slim\Http\Response;
* Class TagController
*
* Slim controller handle tags.
- *
- * @package Front\Controller
*/
-class TagController extends ShaarliController
+class TagController extends ShaarliVisitorController
{
/**
* Add another tag in the current search through an HTTP redirection.
namespace Shaarli\Front\Exception;
-class LoginBannedException extends ShaarliException
+class LoginBannedException extends ShaarliFrontException
{
public function __construct()
{
*
* @package Front\Exception
*/
-abstract class ShaarliException extends \Exception
+abstract class ShaarliFrontException extends \Exception
{
/** Override parent constructor to force $message and $httpCode parameters to be set. */
public function __construct(string $message, int $httpCode, Throwable $previous = null)
namespace Shaarli\Front\Exception;
-class ThumbnailsDisabledException extends ShaarliException
+class ThumbnailsDisabledException extends ShaarliFrontException
{
public function __construct()
{
--- /dev/null
+<?php
+
+declare(strict_types=1);
+
+namespace Shaarli\Front\Exception;
+
+/**
+ * Class UnauthorizedException
+ *
+ * Exception raised if the user tries to access a ShaarliAdminController while logged out.
+ */
+class UnauthorizedException extends \Exception
+{
+
+}
"Shaarli\\Feed\\": "application/feed",
"Shaarli\\Formatter\\": "application/formatter",
"Shaarli\\Front\\": "application/front",
- "Shaarli\\Front\\Controller\\": "application/front/controllers",
+ "Shaarli\\Front\\Controller\\Admin\\": "application/front/controller/admin",
+ "Shaarli\\Front\\Controller\\Visitor\\": "application/front/controller/visitor",
"Shaarli\\Front\\Exception\\": "application/front/exceptions",
"Shaarli\\Http\\": "application/http",
"Shaarli\\Legacy\\": "application/legacy",
http://<replace_domain>/?do=changetag
http://<replace_domain>/?do=configure
http://<replace_domain>/?do=tools
-http://<replace_domain>/?do=daily
+http://<replace_domain>/daily
http://<replace_domain>/?post
http://<replace_domain>/?do=export
http://<replace_domain>/?do=import
})->add('\Shaarli\Api\ApiMiddleware');
$app->group('', function () {
- $this->get('/login', '\Shaarli\Front\Controller\LoginController:index')->setName('login');
- $this->get('/logout', '\Shaarli\Front\Controller\LogoutController:index')->setName('logout');
- $this->get('/picture-wall', '\Shaarli\Front\Controller\PictureWallController:index')->setName('picwall');
- $this->get('/tag-cloud', '\Shaarli\Front\Controller\TagCloudController:cloud')->setName('tagcloud');
- $this->get('/tag-list', '\Shaarli\Front\Controller\TagCloudController:list')->setName('taglist');
- $this->get('/daily', '\Shaarli\Front\Controller\DailyController:index')->setName('daily');
- $this->get('/daily-rss', '\Shaarli\Front\Controller\DailyController:rss')->setName('dailyrss');
- $this->get('/feed-atom', '\Shaarli\Front\Controller\FeedController:atom')->setName('feedatom');
- $this->get('/feed-rss', '\Shaarli\Front\Controller\FeedController:rss')->setName('feedrss');
- $this->get('/open-search', '\Shaarli\Front\Controller\OpenSearchController:index')->setName('opensearch');
-
- $this->get('/add-tag/{newTag}', '\Shaarli\Front\Controller\TagController:addTag')->setName('add-tag');
- $this->get('/remove-tag/{tag}', '\Shaarli\Front\Controller\TagController:removeTag')->setName('remove-tag');
+ /* -- PUBLIC --*/
+ $this->get('/login', '\Shaarli\Front\Controller\Visitor\LoginController:index')->setName('login');
+ $this->get('/picture-wall', '\Shaarli\Front\Controller\Visitor\PictureWallController:index')->setName('picwall');
+ $this->get('/tag-cloud', '\Shaarli\Front\Controller\Visitor\TagCloudController:cloud')->setName('tagcloud');
+ $this->get('/tag-list', '\Shaarli\Front\Controller\Visitor\TagCloudController:list')->setName('taglist');
+ $this->get('/daily', '\Shaarli\Front\Controller\Visitor\DailyController:index')->setName('daily');
+ $this->get('/daily-rss', '\Shaarli\Front\Controller\Visitor\DailyController:rss')->setName('dailyrss');
+ $this->get('/feed-atom', '\Shaarli\Front\Controller\Visitor\FeedController:atom')->setName('feedatom');
+ $this->get('/feed-rss', '\Shaarli\Front\Controller\Visitor\FeedController:rss')->setName('feedrss');
+ $this->get('/open-search', '\Shaarli\Front\Controller\Visitor\OpenSearchController:index')->setName('opensearch');
+
+ $this->get('/add-tag/{newTag}', '\Shaarli\Front\Controller\Visitor\TagController:addTag')->setName('add-tag');
+ $this->get('/remove-tag/{tag}', '\Shaarli\Front\Controller\Visitor\TagController:removeTag')->setName('remove-tag');
+
+ /* -- LOGGED IN -- */
+ $this->get('/logout', '\Shaarli\Front\Controller\Admin\LogoutController:index')->setName('logout');
$this
- ->get('/links-per-page', '\Shaarli\Front\Controller\SessionFilterController:linksPerPage')
+ ->get('/links-per-page', '\Shaarli\Front\Controller\Admin\SessionFilterController:linksPerPage')
->setName('filter-links-per-page')
;
$this
- ->get('/visibility/{visibility}', '\Shaarli\Front\Controller\SessionFilterController:visibility')
+ ->get('/visibility/{visibility}', '\Shaarli\Front\Controller\Admin\SessionFilterController:visibility')
->setName('visibility')
;
$this
- ->get('/untagged-only', '\Shaarli\Front\Controller\SessionFilterController:untaggedOnly')
+ ->get('/untagged-only', '\Shaarli\Front\Controller\Admin\SessionFilterController:untaggedOnly')
->setName('untagged-only')
;
})->add('\Shaarli\Front\ShaarliMiddleware');
require_once 'tests/utils/ReferenceHistory.php';
require_once 'tests/utils/FakeBookmarkService.php';
require_once 'tests/container/ShaarliTestContainer.php';
-require_once 'tests/front/controller/FrontControllerMockHelper.php';
+require_once 'tests/front/controller/visitor/FrontControllerMockHelper.php';
+require_once 'tests/front/controller/admin/FrontAdminControllerMockHelper.php';
--- /dev/null
+<?php
+
+declare(strict_types=1);
+
+namespace Shaarli\Front\Controller\Admin;
+
+use Shaarli\Container\ShaarliTestContainer;
+use Shaarli\Front\Controller\Visitor\FrontControllerMockHelper;
+use Shaarli\Security\LoginManager;
+
+/**
+ * Trait FrontControllerMockHelper
+ *
+ * Helper trait used to initialize the ShaarliContainer and mock its services for admin controller tests.
+ *
+ * @property ShaarliTestContainer $container
+ */
+trait FrontAdminControllerMockHelper
+{
+ use FrontControllerMockHelper {
+ FrontControllerMockHelper::createContainer as parentCreateContainer;
+ }
+
+ /**
+ * Mock the container instance
+ */
+ protected function createContainer(): void
+ {
+ $this->parentCreateContainer();
+
+ $this->container->loginManager = $this->createMock(LoginManager::class);
+ $this->container->loginManager->method('isLoggedIn')->willReturn(true);
+ }
+}
declare(strict_types=1);
-namespace Shaarli\Front\Controller;
+namespace Shaarli\Front\Controller\Admin;
/** Override PHP builtin setcookie function in the local namespace to mock it... more or less */
if (!function_exists('Shaarli\Front\Controller\setcookie')) {
class LogoutControllerTest extends TestCase
{
- use FrontControllerMockHelper;
+ use FrontAdminControllerMockHelper;
/** @var LogoutController */
protected $controller;
declare(strict_types=1);
-namespace Shaarli\Front\Controller;
+namespace Shaarli\Front\Controller\Admin;
use PHPUnit\Framework\TestCase;
+use Shaarli\Security\LoginManager;
use Shaarli\Security\SessionManager;
use Slim\Http\Request;
use Slim\Http\Response;
+use Slim\Http\Uri;
class SessionFilterControllerTest extends TestCase
{
- use FrontControllerMockHelper;
+ use FrontAdminControllerMockHelper;
/** @var SessionFilterController */
protected $controller;
$this->container->environment = ['HTTP_REFERER' => 'http://shaarli/subfolder/controller/?searchtag=abc'];
$request = $this->createMock(Request::class);
+ $request->method('getUri')->willReturnCallback(function (): Uri {
+ $uri = $this->createMock(Uri::class);
+ $uri->method('getBasePath')->willReturn('/subfolder');
+
+ return $uri;
+ });
$request->method('getParam')->with('nb')->willReturn('8');
$response = new Response();
$this->createValidContainerMockSet();
$request = $this->createMock(Request::class);
+ $request->method('getUri')->willReturnCallback(function (): Uri {
+ $uri = $this->createMock(Uri::class);
+ $uri->method('getBasePath')->willReturn('/subfolder');
+
+ return $uri;
+ });
$request->method('getParam')->with('nb')->willReturn('test');
$response = new Response();
static::assertInstanceOf(Response::class, $result);
static::assertSame(302, $result->getStatusCode());
- static::assertSame(['./'], $result->getHeader('location'));
+ static::assertSame(['/subfolder'], $result->getHeader('location'));
}
/**
;
$request = $this->createMock(Request::class);
+ $request->method('getUri')->willReturnCallback(function (): Uri {
+ $uri = $this->createMock(Uri::class);
+ $uri->method('getBasePath')->willReturn('/subfolder');
+
+ return $uri;
+ });
$response = new Response();
$result = $this->controller->visibility($request, $response, $arg);
;
$request = $this->createMock(Request::class);
+ $request->method('getUri')->willReturnCallback(function (): Uri {
+ $uri = $this->createMock(Uri::class);
+ $uri->method('getBasePath')->willReturn('/subfolder');
+
+ return $uri;
+ });
$response = new Response();
$result = $this->controller->visibility($request, $response, $arg);
;
$request = $this->createMock(Request::class);
+ $request->method('getUri')->willReturnCallback(function (): Uri {
+ $uri = $this->createMock(Uri::class);
+ $uri->method('getBasePath')->willReturn('/subfolder');
+
+ return $uri;
+ });
$response = new Response();
$result = $this->controller->visibility($request, $response, $arg);
static::assertInstanceOf(Response::class, $result);
static::assertSame(302, $result->getStatusCode());
- static::assertSame(['./'], $result->getHeader('location'));
+ static::assertSame(['/subfolder'], $result->getHeader('location'));
}
/**
;
$request = $this->createMock(Request::class);
+ $request->method('getUri')->willReturnCallback(function (): Uri {
+ $uri = $this->createMock(Uri::class);
+ $uri->method('getBasePath')->willReturn('/subfolder');
+
+ return $uri;
+ });
$response = new Response();
$result = $this->controller->visibility($request, $response, $arg);
$this->container->environment = ['HTTP_REFERER' => 'http://shaarli/subfolder/controller/?searchtag=abc'];
+ $this->container->loginManager = $this->createMock(LoginManager::class);
$this->container->loginManager->method('isLoggedIn')->willReturn(false);
$this->container->sessionManager
->expects(static::never())
;
$request = $this->createMock(Request::class);
+ $request->method('getUri')->willReturnCallback(function (): Uri {
+ $uri = $this->createMock(Uri::class);
+ $uri->method('getBasePath')->willReturn('/subfolder');
+
+ return $uri;
+ });
$response = new Response();
$result = $this->controller->visibility($request, $response, $arg);
$this->container->environment = ['HTTP_REFERER' => 'http://shaarli/subfolder/controller/?searchtag=abc'];
$request = $this->createMock(Request::class);
+ $request->method('getUri')->willReturnCallback(function (): Uri {
+ $uri = $this->createMock(Uri::class);
+ $uri->method('getBasePath')->willReturn('/subfolder');
+
+ return $uri;
+ });
$response = new Response();
$this->container->sessionManager
$this->container->environment = ['HTTP_REFERER' => 'http://shaarli/subfolder/controller/?searchtag=abc'];
$request = $this->createMock(Request::class);
+ $request->method('getUri')->willReturnCallback(function (): Uri {
+ $uri = $this->createMock(Uri::class);
+ $uri->method('getBasePath')->willReturn('/subfolder');
+
+ return $uri;
+ });
+
$response = new Response();
$this->container->sessionManager
declare(strict_types=1);
-namespace Shaarli\Front\Controller;
+namespace Shaarli\Front\Controller\Visitor;
use PHPUnit\Framework\TestCase;
use Shaarli\Bookmark\Bookmark;
declare(strict_types=1);
-namespace Shaarli\Front\Controller;
+namespace Shaarli\Front\Controller\Visitor;
use PHPUnit\Framework\TestCase;
use Shaarli\Feed\FeedBuilder;
declare(strict_types=1);
-namespace Shaarli\Front\Controller;
+namespace Shaarli\Front\Controller\Visitor;
use PHPUnit\Framework\MockObject\MockObject;
use Shaarli\Bookmark\BookmarkServiceInterface;
declare(strict_types=1);
-namespace Shaarli\Front\Controller;
+namespace Shaarli\Front\Controller\Visitor;
use PHPUnit\Framework\TestCase;
use Shaarli\Config\ConfigManager;
declare(strict_types=1);
-namespace front\controller;
+namespace Shaarli\Front\Controller\Visitor;
use PHPUnit\Framework\TestCase;
-use Shaarli\Front\Controller\FrontControllerMockHelper;
-use Shaarli\Front\Controller\OpenSearchController;
use Slim\Http\Request;
use Slim\Http\Response;
declare(strict_types=1);
-namespace Shaarli\Front\Controller;
+namespace Shaarli\Front\Controller\Visitor;
use PHPUnit\Framework\TestCase;
use Shaarli\Bookmark\Bookmark;
declare(strict_types=1);
-namespace Shaarli\Front\Controller;
+namespace Shaarli\Front\Controller\Visitor;
use PHPUnit\Framework\TestCase;
use Shaarli\Bookmark\BookmarkFilter;
+use Slim\Http\Request;
use Slim\Http\Response;
+use Slim\Http\Uri;
/**
* Class ShaarliControllerTest
/** @var mixed[] List of variable assigned to the template */
protected $assignedValues;
+ /** @var Request */
+ protected $request;
+
public function setUp(): void
{
$this->createContainer();
- $this->controller = new class($this->container) extends ShaarliController
+ $this->controller = new class($this->container) extends ShaarliVisitorController
{
- public function assignView(string $key, $value): ShaarliController
+ public function assignView(string $key, $value): ShaarliVisitorController
{
return parent::assignView($key, $value);
}
}
public function redirectFromReferer(
+ Request $request,
Response $response,
array $loopTerms = [],
array $clearParams = []
): Response {
- return parent::redirectFromReferer($response, $loopTerms, $clearParams);
+ return parent::redirectFromReferer($request, $response, $loopTerms, $clearParams);
}
};
$this->assignedValues = [];
+
+ $this->request = $this->createMock(Request::class);
+ $this->request->method('getUri')->willReturnCallback(function (): Uri {
+ $uri = $this->createMock(Uri::class);
+ $uri->method('getBasePath')->willReturn('/subfolder');
+
+ return $uri;
+ });
}
public function testAssignView(): void
$self = $this->controller->assignView('variableName', 'variableValue');
- static::assertInstanceOf(ShaarliController::class, $self);
+ static::assertInstanceOf(ShaarliVisitorController::class, $self);
static::assertSame('variableValue', $this->assignedValues['variableName']);
}
$response = new Response();
- $result = $this->controller->redirectFromReferer($response);
+ $result = $this->controller->redirectFromReferer($this->request, $response);
static::assertSame(302, $result->getStatusCode());
static::assertSame(['/subfolder/controller?query=param&other=2'], $result->getHeader('location'));
$response = new Response();
- $result = $this->controller->redirectFromReferer($response, ['nope']);
+ $result = $this->controller->redirectFromReferer($this->request, $response, ['nope']);
static::assertSame(302, $result->getStatusCode());
static::assertSame(['/subfolder/controller?query=param&other=2'], $result->getHeader('location'));
$response = new Response();
- $result = $this->controller->redirectFromReferer($response, ['nope', 'controller']);
+ $result = $this->controller->redirectFromReferer($this->request, $response, ['nope', 'controller']);
static::assertSame(302, $result->getStatusCode());
- static::assertSame(['./'], $result->getHeader('location'));
+ static::assertSame(['/subfolder'], $result->getHeader('location'));
}
/**
$response = new Response();
- $result = $this->controller->redirectFromReferer($response, ['nope', 'other']);
+ $result = $this->controller->redirectFromReferer($this->request, $response, ['nope', 'other']);
static::assertSame(302, $result->getStatusCode());
- static::assertSame(['./'], $result->getHeader('location'));
+ static::assertSame(['/subfolder'], $result->getHeader('location'));
}
/**
$response = new Response();
- $result = $this->controller->redirectFromReferer($response, ['nope', 'param']);
+ $result = $this->controller->redirectFromReferer($this->request, $response, ['nope', 'param']);
static::assertSame(302, $result->getStatusCode());
static::assertSame(['/subfolder/controller?query=param&other=2'], $result->getHeader('location'));
$response = new Response();
- $result = $this->controller->redirectFromReferer($response, ['shaarli']);
+ $result = $this->controller->redirectFromReferer($this->request, $response, ['shaarli']);
static::assertSame(302, $result->getStatusCode());
static::assertSame(['/subfolder/controller?query=param&other=2'], $result->getHeader('location'));
$response = new Response();
- $result = $this->controller->redirectFromReferer($response, ['query'], ['query']);
+ $result = $this->controller->redirectFromReferer($this->request, $response, ['query'], ['query']);
static::assertSame(302, $result->getStatusCode());
static::assertSame(['/subfolder/controller?other=2'], $result->getHeader('location'));
declare(strict_types=1);
-namespace Shaarli\Front\Controller;
+namespace Shaarli\Front\Controller\Visitor;
use PHPUnit\Framework\TestCase;
use Shaarli\Bookmark\BookmarkFilter;
declare(strict_types=1);
-namespace Shaarli\Front\Controller;
+namespace Shaarli\Front\Controller\Visitor;
use PHPUnit\Framework\TestCase;
use Slim\Http\Request;
{
use FrontControllerMockHelper;
- /** @var TagController */
- protected $controller;
+ /** @var TagController */ protected $controller;
public function setUp(): void
{
</li>
{/if}
<li class="pure-menu-item" id="shaarli-menu-daily">
- <a href="./?do=daily" class="pure-menu-link">{'Daily'|t}</a>
+ <a href="./daily" class="pure-menu-link">{'Daily'|t}</a>
</li>
{loop="$plugins_header.buttons_toolbar"}
<li class="pure-menu-item shaarli-menu-plugin">
<div class="dailyAbout">
All links of one day<br>in a single page.<br>
- {if="$previousday"} <a href="./?do=daily&day={$previousday}"><b><</b>Previous day</a>{else}<b><</b>Previous day{/if}
+ {if="$previousday"} <a href="./daily&day={$previousday}"><b><</b>Previous day</a>{else}<b><</b>Previous day{/if}
-
- {if="$nextday"}<a href="./?do=daily&day={$nextday}">Next day<b>></b></a>{else}Next day<b>></b>{/if}
+ {if="$nextday"}<a href="./daily&day={$nextday}">Next day<b>></b></a>{else}Next day<b>></b>{/if}
<br>
{loop="$daily_about_plugin"}
{/if}
<li><a href="./tag-cloud">Tag cloud</a></li>
<li><a href="./picture-wall{function="ltrim($searchcrits, '&')"}">Picture wall</a></li>
- <li><a href="./?do=daily">Daily</a></li>
+ <li><a href="./daily">Daily</a></li>
{loop="$plugins_header.buttons_toolbar"}
<li><a
{loop="$value.attr"}