コード例 #1
0
 public function processRequest()
 {
     $drequest = $this->diffusionRequest;
     $results = $this->getBrowseQueryResults();
     $reason = $results->getReasonForEmptyResultSet();
     $content = array();
     $actions = $this->buildActionView($drequest);
     $properties = $this->buildPropertyView($drequest, $actions);
     $object_box = id(new PHUIObjectBoxView())->setHeader($this->buildHeaderView($drequest))->addPropertyList($properties);
     $content[] = $object_box;
     $content[] = $this->renderSearchForm($collapsed = true);
     if (!$results->isValidResults()) {
         $empty_result = new DiffusionEmptyResultView();
         $empty_result->setDiffusionRequest($drequest);
         $empty_result->setDiffusionBrowseResultSet($results);
         $empty_result->setView($this->getRequest()->getStr('view'));
         $content[] = $empty_result;
     } else {
         $phids = array();
         foreach ($results->getPaths() as $result) {
             $data = $result->getLastCommitData();
             if ($data) {
                 if ($data->getCommitDetail('authorPHID')) {
                     $phids[$data->getCommitDetail('authorPHID')] = true;
                 }
             }
         }
         $phids = array_keys($phids);
         $handles = $this->loadViewerHandles($phids);
         $browse_table = new DiffusionBrowseTableView();
         $browse_table->setDiffusionRequest($drequest);
         $browse_table->setHandles($handles);
         $browse_table->setPaths($results->getPaths());
         $browse_table->setUser($this->getRequest()->getUser());
         $browse_panel = new AphrontPanelView();
         $browse_panel->appendChild($browse_table);
         $browse_panel->setNoBackground();
         $content[] = $browse_panel;
     }
     $content[] = $this->buildOpenRevisions();
     $readme = $this->callConduitWithDiffusionRequest('diffusion.readmequery', array('paths' => $results->getPathDicts(), 'commit' => $drequest->getStableCommit()));
     if ($readme) {
         $box = new PHUIBoxView();
         $box->appendChild($readme);
         $box->addPadding(PHUI::PADDING_LARGE);
         $object_box = id(new PHUIObjectBoxView())->setHeaderText(pht('README'))->appendChild($box);
         $content[] = $object_box;
     }
     $crumbs = $this->buildCrumbs(array('branch' => true, 'path' => true, 'view' => 'browse'));
     return $this->buildApplicationPage(array($crumbs, $content), array('title' => array(nonempty(basename($drequest->getPath()), '/'), $drequest->getRepository()->getCallsign() . ' Repository')));
 }
コード例 #2
0
 protected function processDiffusionRequest(AphrontRequest $request)
 {
     $drequest = $this->diffusionRequest;
     $results = $this->getBrowseQueryResults();
     $reason = $results->getReasonForEmptyResultSet();
     $content = array();
     $actions = $this->buildActionView($drequest);
     $properties = $this->buildPropertyView($drequest, $actions);
     $object_box = id(new PHUIObjectBoxView())->setHeader($this->buildHeaderView($drequest))->addPropertyList($properties);
     $content[] = $object_box;
     $content[] = $this->renderSearchForm($collapsed = true);
     if (!$results->isValidResults()) {
         $empty_result = new DiffusionEmptyResultView();
         $empty_result->setDiffusionRequest($drequest);
         $empty_result->setDiffusionBrowseResultSet($results);
         $empty_result->setView($request->getStr('view'));
         $content[] = $empty_result;
     } else {
         $phids = array();
         foreach ($results->getPaths() as $result) {
             $data = $result->getLastCommitData();
             if ($data) {
                 if ($data->getCommitDetail('authorPHID')) {
                     $phids[$data->getCommitDetail('authorPHID')] = true;
                 }
             }
         }
         $phids = array_keys($phids);
         $handles = $this->loadViewerHandles($phids);
         $browse_table = new DiffusionBrowseTableView();
         $browse_table->setDiffusionRequest($drequest);
         $browse_table->setHandles($handles);
         $browse_table->setPaths($results->getPaths());
         $browse_table->setUser($request->getUser());
         $browse_panel = new PHUIObjectBoxView();
         $browse_panel->setHeaderText($drequest->getPath(), '/');
         $browse_panel->setTable($browse_table);
         $content[] = $browse_panel;
     }
     $content[] = $this->buildOpenRevisions();
     $readme_path = $results->getReadmePath();
     if ($readme_path) {
         $readme_content = $this->callConduitWithDiffusionRequest('diffusion.filecontentquery', array('path' => $readme_path, 'commit' => $drequest->getStableCommit()));
         if ($readme_content) {
             $content[] = id(new DiffusionReadmeView())->setUser($this->getViewer())->setPath($readme_path)->setContent($readme_content['corpus']);
         }
     }
     $crumbs = $this->buildCrumbs(array('branch' => true, 'path' => true, 'view' => 'browse'));
     return $this->buildApplicationPage(array($crumbs, $content), array('title' => array(nonempty(basename($drequest->getPath()), '/'), $drequest->getRepository()->getDisplayName())));
 }
コード例 #3
0
 public function processRequest()
 {
     $drequest = $this->diffusionRequest;
     $content = array();
     $crumbs = $this->buildCrumbs();
     $content[] = $crumbs;
     $content[] = $this->buildPropertiesTable($drequest->getRepository());
     $history_query = DiffusionHistoryQuery::newFromDiffusionRequest($drequest);
     $history_query->setLimit(15);
     $history_query->needParents(true);
     $history = $history_query->loadHistory();
     $browse_query = DiffusionBrowseQuery::newFromDiffusionRequest($drequest);
     $browse_results = $browse_query->loadPaths();
     $phids = array();
     foreach ($history as $item) {
         $data = $item->getCommitData();
         if ($data) {
             if ($data->getCommitDetail('authorPHID')) {
                 $phids[$data->getCommitDetail('authorPHID')] = true;
             }
             if ($data->getCommitDetail('committerPHID')) {
                 $phids[$data->getCommitDetail('committerPHID')] = true;
             }
         }
     }
     foreach ($browse_results as $item) {
         $data = $item->getLastCommitData();
         if ($data) {
             if ($data->getCommitDetail('authorPHID')) {
                 $phids[$data->getCommitDetail('authorPHID')] = true;
             }
             if ($data->getCommitDetail('committerPHID')) {
                 $phids[$data->getCommitDetail('committerPHID')] = true;
             }
         }
     }
     $phids = array_keys($phids);
     $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
     $history_table = new DiffusionHistoryTableView();
     $history_table->setDiffusionRequest($drequest);
     $history_table->setHandles($handles);
     $history_table->setHistory($history);
     $history_table->loadRevisions();
     $history_table->setParents($history_query->getParents());
     $history_table->setIsHead(true);
     $callsign = $drequest->getRepository()->getCallsign();
     $all = phutil_render_tag('a', array('href' => "/diffusion/{$callsign}/history/"), 'View Full Commit History');
     $panel = new AphrontPanelView();
     $panel->setHeader("Recent Commits · {$all}");
     $panel->appendChild($history_table);
     $content[] = $panel;
     $browse_table = new DiffusionBrowseTableView();
     $browse_table->setDiffusionRequest($drequest);
     $browse_table->setHandles($handles);
     $browse_table->setPaths($browse_results);
     $browse_panel = new AphrontPanelView();
     $browse_panel->setHeader('Browse Repository');
     $browse_panel->appendChild($browse_table);
     $content[] = $browse_panel;
     $content[] = $this->buildTagListTable($drequest);
     $content[] = $this->buildBranchListTable($drequest);
     $readme = $browse_query->renderReadme($browse_results);
     if ($readme) {
         $panel = new AphrontPanelView();
         $panel->setHeader('README');
         $panel->appendChild($readme);
         $content[] = $panel;
     }
     return $this->buildStandardPageResponse($content, array('title' => $drequest->getRepository()->getName()));
 }
コード例 #4
0
 public function browseDirectory(DiffusionBrowseResultSet $results, PHUIPagerView $pager)
 {
     $request = $this->getRequest();
     $drequest = $this->getDiffusionRequest();
     $repository = $drequest->getRepository();
     $reason = $results->getReasonForEmptyResultSet();
     $content = array();
     $actions = $this->buildActionView($drequest);
     $properties = $this->buildPropertyView($drequest, $actions);
     $object_box = id(new PHUIObjectBoxView())->setHeader($this->buildHeaderView($drequest))->addPropertyList($properties);
     $content[] = $object_box;
     $content[] = $this->renderSearchForm($collapsed = true);
     if (!$results->isValidResults()) {
         $empty_result = new DiffusionEmptyResultView();
         $empty_result->setDiffusionRequest($drequest);
         $empty_result->setDiffusionBrowseResultSet($results);
         $empty_result->setView($request->getStr('view'));
         $content[] = $empty_result;
     } else {
         $phids = array();
         foreach ($results->getPaths() as $result) {
             $data = $result->getLastCommitData();
             if ($data) {
                 if ($data->getCommitDetail('authorPHID')) {
                     $phids[$data->getCommitDetail('authorPHID')] = true;
                 }
             }
         }
         $phids = array_keys($phids);
         $handles = $this->loadViewerHandles($phids);
         $browse_table = new DiffusionBrowseTableView();
         $browse_table->setDiffusionRequest($drequest);
         $browse_table->setHandles($handles);
         $browse_table->setPaths($results->getPaths());
         $browse_table->setUser($request->getUser());
         $browse_panel = new PHUIObjectBoxView();
         $browse_panel->setHeaderText($drequest->getPath(), '/');
         $browse_panel->setTable($browse_table);
         $content[] = $browse_panel;
     }
     $content[] = $this->buildOpenRevisions();
     $content[] = $this->renderDirectoryReadme($results);
     $crumbs = $this->buildCrumbs(array('branch' => true, 'path' => true, 'view' => 'browse'));
     $pager_box = $this->renderTablePagerBox($pager);
     return $this->newPage()->setTitle(array(nonempty(basename($drequest->getPath()), '/'), $repository->getDisplayName()))->setCrumbs($crumbs)->appendChild(array($content, $pager_box));
 }
コード例 #5
0
 public function processRequest()
 {
     $drequest = $this->diffusionRequest;
     $browse_query = DiffusionBrowseQuery::newFromDiffusionRequest($drequest);
     $results = $browse_query->loadPaths();
     $content = array();
     $content[] = $this->buildCrumbs(array('branch' => true, 'path' => true, 'view' => 'browse'));
     if (!$results) {
         if ($browse_query->getReasonForEmptyResultSet() == DiffusionBrowseQuery::REASON_IS_FILE) {
             $controller = new DiffusionBrowseFileController($this->getRequest());
             $controller->setDiffusionRequest($drequest);
             return $this->delegateToController($controller);
         }
         $empty_result = new DiffusionEmptyResultView();
         $empty_result->setDiffusionRequest($drequest);
         $empty_result->setBrowseQuery($browse_query);
         $empty_result->setView($this->getRequest()->getStr('view'));
         $content[] = $empty_result;
     } else {
         $readme = null;
         $phids = array();
         foreach ($results as $result) {
             $data = $result->getLastCommitData();
             if ($data) {
                 if ($data->getCommitDetail('authorPHID')) {
                     $phids[$data->getCommitDetail('authorPHID')] = true;
                 }
             }
             $path = $result->getPath();
             if (preg_match('/^readme(|\\.txt|\\.remarkup)$/i', $path)) {
                 $readme = $result;
             }
         }
         $phids = array_keys($phids);
         $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
         if ($readme) {
             $readme_request = DiffusionRequest::newFromDictionary(array('repository' => $drequest->getRepository(), 'commit' => $drequest->getStableCommitName(), 'path' => $readme->getFullPath()));
             $content_query = DiffusionFileContentQuery::newFromDiffusionRequest($readme_request);
             $content_query->loadFileContent();
             $readme_content = $content_query->getRawData();
             if (preg_match('/.txt$/', $readme->getPath())) {
                 $readme_content = phutil_escape_html($readme_content);
                 $readme_content = nl2br($readme_content);
             } else {
                 // Markup extensionless files as remarkup so we get links and such.
                 $engine = PhabricatorMarkupEngine::newDiffusionMarkupEngine();
                 $readme_content = $engine->markupText($readme_content);
                 $readme_content = phutil_render_tag('div', array('class' => 'phabricator-remarkup'), $readme_content);
             }
             $readme_panel = new AphrontPanelView();
             $readme_panel->setHeader('README');
             $readme_panel->appendChild($readme_content);
             $content[] = $readme_panel;
         }
         $browse_table = new DiffusionBrowseTableView();
         $browse_table->setDiffusionRequest($drequest);
         $browse_table->setHandles($handles);
         $browse_table->setPaths($results);
         $browse_panel = new AphrontPanelView();
         $browse_panel->appendChild($browse_table);
         $content[] = $browse_panel;
     }
     $content[] = $this->buildOpenRevisions();
     $nav = $this->buildSideNav('browse', false);
     $nav->appendChild($content);
     return $this->buildStandardPageResponse($nav, array('title' => basename($drequest->getPath())));
 }
コード例 #6
0
 public function processRequest()
 {
     $drequest = $this->diffusionRequest;
     $browse_query = DiffusionBrowseQuery::newFromDiffusionRequest($drequest);
     $results = $browse_query->loadPaths();
     $content = array();
     $content[] = $this->buildCrumbs(array('branch' => true, 'path' => true, 'view' => 'browse'));
     if ($drequest->getTagContent()) {
         $title = 'Tag: ' . $drequest->getSymbolicCommit();
         $tag_view = new AphrontPanelView();
         $tag_view->setHeader(phutil_escape_html($title));
         $tag_view->appendChild($this->markupText($drequest->getTagContent()));
         $content[] = $tag_view;
     }
     if (!$results) {
         if ($browse_query->getReasonForEmptyResultSet() == DiffusionBrowseQuery::REASON_IS_FILE) {
             $controller = new DiffusionBrowseFileController($this->getRequest());
             $controller->setDiffusionRequest($drequest);
             return $this->delegateToController($controller);
         }
         $empty_result = new DiffusionEmptyResultView();
         $empty_result->setDiffusionRequest($drequest);
         $empty_result->setBrowseQuery($browse_query);
         $empty_result->setView($this->getRequest()->getStr('view'));
         $content[] = $empty_result;
     } else {
         $readme = null;
         $phids = array();
         foreach ($results as $result) {
             $data = $result->getLastCommitData();
             if ($data) {
                 if ($data->getCommitDetail('authorPHID')) {
                     $phids[$data->getCommitDetail('authorPHID')] = true;
                 }
             }
             $path = $result->getPath();
             if (preg_match('/^readme(|\\.txt|\\.remarkup)$/i', $path)) {
                 $readme = $result;
             }
         }
         $phids = array_keys($phids);
         $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
         $browse_table = new DiffusionBrowseTableView();
         $browse_table->setDiffusionRequest($drequest);
         $browse_table->setHandles($handles);
         $browse_table->setPaths($results);
         $browse_table->setUser($this->getRequest()->getUser());
         $browse_panel = new AphrontPanelView();
         $browse_panel->appendChild($browse_table);
         $content[] = $browse_panel;
     }
     $content[] = $this->buildOpenRevisions();
     $readme_content = $browse_query->renderReadme($results);
     if ($readme_content) {
         $readme_panel = new AphrontPanelView();
         $readme_panel->setHeader('README');
         $readme_panel->appendChild($readme_content);
         $content[] = $readme_panel;
     }
     $nav = $this->buildSideNav('browse', false);
     $nav->appendChild($content);
     return $this->buildStandardPageResponse($nav, array('title' => array(nonempty(basename($drequest->getPath()), '/'), $drequest->getRepository()->getCallsign() . ' Repository')));
 }
コード例 #7
0
 public function processRequest()
 {
     $drequest = $this->diffusionRequest;
     $browse_query = DiffusionBrowseQuery::newFromDiffusionRequest($drequest);
     $results = $browse_query->loadPaths();
     $content = array();
     $content[] = $this->buildCrumbs(array('branch' => true, 'path' => true, 'view' => 'browse'));
     if (!$results) {
         // TODO: Format all these commits into nice VCS-agnostic links, and
         // below.
         $commit = $drequest->getCommit();
         $callsign = $drequest->getRepository()->getCallsign();
         if ($commit) {
             $commit = "r{$callsign}{$commit}";
         } else {
             $commit = 'HEAD';
         }
         switch ($browse_query->getReasonForEmptyResultSet()) {
             case DiffusionBrowseQuery::REASON_IS_NONEXISTENT:
                 $title = 'Path Does Not Exist';
                 // TODO: Under git, this error message should be more specific. It
                 // may exist on some other branch.
                 $body = "This path does not exist anywhere.";
                 $severity = AphrontErrorView::SEVERITY_ERROR;
                 break;
             case DiffusionBrowseQuery::REASON_IS_EMPTY:
                 $title = 'Empty Directory';
                 $body = "This path was an empty directory at {$commit}.\n";
                 $severity = AphrontErrorView::SEVERITY_NOTICE;
                 break;
             case DiffusionBrowseQuery::REASON_IS_DELETED:
                 $deleted = $browse_query->getDeletedAtCommit();
                 $existed = $browse_query->getExistedAtCommit();
                 $deleted = "r{$callsign}{$deleted}";
                 $existed = "r{$callsign}{$existed}";
                 $title = 'Path Was Deleted';
                 $body = "This path does not exist at {$commit}. It was deleted in " . "{$deleted} and last existed at {$existed}.";
                 $severity = AphrontErrorView::SEVERITY_WARNING;
                 break;
             case DiffusionBrowseQuery::REASON_IS_FILE:
                 $controller = new DiffusionBrowseFileController($this->getRequest());
                 $controller->setDiffusionRequest($drequest);
                 return $this->delegateToController($controller);
                 break;
             case DiffusionBrowseQuery::REASON_IS_UNTRACKED_PARENT:
                 $subdir = $drequest->getRepository()->getDetail('svn-subpath');
                 $title = 'Directory Not Tracked';
                 $body = "This repository is configured to track only one subdirectory " . "of the entire repository ('" . phutil_escape_html($subdir) . "'), " . "but you aren't looking at something in that subdirectory, so no " . "information is available.";
                 $severity = AphrontErrorView::SEVERITY_WARNING;
                 break;
             default:
                 throw new Exception("Unknown failure reason!");
         }
         $error_view = new AphrontErrorView();
         $error_view->setSeverity($severity);
         $error_view->setTitle($title);
         $error_view->appendChild('<p>' . $body . '</p>');
         $content[] = $error_view;
     } else {
         $phids = array();
         foreach ($results as $result) {
             $data = $result->getLastCommitData();
             if ($data) {
                 if ($data->getCommitDetail('authorPHID')) {
                     $phids[$data->getCommitDetail('authorPHID')] = true;
                 }
             }
         }
         $phids = array_keys($phids);
         $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
         $browse_table = new DiffusionBrowseTableView();
         $browse_table->setDiffusionRequest($drequest);
         $browse_table->setHandles($handles);
         $browse_table->setPaths($results);
         $browse_panel = new AphrontPanelView();
         $browse_panel->appendChild($browse_table);
         $content[] = $browse_panel;
     }
     $content[] = $this->buildOpenRevisions();
     $nav = $this->buildSideNav('browse', false);
     $nav->appendChild($content);
     return $this->buildStandardPageResponse($nav, array('title' => basename($drequest->getPath())));
 }