Rename controllers
This commit is contained in:
67
app/Controller/SearchController.php
Normal file
67
app/Controller/SearchController.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace Kanboard\Controller;
|
||||
|
||||
use Kanboard\Filter\TaskProjectsFilter;
|
||||
|
||||
/**
|
||||
* Search Controller
|
||||
*
|
||||
* @package Kanboard\Controller
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class SearchController extends BaseController
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$projects = $this->projectUserRole->getProjectsByUser($this->userSession->getId());
|
||||
$search = urldecode($this->request->getStringParam('search'));
|
||||
$nb_tasks = 0;
|
||||
|
||||
$paginator = $this->paginator
|
||||
->setUrl('SearchController', 'index', array('search' => $search))
|
||||
->setMax(30)
|
||||
->setOrder('tasks.id')
|
||||
->setDirection('DESC');
|
||||
|
||||
if ($search !== '' && ! empty($projects)) {
|
||||
$paginator
|
||||
->setQuery($this->taskLexer
|
||||
->build($search)
|
||||
->withFilter(new TaskProjectsFilter(array_keys($projects)))
|
||||
->getQuery()
|
||||
)
|
||||
->calculate();
|
||||
|
||||
$nb_tasks = $paginator->getTotal();
|
||||
}
|
||||
|
||||
$this->response->html($this->helper->layout->app('search/index', array(
|
||||
'values' => array(
|
||||
'search' => $search,
|
||||
'controller' => 'SearchController',
|
||||
'action' => 'index',
|
||||
),
|
||||
'paginator' => $paginator,
|
||||
'title' => t('Search tasks').($nb_tasks > 0 ? ' ('.$nb_tasks.')' : '')
|
||||
)));
|
||||
}
|
||||
|
||||
public function activity()
|
||||
{
|
||||
$search = urldecode($this->request->getStringParam('search'));
|
||||
$events = $this->helper->projectActivity->searchEvents($search);
|
||||
$nb_events = count($events);
|
||||
|
||||
$this->response->html($this->helper->layout->app('search/activity', array(
|
||||
'values' => array(
|
||||
'search' => $search,
|
||||
'controller' => 'SearchController',
|
||||
'action' => 'activity',
|
||||
),
|
||||
'title' => t('Search in activity stream').($nb_events > 0 ? ' ('.$nb_events.')' : ''),
|
||||
'nb_events' => $nb_events,
|
||||
'events' => $events,
|
||||
)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user