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 $viewer;
|
|
|
|
private $anchor;
|
2012-12-11 23:01:51 +01:00
|
|
|
private $isEditable;
|
|
|
|
private $isEdited;
|
|
|
|
private $transactionPHID;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function setIsEditable($is_editable) {
|
|
|
|
$this->isEditable = $is_editable;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getIsEditable() {
|
|
|
|
return $this->isEditable;
|
|
|
|
}
|
2012-12-11 22:59:51 +01:00
|
|
|
|
|
|
|
public function setViewer(PhabricatorUser $viewer) {
|
|
|
|
$this->viewer = $viewer;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getViewer() {
|
|
|
|
return $this->viewer;
|
|
|
|
}
|
|
|
|
|
|
|
|
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() {
|
|
|
|
$content = $this->renderChildren();
|
|
|
|
|
|
|
|
$title = $this->title;
|
|
|
|
if (($title === null) && !strlen($content)) {
|
|
|
|
$title = '';
|
|
|
|
}
|
|
|
|
|
2012-12-11 22:59:51 +01:00
|
|
|
$extra = array();
|
2012-12-11 23:01:51 +01:00
|
|
|
$xaction_phid = $this->getTransactionPHID();
|
|
|
|
|
|
|
|
if ($this->getIsEdited()) {
|
|
|
|
$extra[] = javelin_render_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '/transactions/history/'.$xaction_phid.'/',
|
|
|
|
'sigil' => 'workflow',
|
|
|
|
),
|
|
|
|
pht('Edited'));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->getIsEditable()) {
|
|
|
|
$extra[] = javelin_render_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '/transactions/edit/'.$xaction_phid.'/',
|
2012-12-11 23:02:12 +01:00
|
|
|
'sigil' => 'workflow transaction-edit',
|
2012-12-11 23:01:51 +01:00
|
|
|
),
|
|
|
|
pht('Edit'));
|
|
|
|
}
|
2012-12-11 22:59:51 +01:00
|
|
|
|
|
|
|
$source = $this->getContentSource();
|
|
|
|
if ($source) {
|
|
|
|
$extra[] = id(new PhabricatorContentSourceView())
|
|
|
|
->setContentSource($source)
|
|
|
|
->setUser($this->getViewer())
|
|
|
|
->render();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->getDateCreated()) {
|
|
|
|
$date = phabricator_datetime(
|
|
|
|
$this->getDateCreated(),
|
|
|
|
$this->getViewer());
|
|
|
|
if ($this->anchor) {
|
|
|
|
Javelin::initBehavior('phabricator-watch-anchor');
|
|
|
|
|
|
|
|
$anchor = id(new PhabricatorAnchorView())
|
|
|
|
->setAnchorName($this->anchor)
|
|
|
|
->render();
|
|
|
|
|
|
|
|
$date = $anchor.phutil_render_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '#'.$this->anchor,
|
|
|
|
),
|
|
|
|
$date);
|
|
|
|
}
|
|
|
|
$extra[] = $date;
|
|
|
|
}
|
|
|
|
|
|
|
|
$extra = implode(' · ', $extra);
|
|
|
|
if ($extra) {
|
|
|
|
$extra = phutil_render_tag(
|
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-timeline-extra',
|
|
|
|
),
|
|
|
|
$extra);
|
|
|
|
}
|
|
|
|
|
|
|
|
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';
|
|
|
|
|
|
|
|
$icon = phutil_render_tag(
|
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-timeline-icon-fill',
|
|
|
|
),
|
|
|
|
phutil_render_tag(
|
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-timeline-icon sprite-icon '.
|
|
|
|
'action-'.$this->icon.'-white',
|
|
|
|
),
|
|
|
|
''));
|
2012-11-22 02:24:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$title = phutil_render_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => implode(' ', $title_classes),
|
|
|
|
),
|
2012-12-11 22:59:51 +01:00
|
|
|
$icon.$title.$extra);
|
2012-11-22 02:24:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$wedge = phutil_render_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-timeline-wedge phabricator-timeline-border',
|
|
|
|
),
|
|
|
|
'');
|
|
|
|
|
|
|
|
$image_uri = $this->userHandle->getImageURI();
|
|
|
|
$image = phutil_render_tag(
|
|
|
|
'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';
|
|
|
|
if ($content) {
|
|
|
|
$classes[] = 'phabricator-timeline-major-event';
|
|
|
|
$content = phutil_render_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => implode(' ', $content_classes),
|
|
|
|
),
|
|
|
|
phutil_render_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-timeline-inner-content',
|
|
|
|
),
|
|
|
|
$title.
|
|
|
|
phutil_render_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-timeline-core-content',
|
|
|
|
),
|
|
|
|
$content)));
|
|
|
|
$content = $image.$wedge.$content;
|
|
|
|
} else {
|
|
|
|
$classes[] = 'phabricator-timeline-minor-event';
|
|
|
|
$content = phutil_render_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => implode(' ', $content_classes),
|
|
|
|
),
|
|
|
|
$image.$wedge.$title);
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return javelin_render_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
|
|
|
),
|
|
|
|
phutil_render_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => implode(' ', $classes),
|
|
|
|
),
|
|
|
|
$content));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|