2012-11-22 02:24:56 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorTimelineEventView extends AphrontView {
|
|
|
|
|
|
|
|
private $userHandle;
|
|
|
|
private $title;
|
2012-12-11 22:59:35 +01:00
|
|
|
private $icon;
|
|
|
|
private $color;
|
2012-11-22 02:24:56 +01:00
|
|
|
private $classes = array();
|
2012-12-11 22:59:51 +01:00
|
|
|
private $contentSource;
|
|
|
|
private $dateCreated;
|
|
|
|
private $anchor;
|
2012-12-11 23:01:51 +01:00
|
|
|
private $isEditable;
|
|
|
|
private $isEdited;
|
|
|
|
private $transactionPHID;
|
2012-12-21 14:51:33 +01:00
|
|
|
private $isPreview;
|
2012-12-11 23:01:51 +01:00
|
|
|
|
|
|
|
public function setTransactionPHID($transaction_phid) {
|
|
|
|
$this->transactionPHID = $transaction_phid;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTransactionPHID() {
|
|
|
|
return $this->transactionPHID;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setIsEdited($is_edited) {
|
|
|
|
$this->isEdited = $is_edited;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getIsEdited() {
|
|
|
|
return $this->isEdited;
|
|
|
|
}
|
|
|
|
|
2012-12-21 14:51:33 +01:00
|
|
|
public function setIsPreview($is_preview) {
|
|
|
|
$this->isPreview = $is_preview;
|
2012-12-11 23:01:51 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-12-21 14:51:33 +01:00
|
|
|
public function getIsPreview() {
|
|
|
|
return $this->isPreview;
|
2012-12-11 23:01:51 +01:00
|
|
|
}
|
2012-12-11 22:59:51 +01:00
|
|
|
|
2012-12-21 14:51:33 +01:00
|
|
|
public function setIsEditable($is_editable) {
|
|
|
|
$this->isEditable = $is_editable;
|
2012-12-11 22:59:51 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-12-21 14:51:33 +01:00
|
|
|
public function getIsEditable() {
|
|
|
|
return $this->isEditable;
|
2012-12-11 22:59:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setDateCreated($date_created) {
|
|
|
|
$this->dateCreated = $date_created;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDateCreated() {
|
|
|
|
return $this->dateCreated;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setContentSource(PhabricatorContentSource $content_source) {
|
|
|
|
$this->contentSource = $content_source;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getContentSource() {
|
|
|
|
return $this->contentSource;
|
|
|
|
}
|
2012-11-22 02:24:56 +01:00
|
|
|
|
|
|
|
public function setUserHandle(PhabricatorObjectHandle $handle) {
|
|
|
|
$this->userHandle = $handle;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-12-11 22:59:51 +01:00
|
|
|
public function setAnchor($anchor) {
|
|
|
|
$this->anchor = $anchor;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-11-22 02:24:56 +01:00
|
|
|
public function setTitle($title) {
|
|
|
|
$this->title = $title;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addClass($class) {
|
|
|
|
$this->classes[] = $class;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-12-11 22:59:35 +01:00
|
|
|
public function setIcon($icon) {
|
|
|
|
$this->icon = $icon;
|
2012-11-22 02:24:56 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-12-11 22:59:35 +01:00
|
|
|
public function setColor($color) {
|
|
|
|
$this->color = $color;
|
2012-11-22 02:24:56 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function render() {
|
2013-02-13 23:50:15 +01:00
|
|
|
$content = $this->renderChildren();
|
2012-11-22 02:24:56 +01:00
|
|
|
|
|
|
|
$title = $this->title;
|
2013-01-29 03:09:33 +01:00
|
|
|
if (($title === null) && $this->isEmptyContent($content)) {
|
2012-11-22 02:24:56 +01:00
|
|
|
$title = '';
|
|
|
|
}
|
|
|
|
|
2012-12-21 14:51:33 +01:00
|
|
|
$extra = $this->renderExtra();
|
2012-12-11 22:59:51 +01:00
|
|
|
|
|
|
|
if ($title !== null || $extra !== null) {
|
2012-11-22 02:24:56 +01:00
|
|
|
$title_classes = array();
|
|
|
|
$title_classes[] = 'phabricator-timeline-title';
|
2012-12-11 22:59:35 +01:00
|
|
|
|
|
|
|
$icon = null;
|
|
|
|
if ($this->icon) {
|
|
|
|
$title_classes[] = 'phabricator-timeline-title-with-icon';
|
|
|
|
|
2013-01-18 03:47:13 +01:00
|
|
|
$icon = phutil_tag(
|
2012-12-11 22:59:35 +01:00
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-timeline-icon-fill',
|
|
|
|
),
|
2013-01-18 03:57:09 +01:00
|
|
|
phutil_tag(
|
2012-12-11 22:59:35 +01:00
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-timeline-icon sprite-icon '.
|
|
|
|
'action-'.$this->icon.'-white',
|
|
|
|
),
|
|
|
|
''));
|
2012-11-22 02:24:56 +01:00
|
|
|
}
|
|
|
|
|
2013-01-29 03:09:33 +01:00
|
|
|
$title = phutil_tag(
|
2012-11-22 02:24:56 +01:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => implode(' ', $title_classes),
|
|
|
|
),
|
2013-01-29 03:09:33 +01:00
|
|
|
array($title, $extra));
|
2012-12-11 23:02:51 +01:00
|
|
|
|
2013-03-09 22:52:41 +01:00
|
|
|
$title = array($icon, $title);
|
2012-11-22 02:24:56 +01:00
|
|
|
}
|
|
|
|
|
2013-01-18 03:57:09 +01:00
|
|
|
$wedge = phutil_tag(
|
2012-11-22 02:24:56 +01:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-timeline-wedge phabricator-timeline-border',
|
|
|
|
),
|
|
|
|
'');
|
|
|
|
|
|
|
|
$image_uri = $this->userHandle->getImageURI();
|
2013-01-18 03:57:09 +01:00
|
|
|
$image = phutil_tag(
|
2012-11-22 02:24:56 +01:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'style' => 'background-image: url('.$image_uri.')',
|
|
|
|
'class' => 'phabricator-timeline-image',
|
|
|
|
),
|
|
|
|
'');
|
|
|
|
|
|
|
|
$content_classes = array();
|
|
|
|
$content_classes[] = 'phabricator-timeline-content';
|
|
|
|
|
|
|
|
$classes = array();
|
|
|
|
$classes[] = 'phabricator-timeline-event-view';
|
|
|
|
$classes[] = 'phabricator-timeline-border';
|
2013-03-10 18:59:03 +01:00
|
|
|
if (!$this->isEmptyContent($content)) {
|
2012-11-22 02:24:56 +01:00
|
|
|
$classes[] = 'phabricator-timeline-major-event';
|
2013-01-29 03:09:33 +01:00
|
|
|
$content = phutil_tag(
|
2012-11-22 02:24:56 +01:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => implode(' ', $content_classes),
|
|
|
|
),
|
2013-01-29 03:09:33 +01:00
|
|
|
phutil_tag(
|
2012-11-22 02:24:56 +01:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-timeline-inner-content',
|
|
|
|
),
|
2013-01-29 03:09:33 +01:00
|
|
|
array(
|
|
|
|
$title,
|
|
|
|
phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-timeline-core-content',
|
|
|
|
),
|
|
|
|
$content),
|
|
|
|
)));
|
|
|
|
$content = array($image, $wedge, $content);
|
2012-11-22 02:24:56 +01:00
|
|
|
} else {
|
|
|
|
$classes[] = 'phabricator-timeline-minor-event';
|
2013-01-29 03:09:33 +01:00
|
|
|
$content = phutil_tag(
|
2012-11-22 02:24:56 +01:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => implode(' ', $content_classes),
|
|
|
|
),
|
2013-01-29 03:09:33 +01:00
|
|
|
array($image, $wedge, $title));
|
2012-11-22 02:24:56 +01:00
|
|
|
}
|
|
|
|
|
2012-12-11 22:59:35 +01:00
|
|
|
$outer_classes = $this->classes;
|
2012-12-11 22:59:51 +01:00
|
|
|
$outer_classes[] = 'phabricator-timeline-shell';
|
2012-12-11 22:59:35 +01:00
|
|
|
if ($this->color) {
|
|
|
|
$outer_classes[] = 'phabricator-timeline-'.$this->color;
|
|
|
|
}
|
|
|
|
|
2012-12-11 23:02:12 +01:00
|
|
|
$sigil = null;
|
|
|
|
$meta = null;
|
|
|
|
if ($this->getTransactionPHID()) {
|
|
|
|
$sigil = 'transaction';
|
|
|
|
$meta = array(
|
|
|
|
'phid' => $this->getTransactionPHID(),
|
|
|
|
'anchor' => $this->anchor,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2013-01-29 03:09:33 +01:00
|
|
|
return javelin_tag(
|
2012-11-22 02:24:56 +01:00
|
|
|
'div',
|
|
|
|
array(
|
2012-12-11 22:59:35 +01:00
|
|
|
'class' => implode(' ', $outer_classes),
|
2012-12-11 22:59:51 +01:00
|
|
|
'id' => $this->anchor ? 'anchor-'.$this->anchor : null,
|
2012-12-11 23:02:12 +01:00
|
|
|
'sigil' => $sigil,
|
|
|
|
'meta' => $meta,
|
2012-11-22 02:24:56 +01:00
|
|
|
),
|
2013-01-29 03:09:33 +01:00
|
|
|
phutil_tag(
|
2012-11-22 02:24:56 +01:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => implode(' ', $classes),
|
|
|
|
),
|
|
|
|
$content));
|
|
|
|
}
|
|
|
|
|
2012-12-21 14:51:33 +01:00
|
|
|
private function renderExtra() {
|
|
|
|
$extra = array();
|
|
|
|
|
|
|
|
if ($this->getIsPreview()) {
|
|
|
|
$extra[] = pht('PREVIEW');
|
|
|
|
} else {
|
|
|
|
$xaction_phid = $this->getTransactionPHID();
|
|
|
|
|
|
|
|
|
|
|
|
if ($this->getIsEdited()) {
|
2013-01-25 21:57:17 +01:00
|
|
|
$extra[] = javelin_tag(
|
2012-12-21 14:51:33 +01:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '/transactions/history/'.$xaction_phid.'/',
|
|
|
|
'sigil' => 'workflow',
|
|
|
|
),
|
|
|
|
pht('Edited'));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->getIsEditable()) {
|
2013-01-25 21:57:17 +01:00
|
|
|
$extra[] = javelin_tag(
|
2012-12-21 14:51:33 +01:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '/transactions/edit/'.$xaction_phid.'/',
|
|
|
|
'sigil' => 'workflow transaction-edit',
|
|
|
|
),
|
|
|
|
pht('Edit'));
|
|
|
|
}
|
|
|
|
|
|
|
|
$source = $this->getContentSource();
|
|
|
|
if ($source) {
|
|
|
|
$extra[] = id(new PhabricatorContentSourceView())
|
|
|
|
->setContentSource($source)
|
|
|
|
->setUser($this->getUser())
|
|
|
|
->render();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->getDateCreated()) {
|
|
|
|
$date = phabricator_datetime(
|
|
|
|
$this->getDateCreated(),
|
|
|
|
$this->getUser());
|
|
|
|
if ($this->anchor) {
|
|
|
|
Javelin::initBehavior('phabricator-watch-anchor');
|
|
|
|
|
|
|
|
$anchor = id(new PhabricatorAnchorView())
|
|
|
|
->setAnchorName($this->anchor)
|
|
|
|
->render();
|
|
|
|
|
2013-03-09 22:52:41 +01:00
|
|
|
$date = array(
|
|
|
|
$anchor,
|
|
|
|
phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '#'.$this->anchor,
|
|
|
|
),
|
|
|
|
$date),
|
|
|
|
);
|
2012-12-21 14:51:33 +01:00
|
|
|
}
|
|
|
|
$extra[] = $date;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($extra) {
|
2013-01-29 03:09:33 +01:00
|
|
|
$extra = phutil_tag(
|
2012-12-21 14:51:33 +01:00
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-timeline-extra',
|
|
|
|
),
|
2013-02-13 23:50:15 +01:00
|
|
|
phutil_implode_html(" \xC2\xB7 ", $extra));
|
2012-12-21 14:51:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return $extra;
|
|
|
|
}
|
|
|
|
|
2012-11-22 02:24:56 +01:00
|
|
|
}
|