private function buildPropertyListView(DrydockBlueprint $blueprint, PhabricatorActionListView $actions)
 {
     $view = new PHUIPropertyListView();
     $view->setActionList($actions);
     $view->addProperty(pht('Type'), $blueprint->getImplementation()->getBlueprintName());
     return $view;
 }
 private function renderItemCommonProperties(PhabricatorUser $viewer, NuanceItem $item, PHUIPropertyListView $view)
 {
     $complaint = $item->getNuanceProperty('complaint');
     $complaint = new PHUIRemarkupView($viewer, $complaint);
     $view->addSectionHeader(pht('Complaint'), 'fa-exclamation-circle');
     $view->addTextContent($complaint);
 }
 private function renderItemCommonProperties(PhabricatorUser $viewer, NuanceItem $item, PHUIPropertyListView $view)
 {
     $complaint = $item->getNuanceProperty('complaint');
     $complaint = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($complaint), 'default', $viewer);
     $view->addSectionHeader(pht('Complaint'), 'fa-exclamation-circle');
     $view->addTextContent($complaint);
 }
 private function buildDocument(PhabricatorMarkupEngine $engine, LegalpadDocumentBody $body)
 {
     $view = new PHUIPropertyListView();
     $view->addClass('legalpad');
     $view->addSectionHeader(pht('Document'));
     $view->addTextContent($engine->getOutput($body, LegalpadDocumentBody::MARKUP_FIELD_TEXT));
     return $view;
 }
 private function buildPropertyListView(DrydockRepositoryOperation $operation)
 {
     $viewer = $this->getViewer();
     $view = new PHUIPropertyListView();
     $view->addProperty(pht('Repository'), $viewer->renderHandle($operation->getRepositoryPHID()));
     $view->addProperty(pht('Object'), $viewer->renderHandle($operation->getObjectPHID()));
     return $view;
 }
 private function buildPropertyList(PhabricatorRepositoryPushEvent $event)
 {
     $viewer = $this->getRequest()->getUser();
     $view = new PHUIPropertyListView();
     $view->addProperty(pht('Pushed At'), phabricator_datetime($event->getEpoch(), $viewer));
     $view->addProperty(pht('Pushed By'), $viewer->renderHandle($event->getPusherPHID()));
     $view->addProperty(pht('Pushed Via'), $event->getRemoteProtocol());
     return $view;
 }
 public function addPropertyList(PHUIPropertyListView $property_list)
 {
     $this->propertyLists[] = $property_list;
     $action_list = $property_list->getActionList();
     if ($action_list) {
         $this->actionListID = celerity_generate_unique_node_id();
         $action_list->setId($this->actionListID);
     }
     return $this;
 }
 private function buildPropertyListView(DrydockLease $lease, PhabricatorActionListView $actions)
 {
     $viewer = $this->getViewer();
     $view = new PHUIPropertyListView();
     $view->setActionList($actions);
     $view->addProperty(pht('Status'), DrydockLeaseStatus::getNameForStatus($lease->getStatus()));
     $view->addProperty(pht('Resource Type'), $lease->getResourceType());
     $resource_phid = $lease->getResourcePHID();
     if ($resource_phid) {
         $resource_display = $viewer->renderHandle($resource_phid);
     } else {
         $resource_display = phutil_tag('em', array(), pht('No Resource'));
     }
     $view->addProperty(pht('Resource'), $resource_display);
     $until = $lease->getUntil();
     if ($until) {
         $until_display = phabricator_datetime($until, $viewer);
     } else {
         $until_display = phutil_tag('em', array(), pht('Never'));
     }
     $view->addProperty(pht('Expires'), $until_display);
     $attributes = $lease->getAttributes();
     if ($attributes) {
         $view->addSectionHeader(pht('Attributes'), 'fa-list-ul');
         foreach ($attributes as $key => $value) {
             $view->addProperty($key, $value);
         }
     }
     return $view;
 }
 private function buildPropertyListView(DrydockAuthorization $authorization)
 {
     $viewer = $this->getViewer();
     $object_phid = $authorization->getObjectPHID();
     $handles = $viewer->loadHandles(array($object_phid));
     $handle = $handles[$object_phid];
     $view = new PHUIPropertyListView();
     $view->addProperty(pht('Authorized Object'), $handle->renderLink($handle->getFullName()));
     $view->addProperty(pht('Object Type'), $handle->getTypeName());
     $object_state = $authorization->getObjectAuthorizationState();
     $view->addProperty(pht('Authorization State'), DrydockAuthorization::getObjectStateName($object_state));
     return $view;
 }
 private function buildPropertyListView(DrydockResource $resource)
 {
     $viewer = $this->getViewer();
     $view = new PHUIPropertyListView();
     $status = $resource->getStatus();
     $status = DrydockResourceStatus::getNameForStatus($status);
     $view->addProperty(pht('Status'), $status);
     $until = $resource->getUntil();
     if ($until) {
         $until_display = phabricator_datetime($until, $viewer);
     } else {
         $until_display = phutil_tag('em', array(), pht('Never'));
     }
     $view->addProperty(pht('Expires'), $until_display);
     $view->addProperty(pht('Resource Type'), $resource->getType());
     $view->addProperty(pht('Blueprint'), $viewer->renderHandle($resource->getBlueprintPHID()));
     $attributes = $resource->getAttributes();
     if ($attributes) {
         $view->addSectionHeader(pht('Attributes'), 'fa-list-ul');
         foreach ($attributes as $key => $value) {
             $view->addProperty($key, $value);
         }
     }
     return $view;
 }
 private function buildPropertyListView(DrydockRepositoryOperation $operation)
 {
     $viewer = $this->getViewer();
     $view = new PHUIPropertyListView();
     $view->addProperty(pht('Repository'), $viewer->renderHandle($operation->getRepositoryPHID()));
     $view->addProperty(pht('Object'), $viewer->renderHandle($operation->getObjectPHID()));
     $lease_phid = $operation->getWorkingCopyLeasePHID();
     if ($lease_phid) {
         $lease_display = $viewer->renderHandle($lease_phid);
     } else {
         $lease_display = phutil_tag('em', array(), pht('None'));
     }
     $view->addProperty(pht('Working Copy'), $lease_display);
     return $view;
 }
 public function appendImportProperties(PhabricatorUser $viewer, PhabricatorCalendarImport $import, PHUIPropertyListView $properties)
 {
     $uri_key = PhabricatorCalendarImportICSURITransaction::PARAMKEY_URI;
     $uri = $import->getParameter($uri_key);
     // Since the URI may contain a secret hash, don't show it to users who
     // can not edit the import.
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $import, PhabricatorPolicyCapability::CAN_EDIT);
     if (!$can_edit) {
         $uri_display = phutil_tag('em', array(), pht('Restricted'));
     } else {
         if (!PhabricatorEnv::isValidRemoteURIForLink($uri)) {
             $uri_display = $uri;
         } else {
             $uri_display = phutil_tag('a', array('href' => $uri, 'target' => '_blank'), $uri);
         }
     }
     $properties->addProperty(pht('Source URI'), $uri_display);
 }
 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));
 }
 private function renderProperties(PhameBlog $blog, PhabricatorUser $user, PhabricatorActionListView $actions)
 {
     require_celerity_resource('aphront-tooltip-css');
     Javelin::initBehavior('phabricator-tooltips');
     $properties = new PHUIPropertyListView();
     $properties->setActionList($actions);
     $properties->addProperty(pht('Skin'), $blog->getSkin());
     $properties->addProperty(pht('Domain'), $blog->getDomain());
     $feed_uri = PhabricatorEnv::getProductionURI($this->getApplicationURI('blog/feed/' . $blog->getID() . '/'));
     $properties->addProperty(pht('Atom URI'), javelin_tag('a', array('href' => $feed_uri, 'sigil' => 'has-tooltip', 'meta' => array('tip' => pht('Atom URI does not support custom domains.'), 'size' => 320)), $feed_uri));
     $descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions($user, $blog);
     $properties->addProperty(pht('Editable By'), $descriptions[PhabricatorPolicyCapability::CAN_EDIT]);
     $properties->addProperty(pht('Joinable By'), $descriptions[PhabricatorPolicyCapability::CAN_JOIN]);
     $engine = id(new PhabricatorMarkupEngine())->setViewer($user)->addObject($blog, PhameBlog::MARKUP_FIELD_DESCRIPTION)->process();
     $properties->addTextContent(phutil_tag('div', array('class' => 'phabricator-remarkup'), $engine->getOutput($blog, PhameBlog::MARKUP_FIELD_DESCRIPTION)));
     return $properties;
 }
 private function renderCommonProperties(PHUIPropertyListView $properties, PhabricatorCacheSpec $cache)
 {
     if ($cache->getName() !== null) {
         $name = $this->renderYes($cache->getName());
     } else {
         $name = $this->renderNo(pht('None'));
     }
     $properties->addProperty(pht('Cache'), $name);
     if ($cache->getIsEnabled()) {
         $enabled = $this->renderYes(pht('Enabled'));
     } else {
         $enabled = $this->renderNo(pht('Not Enabled'));
     }
     $properties->addProperty(pht('Enabled'), $enabled);
     $version = $cache->getVersion();
     if ($version) {
         $properties->addProperty(pht('Version'), $this->renderInfo($version));
     }
     if ($cache->getName() === null) {
         return;
     }
     $mem_total = $cache->getTotalMemory();
     $mem_used = $cache->getUsedMemory();
     if ($mem_total) {
         $percent = 100 * ($mem_used / $mem_total);
         $properties->addProperty(pht('Memory Usage'), pht('%s of %s', phutil_tag('strong', array(), sprintf('%.1f%%', $percent)), phutil_format_bytes($mem_total)));
     }
     $entry_count = $cache->getEntryCount();
     if ($entry_count !== null) {
         $properties->addProperty(pht('Cache Entries'), pht('%s', new PhutilNumber($entry_count)));
     }
 }
 public function addPropertyList(PHUIPropertyListView $property_list, $tab = null)
 {
     if (!$tab instanceof PHUIListItemView && $tab !== null) {
         assert_stringlike($tab);
         $tab = id(new PHUIListItemView())->setName($tab);
     }
     if ($tab) {
         if ($tab->getKey()) {
             $key = $tab->getKey();
         } else {
             $key = 'tab.default.' . spl_object_hash($tab);
             $tab->setKey($key);
         }
     } else {
         $key = 'tab.default';
     }
     if ($tab) {
         if (empty($this->tabs[$key])) {
             $tab->addSigil('phui-object-box-tab');
             $tab->setMetadata(array('tabKey' => $key));
             if (!$tab->getHref()) {
                 $tab->setHref('#');
             }
             if (!$tab->getType()) {
                 $tab->setType(PHUIListItemView::TYPE_LINK);
             }
             $this->tabs[$key] = $tab;
         }
     }
     $this->propertyLists[$key][] = $property_list;
     $action_list = $property_list->getActionList();
     if ($action_list) {
         $this->actionListID = celerity_generate_unique_node_id();
         $action_list->setId($this->actionListID);
     }
     return $this;
 }
 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 buildPropertyListView(DrydockResource $resource, PhabricatorActionListView $actions)
 {
     $view = new PHUIPropertyListView();
     $view->setActionList($actions);
     $status = $resource->getStatus();
     $status = DrydockResourceStatus::getNameForStatus($status);
     $view->addProperty(pht('Status'), $status);
     $view->addProperty(pht('Resource Type'), $resource->getType());
     // TODO: Load handle.
     $view->addProperty(pht('Blueprint'), $resource->getBlueprintPHID());
     $attributes = $resource->getAttributes();
     if ($attributes) {
         $view->addSectionHeader(pht('Attributes'));
         foreach ($attributes as $key => $value) {
             $view->addProperty($key, $value);
         }
     }
     return $view;
 }
 private function buildPropertyListView(DrydockLease $lease, PhabricatorActionListView $actions)
 {
     $view = new PHUIPropertyListView();
     $view->setActionList($actions);
     switch ($lease->getStatus()) {
         case DrydockLeaseStatus::STATUS_ACTIVE:
             $status = pht('Active');
             break;
         case DrydockLeaseStatus::STATUS_RELEASED:
             $status = pht('Released');
             break;
         case DrydockLeaseStatus::STATUS_EXPIRED:
             $status = pht('Expired');
             break;
         case DrydockLeaseStatus::STATUS_PENDING:
             $status = pht('Pending');
             break;
         case DrydockLeaseStatus::STATUS_BROKEN:
             $status = pht('Broken');
             break;
         default:
             $status = pht('Unknown');
             break;
     }
     $view->addProperty(pht('Status'), $status);
     $view->addProperty(pht('Resource Type'), $lease->getResourceType());
     $view->addProperty(pht('Resource'), $lease->getResourceID());
     $attributes = $lease->getAttributes();
     if ($attributes) {
         $view->addSectionHeader(pht('Attributes'));
         foreach ($attributes as $key => $value) {
             $view->addProperty($key, $value);
         }
     }
     return $view;
 }
 protected function processDiffusionRequest(AphrontRequest $request)
 {
     $user = $request->getUser();
     // This controller doesn't use blob/path stuff, just pass the dictionary
     // in directly instead of using the AphrontRequest parsing mechanism.
     $data = $request->getURIMap();
     $data['user'] = $user;
     $drequest = DiffusionRequest::newFromDictionary($data);
     $this->diffusionRequest = $drequest;
     if ($request->getStr('diff')) {
         return $this->buildRawDiffResponse($drequest);
     }
     $repository = $drequest->getRepository();
     $callsign = $repository->getCallsign();
     $content = array();
     $commit = id(new DiffusionCommitQuery())->setViewer($request->getUser())->withRepository($repository)->withIdentifiers(array($drequest->getCommit()))->needCommitData(true)->needAuditRequests(true)->executeOne();
     $crumbs = $this->buildCrumbs(array('commit' => true));
     if (!$commit) {
         $exists = $this->callConduitWithDiffusionRequest('diffusion.existsquery', array('commit' => $drequest->getCommit()));
         if (!$exists) {
             return new Aphront404Response();
         }
         $error = id(new PHUIInfoView())->setTitle(pht('Commit Still Parsing'))->appendChild(pht('Failed to load the commit because the commit has not been ' . 'parsed yet.'));
         return $this->buildApplicationPage(array($crumbs, $error), array('title' => pht('Commit Still Parsing')));
     }
     $audit_requests = $commit->getAudits();
     $this->auditAuthorityPHIDs = PhabricatorAuditCommentEditor::loadAuditPHIDsForUser($user);
     $commit_data = $commit->getCommitData();
     $is_foreign = $commit_data->getCommitDetail('foreign-svn-stub');
     if ($is_foreign) {
         $subpath = $commit_data->getCommitDetail('svn-subpath');
         $error_panel = new PHUIInfoView();
         $error_panel->setTitle(pht('Commit Not Tracked'));
         $error_panel->setSeverity(PHUIInfoView::SEVERITY_WARNING);
         $error_panel->appendChild(pht("This Diffusion repository is configured to track only one " . "subdirectory of the entire Subversion repository, and this commit " . "didn't affect the tracked subdirectory ('%s'), so no " . "information is available.", $subpath));
         $content[] = $error_panel;
     } else {
         $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
         $engine->setConfig('viewer', $user);
         require_celerity_resource('phabricator-remarkup-css');
         $parents = $this->callConduitWithDiffusionRequest('diffusion.commitparentsquery', array('commit' => $drequest->getCommit()));
         if ($parents) {
             $parents = id(new DiffusionCommitQuery())->setViewer($user)->withRepository($repository)->withIdentifiers($parents)->execute();
         }
         $headsup_view = id(new PHUIHeaderView())->setHeader(nonempty($commit->getSummary(), pht('Commit Detail')));
         $headsup_actions = $this->renderHeadsupActionList($commit, $repository);
         $commit_properties = $this->loadCommitProperties($commit, $commit_data, $parents, $audit_requests);
         $property_list = id(new PHUIPropertyListView())->setHasKeyboardShortcuts(true)->setUser($user)->setObject($commit);
         foreach ($commit_properties as $key => $value) {
             $property_list->addProperty($key, $value);
         }
         $message = $commit_data->getCommitMessage();
         $revision = $commit->getCommitIdentifier();
         $message = $this->linkBugtraq($message);
         $message = $engine->markupText($message);
         $property_list->invokeWillRenderEvent();
         $property_list->setActionList($headsup_actions);
         $detail_list = new PHUIPropertyListView();
         $detail_list->addSectionHeader(pht('Description'), PHUIPropertyListView::ICON_SUMMARY);
         $detail_list->addTextContent(phutil_tag('div', array('class' => 'diffusion-commit-message phabricator-remarkup'), $message));
         $headsup_view->setTall(true);
         $object_box = id(new PHUIObjectBoxView())->setHeader($headsup_view)->addPropertyList($property_list)->addPropertyList($detail_list);
         $content[] = $object_box;
     }
     $content[] = $this->buildComments($commit);
     $hard_limit = 1000;
     if ($commit->isImported()) {
         $change_query = DiffusionPathChangeQuery::newFromDiffusionRequest($drequest);
         $change_query->setLimit($hard_limit + 1);
         $changes = $change_query->loadChanges();
     } else {
         $changes = array();
     }
     $was_limited = count($changes) > $hard_limit;
     if ($was_limited) {
         $changes = array_slice($changes, 0, $hard_limit);
     }
     $content[] = $this->buildMergesTable($commit);
     $highlighted_audits = $commit->getAuthorityAudits($user, $this->auditAuthorityPHIDs);
     $count = count($changes);
     $bad_commit = null;
     if ($count == 0) {
         $bad_commit = queryfx_one(id(new PhabricatorRepository())->establishConnection('r'), 'SELECT * FROM %T WHERE fullCommitName = %s', PhabricatorRepository::TABLE_BADCOMMIT, 'r' . $callsign . $commit->getCommitIdentifier());
     }
     $show_changesets = false;
     if ($bad_commit) {
         $content[] = $this->renderStatusMessage(pht('Bad Commit'), $bad_commit['description']);
     } else {
         if ($is_foreign) {
             // Don't render anything else.
         } else {
             if (!$commit->isImported()) {
                 $content[] = $this->renderStatusMessage(pht('Still Importing...'), pht('This commit is still importing. Changes will be visible once ' . 'the import finishes.'));
             } else {
                 if (!count($changes)) {
                     $content[] = $this->renderStatusMessage(pht('Empty Commit'), pht('This commit is empty and does not affect any paths.'));
                 } else {
                     if ($was_limited) {
                         $content[] = $this->renderStatusMessage(pht('Enormous Commit'), pht('This commit is enormous, and affects more than %d files. ' . 'Changes are not shown.', $hard_limit));
                     } else {
                         $show_changesets = true;
                         // The user has clicked "Show All Changes", and we should show all the
                         // changes inline even if there are more than the soft limit.
                         $show_all_details = $request->getBool('show_all');
                         $change_panel = new PHUIObjectBoxView();
                         $header = new PHUIHeaderView();
                         $header->setHeader(pht('Changes (%s)', new PhutilNumber($count)));
                         $change_panel->setID('toc');
                         if ($count > self::CHANGES_LIMIT && !$show_all_details) {
                             $icon = id(new PHUIIconView())->setIconFont('fa-files-o');
                             $button = id(new PHUIButtonView())->setText(pht('Show All Changes'))->setHref('?show_all=true')->setTag('a')->setIcon($icon);
                             $warning_view = id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_WARNING)->setTitle(pht('Very Large Commit'))->appendChild(pht('This commit is very large. Load each file individually.'));
                             $change_panel->setInfoView($warning_view);
                             $header->addActionLink($button);
                         }
                         $changesets = DiffusionPathChange::convertToDifferentialChangesets($user, $changes);
                         // TODO: This table and panel shouldn't really be separate, but we need
                         // to clean up the "Load All Files" interaction first.
                         $change_table = $this->buildTableOfContents($changesets);
                         $change_panel->setTable($change_table);
                         $change_panel->setHeader($header);
                         $content[] = $change_panel;
                         $vcs = $repository->getVersionControlSystem();
                         switch ($vcs) {
                             case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
                                 $vcs_supports_directory_changes = true;
                                 break;
                             case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
                             case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
                                 $vcs_supports_directory_changes = false;
                                 break;
                             default:
                                 throw new Exception(pht('Unknown VCS.'));
                         }
                         $references = array();
                         foreach ($changesets as $key => $changeset) {
                             $file_type = $changeset->getFileType();
                             if ($file_type == DifferentialChangeType::FILE_DIRECTORY) {
                                 if (!$vcs_supports_directory_changes) {
                                     unset($changesets[$key]);
                                     continue;
                                 }
                             }
                             $references[$key] = $drequest->generateURI(array('action' => 'rendering-ref', 'path' => $changeset->getFilename()));
                         }
                         // TODO: Some parts of the views still rely on properties of the
                         // DifferentialChangeset. Make the objects ephemeral to make sure we don't
                         // accidentally save them, and then set their ID to the appropriate ID for
                         // this application (the path IDs).
                         $path_ids = array_flip(mpull($changes, 'getPath'));
                         foreach ($changesets as $changeset) {
                             $changeset->makeEphemeral();
                             $changeset->setID($path_ids[$changeset->getFilename()]);
                         }
                         if ($count <= self::CHANGES_LIMIT || $show_all_details) {
                             $visible_changesets = $changesets;
                         } else {
                             $visible_changesets = array();
                             $inlines = PhabricatorAuditInlineComment::loadDraftAndPublishedComments($user, $commit->getPHID());
                             $path_ids = mpull($inlines, null, 'getPathID');
                             foreach ($changesets as $key => $changeset) {
                                 if (array_key_exists($changeset->getID(), $path_ids)) {
                                     $visible_changesets[$key] = $changeset;
                                 }
                             }
                         }
                         $change_list_title = DiffusionView::nameCommit($repository, $commit->getCommitIdentifier());
                         $change_list = new DifferentialChangesetListView();
                         $change_list->setTitle($change_list_title);
                         $change_list->setChangesets($changesets);
                         $change_list->setVisibleChangesets($visible_changesets);
                         $change_list->setRenderingReferences($references);
                         $change_list->setRenderURI('/diffusion/' . $callsign . '/diff/');
                         $change_list->setRepository($repository);
                         $change_list->setUser($user);
                         // TODO: Try to setBranch() to something reasonable here?
                         $change_list->setStandaloneURI('/diffusion/' . $callsign . '/diff/');
                         $change_list->setRawFileURIs(null, '/diffusion/' . $callsign . '/diff/?view=r');
                         $change_list->setInlineCommentControllerURI('/diffusion/inline/edit/' . phutil_escape_uri($commit->getPHID()) . '/');
                         $content[] = $change_list->render();
                     }
                 }
             }
         }
     }
     $content[] = $this->renderAddCommentPanel($commit, $audit_requests);
     $commit_id = 'r' . $callsign . $commit->getCommitIdentifier();
     $short_name = DiffusionView::nameCommit($repository, $commit->getCommitIdentifier());
     $prefs = $user->loadPreferences();
     $pref_filetree = PhabricatorUserPreferences::PREFERENCE_DIFF_FILETREE;
     $pref_collapse = PhabricatorUserPreferences::PREFERENCE_NAV_COLLAPSED;
     $show_filetree = $prefs->getPreference($pref_filetree);
     $collapsed = $prefs->getPreference($pref_collapse);
     if ($show_changesets && $show_filetree) {
         $nav = id(new DifferentialChangesetFileTreeSideNavBuilder())->setTitle($short_name)->setBaseURI(new PhutilURI('/' . $commit_id))->build($changesets)->setCrumbs($crumbs)->setCollapsed((bool) $collapsed)->appendChild($content);
         $content = $nav;
     } else {
         $content = array($crumbs, $content);
     }
     return $this->buildApplicationPage($content, array('title' => $commit_id, 'pageObjects' => array($commit->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(basename($this->getDiffusionRequest()->getPath()))->addActionLink($file)->setHeaderIcon('fa-file-image-o');
     return id(new PHUIObjectBoxView())->setHeader($header)->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->addPropertyList($properties);
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $id = $this->id;
     $generation = $request->getInt('g');
     $build = id(new HarbormasterBuildQuery())->setViewer($viewer)->withIDs(array($id))->executeOne();
     if (!$build) {
         return new Aphront404Response();
     }
     require_celerity_resource('harbormaster-css');
     $title = pht('Build %d', $id);
     $header = id(new PHUIHeaderView())->setHeader($title)->setUser($viewer)->setPolicyObject($build);
     if ($build->isRestarting()) {
         $header->setStatus('fa-exclamation-triangle', 'red', pht('Restarting'));
     } else {
         if ($build->isStopping()) {
             $header->setStatus('fa-exclamation-triangle', 'red', pht('Pausing'));
         } else {
             if ($build->isResuming()) {
                 $header->setStatus('fa-exclamation-triangle', 'red', pht('Resuming'));
             }
         }
     }
     $box = id(new PHUIObjectBoxView())->setHeader($header);
     $actions = $this->buildActionList($build);
     $this->buildPropertyLists($box, $build, $actions);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb($build->getBuildable()->getMonogram(), '/' . $build->getBuildable()->getMonogram());
     $crumbs->addTextCrumb($title);
     if ($generation === null || $generation > $build->getBuildGeneration() || $generation < 0) {
         $generation = $build->getBuildGeneration();
     }
     $build_targets = id(new HarbormasterBuildTargetQuery())->setViewer($viewer)->needBuildSteps(true)->withBuildPHIDs(array($build->getPHID()))->withBuildGenerations(array($generation))->execute();
     if ($build_targets) {
         $messages = id(new HarbormasterBuildMessageQuery())->setViewer($viewer)->withBuildTargetPHIDs(mpull($build_targets, 'getPHID'))->execute();
         $messages = mgroup($messages, 'getBuildTargetPHID');
     } else {
         $messages = array();
     }
     $targets = array();
     foreach ($build_targets as $build_target) {
         $header = id(new PHUIHeaderView())->setHeader($build_target->getName())->setUser($viewer);
         $target_box = id(new PHUIObjectBoxView())->setHeader($header);
         $properties = new PHUIPropertyListView();
         $status_view = new PHUIStatusListView();
         $item = new PHUIStatusItemView();
         $status = $build_target->getTargetStatus();
         $status_name = HarbormasterBuildTarget::getBuildTargetStatusName($status);
         $icon = HarbormasterBuildTarget::getBuildTargetStatusIcon($status);
         $color = HarbormasterBuildTarget::getBuildTargetStatusColor($status);
         $item->setTarget($status_name);
         $item->setIcon($icon, $color);
         $status_view->addItem($item);
         $properties->addProperty(pht('Name'), $build_target->getName());
         if ($build_target->getDateStarted() !== null) {
             $properties->addProperty(pht('Started'), phabricator_datetime($build_target->getDateStarted(), $viewer));
             if ($build_target->isComplete()) {
                 $properties->addProperty(pht('Completed'), phabricator_datetime($build_target->getDateCompleted(), $viewer));
                 $properties->addProperty(pht('Duration'), phutil_format_relative_time_detailed($build_target->getDateCompleted() - $build_target->getDateStarted()));
             } else {
                 $properties->addProperty(pht('Elapsed'), phutil_format_relative_time_detailed(time() - $build_target->getDateStarted()));
             }
         }
         $properties->addProperty(pht('Status'), $status_view);
         $target_box->addPropertyList($properties, pht('Overview'));
         $step = $build_target->getBuildStep();
         if ($step) {
             $description = $step->getDescription();
             if ($description) {
                 $rendered = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($description)->setPreserveLinebreaks(true), 'default', $viewer);
                 $properties->addSectionHeader(pht('Description'));
                 $properties->addTextContent($rendered);
             }
         } else {
             $target_box->setFormErrors(array(pht('This build step has since been deleted on the build plan.  ' . 'Some information may be omitted.')));
         }
         $details = $build_target->getDetails();
         if ($details) {
             $properties = new PHUIPropertyListView();
             foreach ($details as $key => $value) {
                 $properties->addProperty($key, $value);
             }
             $target_box->addPropertyList($properties, pht('Configuration'));
         }
         $variables = $build_target->getVariables();
         if ($variables) {
             $properties = new PHUIPropertyListView();
             foreach ($variables as $key => $value) {
                 $properties->addProperty($key, $value);
             }
             $target_box->addPropertyList($properties, pht('Variables'));
         }
         $artifacts = $this->buildArtifacts($build_target);
         if ($artifacts) {
             $properties = new PHUIPropertyListView();
             $properties->addRawContent($artifacts);
             $target_box->addPropertyList($properties, pht('Artifacts'));
         }
         $build_messages = idx($messages, $build_target->getPHID(), array());
         if ($build_messages) {
             $properties = new PHUIPropertyListView();
             $properties->addRawContent($this->buildMessages($build_messages));
             $target_box->addPropertyList($properties, pht('Messages'));
         }
         $properties = new PHUIPropertyListView();
         $properties->addProperty('Build Target ID', $build_target->getID());
         $target_box->addPropertyList($properties, pht('Metadata'));
         $targets[] = $target_box;
         $targets[] = $this->buildLog($build, $build_target);
     }
     $xactions = id(new HarbormasterBuildTransactionQuery())->setViewer($viewer)->withObjectPHIDs(array($build->getPHID()))->execute();
     $timeline = id(new PhabricatorApplicationTransactionView())->setUser($viewer)->setObjectPHID($build->getPHID())->setTransactions($xactions);
     return $this->buildApplicationPage(array($crumbs, $box, $targets, $timeline), array('title' => $title));
 }
 private function buildRetryListView(PhabricatorWorkerTask $task)
 {
     $view = new PHUIPropertyListView();
     $data = id(new PhabricatorWorkerTaskData())->load($task->getDataID());
     $task->setData($data->getData());
     $worker = $task->getWorkerInstance();
     $view->addProperty(pht('Failure Count'), $task->getFailureCount());
     $retry_count = $worker->getMaximumRetryCount();
     if ($retry_count === null) {
         $max_retries = phutil_tag('em', array(), pht('Retries Forever'));
         $retry_count = INF;
     } else {
         $max_retries = $retry_count;
     }
     $view->addProperty(pht('Maximum Retries'), $max_retries);
     $projection = clone $task;
     $projection->makeEphemeral();
     $next = array();
     for ($ii = $task->getFailureCount(); $ii < $retry_count; $ii++) {
         $projection->setFailureCount($ii);
         $next[] = $worker->getWaitBeforeRetry($projection);
         if (count($next) > 10) {
             break;
         }
     }
     if ($next) {
         $cumulative = 0;
         foreach ($next as $key => $duration) {
             if ($duration === null) {
                 $duration = 60;
             }
             $cumulative += $duration;
             $next[$key] = phutil_format_relative_time($cumulative);
         }
         if ($ii != $retry_count) {
             $next[] = '...';
         }
         $retries_in = implode(', ', $next);
     } else {
         $retries_in = pht('No More Retries');
     }
     $view->addProperty(pht('Retries After'), $retries_in);
     return $view;
 }
 private function buildDefined(PHUIPropertyListView $view, DivinerLiveSymbol $symbol)
 {
     $atom = $symbol->getAtom();
     $defined = $atom->getFile() . ':' . $atom->getLine();
     $link = $symbol->getBook()->getConfig('uri.source');
     if ($link) {
         $link = strtr($link, array('%%' => '%', '%f' => phutil_escape_uri($atom->getFile()), '%l' => phutil_escape_uri($atom->getLine())));
         $defined = phutil_tag('a', array('href' => $link, 'target' => '_blank'), $defined);
     }
     $view->addProperty(pht('Defined'), $defined);
 }
 private function buildDescriptionView(ManiphestTask $task)
 {
     $viewer = $this->getViewer();
     $section = null;
     $description = $task->getDescription();
     if (strlen($description)) {
         $section = new PHUIPropertyListView();
         $section->addTextContent(phutil_tag('div', array('class' => 'phabricator-remarkup'), id(new PHUIRemarkupView($viewer, $description))->setContextObject($task)));
     }
     return $section;
 }
 private function buildDescriptionView(ManiphestTask $task, PhabricatorMarkupEngine $engine)
 {
     $section = null;
     if (strlen($task->getDescription())) {
         $section = new PHUIPropertyListView();
         $section->addSectionHeader(pht('Description'), PHUIPropertyListView::ICON_SUMMARY);
         $section->addTextContent(phutil_tag('div', array('class' => 'phabricator-remarkup'), $engine->getOutput($task, ManiphestTask::MARKUP_FIELD_DESCRIPTION)));
     }
     return $section;
 }
 private function buildObjectTranscriptPanel(HeraldTranscript $xscript)
 {
     $adapter = $this->getAdapter();
     $field_names = $adapter->getFieldNameMap();
     $object_xscript = $xscript->getObjectTranscript();
     $data = array();
     if ($object_xscript) {
         $phid = $object_xscript->getPHID();
         $handles = $this->handles;
         $data += array(pht('Object Name') => $object_xscript->getName(), pht('Object Type') => $object_xscript->getType(), pht('Object PHID') => $phid, pht('Object Link') => $handles[$phid]->renderLink());
     }
     $data += $xscript->getMetadataMap();
     if ($object_xscript) {
         foreach ($object_xscript->getFields() as $field => $value) {
             $field = idx($field_names, $field, '[' . $field . '?]');
             $data['Field: ' . $field] = $value;
         }
     }
     $rows = array();
     foreach ($data as $name => $value) {
         if (!$value instanceof PhutilSafeHTML) {
             if (!is_scalar($value) && !is_null($value)) {
                 $value = implode("\n", $value);
             }
             if (strlen($value) > 256) {
                 $value = phutil_tag('textarea', array('class' => 'herald-field-value-transcript'), $value);
             }
         }
         $rows[] = array($name, $value);
     }
     $property_list = new PHUIPropertyListView();
     $property_list->setStacked(true);
     foreach ($rows as $row) {
         $property_list->addProperty($row[0], $row[1]);
     }
     $box = new PHUIObjectBoxView();
     $box->setHeaderText(pht('Object Transcript'));
     $box->appendChild($property_list);
     return $box;
 }
 public function renderExample()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $details1 = id(new PHUIListItemView())->setName('Details')->setSelected(true);
     $details2 = id(new PHUIListItemView())->setName('Rainbow Info')->setStatusColor(PHUIListItemView::STATUS_WARN);
     $details3 = id(new PHUIListItemView())->setName('Pasta Haiku')->setStatusColor(PHUIListItemView::STATUS_FAIL);
     $statustabs = id(new PHUIListView())->setType(PHUIListView::NAVBAR_LIST)->addMenuItem($details1)->addMenuItem($details2)->addMenuItem($details3);
     $view = new PHUIPropertyListView();
     $view->addProperty(pht('Color'), pht('Yellow'));
     $view->addProperty(pht('Size'), pht('Mouse'));
     $view->addProperty(pht('Element'), pht('Electric'));
     $view->addTextContent('Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' . 'Quisque rhoncus tempus massa, sit amet faucibus lectus bibendum ' . 'viverra. Nunc tempus tempor quam id iaculis. Maecenas lectus ' . 'velit, aliquam et consequat quis, tincidunt id dolor.');
     $view2 = new PHUIPropertyListView();
     $view2->addSectionHeader('Colors of the Rainbow');
     $view2->addProperty('R', 'Red');
     $view2->addProperty('O', 'Orange');
     $view2->addProperty('Y', 'Yellow');
     $view2->addProperty('G', 'Green');
     $view2->addProperty('B', 'Blue');
     $view2->addProperty('I', 'Indigo');
     $view2->addProperty('V', 'Violet');
     $view3 = new PHUIPropertyListView();
     $view3->addSectionHeader('Haiku About Pasta');
     $view3->addTextContent(hsprintf('this is a pasta<br />' . 'haiku. it is very bad.<br />' . 'what did you expect?'));
     $object_box1 = id(new PHUIObjectBoxView())->setHeaderText('PHUIPropertyListView Stackered')->addPropertyList($view, $details1)->addPropertyList($view2, $details2)->addPropertyList($view3, $details3);
     $edge_cases_view = new PHUIPropertyListView();
     $edge_cases_view->addProperty(pht('Description'), pht('These layouts test UI edge cases in the element. This block ' . 'tests wrapping and overflow behavior.'));
     $edge_cases_view->addProperty(pht('A Very Very Very Very Very Very Very Very Very Long Property Label'), pht('This property label and property value are quite long. They ' . 'demonstrate the wrapping behavior of the element, or lack thereof ' . 'if something terrible has happened.'));
     $edge_cases_view->addProperty(pht('AVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongUnbrokenPropertyLabel'), pht('Thispropertylabelandpropertyvaluearequitelongandhave' . 'nospacestheydemonstratetheoverflowbehavioroftheelement' . 'orlackthereof.'));
     $edge_cases_view->addProperty(pht('Description'), pht('The next section is an empty text block.'));
     $edge_cases_view->addTextContent('');
     $edge_cases_view->addProperty(pht('Description'), pht('This section should have multiple properties with the same name.'));
     $edge_cases_view->addProperty(pht('Joe'), pht('Smith'));
     $edge_cases_view->addProperty(pht('Joe'), pht('Smith'));
     $edge_cases_view->addProperty(pht('Joe'), pht('Smith'));
     $object_box2 = id(new PHUIObjectBoxView())->setHeaderText('Some Bad Examples')->addPropertyList($edge_cases_view);
     return array($object_box1, $object_box2);
 }
 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);
 }
 public function appendFieldsToPropertyList(PhabricatorCustomFieldInterface $object, PhabricatorUser $viewer, PHUIPropertyListView $view)
 {
     $this->readFieldsFromStorage($object);
     $fields = $this->fields;
     foreach ($fields as $field) {
         $field->setViewer($viewer);
     }
     // Move all the blocks to the end, regardless of their configuration order,
     // because it always looks silly to render a block in the middle of a list
     // of properties.
     $head = array();
     $tail = array();
     foreach ($fields as $key => $field) {
         $style = $field->getStyleForPropertyView();
         switch ($style) {
             case 'property':
             case 'header':
                 $head[$key] = $field;
                 break;
             case 'block':
                 $tail[$key] = $field;
                 break;
             default:
                 throw new Exception(pht("Unknown field property view style '%s'; valid styles are " . "'%s' and '%s'.", $style, 'block', 'property'));
         }
     }
     $fields = $head + $tail;
     $add_header = null;
     $phids = array();
     foreach ($fields as $key => $field) {
         $phids[$key] = $field->getRequiredHandlePHIDsForPropertyView();
     }
     $all_phids = array_mergev($phids);
     if ($all_phids) {
         $handles = id(new PhabricatorHandleQuery())->setViewer($viewer)->withPHIDs($all_phids)->execute();
     } else {
         $handles = array();
     }
     foreach ($fields as $key => $field) {
         $field_handles = array_select_keys($handles, $phids[$key]);
         $label = $field->renderPropertyViewLabel();
         $value = $field->renderPropertyViewValue($field_handles);
         if ($value !== null) {
             switch ($field->getStyleForPropertyView()) {
                 case 'header':
                     // We want to hide headers if the fields the're assciated with
                     // don't actually produce any visible properties. For example, in a
                     // list like this:
                     //
                     //   Header A
                     //   Prop A: Value A
                     //   Header B
                     //   Prop B: Value B
                     //
                     // ...if the "Prop A" field returns `null` when rendering its
                     // property value and we rendered naively, we'd get this:
                     //
                     //   Header A
                     //   Header B
                     //   Prop B: Value B
                     //
                     // This is silly. Instead, we hide "Header A".
                     $add_header = $value;
                     break;
                 case 'property':
                     if ($add_header !== null) {
                         // Add the most recently seen header.
                         $view->addSectionHeader($add_header);
                         $add_header = null;
                     }
                     $view->addProperty($label, $value);
                     break;
                 case 'block':
                     $icon = $field->getIconForPropertyView();
                     $view->invokeWillRenderEvent();
                     if ($label !== null) {
                         $view->addSectionHeader($label, $icon);
                     }
                     $view->addTextContent($value);
                     break;
             }
         }
     }
 }