Path: blob/master/src/applications/diffusion/view/DiffusionEmptyResultView.php
12242 views
<?php12final class DiffusionEmptyResultView extends DiffusionView {34private $browseResultSet;5private $view;67public function setDiffusionBrowseResultSet(DiffusionBrowseResultSet $set) {8$this->browseResultSet = $set;9return $this;10}1112public function setView($view) {13$this->view = $view;14return $this;15}1617public function render() {18$drequest = $this->getDiffusionRequest();19$repository = $drequest->getRepository();2021$commit = $drequest->getCommit();22if ($commit) {23$commit = $repository->formatCommitName($commit);24} else {25$commit = 'HEAD';26}2728$reason = $this->browseResultSet->getReasonForEmptyResultSet();29switch ($reason) {30case DiffusionBrowseResultSet::REASON_IS_NONEXISTENT:31$title = pht('Path Does Not Exist');32// TODO: Under git, this error message should be more specific. It33// may exist on some other branch.34$body = pht('This path does not exist anywhere.');35$severity = PHUIInfoView::SEVERITY_ERROR;36break;37case DiffusionBrowseResultSet::REASON_IS_EMPTY:38$title = pht('Empty Directory');39$body = pht('This path was an empty directory at %s.', $commit);40$severity = PHUIInfoView::SEVERITY_NOTICE;41break;42case DiffusionBrowseResultSet::REASON_IS_SUBMODULE:43$title = pht('Submodule');44// TODO: We could improve this, but it is normally difficult to45// reach this page for a submodule.46$body = pht('This path was a submodule at %s.', $commit);47$severity = PHUIInfoView::SEVERITY_NOTICE;48break;49case DiffusionBrowseResultSet::REASON_IS_DELETED:50$deleted = $this->browseResultSet->getDeletedAtCommit();51$existed = $this->browseResultSet->getExistedAtCommit();5253$existed_text = $repository->formatCommitName($existed);54$existed_href = $drequest->generateURI(55array(56'action' => 'browse',57'path' => $drequest->getPath(),58'commit' => $existed,59'params' => array(60'view' => $this->view,61),62));6364$existed_link = phutil_tag(65'a',66array(67'href' => $existed_href,68),69$existed_text);7071$title = pht('Path Was Deleted');72$body = pht(73'This path does not exist at %s. It was deleted in %s and last '.74'existed at %s.',75$commit,76self::linkCommit($drequest->getRepository(), $deleted),77$existed_link);78$severity = PHUIInfoView::SEVERITY_WARNING;79break;80case DiffusionBrowseResultSet::REASON_IS_UNTRACKED_PARENT:81$subdir = $drequest->getRepository()->getDetail('svn-subpath');82$title = pht('Directory Not Tracked');83$body =84pht(85"This repository is configured to track only one subdirectory ".86"of the entire repository ('%s'), but you aren't looking at ".87"something in that subdirectory, so no information is available.",88$subdir);89$severity = PHUIInfoView::SEVERITY_WARNING;90break;91default:92throw new Exception(pht('Unknown failure reason: %s', $reason));93}9495$error_view = new PHUIInfoView();96$error_view->setSeverity($severity);97$error_view->setTitle($title);98$error_view->appendChild(phutil_tag('p', array(), $body));99100return $error_view->render();101}102103}104105106