3 final class PholioMockViewController
extends PholioController
{
5 private $maniphestTaskPHIDs = array();
7 private function setManiphestTaskPHIDs($maniphest_task_phids) {
8 $this->maniphestTaskPHIDs
= $maniphest_task_phids;
11 private function getManiphestTaskPHIDs() {
12 return $this->maniphestTaskPHIDs
;
15 public function shouldAllowPublic() {
19 public function handleRequest(AphrontRequest
$request) {
20 $viewer = $request->getViewer();
21 $id = $request->getURIData('id');
22 $image_id = $request->getURIData('imageID');
24 $mock = id(new PholioMockQuery())
28 ->needInlineComments(true)
32 return new Aphront404Response();
35 $phids = PhabricatorEdgeQuery
::loadDestinationPHIDs(
37 PholioMockHasTaskEdgeType
::EDGECONST
);
38 $this->setManiphestTaskPHIDs($phids);
40 $title = $mock->getName();
42 if ($mock->isClosed()) {
43 $header_icon = 'fa-ban';
44 $header_name = pht('Closed');
45 $header_color = 'dark';
47 $header_icon = 'fa-square-o';
48 $header_name = pht('Open');
49 $header_color = 'bluegrey';
52 $header = id(new PHUIHeaderView())
55 ->setStatus($header_icon, $header_color, $header_name)
56 ->setPolicyObject($mock)
57 ->setHeaderIcon('fa-camera-retro');
59 $timeline = $this->buildTransactionTimeline(
61 new PholioTransactionQuery());
62 $timeline->setMock($mock);
64 $timeline->setQuoteRef($mock->getMonogram());
66 $curtain = $this->buildCurtainView($mock);
67 $details = $this->buildDescriptionView($mock);
69 require_celerity_resource('pholio-css');
70 require_celerity_resource('pholio-inline-comments-css');
72 $comment_form_id = celerity_generate_unique_node_id();
73 $mock_view = id(new PholioMockImagesView())
74 ->setRequestURI($request->getRequestURI())
75 ->setCommentFormID($comment_form_id)
78 ->setImageID($image_id);
80 $output = id(new PHUIObjectBoxView())
81 ->setBackground(PHUIObjectBoxView
::BLUE_PROPERTY
)
82 ->appendChild($mock_view);
84 $add_comment = $this->buildAddCommentView($mock, $comment_form_id);
85 $add_comment->setTransactionTimeline($timeline);
87 $crumbs = $this->buildApplicationCrumbs();
88 $crumbs->addTextCrumb($mock->getMonogram(), $mock->getURI());
89 $crumbs->setBorder(true);
91 $thumb_grid = id(new PholioMockThumbGridView())
95 $view = id(new PHUITwoColumnView())
97 ->setCurtain($curtain)
107 return $this->newPage()
108 ->setTitle(pht('%s %s', $mock->getMonogram(), $title))
110 ->setPageObjectPHIDs(array($mock->getPHID()))
111 ->addQuicksandConfig(
112 array('mockViewConfig' => $mock_view->getBehaviorConfig()))
113 ->appendChild($view);
116 private function buildCurtainView(PholioMock
$mock) {
117 $viewer = $this->getViewer();
119 $curtain = $this->newCurtainView($mock);
121 $can_edit = PhabricatorPolicyFilter
::hasCapability(
124 PhabricatorPolicyCapability
::CAN_EDIT
);
127 id(new PhabricatorActionView())
128 ->setIcon('fa-pencil')
129 ->setName(pht('Edit Mock'))
130 ->setHref($this->getApplicationURI('/edit/'.$mock->getID().'/'))
131 ->setDisabled(!$can_edit)
132 ->setWorkflow(!$can_edit));
134 if ($mock->isClosed()) {
136 id(new PhabricatorActionView())
137 ->setIcon('fa-check')
138 ->setName(pht('Open Mock'))
139 ->setHref($this->getApplicationURI('/archive/'.$mock->getID().'/'))
140 ->setDisabled(!$can_edit)
141 ->setWorkflow(true));
144 id(new PhabricatorActionView())
146 ->setName(pht('Close Mock'))
147 ->setHref($this->getApplicationURI('/archive/'.$mock->getID().'/'))
148 ->setDisabled(!$can_edit)
149 ->setWorkflow(true));
152 $relationship_list = PhabricatorObjectRelationshipList
::newForObject(
156 $relationship_submenu = $relationship_list->newActionMenu();
157 if ($relationship_submenu) {
158 $curtain->addAction($relationship_submenu);
161 if ($this->getManiphestTaskPHIDs()) {
163 ->setHeaderText(pht('Maniphest Tasks'))
165 $viewer->renderHandleList($this->getManiphestTaskPHIDs()));
169 ->setHeaderText(pht('Authored By'))
170 ->appendChild($this->buildAuthorPanel($mock));
175 private function buildDescriptionView(PholioMock
$mock) {
176 $viewer = $this->getViewer();
178 $properties = id(new PHUIPropertyListView())
180 $description = $mock->getDescription();
182 if (strlen($description)) {
183 $properties->addTextContent(
184 new PHUIRemarkupView($viewer, $description));
185 return id(new PHUIObjectBoxView())
186 ->setHeaderText(pht('Mock Description'))
187 ->setBackground(PHUIObjectBoxView
::BLUE_PROPERTY
)
188 ->appendChild($properties);
194 private function buildAuthorPanel(PholioMock
$mock) {
195 $viewer = $this->getViewer();
196 $author_phid = $mock->getAuthorPHID();
197 $handles = $viewer->loadHandles(array($author_phid));
199 $author_uri = $handles[$author_phid]->getImageURI();
200 $author_href = $handles[$author_phid]->getURI();
201 $author = $viewer->renderHandle($author_phid)->render();
203 $content = phutil_tag('strong', array(), $author);
204 $date = phabricator_date($mock->getDateCreated(), $viewer);
205 $content = pht('%s, %s', $content, $date);
206 $authored_by = id(new PHUIHeadThingView())
207 ->setImage($author_uri)
208 ->setImageHref($author_href)
209 ->setContent($content);
214 private function buildAddCommentView(PholioMock
$mock, $comment_form_id) {
215 $viewer = $this->getViewer();
217 $draft = PhabricatorDraft
::newFromUserAndKey($viewer, $mock->getPHID());
219 $is_serious = PhabricatorEnv
::getEnvConfig('phabricator.serious-business');
222 : pht('History Beckons');
224 $form = id(new PhabricatorApplicationTransactionCommentView())
226 ->setObjectPHID($mock->getPHID())
227 ->setFormID($comment_form_id)
229 ->setHeaderText($title)
230 ->setSubmitButtonName(pht('Add Comment'))
231 ->setAction($this->getApplicationURI('/comment/'.$mock->getID().'/'))
232 ->setRequestURI($this->getRequest()->getRequestURI());