Changeset View
Changeset View
Standalone View
Standalone View
src/applications/slowvote/view/SlowvoteEmbedView.php
Show First 20 Lines • Show All 218 Lines • ▼ Show 20 Lines | return phutil_tag( | ||||
'class' => 'slowvote-control-offset', | 'class' => 'slowvote-control-offset', | ||||
), | ), | ||||
$option->getName()), | $option->getName()), | ||||
)); | )); | ||||
} | } | ||||
private function renderControl(PhabricatorSlowvoteOption $option, $selected) { | private function renderControl(PhabricatorSlowvoteOption $option, $selected) { | ||||
$types = array( | $types = array( | ||||
PhabricatorSlowvotePoll::METHOD_PLURALITY => 'radio', | SlowvotePollVotingMethod::METHOD_PLURALITY => 'radio', | ||||
PhabricatorSlowvotePoll::METHOD_APPROVAL => 'checkbox', | SlowvotePollVotingMethod::METHOD_APPROVAL => 'checkbox', | ||||
); | ); | ||||
$closed = $this->getPoll()->getIsClosed(); | $closed = $this->getPoll()->getIsClosed(); | ||||
return phutil_tag( | return phutil_tag( | ||||
'input', | 'input', | ||||
array( | array( | ||||
'type' => idx($types, $this->getPoll()->getMethod()), | 'type' => idx($types, $this->getPoll()->getMethod()), | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | private function renderStatus(PhabricatorSlowvoteOption $option) { | ||||
$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()) { | switch ($poll->getMethod()) { | ||||
case PhabricatorSlowvotePoll::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 PhabricatorSlowvotePoll::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; | ||||
} | } | ||||
return phutil_tag( | return phutil_tag( | ||||
'div', | 'div', | ||||
array( | array( | ||||
'class' => 'slowvote-status', | 'class' => 'slowvote-status', | ||||
Show All 23 Lines |