Mass tag: friendler pagination

If user is in mass tag mode and changes target tag but doesn't change the
query, he now remains at the same page. (Concerns only users who have disabled
endless scrolling.)
This commit is contained in:
Marcin Kurczewski 2014-02-22 23:51:25 +01:00
parent f783552820
commit 9eee8ba612
2 changed files with 13 additions and 5 deletions

View file

@ -103,13 +103,19 @@ class TagController
PrivilegesHelper::confirmWithException(Privilege::MassTag);
if (InputHelper::get('submit'))
{
$suppliedOldPage = intval(InputHelper::get('old-page'));
$suppliedOldQuery = InputHelper::get('old-query');
$suppliedQuery = InputHelper::get('query');
if (!$suppliedQuery)
$suppliedQuery = ' ';
$suppliedTag = InputHelper::get('tag');
if (!empty($suppliedTag))
$suppliedTag = TagModel::validateTag($suppliedTag);
\Chibi\UrlHelper::forward(\Chibi\UrlHelper::route('post', 'list', ['source' => 'mass-tag', 'query' => $suppliedQuery, 'additionalInfo' => $suppliedTag]));
$params = [
'source' => 'mass-tag',
'query' => $suppliedQuery ?: ' ',
'additionalInfo' => $suppliedTag ? TagModel::validateTag($suppliedTag) : '',
];
if ($suppliedOldPage != 0 and $suppliedOldQuery == $suppliedQuery)
$params['page'] = $suppliedOldPage;
\Chibi\UrlHelper::forward(\Chibi\UrlHelper::route('post', 'list', $params));
}
}
}

View file

@ -12,6 +12,8 @@
<div class="input-wrapper"><input class="autocomplete" type="text" name="tag" id="mass-tag-tag" value="<?php echo isset($this->context->massTagTag) ? htmlspecialchars($this->context->massTagTag) : '' ?>"/></div>
</div>
<input type="hidden" name="old-page" value="<?php echo isset($this->context->transport->paginator) ? htmlspecialchars($this->context->transport->paginator->page) : '' ?>"/>
<input type="hidden" name="old-query" value="<?php echo isset($this->context->massTagQuery) ? htmlspecialchars($this->context->massTagQuery) : '' ?>"/>
<input type="hidden" name="submit" value="1"/>
<div class="form-row">