Example #1
0
 /**
  * Display a list of participants with summary of their contributions
  * 
  * @param string $id
  * @return string XHTML markup
  * @access private
  * @since 1/28/09
  */
 private function getActionsList()
 {
     $node = SiteDispatcher::getCurrentNode();
     $view = new Participation_View($node);
     $participants = $view->getParticipants();
     // create an array of reorder urls
     $sortValues = array('timestamp', 'contributor', 'contribution', 'role');
     $reorderUrl = array();
     foreach ($sortValues as $sortValue) {
         $reorderUrl[$sortValue] = SiteDispatcher::quickURL('participation', 'actions', array('node' => $node->getId(), 'sort' => $sortValue, 'direction' => $this->_reorder, 'participant' => $this->_participant, 'role' => $this->_role));
     }
     // header row for list of actions
     ob_start();
     print "\n\t<thead>";
     print "\n\t\t<tr>";
     // time
     print "\n\t\t\t<th style='border-bottom: 1px dotted'><a href='";
     print $reorderUrl['timestamp'];
     print "'>" . _("Time") . " " . ($this->_sort == 'timestamp' ? $this->_reorderFlag : "") . "</a></th>";
     // contributor
     print "\n\t\t\t<th style='border-bottom: 1px dotted'><a href='";
     print $reorderUrl['contributor'];
     print "'>" . _("Contributor") . " " . ($this->_sort == 'contributor' ? $this->_reorderFlag : "") . "</a></th>";
     // role
     print "\n\t\t\t<th style='border-bottom: 1px dotted'><a href='";
     print $reorderUrl['role'];
     print "'>" . _("Role") . " " . ($this->_sort == 'role' ? $this->_reorderFlag : "") . "</a>";
     print "</th>";
     // contribution
     print "\n\t\t\t<th style='border-bottom: 1px dotted'><a href='";
     print $reorderUrl['contribution'];
     print "'>" . _("Contribution") . " " . ($this->_sort == 'contribution' ? $this->_reorderFlag : "") . "</a></th>";
     // pushdown link
     print "\n\t\t\t<th style='border-bottom: 1px dotted'></th>";
     print "\n\t</thead>";
     $headRow = ob_get_clean();
     // if participant specified get their actions
     if (isset($this->_participant) && $this->_participant != 'all') {
         $idMgr = Services::getService('Id');
         $participantId = $idMgr->getId($this->_participant);
         $participantView = new Participation_Participant($view, $participantId);
         $actions = $participantView->getActions();
         //get list of all actions in site
     } else {
         $actions = $view->getActions();
     }
     // sort actions by sort key
     $sortKeys = array();
     if ($this->_sort == 'timestamp') {
         foreach ($actions as $action) {
             $sortKeys[] = $action->getTimeStamp()->asString();
         }
     } else {
         if ($this->_sort == 'contributor') {
             foreach ($actions as $action) {
                 $sortKeys[] = $action->getParticipant()->getDisplayName();
             }
         } else {
             if ($this->_sort == 'contribution') {
                 foreach ($actions as $action) {
                     $sortKeys[] = $action->getTargetDisplayName();
                 }
             } else {
                 if ($this->_sort == 'role') {
                     foreach ($actions as $action) {
                         $sortKeys[] = $action->getCategoryDisplayName();
                     }
                 } else {
                     throw new InvalidArguementException("Unknown sort field {$sort}");
                 }
             }
         }
     }
     array_multisort($sortKeys, $this->_direction, array_keys($actions), SORT_ASC, $actions);
     // if role action specified then filter actions
     $selectedActions = array();
     if ($this->_role != 'all') {
         foreach ($actions as $action) {
             if ($action->getCategoryId() == $this->_role) {
                 $selectedActions[] = $action;
             }
         }
     } else {
         $selectedActions = $actions;
     }
     $this->_node = $node;
     $this->_sortValue = $sortValue;
     $printer = new ParticipationResultPrinter($selectedActions, $headRow, $this->_display, array($this, 'printAction'));
     print $printer->getMarkup();
     return ob_get_clean();
 }
Example #2
0
 /**
  * Display a list of participants with summary of their contributions
  * 
  * @param string $id
  * @return string XHTML markup
  * @access private
  * @since 1/28/09
  */
 private function getParticipantsList($action = 'all')
 {
     ob_start();
     //$site = SiteDispatcher::getCurrentRootNode();
     $node = SiteDispatcher::getCurrentNode();
     $view = new Participation_View($node);
     if (RequestContext::value('sort')) {
         $sort = RequestContext::value('sort');
     } else {
         $sort = 'name';
     }
     if (RequestContext::value('direction')) {
         if (RequestContext::value('direction') == 'DESC') {
             $direction = SORT_DESC;
             $reorder = 'ASC';
             $reorderFlag = '&#94;';
         } else {
             $direction = SORT_ASC;
             $reorder = 'DESC';
             $reorderFlag = 'v';
         }
     } else {
         $direction = SORT_ASC;
         $reorder = 'ASC';
         $reorderFlag = '&#94;';
     }
     // create an array of reorder urls
     $sortValues = array('name', 'commenter', 'author', 'editor');
     $reorderUrl = array();
     foreach ($sortValues as $sortValue) {
         $reorderUrl[$sortValue] = SiteDispatcher::quickURL('participation', 'summary', array('node' => $node->getId(), 'sort' => $sortValue, 'direction' => $reorder));
     }
     // print out header row for list of participants
     ob_start();
     print "\n\t<thead>";
     print "\n\t\t<tr>";
     print "\n\t\t\t<th style='border-bottom: 1px dotted'><a href='";
     print $reorderUrl['name'];
     print "'>" . _("Participants") . " " . ($sort == 'name' ? $reorderFlag : "") . "</a></th>";
     print "\n\t\t\t<th style='border-bottom: 1px dotted'><a href='";
     print $reorderUrl['commenter'];
     print "'>" . _("Commenter") . " " . ($sort == 'commenter' ? $reorderFlag : "") . "</a></th>";
     print "\n\t\t\t<th style='border-bottom: 1px dotted'><a href='";
     print $reorderUrl['author'];
     print "'>" . _("Author") . " " . ($sort == 'author' ? $reorderFlag : "") . "</a></th>";
     print "\n\t\t\t<th style='border-bottom: 1px dotted'><a href='";
     print $reorderUrl['editor'];
     print "'>" . _("Editor") . " " . ($sort == 'editor' ? $reorderFlag : "") . "</a></th>";
     print "\n\t</thead>";
     $headRow = ob_get_clean();
     //get list of participants in site
     $participants = $view->getParticipants();
     // sort actions by sort key
     $sortKeys = array();
     if ($sort == 'name') {
         foreach ($participants as $participant) {
             $sortKeys[] = $participant->getDisplayName();
         }
     } else {
         if ($sort == 'commenter') {
             foreach ($participants as $participant) {
                 $participantView = new Participation_Participant($view, $participant->getId());
                 $sortKeys[] = $participantView->getNumActionsByCategory('commenter');
             }
         } else {
             if ($sort == 'author') {
                 foreach ($participants as $participant) {
                     $participantView = new Participation_Participant($view, $participant->getId());
                     $sortKeys[] = $participantView->getNumActionsByCategory('author');
                 }
             } else {
                 if ($sort == 'editor') {
                     foreach ($participants as $participant) {
                         $participantView = new Participation_Participant($view, $participant->getId());
                         $sortKeys[] = $participantView->getNumActionsByCategory('editor');
                     }
                 } else {
                     throw new InvalidArguementException("Unknown sort field {$sort}");
                 }
             }
         }
     }
     array_multisort($sortKeys, $direction, array_keys($participants), SORT_ASC, $participants);
     $this->_view = $view;
     $this->_node = $node;
     $this->_sortValue = $sortValue;
     $this->_reorder = $reorder;
     $printer = new ParticipationResultPrinter($participants, $headRow, 30, array($this, 'printAction'));
     print $printer->getMarkup();
     return ob_get_clean();
 }