Merged mass tag and post list redirection
This commit is contained in:
parent
acbd45d530
commit
7609cbcccf
4 changed files with 20 additions and 30 deletions
|
@ -43,7 +43,15 @@ class PostController extends AbstractController
|
|||
public function listRedirectAction($source = 'posts')
|
||||
{
|
||||
$context = Core::getContext();
|
||||
|
||||
if ($source == 'mass-tag')
|
||||
Access::assert(new Privilege(Privilege::MassTag));
|
||||
|
||||
$oldPage = intval(InputHelper::get('old-page'));
|
||||
$oldQuery = trim(InputHelper::get('old-query'));
|
||||
$query = trim(InputHelper::get('query'));
|
||||
$additionalInfo = trim(InputHelper::get('tag'));
|
||||
|
||||
$context->transport->searchQuery = $query;
|
||||
$context->transport->lastSearchQuery = $query;
|
||||
if (strpos($query, '/') !== false)
|
||||
|
@ -53,10 +61,15 @@ class PostController extends AbstractController
|
|||
$params['source'] = $source;
|
||||
if ($query)
|
||||
$params['query'] = $query;
|
||||
#if ($additionalInfo)
|
||||
# $params['additionalInfo'] = $additionalInfo;
|
||||
if ($additionalInfo)
|
||||
$params['additionalInfo'] = $additionalInfo;
|
||||
|
||||
if ($oldPage != 0 and $oldQuery == $query)
|
||||
$params['page'] = $oldPage;
|
||||
else
|
||||
$params['page'] = 1;
|
||||
|
||||
|
||||
$url = \Chibi\Router::linkTo(['PostController', 'listView'], $params);
|
||||
$this->redirect($url);
|
||||
}
|
||||
|
|
|
@ -131,30 +131,6 @@ class TagController extends AbstractController
|
|||
$this->renderViewWithSource('tag-list-wrapper', 'mass-tag');
|
||||
}
|
||||
|
||||
public function massTagRedirectAction()
|
||||
{
|
||||
Access::assert(new Privilege(Privilege::MassTag));
|
||||
$suppliedOldPage = intval(InputHelper::get('old-page'));
|
||||
$suppliedOldQuery = InputHelper::get('old-query');
|
||||
$suppliedQuery = InputHelper::get('query');
|
||||
$suppliedTag = InputHelper::get('tag');
|
||||
|
||||
$params =
|
||||
[
|
||||
'source' => 'mass-tag',
|
||||
'query' => trim($suppliedQuery ?: ''),
|
||||
'additionalInfo' => $suppliedTag ? $suppliedTag : '',
|
||||
];
|
||||
|
||||
if ($suppliedOldPage != 0 and $suppliedOldQuery == $suppliedQuery)
|
||||
$params['page'] = $suppliedOldPage;
|
||||
else
|
||||
$params['page'] = 1;
|
||||
|
||||
$url = \Chibi\Router::linkTo(['PostController', 'listView'], $params);
|
||||
$this->redirect($url);
|
||||
}
|
||||
|
||||
|
||||
private function renderViewWithSource($viewName, $source)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<div class="form-wrapper">
|
||||
<form method="post" action="<?= \Chibi\Router::linkTo(['TagController', 'massTagRedirectAction']) ?>">
|
||||
<form method="post" action="<?= \Chibi\Router::linkTo(
|
||||
['PostController', 'listRedirectAction'],
|
||||
['source' => 'mass-tag']) ?>">
|
||||
<h1>mass tag</h1>
|
||||
|
||||
<div class="form-row">
|
||||
|
|
|
@ -40,7 +40,7 @@ $postValidation =
|
|||
\Chibi\Router::register(['PostController', 'listView'], 'GET', '/{source}/{page}', $postValidation);
|
||||
\Chibi\Router::register(['PostController', 'listView'], 'GET', '/{source}/{query}/{page}', $postValidation);
|
||||
\Chibi\Router::register(['PostController', 'listView'], 'GET', '/{source}/{query}/{additionalInfo}/{page}', $postValidation);
|
||||
\Chibi\Router::register(['PostController', 'listRedirectAction'], 'POST', '/posts-redirect', $postValidation);
|
||||
\Chibi\Router::register(['PostController', 'listRedirectAction'], 'POST', '/{source}-redirect', $postValidation);
|
||||
|
||||
\Chibi\Router::register(['PostController', 'randomView'], 'GET', '/random', $postValidation);
|
||||
\Chibi\Router::register(['PostController', 'randomView'], 'GET', '/random/{page}', $postValidation);
|
||||
|
@ -91,7 +91,6 @@ $tagValidation =
|
|||
\Chibi\Router::register(['TagController', 'mergeView'], 'GET', '/tags-merge', $tagValidation);
|
||||
\Chibi\Router::register(['TagController', 'mergeAction'], 'POST', '/tags-merge', $tagValidation);
|
||||
\Chibi\Router::register(['TagController', 'massTagRedirectView'], 'GET', '/mass-tag-redirect', $tagValidation);
|
||||
\Chibi\Router::register(['TagController', 'massTagRedirectAction'], 'POST', '/mass-tag-redirect', $tagValidation);
|
||||
|
||||
$userValidation =
|
||||
[
|
||||
|
|
Loading…
Reference in a new issue