public function render()
 {
     $request = $this->getDiffusionRequest();
     $repository = $request->getRepository();
     $base_path = trim($request->getPath(), '/');
     if ($base_path) {
         $base_path = $base_path . '/';
     }
     $need_pull = array();
     $rows = array();
     $show_edit = false;
     foreach ($this->paths as $path) {
         $full_path = $base_path . $path->getPath();
         $dir_slash = null;
         $file_type = $path->getFileType();
         if ($file_type == DifferentialChangeType::FILE_DIRECTORY) {
             $browse_text = $path->getPath() . '/';
             $dir_slash = '/';
             $browse_link = phutil_tag('strong', array(), $this->linkBrowse($full_path . $dir_slash, array('type' => $file_type, 'name' => $browse_text)));
             $history_path = $full_path . '/';
         } else {
             if ($file_type == DifferentialChangeType::FILE_SUBMODULE) {
                 $browse_text = $path->getPath() . '/';
                 $browse_link = phutil_tag('strong', array(), $this->linkBrowse(null, array('type' => $file_type, 'name' => $browse_text, 'hash' => $path->getHash(), 'external' => $path->getExternalURI())));
                 $history_path = $full_path . '/';
             } else {
                 $browse_text = $path->getPath();
                 $browse_link = $this->linkBrowse($full_path, array('type' => $file_type, 'name' => $browse_text));
                 $history_path = $full_path;
             }
         }
         $history_link = $this->linkHistory($history_path);
         $dict = array('lint' => celerity_generate_unique_node_id(), 'commit' => celerity_generate_unique_node_id(), 'date' => celerity_generate_unique_node_id(), 'author' => celerity_generate_unique_node_id(), 'details' => celerity_generate_unique_node_id());
         $need_pull[$full_path . $dir_slash] = $dict;
         foreach ($dict as $k => $uniq) {
             $dict[$k] = phutil_tag('span', array('id' => $uniq), '');
         }
         $rows[] = array($history_link, $browse_link, idx($dict, 'lint'), $dict['commit'], $dict['details'], $dict['date']);
     }
     if ($need_pull) {
         Javelin::initBehavior('diffusion-pull-lastmodified', array('uri' => (string) $request->generateURI(array('action' => 'lastmodified', 'stable' => true)), 'map' => $need_pull));
     }
     $branch = $this->getDiffusionRequest()->loadBranch();
     $show_lint = $branch && $branch->getLintCommit();
     $lint = $request->getLint();
     $view = new AphrontTableView($rows);
     $view->setHeaders(array(null, pht('Path'), $lint ? $lint : pht('Lint'), pht('Modified'), pht('Details'), pht('Committed')));
     $view->setColumnClasses(array('nudgeright', '', '', '', 'wide', 'right'));
     $view->setColumnVisibility(array(true, true, $show_lint, true, true, true));
     $view->setDeviceVisibility(array(true, true, false, false, true, false));
     return $view->render();
 }
 public function processRequest(AphrontRequest $request)
 {
     if ($request->getExists('new')) {
         return $this->processNew($request);
     }
     if ($request->getExists('edit')) {
         return $this->processEdit($request);
     }
     if ($request->getExists('delete')) {
         return $this->processDelete($request);
     }
     $user = $this->getUser();
     $viewer = $request->getUser();
     $factors = id(new PhabricatorAuthFactorConfig())->loadAllWhere('userPHID = %s', $user->getPHID());
     $rows = array();
     $rowc = array();
     $highlight_id = $request->getInt('id');
     foreach ($factors as $factor) {
         $impl = $factor->getImplementation();
         if ($impl) {
             $type = $impl->getFactorName();
         } else {
             $type = $factor->getFactorKey();
         }
         if ($factor->getID() == $highlight_id) {
             $rowc[] = 'highlighted';
         } else {
             $rowc[] = null;
         }
         $rows[] = array(javelin_tag('a', array('href' => $this->getPanelURI('?edit=' . $factor->getID()), 'sigil' => 'workflow'), $factor->getFactorName()), $type, phabricator_datetime($factor->getDateCreated(), $viewer), javelin_tag('a', array('href' => $this->getPanelURI('?delete=' . $factor->getID()), 'sigil' => 'workflow', 'class' => 'small grey button'), pht('Remove')));
     }
     $table = new AphrontTableView($rows);
     $table->setNoDataString(pht("You haven't added any authentication factors to your account yet."));
     $table->setHeaders(array(pht('Name'), pht('Type'), pht('Created'), ''));
     $table->setColumnClasses(array('wide pri', '', 'right', 'action'));
     $table->setRowClasses($rowc);
     $table->setDeviceVisibility(array(true, false, false, true));
     $panel = new PHUIObjectBoxView();
     $header = new PHUIHeaderView();
     $help_uri = PhabricatorEnv::getDoclink('User Guide: Multi-Factor Authentication');
     $help_icon = id(new PHUIIconView())->setIconFont('fa-info-circle');
     $help_button = id(new PHUIButtonView())->setText(pht('Help'))->setHref($help_uri)->setTag('a')->setIcon($help_icon);
     $create_icon = id(new PHUIIconView())->setIconFont('fa-plus');
     $create_button = id(new PHUIButtonView())->setText(pht('Add Authentication Factor'))->setHref($this->getPanelURI('?new=true'))->setTag('a')->setWorkflow(true)->setIcon($create_icon);
     $header->setHeader(pht('Authentication Factors'));
     $header->addActionLink($help_button);
     $header->addActionLink($create_button);
     $panel->setHeader($header);
     $panel->setTable($table);
     return $panel;
 }
 public function render()
 {
     $drequest = $this->getDiffusionRequest();
     $viewer = $this->getUser();
     $buildables = $this->loadBuildables(mpull($this->history, 'getCommit'));
     $has_any_build = false;
     $show_revisions = PhabricatorApplication::isClassInstalledForViewer('PhabricatorDifferentialApplication', $viewer);
     $handles = $viewer->loadHandles($this->getRequiredHandlePHIDs());
     $graph = null;
     if ($this->parents) {
         $graph = $this->renderGraph();
     }
     $show_builds = PhabricatorApplication::isClassInstalledForViewer('PhabricatorHarbormasterApplication', $this->getUser());
     $rows = array();
     $ii = 0;
     foreach ($this->history as $history) {
         $epoch = $history->getEpoch();
         if ($epoch) {
             $committed = phabricator_datetime($epoch, $viewer);
         } else {
             $committed = null;
         }
         $data = $history->getCommitData();
         $author_phid = $committer = $committer_phid = null;
         if ($data) {
             $author_phid = $data->getCommitDetail('authorPHID');
             $committer_phid = $data->getCommitDetail('committerPHID');
             $committer = $data->getCommitDetail('committer');
         }
         if ($author_phid && isset($handles[$author_phid])) {
             $author = $handles[$author_phid]->renderLink();
         } else {
             $author = self::renderName($history->getAuthorName());
         }
         $different_committer = false;
         if ($committer_phid) {
             $different_committer = $committer_phid != $author_phid;
         } else {
             if ($committer != '') {
                 $different_committer = $committer != $history->getAuthorName();
             }
         }
         if ($different_committer) {
             if ($committer_phid && isset($handles[$committer_phid])) {
                 $committer = $handles[$committer_phid]->renderLink();
             } else {
                 $committer = self::renderName($committer);
             }
             $author = hsprintf('%s/%s', $author, $committer);
         }
         // We can show details once the message and change have been imported.
         $partial_import = PhabricatorRepositoryCommit::IMPORTED_MESSAGE | PhabricatorRepositoryCommit::IMPORTED_CHANGE;
         $commit = $history->getCommit();
         if ($commit && $commit->isPartiallyImported($partial_import) && $data) {
             $summary = AphrontTableView::renderSingleDisplayLine($history->getSummary());
         } else {
             $summary = phutil_tag('em', array(), pht("Importing…"));
         }
         $build = null;
         if ($show_builds) {
             $buildable = idx($buildables, $commit->getPHID());
             if ($buildable !== null) {
                 $build = $this->renderBuildable($buildable);
                 $has_any_build = true;
             }
         }
         $browse = $this->linkBrowse($history->getPath(), array('commit' => $history->getCommitIdentifier(), 'branch' => $drequest->getBranch(), 'type' => $history->getFileType()));
         $rows[] = array($graph ? $graph[$ii++] : null, $browse, self::linkCommit($drequest->getRepository(), $history->getCommitIdentifier()), $build, $commit ? self::linkRevision(idx($this->revisions, $commit->getPHID())) : null, $author, $summary, $committed);
     }
     $view = new AphrontTableView($rows);
     $view->setHeaders(array(null, null, pht('Commit'), null, null, pht('Author/Committer'), pht('Details'), pht('Committed')));
     $view->setColumnClasses(array('threads', 'nudgeright', '', 'icon', '', '', 'wide', ''));
     $view->setColumnVisibility(array($graph ? true : false, true, true, $has_any_build, $show_revisions));
     $view->setDeviceVisibility(array($graph ? true : false, true, true, true, true, false, true, false));
     return $view->render();
 }
 public function render()
 {
     $drequest = $this->getDiffusionRequest();
     $handles = $this->handles;
     $graph = null;
     if ($this->parents) {
         $graph = $this->renderGraph();
     }
     $show_builds = PhabricatorApplication::isClassInstalledForViewer('PhabricatorHarbormasterApplication', $this->getUser());
     $rows = array();
     $ii = 0;
     foreach ($this->history as $history) {
         $epoch = $history->getEpoch();
         if ($epoch) {
             $date = phabricator_date($epoch, $this->user);
             $time = phabricator_time($epoch, $this->user);
         } else {
             $date = null;
             $time = null;
         }
         $data = $history->getCommitData();
         $author_phid = $committer = $committer_phid = null;
         if ($data) {
             $author_phid = $data->getCommitDetail('authorPHID');
             $committer_phid = $data->getCommitDetail('committerPHID');
             $committer = $data->getCommitDetail('committer');
         }
         if ($author_phid && isset($handles[$author_phid])) {
             $author = $handles[$author_phid]->renderLink();
         } else {
             $author = self::renderName($history->getAuthorName());
         }
         $different_committer = false;
         if ($committer_phid) {
             $different_committer = $committer_phid != $author_phid;
         } else {
             if ($committer != '') {
                 $different_committer = $committer != $history->getAuthorName();
             }
         }
         if ($different_committer) {
             if ($committer_phid && isset($handles[$committer_phid])) {
                 $committer = $handles[$committer_phid]->renderLink();
             } else {
                 $committer = self::renderName($committer);
             }
             $author = hsprintf('%s/%s', $author, $committer);
         }
         // We can show details once the message and change have been imported.
         $partial_import = PhabricatorRepositoryCommit::IMPORTED_MESSAGE | PhabricatorRepositoryCommit::IMPORTED_CHANGE;
         $commit = $history->getCommit();
         if ($commit && $commit->isPartiallyImported($partial_import) && $data) {
             $summary = AphrontTableView::renderSingleDisplayLine($history->getSummary());
         } else {
             $summary = phutil_tag('em', array(), "Importing…");
         }
         $build = null;
         if ($show_builds) {
             $buildable_lookup = $this->loadBuildablesOnDemand();
             $buildable = idx($buildable_lookup, $commit->getPHID());
             if ($buildable !== null) {
                 $icon = HarbormasterBuildable::getBuildableStatusIcon($buildable->getBuildableStatus());
                 $color = HarbormasterBuildable::getBuildableStatusColor($buildable->getBuildableStatus());
                 $name = HarbormasterBuildable::getBuildableStatusName($buildable->getBuildableStatus());
                 $icon_view = id(new PHUIIconView())->setIconFont($icon . ' ' . $color);
                 $tooltip_view = javelin_tag('span', array('sigil' => 'has-tooltip', 'meta' => array('tip' => $name)), $icon_view);
                 Javelin::initBehavior('phabricator-tooltips');
                 $href_view = phutil_tag('a', array('href' => '/' . $buildable->getMonogram()), $tooltip_view);
                 $build = $href_view;
                 $has_any_build = true;
             }
         }
         $rows[] = array($graph ? $graph[$ii++] : null, self::linkCommit($drequest->getRepository(), $history->getCommitIdentifier()), $build, $commit ? self::linkRevision(idx($this->revisions, $commit->getPHID())) : null, $author, $summary, $date, $time);
     }
     $view = new AphrontTableView($rows);
     $view->setHeaders(array('', pht('Commit'), '', pht('Revision'), pht('Author/Committer'), pht('Details'), pht('Date'), pht('Time')));
     $view->setColumnClasses(array('threads', 'n', 'icon', 'n', '', 'wide', '', 'right'));
     $view->setColumnVisibility(array($graph ? true : false));
     $view->setDeviceVisibility(array($graph ? true : false, true, true, true, false, true, false, false));
     return $view->render();
 }