private function buildSubheaderView(PhabricatorSlowvotePoll $poll)
 {
     $viewer = $this->getViewer();
     $author = $viewer->renderHandle($poll->getAuthorPHID())->render();
     $date = phabricator_datetime($poll->getDateCreated(), $viewer);
     $author = phutil_tag('strong', array(), $author);
     $person = id(new PhabricatorPeopleQuery())->setViewer($viewer)->withPHIDs(array($poll->getAuthorPHID()))->needProfileImage(true)->executeOne();
     $image_uri = $person->getProfileImageURI();
     $image_href = '/p/' . $person->getUsername();
     $content = pht('Asked by %s on %s.', $author, $date);
     return id(new PHUIHeadThingView())->setImage($image_uri)->setImageHref($image_href)->setContent($content);
 }
 private function renderResultMarkup(PhabricatorSlowvotePoll $poll, array $options, array $choices, array $comments, array $viewer_choices, array $choices_by_option, array $comments_by_option, array $handles, array $objects)
 {
     $viewer_phid = $this->getRequest()->getUser()->getPHID();
     $can_see_responses = false;
     $need_vote = false;
     switch ($poll->getResponseVisibility()) {
         case PhabricatorSlowvotePoll::RESPONSES_VISIBLE:
             $can_see_responses = true;
             break;
         case PhabricatorSlowvotePoll::RESPONSES_VOTERS:
             $can_see_responses = (bool) $viewer_choices;
             $need_vote = true;
             break;
         case PhabricatorSlowvotePoll::RESPONSES_OWNER:
             $can_see_responses = $viewer_phid == $poll->getAuthorPHID();
             break;
     }
     $result_markup = id(new AphrontFormLayoutView())->appendChild('<h1>Ongoing Deliberation</h1>');
     if (!$can_see_responses) {
         if ($need_vote) {
             $reason = "You must vote to see the results.";
         } else {
             $reason = "The results are not public.";
         }
         $result_markup->appendChild('<p class="aphront-form-instructions"><em>' . $reason . '</em></p>');
         return $result_markup;
     }
     foreach ($options as $option) {
         $id = $option->getID();
         $chosen = idx($choices_by_option, $id, array());
         $users = array_select_keys($handles, mpull($chosen, 'getAuthorPHID'));
         if ($users) {
             $user_markup = array();
             foreach ($users as $handle) {
                 $object = idx($objects, $handle->getPHID());
                 if (!$object) {
                     continue;
                 }
                 $profile_image = PhabricatorFileURI::getViewURIForPHID($object->getProfileImagePHID());
                 $user_markup[] = phutil_render_tag('a', array('href' => $handle->getURI(), 'class' => 'phabricator-slowvote-facepile'), phutil_render_tag('img', array('src' => $profile_image)));
             }
             $user_markup = implode('', $user_markup);
         } else {
             $user_markup = 'This option has failed to appeal to anyone.';
         }
         $comment_markup = $this->renderComments(idx($comments_by_option, $id, array()), $handles);
         $vote_count = $this->renderVoteCount($poll, $choices, $chosen);
         $result_markup->appendChild('<div>' . '<div class="phabricator-slowvote-count">' . $vote_count . '</div>' . '<h1>' . phutil_escape_html($option->getName()) . '</h1>' . '<hr class="phabricator-slowvote-hr" />' . $user_markup . '<div style="clear: both;">' . '<hr class="phabricator-slowvote-hr" />' . $comment_markup . '</div>');
     }
     if ($poll->getMethod() == PhabricatorSlowvotePoll::METHOD_APPROVAL && $comments) {
         $comment_markup = $this->renderComments($comments, $handles);
         $result_markup->appendChild('<h1>Motions Proposed for Consideration</h1>');
         $result_markup->appendChild($comment_markup);
     }
     return $result_markup;
 }