/** * Returns a paginated table with votes * @param int $pageId * @param string $orderBy * @param int $order * @param int $page * @param int $perPage * @return Application\Component\PaginatedTable\TableInterface */ protected function getVotesTable($pageId, $orderBy, $order, $page, $perPage) { $votes = $this->services->getVoteService()->findVotesOnPage($pageId, array($orderBy => $order), true, $page, $perPage); $table = PaginatedTableFactory::createVotesTable($votes); $table->getColumns()->setOrder($orderBy, $order === Order::ASCENDING); return $table; }
protected function getVotesTable($userId, $siteId, $orderBy, $order, $page, $perPage) { $votes = $this->services->getVoteService()->findVotesOfUser($userId, $siteId, array($orderBy => $order), true, $page, $perPage); $votes->setCurrentPageNumber($page); $votes->setItemCountPerPage($perPage); $table = PaginatedTableFactory::createUserVotesTable($votes); $table->getColumns()->setOrder($orderBy, $order === Order::ASCENDING); return $table; }
/** * * @param int $siteId * @param string $orderBy * @param int $order * @param int $page * @param int $perPage * @return Application\Component\TableInterface */ protected function getPagesTable($siteId, $orderBy, $order, $page, $perPage) { $pages = $this->services->getPageService()->findSitePages($siteId, PageStatus::ANY, null, null, array($orderBy => $order), true); $pages->setCurrentPageNumber($page); $pages->setItemCountPerPage($perPage); $table = PaginatedTableFactory::createPagesTable($pages); $table->getColumns()->setOrder($orderBy, $order === Order::ASCENDING); return $table; }
/** * * @param int $siteId * @param string $orderBy * @param int $order * @param int $page * @param int $perPage * @return Application\Component\TableInterface */ protected function getEditorsTable($siteId, $orderBy, $order, $page, $perPage) { $aggregates = array(new Aggregate(DbViewRevisions::USERID, Aggregate::NONE, null, true), new Aggregate(DbViewRevisions::USERWIKIDOTNAME, Aggregate::NONE, null, true), new Aggregate(DbViewRevisions::USERDISPLAYNAME, Aggregate::NONE, null, true), new Aggregate(DbViewRevisions::USERDELETED, Aggregate::NONE, null, true), new Aggregate('*', Aggregate::COUNT, 'Revisions')); $editors = $this->services->getRevisionService()->getAggregatedValues($siteId, $aggregates, null, null, array($orderBy => $order), true); $editors->setCurrentPageNumber($page); $editors->setItemCountPerPage($perPage); $table = PaginatedTableFactory::createEditorsTable($editors); $table->getColumns()->setOrder($orderBy, $order === Order::ASCENDING); return $table; }
/** * * @param int $siteId * @param string $orderBy * @param int $order * @param int $page * @param int $perPage * @return Application\Component\TableInterface */ protected function getVotersTable($siteId, $orderBy, $order, $page, $perPage) { $aggregates = array(new Aggregate(DbViewVotes::USERID, Aggregate::NONE, null, true), new Aggregate(DbViewVotes::USERNAME, Aggregate::NONE, null, true), new Aggregate(DbViewVotes::USERDISPLAYNAME, Aggregate::NONE, null, true), new Aggregate(DbViewVotes::USERDELETED, Aggregate::NONE, null, true), new Aggregate('*', Aggregate::COUNT, 'Votes'), new Aggregate(DbViewVotes::VALUE, Aggregate::SUM, 'Sum')); $voters = $this->services->getVoteService()->getAggregatedForSite($siteId, $aggregates, null, null, array($orderBy => $order), true); $voters->setCurrentPageNumber($page); $voters->setItemCountPerPage($perPage); $table = PaginatedTableFactory::createVotersTable($voters); $table->getColumns()->setOrder($orderBy, $order === Order::ASCENDING); return $table; }
/** * Get a paginated table with authors for a selected site * @param int $siteId * @param string $orderBy * @param int $order * @param int $page * @param int $perPage * @return \Application\Component\PaginatedTable\TableInterface; */ protected function getAuthorsTable($siteId, $orderBy, $order, $page, $perPage) { $authors = $this->services->getUserService()->findAuthorSummaries($siteId, array($orderBy => $order), true); $authors->setItemCountPerPage($perPage); $authors->setCurrentPageNumber($page); $userIds = array(); $authorById = array(); foreach ($authors as $author) { $userIds[] = $author->getUserId(); $authorById[$author->getUserId()] = $author; } $users = $this->services->getUserService()->findAll(array(sprintf('%s IN (%s)', DbViewUsers::USERID, implode(',', $userIds)))); foreach ($users as $user) { $authorById[$user->getId()]->setUser($user); } $table = \Application\Factory\Component\PaginatedTableFactory::createAuthorsTable($authors); $table->getColumns()->setOrder($orderBy, $order === Order::ASCENDING); return $table; }
public function votersAction() { $result = array('success' => false); $siteId = -1; $from = null; $to = null; if ($this->getCommonParams($siteId, $from, $to)) { $page = (int) $this->params()->fromQuery('page', 1); $perPage = (int) $this->params()->fromQuery('perPage', 10); $orderBy = $this->params()->fromQuery('orderBy'); if (!$orderBy || $orderBy !== 'Votes' && !DbViewVotes::hasField($orderBy)) { $orderBy = 'Votes'; $order = Order::DESCENDING; } else { if ($this->params()->fromQuery('ascending', true)) { $order = Order::ASCENDING; } else { $order = Order::DESCENDING; } } $voters = $this->getVotersPaginator($siteId, $from, $to, $orderBy, $order, $page, $perPage); $table = PaginatedTableFactory::createVotersTable($voters); $renderer = $this->getServiceLocator()->get('ViewHelperManager')->get('partial'); $table->getColumns()->setOrder($orderBy, $order === Order::ASCENDING); if ($renderer) { $result['success'] = true; $result['content'] = $renderer('partial/tables/table.phtml', array('table' => $table, 'data' => array())); } } return new JsonModel($result); }