Example #1
0
 public function ratingChartAction()
 {
     $result = array('success' => false);
     $userId = (int) $this->params()->fromQuery('userId');
     $siteId = (int) $this->params()->fromQuery('siteId');
     $user = $this->services->getUserService()->find($userId);
     if ($user) {
         $byDate = new DateAggregate(DbViewVotes::DATETIME, 'Date');
         $count = new Aggregate(DbViewVotes::VALUE, Aggregate::SUM, 'Votes');
         $votes = $this->services->getVoteService()->getAggregatedVotesOnUser($userId, $siteId, array($byDate, $count));
         $resVotes = array();
         foreach ($votes as $vote) {
             $resVotes[] = array($vote['Date']->format(\DateTime::ISO8601), (int) $vote['Votes']);
         }
         $authorships = $this->services->getUserService()->findAuthorshipsOfUser($userId, $siteId);
         $milestones = array();
         foreach ($authorships as $auth) {
             $name = $auth->getPage()->getTitle();
             if (mb_strlen($name) > 11) {
                 $name = mb_substr($name, 0, 8) . '...';
             }
             $milestones[] = array($auth->getPage()->getCreationDate()->format(\DateTime::ISO8601), array('name' => $name, 'text' => $auth->getPage()->getTitle()));
         }
         $result = array('success' => true, 'votes' => $resVotes, 'milestones' => $milestones);
     }
     return new JsonModel($result);
 }
Example #2
0
 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));
 }
 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);
 }
Example #4
0
 public function pageListAction()
 {
     $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', DbViewPages::CLEANRATING);
     $order = $this->params()->fromQuery('ascending', true);
     if ($order) {
         $order = Order::ASCENDING;
     } else {
         $order = Order::DESCENDING;
     }
     $this->extractTagParameters($method, $searchTags, $includeTags, $excludeTags);
     $table = $this->getPagesTable($siteId, $includeTags, $excludeTags, $method === 'and', $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('siteId' => $siteId)));
     }
     return new JsonModel($result);
 }