2012-11-22 02:24:56 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorTimelineExample extends PhabricatorUIExample {
|
|
|
|
|
|
|
|
public function getName() {
|
|
|
|
return 'Timeline View';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDescription() {
|
2013-02-08 21:07:44 +01:00
|
|
|
return hsprintf(
|
|
|
|
'Use <tt>PhabricatorTimelineView</tt> to comments and transactions.');
|
2012-11-22 02:24:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function renderExample() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
|
|
|
$handle = PhabricatorObjectHandleData::loadOneHandle(
|
|
|
|
$user->getPHID(),
|
|
|
|
$user);
|
|
|
|
|
|
|
|
$events = array();
|
|
|
|
|
|
|
|
$events[] = id(new PhabricatorTimelineEventView())
|
|
|
|
->setUserHandle($handle)
|
|
|
|
->setTitle('A major event.')
|
|
|
|
->appendChild('This is a major timeline event.');
|
|
|
|
|
|
|
|
$events[] = id(new PhabricatorTimelineEventView())
|
|
|
|
->setUserHandle($handle)
|
|
|
|
->setTitle('A minor event.');
|
|
|
|
|
|
|
|
$events[] = id(new PhabricatorTimelineEventView())
|
|
|
|
->setUserHandle($handle)
|
|
|
|
->appendChild('A major event with no title.');
|
|
|
|
|
|
|
|
$events[] = id(new PhabricatorTimelineEventView())
|
|
|
|
->setUserHandle($handle)
|
|
|
|
->setTitle('Another minor event.');
|
|
|
|
|
|
|
|
$events[] = id(new PhabricatorTimelineEventView())
|
|
|
|
->setUserHandle($handle);
|
|
|
|
|
|
|
|
$events[] = id(new PhabricatorTimelineEventView())
|
|
|
|
->setUserHandle($handle)
|
|
|
|
->setTitle('Major Red Event')
|
2012-12-11 22:59:35 +01:00
|
|
|
->setIcon('love')
|
2012-11-22 02:24:56 +01:00
|
|
|
->appendChild('This event is red!')
|
2012-12-11 22:59:35 +01:00
|
|
|
->setColor(PhabricatorTransactions::COLOR_RED);
|
2012-11-22 02:24:56 +01:00
|
|
|
|
|
|
|
$events[] = id(new PhabricatorTimelineEventView())
|
|
|
|
->setUserHandle($handle)
|
|
|
|
->setTitle('Minor Red Event')
|
2012-12-11 22:59:35 +01:00
|
|
|
->setColor(PhabricatorTransactions::COLOR_RED);
|
2012-11-22 02:24:56 +01:00
|
|
|
|
|
|
|
$events[] = id(new PhabricatorTimelineEventView())
|
|
|
|
->setUserHandle($handle)
|
|
|
|
->setTitle('Minor Not-Red Event');
|
|
|
|
|
|
|
|
$events[] = id(new PhabricatorTimelineEventView())
|
|
|
|
->setUserHandle($handle)
|
|
|
|
->setTitle('Minor Red Event')
|
2012-12-11 22:59:35 +01:00
|
|
|
->setColor(PhabricatorTransactions::COLOR_RED);
|
2012-11-22 02:24:56 +01:00
|
|
|
|
|
|
|
$events[] = id(new PhabricatorTimelineEventView())
|
|
|
|
->setUserHandle($handle)
|
|
|
|
->setTitle('Minor Not-Red Event');
|
|
|
|
|
|
|
|
$events[] = id(new PhabricatorTimelineEventView())
|
|
|
|
->setUserHandle($handle)
|
2012-12-11 22:59:35 +01:00
|
|
|
->setTitle('Major Green Event')
|
|
|
|
->appendChild('This event is green!')
|
|
|
|
->setColor(PhabricatorTransactions::COLOR_GREEN);
|
|
|
|
|
2012-12-11 23:02:51 +01:00
|
|
|
$events[] = id(new PhabricatorTimelineEventView())
|
|
|
|
->setUserHandle($handle)
|
|
|
|
->setTitle(str_repeat('Long Text Title ', 64))
|
|
|
|
->appendChild(str_repeat('Long Text Body ', 64))
|
|
|
|
->setColor(PhabricatorTransactions::COLOR_ORANGE);
|
|
|
|
|
|
|
|
$events[] = id(new PhabricatorTimelineEventView())
|
|
|
|
->setUserHandle($handle)
|
|
|
|
->setTitle(str_repeat('LongTextEventNoSpaces', 1024))
|
|
|
|
->appendChild(str_repeat('LongTextNoSpaces', 1024))
|
|
|
|
->setColor(PhabricatorTransactions::COLOR_RED);
|
|
|
|
|
2012-12-11 22:59:35 +01:00
|
|
|
$colors = array(
|
|
|
|
PhabricatorTransactions::COLOR_RED,
|
|
|
|
PhabricatorTransactions::COLOR_ORANGE,
|
|
|
|
PhabricatorTransactions::COLOR_YELLOW,
|
|
|
|
PhabricatorTransactions::COLOR_GREEN,
|
|
|
|
PhabricatorTransactions::COLOR_SKY,
|
|
|
|
PhabricatorTransactions::COLOR_BLUE,
|
|
|
|
PhabricatorTransactions::COLOR_INDIGO,
|
|
|
|
PhabricatorTransactions::COLOR_VIOLET,
|
|
|
|
PhabricatorTransactions::COLOR_GREY,
|
|
|
|
PhabricatorTransactions::COLOR_BLACK,
|
|
|
|
);
|
2012-11-22 02:24:56 +01:00
|
|
|
|
|
|
|
$events[] = id(new PhabricatorTimelineEventView())
|
|
|
|
->setUserHandle($handle)
|
2013-01-29 03:09:33 +01:00
|
|
|
->setTitle("Colorless")
|
2012-12-11 22:59:35 +01:00
|
|
|
->setIcon('lock');
|
|
|
|
|
|
|
|
foreach ($colors as $color) {
|
|
|
|
$events[] = id(new PhabricatorTimelineEventView())
|
|
|
|
->setUserHandle($handle)
|
2013-01-29 03:09:33 +01:00
|
|
|
->setTitle("Color '{$color}'")
|
2012-12-11 22:59:35 +01:00
|
|
|
->setIcon('lock')
|
|
|
|
->setColor($color);
|
|
|
|
}
|
2012-11-22 02:24:56 +01:00
|
|
|
|
2012-12-11 22:59:51 +01:00
|
|
|
$anchor = 0;
|
|
|
|
foreach ($events as $event) {
|
2013-01-10 18:51:26 +01:00
|
|
|
$event->setUser($user);
|
2012-12-11 22:59:51 +01:00
|
|
|
$event->setDateCreated(time() + ($anchor * 60 * 8));
|
|
|
|
$event->setAnchor(++$anchor);
|
|
|
|
}
|
|
|
|
|
2012-11-22 02:24:56 +01:00
|
|
|
$timeline = id(new PhabricatorTimelineView());
|
|
|
|
foreach ($events as $event) {
|
|
|
|
$timeline->addEvent($event);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $timeline;
|
|
|
|
}
|
|
|
|
}
|