diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/Core/Lexer.php | 4 | ||||
-rw-r--r-- | app/Model/TaskFilter.php | 50 | ||||
-rw-r--r-- | app/Template/search/index.php | 17 |
3 files changed, 68 insertions, 3 deletions
diff --git a/app/Core/Lexer.php b/app/Core/Lexer.php index ad0631d5..d277f998 100644 --- a/app/Core/Lexer.php +++ b/app/Core/Lexer.php @@ -31,6 +31,8 @@ class Lexer "/^(status:)/" => 'T_STATUS', "/^(description:)/" => 'T_DESCRIPTION', "/^(category:)/" => 'T_CATEGORY', + "/^(column:)/" => 'T_COLUMN', + "/^(project:)/" => 'T_PROJECT', "/^(\s+)/" => 'T_WHITESPACE', '/^([<=>]{0,2}[0-9]{4}-[0-9]{2}-[0-9]{2})/' => 'T_DATE', '/^(yesterday|tomorrow|today)/' => 'T_DATE', @@ -109,6 +111,8 @@ class Lexer case 'T_ASSIGNEE': case 'T_COLOR': case 'T_CATEGORY': + case 'T_COLUMN': + case 'T_PROJECT': $next = next($tokens); if ($next !== false && $next['token'] === 'T_STRING') { diff --git a/app/Model/TaskFilter.php b/app/Model/TaskFilter.php index 4a086078..31080cb5 100644 --- a/app/Model/TaskFilter.php +++ b/app/Model/TaskFilter.php @@ -62,6 +62,12 @@ class TaskFilter extends Base case 'T_CATEGORY': $this->filterByCategoryName($value); break; + case 'T_PROJECT': + $this->filterByProjectName($value); + break; + case 'T_COLUMN': + $this->filterByColumnName($value); + break; } } @@ -190,6 +196,29 @@ class TaskFilter extends Base } /** + * Filter by project name + * + * @access public + * @param array $values List of project name + * @return TaskFilter + */ + public function filterByProjectName(array $values) + { + $this->query->beginOr(); + + foreach ($values as $project) { + if (ctype_digit($project)) { + $this->query->eq(Task::TABLE.'.project_id', $project); + } + else { + $this->query->ilike(Project::TABLE.'.name', $project); + } + } + + $this->query->closeOr(); + } + + /** * Filter by category id * * @access public @@ -326,6 +355,24 @@ class TaskFilter extends Base } /** + * Filter by column name + * + * @access public + * @param array $values List of column name + * @return TaskFilter + */ + public function filterByColumnName(array $values) + { + $this->query->beginOr(); + + foreach ($values as $project) { + $this->query->ilike(Board::TABLE.'.title', $project); + } + + $this->query->closeOr(); + } + + /** * Filter by swimlane * * @access public @@ -382,7 +429,6 @@ class TaskFilter extends Base */ public function filterByDueDate($date) { - $this->query->neq(Task::TABLE.'.date_due', ''); $this->query->neq(Task::TABLE.'.date_due', 0); $this->query->notNull(Task::TABLE.'.date_due'); return $this->filterWithOperator(Task::TABLE.'.date_due', $date, true); @@ -452,7 +498,7 @@ class TaskFilter extends Base */ public function findAll() { - return $this->query->findAll(); + return $this->query->asc(Task::TABLE.'.id')->findAll(); } /** diff --git a/app/Template/search/index.php b/app/Template/search/index.php index 058f428d..47a926f4 100644 --- a/app/Template/search/index.php +++ b/app/Template/search/index.php @@ -15,7 +15,22 @@ <input type="submit" value="<?= t('Search') ?>" class="btn btn-blue"/> </form> - <?php if (! empty($values['search']) && $paginator->isEmpty()): ?> + <?php if (empty($values['search'])): ?> + <div class="listing"> + <h3><?= t('Advanced search') ?></h3> + <p><?= t('Example of query: ') ?><strong>project:"My project" assignee:me due:tomorrow</strong></p> + <ul> + <li><?= t('Search by project: ') ?><strong>project:"My project"</strong></li> + <li><?= t('Search by column: ') ?><strong>column:"Work in progress"</strong></li> + <li><?= t('Search by assignee: ') ?><strong>assignee:nobody</strong></li> + <li><?= t('Search by color: ') ?><strong>color:Blue</strong></li> + <li><?= t('Search by category: ') ?><strong>category:"Feature Request"</strong></li> + <li><?= t('Search by description: ') ?><strong>description:"Something to find"</strong></li> + <li><?= t('Search by due date: ') ?><strong>due:2015-07-01</strong></li> + </ul> + <p><a href="http://kanboard.net/documentation/search" target="_blank"><?= t('More examples in the documentation') ?></a></p> + </div> + <?php elseif (! empty($values['search']) && $paginator->isEmpty()): ?> <p class="alert"><?= t('Nothing found.') ?></p> <?php elseif (! $paginator->isEmpty()): ?> <?= $this->render('search/results', array( |