mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-26 21:49:08 +01:00
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
118 lines
2.7 KiB
PHP
118 lines
2.7 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group countdown
|
|
*/
|
|
final class PhabricatorCountdownViewController
|
|
extends PhabricatorCountdownController {
|
|
|
|
private $id;
|
|
|
|
public function willProcessRequest(array $data) {
|
|
$this->id = $data['id'];
|
|
}
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
$user = $request->getUser();
|
|
|
|
$countdown = id(new PhabricatorCountdownQuery())
|
|
->setViewer($user)
|
|
->withIDs(array($this->id))
|
|
->executeOne();
|
|
|
|
if (!$countdown) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
$countdown_view = id(new PhabricatorCountdownView())
|
|
->setUser($user)
|
|
->setCountdown($countdown)
|
|
->setHeadless(true);
|
|
|
|
$id = $countdown->getID();
|
|
$title = $countdown->getTitle();
|
|
|
|
$crumbs = $this
|
|
->buildApplicationCrumbs()
|
|
->addCrumb(
|
|
id(new PhabricatorCrumbView())
|
|
->setName("C{$id}"));
|
|
|
|
$header = id(new PHUIHeaderView())
|
|
->setHeader($title);
|
|
|
|
$actions = $this->buildActionListView($countdown);
|
|
$properties = $this->buildPropertyListView($countdown);
|
|
|
|
$object_box = id(new PHUIObjectBoxView())
|
|
->setHeader($header)
|
|
->setActionList($actions)
|
|
->setPropertyList($properties);
|
|
|
|
$content = array(
|
|
$crumbs,
|
|
$object_box,
|
|
$countdown_view,
|
|
);
|
|
|
|
return $this->buildApplicationPage(
|
|
$content,
|
|
array(
|
|
'title' => $title,
|
|
'device' => true,
|
|
));
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
}
|