2011-06-12 23:06:17 +00:00
|
|
|
<?php
|
|
|
|
|
2013-05-23 06:47:54 -07:00
|
|
|
/**
|
|
|
|
* @group countdown
|
|
|
|
*/
|
2012-03-09 15:46:25 -08:00
|
|
|
final class PhabricatorCountdownViewController
|
2011-06-12 23:06:17 +00:00
|
|
|
extends PhabricatorCountdownController {
|
|
|
|
|
|
|
|
private $id;
|
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->id = $data['id'];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
2013-05-23 06:47:54 -07:00
|
|
|
|
2013-07-22 14:42:25 -07:00
|
|
|
$countdown = id(new PhabricatorCountdownQuery())
|
2013-05-23 06:47:54 -07:00
|
|
|
->setViewer($user)
|
|
|
|
->withIDs(array($this->id))
|
|
|
|
->executeOne();
|
|
|
|
|
|
|
|
if (!$countdown) {
|
2011-06-12 23:06:17 +00:00
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
2013-07-23 06:16:19 -07:00
|
|
|
$countdown_view = id(new PhabricatorCountdownView())
|
|
|
|
->setUser($user)
|
|
|
|
->setCountdown($countdown)
|
|
|
|
->setHeadless(true);
|
2011-06-12 23:06:17 +00:00
|
|
|
|
2013-07-23 06:16:19 -07:00
|
|
|
$id = $countdown->getID();
|
|
|
|
$title = $countdown->getTitle();
|
2011-06-12 23:06:17 +00:00
|
|
|
|
2013-02-25 12:48:55 -08:00
|
|
|
$crumbs = $this
|
|
|
|
->buildApplicationCrumbs()
|
|
|
|
->addCrumb(
|
|
|
|
id(new PhabricatorCrumbView())
|
2013-07-23 06:16:19 -07:00
|
|
|
->setName("C{$id}"));
|
|
|
|
|
2013-09-17 09:12:37 -07:00
|
|
|
$header = id(new PHUIHeaderView())
|
2013-07-23 06:16:19 -07:00
|
|
|
->setHeader($title);
|
|
|
|
|
|
|
|
$actions = $this->buildActionListView($countdown);
|
|
|
|
$properties = $this->buildPropertyListView($countdown);
|
|
|
|
|
2013-09-28 15:55:38 -07:00
|
|
|
$object_box = id(new PHUIObjectBoxView())
|
|
|
|
->setHeader($header)
|
Provide more structure to PHUIObjectBoxView
Summary:
Three changes here.
- Add `setActionList()`, and use that to set the action list.
- Add `setPropertyList()`, and use that to set the property list.
These will let us add some apropriate CSS so we can fix the border issue, and get rid of a bunch of goofy `.x + .y` selectors.
- Replace `addContent()` with `appendChild()`.
This is just a consistency thing; `AphrontView` already provides `appendChild()`, and `addContent()` did the same thing.
Test Plan:
- Viewed "All Config".
- Viewed a countdown.
- Viewed a revision (add comment, change list, table of contents, comment, local commits, open revisions affecting these files, update history).
- Viewed Diffusion (browse, change, history, repository, lint).
- Viewed Drydock (resource, lease).
- Viewed Files.
- Viewed Herald.
- Viewed Legalpad.
- Viewed macro (edit, edit audio, view).
- Viewed Maniphest.
- Viewed Applications.
- Viewed Paste.
- Viewed People.
- Viewed Phulux.
- Viewed Pholio.
- Viewed Phame (blog, post).
- Viewed Phortune (account, product).
- Viewed Ponder (questions, answers, comments).
- Viewed Releeph.
- Viewed Projects.
- Viewed Slowvote.
NOTE: Images in Files aren't on a black background anymore -- I assume that's on purpose?
NOTE: Some jankiness in Phortune, I'll clean that up when I get back to it. Not related to this diff.
Reviewers: chad
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D7174
2013-09-30 09:36:04 -07:00
|
|
|
->setActionList($actions)
|
|
|
|
->setPropertyList($properties);
|
2013-09-28 15:55:38 -07:00
|
|
|
|
2013-07-23 06:16:19 -07:00
|
|
|
$content = array(
|
|
|
|
$crumbs,
|
2013-09-28 15:55:38 -07:00
|
|
|
$object_box,
|
2013-07-23 06:16:19 -07:00
|
|
|
$countdown_view,
|
|
|
|
);
|
2013-02-25 12:48:55 -08:00
|
|
|
|
|
|
|
return $this->buildApplicationPage(
|
2013-07-23 06:16:19 -07:00
|
|
|
$content,
|
2013-02-25 12:48:55 -08:00
|
|
|
array(
|
2013-07-23 06:16:19 -07:00
|
|
|
'title' => $title,
|
2013-02-25 12:48:55 -08:00
|
|
|
'device' => true,
|
2011-06-12 23:06:17 +00:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2013-07-23 06:16:19 -07:00
|
|
|
private function buildActionListView(PhabricatorCountdown $countdown) {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$viewer = $request->getUser();
|
|
|
|
|
|
|
|
$id = $countdown->getID();
|
|
|
|
|
|
|
|
$view = id(new PhabricatorActionListView())
|
|
|
|
->setUser($viewer);
|
|
|
|
|
|
|
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
|
|
|
$viewer,
|
|
|
|
$countdown,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT);
|
|
|
|
|
|
|
|
$view->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setIcon('edit')
|
|
|
|
->setName(pht('Edit Countdown'))
|
|
|
|
->setHref($this->getApplicationURI("edit/{$id}/"))
|
|
|
|
->setDisabled(!$can_edit)
|
|
|
|
->setWorkflow(!$can_edit));
|
|
|
|
|
|
|
|
$view->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setIcon('delete')
|
|
|
|
->setName(pht('Delete Countdown'))
|
|
|
|
->setHref($this->getApplicationURI("delete/{$id}/"))
|
|
|
|
->setDisabled(!$can_edit)
|
|
|
|
->setWorkflow(true));
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildPropertyListView(PhabricatorCountdown $countdown) {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$viewer = $request->getUser();
|
|
|
|
|
|
|
|
$this->loadHandles(array($countdown->getAuthorPHID()));
|
|
|
|
|
|
|
|
$view = id(new PhabricatorPropertyListView())
|
|
|
|
->setUser($viewer);
|
|
|
|
|
|
|
|
$view->addProperty(
|
|
|
|
pht('Author'),
|
|
|
|
$this->getHandle($countdown->getAuthorPHID())->renderLink());
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
2011-06-12 23:06:17 +00:00
|
|
|
}
|