3 final class PhabricatorPhurlURLViewController
4 extends PhabricatorPhurlController
{
6 public function shouldAllowPublic() {
10 public function handleRequest(AphrontRequest
$request) {
11 $viewer = $request->getViewer();
12 $id = $request->getURIData('id');
16 $url = id(new PhabricatorPhurlURLQuery())
21 return new Aphront404Response();
24 $title = $url->getMonogram();
25 $page_title = $title.' '.$url->getName();
26 $crumbs = $this->buildApplicationCrumbs();
27 $crumbs->addTextCrumb($title);
28 $crumbs->setBorder(true);
30 $timeline = $this->buildTransactionTimeline(
32 new PhabricatorPhurlURLTransactionQuery());
33 $timeline->setQuoteRef($url->getMonogram());
35 $header = $this->buildHeaderView($url);
36 $curtain = $this->buildCurtain($url);
37 $details = $this->buildPropertySectionView($url);
39 $url_error = id(new PHUIInfoView())
40 ->setErrors(array(pht('This URL is invalid due to a bad protocol.')))
41 ->setIsHidden($url->isValid());
43 $add_comment_form = $this->buildCommentForm($url, $timeline);
45 $view = id(new PHUITwoColumnView())
47 ->setCurtain($curtain)
48 ->setMainColumn(array(
55 return $this->newPage()
56 ->setTitle($page_title)
58 ->setPageObjectPHIDs(array($url->getPHID()))
65 private function buildCommentForm(PhabricatorPhurlURL
$url, $timeline) {
66 $viewer = $this->getViewer();
67 $box = id(new PhabricatorPhurlURLEditEngine())
69 ->buildEditEngineCommentView($url)
70 ->setTransactionTimeline($timeline);
75 private function buildHeaderView(PhabricatorPhurlURL
$url) {
76 $viewer = $this->getViewer();
79 $status = pht('Active');
82 $visit = id(new PHUIButtonView())
84 ->setText(pht('Visit URL'))
85 ->setIcon('fa-external-link')
86 ->setHref($url->getRedirectURI())
87 ->setDisabled(!$url->isValid());
89 $header = id(new PHUIHeaderView())
91 ->setHeader($url->getDisplayName())
92 ->setStatus($icon, $color, $status)
93 ->setPolicyObject($url)
94 ->setHeaderIcon('fa-compress')
95 ->addActionLink($visit);
100 private function buildCurtain(PhabricatorPhurlURL
$url) {
101 $viewer = $this->getViewer();
104 $curtain = $this->newCurtainView($url);
106 $can_edit = PhabricatorPolicyFilter
::hasCapability(
109 PhabricatorPolicyCapability
::CAN_EDIT
);
113 id(new PhabricatorActionView())
114 ->setName(pht('Edit Phurl'))
115 ->setIcon('fa-pencil')
116 ->setHref($this->getApplicationURI("url/edit/{$id}/"))
117 ->setDisabled(!$can_edit)
118 ->setWorkflow(!$can_edit));
123 private function buildPropertySectionView(PhabricatorPhurlURL
$url) {
124 $viewer = $this->getViewer();
126 $properties = id(new PHUIPropertyListView())
129 $properties->addProperty(
131 $url->getRedirectURI());
133 $properties->addProperty(
137 $properties->addProperty(
141 $description = $url->getDescription();
142 if (strlen($description)) {
143 $description = new PHUIRemarkupView($viewer, $description);
144 $properties->addSectionHeader(pht('Description'));
145 $properties->addTextContent($description);
148 return id(new PHUIObjectBoxView())
149 ->setHeaderText(pht('Details'))
150 ->setBackground(PHUIObjectBoxView
::BLUE_PROPERTY
)
151 ->appendChild($properties);