Move dashboard pagination into separate classes
This commit is contained in:
35
app/Pagination/ProjectPagination.php
Normal file
35
app/Pagination/ProjectPagination.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Kanboard\Pagination;
|
||||
|
||||
use Kanboard\Core\Base;
|
||||
use Kanboard\Core\Paginator;
|
||||
use Kanboard\Model\ProjectModel;
|
||||
|
||||
/**
|
||||
* Class ProjectPagination
|
||||
*
|
||||
* @package Kanboard\Pagination
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class ProjectPagination extends Base
|
||||
{
|
||||
/**
|
||||
* Get dashboard pagination
|
||||
*
|
||||
* @access public
|
||||
* @param integer $user_id
|
||||
* @param string $method
|
||||
* @param integer $max
|
||||
* @return Paginator
|
||||
*/
|
||||
public function getDashboardPaginator($user_id, $method, $max)
|
||||
{
|
||||
return $this->paginator
|
||||
->setUrl('DashboardController', $method, array('pagination' => 'projects', 'user_id' => $user_id))
|
||||
->setMax($max)
|
||||
->setOrder(ProjectModel::TABLE.'.name')
|
||||
->setQuery($this->projectModel->getQueryColumnStats($this->projectPermissionModel->getActiveProjectIds($user_id)))
|
||||
->calculateOnlyIf($this->request->getStringParam('pagination') === 'projects');
|
||||
}
|
||||
}
|
||||
36
app/Pagination/SubtaskPagination.php
Normal file
36
app/Pagination/SubtaskPagination.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Kanboard\Pagination;
|
||||
|
||||
use Kanboard\Core\Base;
|
||||
use Kanboard\Core\Paginator;
|
||||
use Kanboard\Model\SubtaskModel;
|
||||
use Kanboard\Model\TaskModel;
|
||||
|
||||
/**
|
||||
* Class SubtaskPagination
|
||||
*
|
||||
* @package Kanboard\Pagination
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class SubtaskPagination extends Base
|
||||
{
|
||||
/**
|
||||
* Get dashboard pagination
|
||||
*
|
||||
* @access public
|
||||
* @param integer $user_id
|
||||
* @param string $method
|
||||
* @param integer $max
|
||||
* @return Paginator
|
||||
*/
|
||||
public function getDashboardPaginator($user_id, $method, $max)
|
||||
{
|
||||
return $this->paginator
|
||||
->setUrl('DashboardController', $method, array('pagination' => 'subtasks', 'user_id' => $user_id))
|
||||
->setMax($max)
|
||||
->setOrder(TaskModel::TABLE.'.id')
|
||||
->setQuery($this->subtaskModel->getUserQuery($user_id, array(SubtaskModel::STATUS_TODO, SubtaskModel::STATUS_INPROGRESS)))
|
||||
->calculateOnlyIf($this->request->getStringParam('pagination') === 'subtasks');
|
||||
}
|
||||
}
|
||||
35
app/Pagination/TaskPagination.php
Normal file
35
app/Pagination/TaskPagination.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Kanboard\Pagination;
|
||||
|
||||
use Kanboard\Core\Base;
|
||||
use Kanboard\Core\Paginator;
|
||||
use Kanboard\Model\TaskModel;
|
||||
|
||||
/**
|
||||
* Class TaskPagination
|
||||
*
|
||||
* @package Kanboard\Pagination
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class TaskPagination extends Base
|
||||
{
|
||||
/**
|
||||
* Get dashboard pagination
|
||||
*
|
||||
* @access public
|
||||
* @param integer $user_id
|
||||
* @param string $method
|
||||
* @param integer $max
|
||||
* @return Paginator
|
||||
*/
|
||||
public function getDashboardPaginator($user_id, $method, $max)
|
||||
{
|
||||
return $this->paginator
|
||||
->setUrl('DashboardController', $method, array('pagination' => 'tasks', 'user_id' => $user_id))
|
||||
->setMax($max)
|
||||
->setOrder(TaskModel::TABLE.'.id')
|
||||
->setQuery($this->taskFinderModel->getUserQuery($user_id))
|
||||
->calculateOnlyIf($this->request->getStringParam('pagination') === 'tasks');
|
||||
}
|
||||
}
|
||||
32
app/Pagination/UserPagination.php
Normal file
32
app/Pagination/UserPagination.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Kanboard\Pagination;
|
||||
|
||||
use Kanboard\Core\Base;
|
||||
use Kanboard\Core\Paginator;
|
||||
use Kanboard\Model\UserModel;
|
||||
|
||||
/**
|
||||
* Class UserPagination
|
||||
*
|
||||
* @package Kanboard\Pagination
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class UserPagination extends Base
|
||||
{
|
||||
/**
|
||||
* Get user listing paginator
|
||||
*
|
||||
* @access public
|
||||
* @return Paginator
|
||||
*/
|
||||
public function getListingPaginator()
|
||||
{
|
||||
return $this->paginator
|
||||
->setUrl('UserListController', 'show')
|
||||
->setMax(30)
|
||||
->setOrder(UserModel::TABLE.'.username')
|
||||
->setQuery($this->userModel->getQuery())
|
||||
->calculate();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user