2013-04-02 18:15:33 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorHovercardExample extends PhabricatorUIExample {
|
|
|
|
|
|
|
|
public function getName() {
|
|
|
|
return 'Hovercard';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDescription() {
|
|
|
|
return hsprintf('Use <tt>PhabricatorHovercardView</tt> to render '.
|
|
|
|
'hovercards. Aren\'t I genius?');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function renderExample() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
|
|
|
$elements = array();
|
|
|
|
|
|
|
|
$diff_handle = $this->createBasicDummyHandle(
|
2013-04-05 17:11:16 +02:00
|
|
|
"D123",
|
2013-07-21 17:11:37 +02:00
|
|
|
DifferentialPHIDTypeRevision::TYPECONST,
|
2013-04-05 17:11:16 +02:00
|
|
|
"Introduce cooler Differential Revisions");
|
2013-04-02 18:15:33 +02:00
|
|
|
|
|
|
|
$panel = $this->createPanel("Differential Hovercard");
|
|
|
|
$panel->appendChild(id(new PhabricatorHovercardView())
|
|
|
|
->setObjectHandle($diff_handle)
|
|
|
|
->addField(pht('Author'), $user->getUsername())
|
|
|
|
->addField(pht('Updated'), phabricator_datetime(time(), $user))
|
|
|
|
->addAction(pht('Subscribe'), '/dev/random')
|
|
|
|
->setUser($user));
|
|
|
|
$elements[] = $panel;
|
|
|
|
|
|
|
|
$task_handle = $this->createBasicDummyHandle(
|
2013-04-05 17:11:16 +02:00
|
|
|
"T123",
|
2013-07-21 21:05:28 +02:00
|
|
|
ManiphestPHIDTypeTask::TYPECONST,
|
2013-04-05 17:11:16 +02:00
|
|
|
"Improve Mobile Experience for Phabricator");
|
2013-04-02 18:15:33 +02:00
|
|
|
|
|
|
|
$tag = id(new PhabricatorTagView())
|
|
|
|
->setType(PhabricatorTagView::TYPE_STATE)
|
2013-09-24 17:42:04 +02:00
|
|
|
->setName('Closed, Resolved');
|
2013-04-02 18:15:33 +02:00
|
|
|
$panel = $this->createPanel("Maniphest Hovercard");
|
|
|
|
$panel->appendChild(id(new PhabricatorHovercardView())
|
|
|
|
->setObjectHandle($task_handle)
|
|
|
|
->setUser($user)
|
|
|
|
->addField(pht('Assigned to'), $user->getUsername())
|
|
|
|
->addField(pht('Dependent Tasks'), 'T123, T124, T125')
|
|
|
|
->addAction(pht('Subscribe'), '/dev/random')
|
|
|
|
->addAction(pht('Create Subtask'), '/dev/urandom')
|
|
|
|
->addTag($tag));
|
|
|
|
$elements[] = $panel;
|
|
|
|
|
|
|
|
$user_handle = $this->createBasicDummyHandle(
|
|
|
|
'gwashington',
|
2013-07-26 23:05:19 +02:00
|
|
|
PhabricatorPeoplePHIDTypeUser::TYPECONST,
|
2013-04-02 18:15:33 +02:00
|
|
|
'George Washington');
|
|
|
|
$user_handle->setImageURI(
|
|
|
|
celerity_get_resource_uri('/rsrc/image/people/washington.png'));
|
|
|
|
$panel = $this->createPanel("Whatevery Hovercard");
|
|
|
|
$panel->appendChild(id(new PhabricatorHovercardView())
|
|
|
|
->setObjectHandle($user_handle)
|
|
|
|
->addField(pht('Status'), 'Available')
|
|
|
|
->addField(pht('Member since'), '30. February 1750')
|
2013-04-16 23:56:30 +02:00
|
|
|
->addAction(pht('Send a Message'), '/dev/null')
|
2013-04-02 18:15:33 +02:00
|
|
|
->setUser($user));
|
|
|
|
$elements[] = $panel;
|
|
|
|
|
|
|
|
return phutil_implode_html("", $elements);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function createPanel($header) {
|
|
|
|
$panel = new AphrontPanelView();
|
|
|
|
$panel->setNoBackground();
|
|
|
|
$panel->setHeader($header);
|
|
|
|
return $panel;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|