Changeset View
Changeset View
Standalone View
Standalone View
src/applications/slowvote/view/SlowvoteEmbedView.php
Show First 20 Lines • Show All 295 Lines • ▼ Show 20 Lines | private function renderStatus(PhabricatorSlowvoteOption $option) { | ||||
$poll = $this->getPoll(); | $poll = $this->getPoll(); | ||||
$choices = mgroup($poll->getChoices(), 'getOptionID'); | $choices = mgroup($poll->getChoices(), 'getOptionID'); | ||||
$choices = count(idx($choices, $option->getID(), array())); | $choices = count(idx($choices, $option->getID(), array())); | ||||
$count = count(mgroup($poll->getChoices(), 'getAuthorPHID')); | $count = count(mgroup($poll->getChoices(), 'getAuthorPHID')); | ||||
$percent = sprintf('%d%%', $count ? 100 * $choices / $count : 0); | $percent = sprintf('%d%%', $count ? 100 * $choices / $count : 0); | ||||
switch ($poll->getMethod()) { | $method = $poll->getMethod(); | ||||
switch ($method) { | |||||
case SlowvotePollVotingMethod::METHOD_PLURALITY: | case SlowvotePollVotingMethod::METHOD_PLURALITY: | ||||
$status = pht('%s (%d / %d)', $percent, $choices, $count); | $status = pht('%s (%d / %d)', $percent, $choices, $count); | ||||
break; | break; | ||||
case SlowvotePollVotingMethod::METHOD_APPROVAL: | case SlowvotePollVotingMethod::METHOD_APPROVAL: | ||||
$status = pht('%s Approval (%d / %d)', $percent, $choices, $count); | $status = pht('%s Approval (%d / %d)', $percent, $choices, $count); | ||||
break; | break; | ||||
default: | |||||
$status = pht('Unknown ("%s")', $method); | |||||
break; | |||||
} | } | ||||
return phutil_tag( | return phutil_tag( | ||||
'div', | 'div', | ||||
array( | array( | ||||
'class' => 'slowvote-status', | 'class' => 'slowvote-status', | ||||
), | ), | ||||
$status); | $status); | ||||
Show All 21 Lines |