Changeset View
Changeset View
Standalone View
Standalone View
src/view/phui/PHUITimelineView.php
Show First 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | return phutil_tag( | ||||
$events); | $events); | ||||
} | } | ||||
public function buildEvents() { | public function buildEvents() { | ||||
require_celerity_resource('phui-timeline-view-css'); | require_celerity_resource('phui-timeline-view-css'); | ||||
$spacer = self::renderSpacer(); | $spacer = self::renderSpacer(); | ||||
// Track why we're hiding older results. | |||||
$hide_reason = null; | |||||
$hide = array(); | $hide = array(); | ||||
$show = array(); | $show = array(); | ||||
// Bucket timeline events into events we'll hide by default (because they | // Bucket timeline events into events we'll hide by default (because they | ||||
// predate your most recent interaction with the object) and events we'll | // predate your most recent interaction with the object) and events we'll | ||||
// show by default. | // show by default. | ||||
foreach ($this->events as $event) { | foreach ($this->events as $event) { | ||||
if ($event->getHideByDefault()) { | if ($event->getHideByDefault()) { | ||||
$hide[] = $event; | $hide[] = $event; | ||||
} else { | } else { | ||||
$show[] = $event; | $show[] = $event; | ||||
} | } | ||||
} | } | ||||
// If you've never interacted with the object, all the events will be shown | // If you've never interacted with the object, all the events will be shown | ||||
// by default. We may still need to paginate if there are a large number | // by default. We may still need to paginate if there are a large number | ||||
// of events. | // of events. | ||||
$more = (bool)$hide; | $more = (bool)$hide; | ||||
if ($more) { | |||||
$hide_reason = 'comment'; | |||||
} | |||||
if ($this->getPager()) { | if ($this->getPager()) { | ||||
if ($this->getPager()->getHasMoreResults()) { | if ($this->getPager()->getHasMoreResults()) { | ||||
if (!$more) { | |||||
$hide_reason = 'limit'; | |||||
} | |||||
$more = true; | $more = true; | ||||
} | } | ||||
} | } | ||||
$events = array(); | $events = array(); | ||||
if ($more && $this->getPager()) { | if ($more && $this->getPager()) { | ||||
switch ($hide_reason) { | |||||
case 'comment': | |||||
$hide_help = pht( | |||||
'Changes from before your most recent comment are hidden.'); | |||||
break; | |||||
case 'limit': | |||||
default: | |||||
$hide_help = pht( | |||||
'There are a very large number of changes, so older changes are '. | |||||
'hidden.'); | |||||
break; | |||||
} | |||||
$uri = $this->getPager()->getNextPageURI(); | $uri = $this->getPager()->getNextPageURI(); | ||||
$uri->setQueryParam('quoteTargetID', $this->getQuoteTargetID()); | $uri->setQueryParam('quoteTargetID', $this->getQuoteTargetID()); | ||||
$uri->setQueryParam('quoteRef', $this->getQuoteRef()); | $uri->setQueryParam('quoteRef', $this->getQuoteRef()); | ||||
$events[] = javelin_tag( | $events[] = javelin_tag( | ||||
'div', | 'div', | ||||
array( | array( | ||||
'sigil' => 'show-older-block', | 'sigil' => 'show-older-block', | ||||
'class' => 'phui-timeline-older-transactions-are-hidden', | 'class' => 'phui-timeline-older-transactions-are-hidden', | ||||
), | ), | ||||
array( | array( | ||||
pht('Older changes are hidden. '), | $hide_help, | ||||
' ', | ' ', | ||||
javelin_tag( | javelin_tag( | ||||
'a', | 'a', | ||||
array( | array( | ||||
'href' => (string)$uri, | 'href' => (string)$uri, | ||||
'mustcapture' => true, | 'mustcapture' => true, | ||||
'sigil' => 'show-older-link', | 'sigil' => 'show-older-link', | ||||
), | ), | ||||
pht('Show older changes.')), | pht('Show Older Changes')), | ||||
)); | )); | ||||
if ($show) { | if ($show) { | ||||
$events[] = $spacer; | $events[] = $spacer; | ||||
} | } | ||||
} | } | ||||
if ($show) { | if ($show) { | ||||
▲ Show 20 Lines • Show All 119 Lines • Show Last 20 Lines |