public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $macro = id(new PhabricatorMacroQuery())->setViewer($user)->withIDs(array($this->id))->needFiles(true)->executeOne();
     if (!$macro) {
         return new Aphront404Response();
     }
     $file = $macro->getFile();
     $title_short = pht('Macro "%s"', $macro->getName());
     $title_long = pht('Image Macro "%s"', $macro->getName());
     $actions = $this->buildActionView($macro);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->setActionList($actions);
     $crumbs->addTextCrumb($title_short, $this->getApplicationURI('/view/' . $macro->getID() . '/'));
     $properties = $this->buildPropertyView($macro, $actions);
     if ($file) {
         $file_view = new PHUIPropertyListView();
         $file_view->addImageContent(phutil_tag('img', array('src' => $file->getViewURI(), 'class' => 'phabricator-image-macro-hero')));
     }
     $xactions = id(new PhabricatorMacroTransactionQuery())->setViewer($request->getUser())->withObjectPHIDs(array($macro->getPHID()))->execute();
     $engine = id(new PhabricatorMarkupEngine())->setViewer($user);
     foreach ($xactions as $xaction) {
         if ($xaction->getComment()) {
             $engine->addObject($xaction->getComment(), PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT);
         }
     }
     $engine->process();
     $timeline = id(new PhabricatorApplicationTransactionView())->setUser($user)->setObjectPHID($macro->getPHID())->setTransactions($xactions)->setMarkupEngine($engine);
     $header = id(new PHUIHeaderView())->setUser($user)->setPolicyObject($macro)->setHeader($title_long);
     if ($macro->getIsDisabled()) {
         $header->addTag(id(new PHUITagView())->setType(PHUITagView::TYPE_STATE)->setName(pht('Macro Disabled'))->setBackgroundColor(PHUITagView::COLOR_BLACK));
     }
     $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
     $comment_header = $is_serious ? pht('Add Comment') : pht('Grovel in Awe');
     $draft = PhabricatorDraft::newFromUserAndKey($user, $macro->getPHID());
     $add_comment_form = id(new PhabricatorApplicationTransactionCommentView())->setUser($user)->setObjectPHID($macro->getPHID())->setDraft($draft)->setHeaderText($comment_header)->setAction($this->getApplicationURI('/comment/' . $macro->getID() . '/'))->setSubmitButtonName(pht('Add Comment'));
     $object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties);
     if ($file_view) {
         $object_box->addPropertyList($file_view);
     }
     return $this->buildApplicationPage(array($crumbs, $object_box, $timeline, $add_comment_form), array('title' => $title_short));
 }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     $macro = id(new PhabricatorMacroQuery())->setViewer($viewer)->withIDs(array($id))->needFiles(true)->executeOne();
     if (!$macro) {
         return new Aphront404Response();
     }
     $file = $macro->getFile();
     $title_short = pht('Macro "%s"', $macro->getName());
     $title_long = pht('Image Macro "%s"', $macro->getName());
     $actions = $this->buildActionView($macro);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb($title_short, $this->getApplicationURI('/view/' . $macro->getID() . '/'));
     $properties = $this->buildPropertyView($macro, $actions);
     if ($file) {
         $file_view = new PHUIPropertyListView();
         $file_view->addImageContent(phutil_tag('img', array('src' => $file->getViewURI(), 'class' => 'phabricator-image-macro-hero')));
     }
     $timeline = $this->buildTransactionTimeline($macro, new PhabricatorMacroTransactionQuery());
     $header = id(new PHUIHeaderView())->setUser($viewer)->setPolicyObject($macro)->setHeader($title_long);
     if (!$macro->getIsDisabled()) {
         $header->setStatus('fa-check', 'bluegrey', pht('Active'));
     } else {
         $header->setStatus('fa-ban', 'red', pht('Archived'));
     }
     $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
     $comment_header = $is_serious ? pht('Add Comment') : pht('Grovel in Awe');
     $draft = PhabricatorDraft::newFromUserAndKey($viewer, $macro->getPHID());
     $add_comment_form = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($macro->getPHID())->setDraft($draft)->setHeaderText($comment_header)->setAction($this->getApplicationURI('/comment/' . $macro->getID() . '/'))->setSubmitButtonName(pht('Add Comment'));
     $object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties);
     if ($file_view) {
         $object_box->addPropertyList($file_view);
     }
     return $this->buildApplicationPage(array($crumbs, $object_box, $timeline, $add_comment_form), array('title' => $title_short, 'pageObjects' => array($macro->getPHID())));
 }
 private function buildImageCorpus($file_uri)
 {
     $properties = new PHUIPropertyListView();
     $properties->addImageContent(phutil_tag('img', array('src' => $file_uri)));
     $file = $this->renderFileButton($file_uri);
     $header = id(new PHUIHeaderView())->setHeader(pht('Image'))->addActionLink($file);
     return id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties);
 }
 private function buildImageCorpus($file_uri)
 {
     $properties = new PHUIPropertyListView();
     $properties->addImageContent(phutil_tag('img', array('src' => $file_uri)));
     $file = $this->renderFileButton($file_uri);
     $header = id(new PHUIHeaderView())->setHeader(basename($this->getDiffusionRequest()->getPath()))->addActionLink($file)->setHeaderIcon('fa-file-image-o');
     return id(new PHUIObjectBoxView())->setHeader($header)->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->addPropertyList($properties);
 }