public function run() { $loggedStudent = $this->loginHelper->isLoggedIn(); $notify = $this->getQuery('Success'); $token = $this->helper->getCookie('token'); $this->render('templates/index.phtml', compact('loggedStudent', 'notify', 'token')); $correntPage = $this->getPageQuery(); $sortQueries = $this->getSortQuery(); $sort = $sortQueries['sort']; $by = $sortQueries['by']; $pager = new Pager(compact('correntPage', 'sort', 'by')); $limit = $pager->getLimit(); $offset = $pager->getOffset(); $records = $this->studentGateway->getStudents($sort, $by, $limit, $offset); $recordsCount = $this->studentGateway->getStudentsCount(); $pager->setRecords($records); $pager->setRecordsCount($recordsCount); $this->render('templates/list.phtml', compact('pager')); }
public function search() { if ($_GET) { $query = $this->getQuery('query'); $this->render('templates\\search.phtml', compact('query')); $correntPage = $this->getPageQuery(); $sortQueries = $this->getSortQuery(); $sort = $sortQueries['sort']; $by = $sortQueries['by']; $pager = new Pager(compact('query', 'correntPage', 'sort', 'by')); $limit = $pager->getLimit(); $offset = $pager->getOffset(); $records = $this->studentGateway->searchStudents($query, $sort, $by, $limit, $offset); $recordsCount = $this->studentGateway->getStudentsCount($query); $pager->setRecords($records); $pager->setRecordsCount($recordsCount); $this->render('templates\\list.phtml', compact('pager')); } else { $this->render('templates\\search.phtml'); } }