private function calculateBehaviorConfig()
 {
     $mock = $this->getMock();
     // TODO: We could maybe do a better job with tailoring this, which is the
     // image shown on the review stage.
     $default_name = 'image-100x100.png';
     $builtins = PhabricatorFile::loadBuiltins($this->getUser(), array($default_name));
     $default = $builtins[$default_name];
     $engine = id(new PhabricatorMarkupEngine())->setViewer($this->getUser());
     foreach ($mock->getAllImages() as $image) {
         $engine->addObject($image, 'default');
     }
     $engine->process();
     $images = array();
     $current_set = 0;
     foreach ($mock->getAllImages() as $image) {
         $file = $image->getFile();
         $metadata = $file->getMetadata();
         $x = idx($metadata, PhabricatorFile::METADATA_IMAGE_WIDTH);
         $y = idx($metadata, PhabricatorFile::METADATA_IMAGE_HEIGHT);
         $is_obs = (bool) $image->getIsObsolete();
         if (!$is_obs) {
             $current_set++;
         }
         $history_uri = '/pholio/image/history/' . $image->getID() . '/';
         $images[] = array('id' => $image->getID(), 'fullURI' => $file->getBestURI(), 'stageURI' => $file->isViewableImage() ? $file->getBestURI() : $default->getBestURI(), 'pageURI' => $this->getImagePageURI($image, $mock), 'downloadURI' => $file->getDownloadURI(), 'historyURI' => $history_uri, 'width' => $x, 'height' => $y, 'title' => $image->getName(), 'descriptionMarkup' => $engine->getOutput($image, 'default'), 'isObsolete' => (bool) $image->getIsObsolete(), 'isImage' => $file->isViewableImage(), 'isViewable' => $file->isViewableInBrowser());
     }
     $ids = mpull($mock->getImages(), 'getID');
     if ($this->imageID && isset($ids[$this->imageID])) {
         $selected_id = $this->imageID;
     } else {
         $selected_id = head_key($ids);
     }
     $navsequence = array();
     foreach ($mock->getImages() as $image) {
         $navsequence[] = $image->getID();
     }
     $full_icon = array(javelin_tag('span', array('aural' => true), pht('View Raw File')), id(new PHUIIconView())->setIconFont('fa-file-image-o'));
     $download_icon = array(javelin_tag('span', array('aural' => true), pht('Download File')), id(new PHUIIconView())->setIconFont('fa-download'));
     $login_uri = id(new PhutilURI('/login/'))->setQueryParam('next', (string) $this->getRequestURI());
     $config = array('mockID' => $mock->getID(), 'panelID' => $this->panelID, 'viewportID' => $this->viewportID, 'commentFormID' => $this->getCommentFormID(), 'images' => $images, 'selectedID' => $selected_id, 'loggedIn' => $this->getUser()->isLoggedIn(), 'logInLink' => (string) $login_uri, 'navsequence' => $navsequence, 'fullIcon' => hsprintf('%s', $full_icon), 'downloadIcon' => hsprintf('%s', $download_icon), 'currentSetSize' => $current_set);
     return $config;
 }
 private function renderDefaultForm(PhabricatorProject $project)
 {
     $viewer = $this->getViewer();
     $compose_color = $project->getDisplayIconComposeColor();
     $compose_icon = $project->getDisplayIconComposeIcon();
     $default_builtin = id(new PhabricatorFilesComposeIconBuiltinFile())->setColor($compose_color)->setIcon($compose_icon);
     $file_builtins = PhabricatorFile::loadBuiltins($viewer, array($default_builtin));
     $file_builtin = head($file_builtins);
     $default_button = javelin_tag('button', array('class' => 'grey profile-image-button', 'sigil' => 'has-tooltip', 'meta' => array('tip' => pht('Use Icon and Color'), 'size' => 300)), phutil_tag('img', array('height' => 50, 'width' => 50, 'src' => $file_builtin->getBestURI())));
     $inputs = array('projectPHID' => $project->getPHID(), 'icon' => $compose_icon, 'color' => $compose_color);
     foreach ($inputs as $key => $value) {
         $inputs[$key] = javelin_tag('input', array('type' => 'hidden', 'name' => $key, 'value' => $value));
     }
     $default_form = phabricator_form($viewer, array('class' => 'profile-image-form', 'method' => 'POST', 'action' => '/file/compose/'), array($inputs, $default_button));
     return $default_form;
 }