Added ability to search tags by creation/edit time

This commit is contained in:
rr- 2015-11-24 21:56:07 +01:00
parent d769eaed61
commit 96195f0efc
2 changed files with 25 additions and 8 deletions

View file

@ -10,6 +10,8 @@ class TagFilter extends BasicFilter implements IFilter
const ORDER_USAGE_COUNT = 'usages'; const ORDER_USAGE_COUNT = 'usages';
const REQUIREMENT_PARTIAL_TAG_NAME = 'partialTagName'; const REQUIREMENT_PARTIAL_TAG_NAME = 'partialTagName';
const REQUIREMENT_CREATION_TIME = 'creationTime';
const REQUIREMENT_LAST_EDIT_TIME = 'lastEditTime';
const REQUIREMENT_CATEGORY = 'category'; const REQUIREMENT_CATEGORY = 'category';
public function __construct() public function __construct()

View file

@ -24,18 +24,33 @@ class TagSearchParser extends AbstractSearchParser
$filter->addRequirement($requirement); $filter->addRequirement($requirement);
} }
protected function decorateFilterFromNamedToken(IFilter $filter, NamedSearchToken $namedToken) protected function decorateFilterFromNamedToken(IFilter $filter, NamedSearchToken $token)
{ {
if ($this->matches($namedToken->getKey(), ['category'])) if ($this->matches($token->getKey(), ['creation_time', 'creation_date', 'date']))
{ {
return $this->addRequirementFromToken( $this->addRequirementFromDateRangeToken(
$filter, $filter, $token, TagFilter::REQUIREMENT_CREATION_TIME);
$namedToken, return;
TagFilter::REQUIREMENT_CATEGORY,
self::ALLOW_COMPOSITE);
} }
throw new NotSupportedException('Unknown token: ' . $namedToken->getKey()); if ($this->matches($token->getKey(), ['edit_time', 'edit_date']))
{
$this->addRequirementFromDateRangeToken(
$filter, $token, TagFilter::REQUIREMENT_LAST_EDIT_TIME);
return;
}
if ($this->matches($token->getKey(), ['category']))
{
$this->addRequirementFromToken(
$filter,
$token,
TagFilter::REQUIREMENT_CATEGORY,
self::ALLOW_COMPOSITE);
return;
}
throw new NotSupportedException('Unknown token: ' . $token->getKey());
} }
protected function getOrderColumnMap() protected function getOrderColumnMap()