public function editorListAction() { $result = array('success' => false); $siteId = (int) $this->params()->fromQuery('siteId', $this->services->getUtilityService()->getSiteId()); $page = (int) $this->params()->fromQuery('page', 1); $perPage = (int) $this->params()->fromQuery('perPage', 10); $orderBy = $this->params()->fromQuery('orderBy', 'Revisions'); $order = $this->params()->fromQuery('ascending', true); if ($order) { $order = Order::ASCENDING; } else { $order = Order::DESCENDING; } $table = $this->getEditorsTable($siteId, $orderBy, $order, $page, $perPage); $renderer = $this->getServiceLocator()->get('ViewHelperManager')->get('partial'); if ($renderer) { $result['success'] = true; $result['content'] = $renderer('partial/tables/table.phtml', array('table' => $table, 'data' => array('total' => $this->services->getRevisionService()->countSiteRevisions($siteId)))); } return new JsonModel($result); }
public function ratingChartAction() { $pageId = (int) $this->params()->fromQuery('pageId'); $byDate = new DateAggregate(DbViewVotes::DATETIME, 'Date'); $count = new Aggregate(DbViewVotes::VALUE, Aggregate::SUM, 'Votes'); $votes = $this->services->getVoteService()->getAggregatedForPage($pageId, array($byDate, $count), true); $resVotes = array(); foreach ($votes as $vote) { $resVotes[] = array($vote['Date']->format(\DateTime::ISO8601), (int) $vote['Votes']); } $revisions = $this->services->getRevisionService()->findRevisionsOfPage($pageId); $resRevisions = array(); foreach ($revisions as $rev) { $resRevisions[] = array($rev->getDateTime()->format(\DateTime::ISO8601), array('name' => (string) ($rev->getIndex() + 1), 'text' => $rev->getComments() === '' ? $rev->getUser()->getDisplayName() : sprintf('%s: "%s"', $rev->getUser()->getDisplayName(), $rev->getComments()))); } return new JsonModel(array('success' => true, 'votes' => $resVotes, 'milestones' => $resRevisions)); }