Page MenuHomePhabricator

D16298.diff
No OneTemporary

D16298.diff

diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php b/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
--- a/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
+++ b/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
@@ -34,6 +34,7 @@
new PhabricatorCalendarEventTransactionQuery());
$header = $this->buildHeaderView($event);
+ $subheader = $this->buildSubheaderView($event);
$curtain = $this->buildCurtain($event);
$details = $this->buildPropertySection($event);
$description = $this->buildDescriptionView($event);
@@ -47,6 +48,7 @@
$view = id(new PHUITwoColumnView())
->setHeader($header)
+ ->setSubheader($subheader)
->setMainColumn(
array(
$timeline,
@@ -201,32 +203,6 @@
$properties = id(new PHUIPropertyListView())
->setUser($viewer);
- if ($event->getIsAllDay()) {
- $date_start = phabricator_date($event->getViewerDateFrom(), $viewer);
- $date_end = phabricator_date($event->getViewerDateTo(), $viewer);
-
- if ($date_start == $date_end) {
- $properties->addProperty(
- pht('Time'),
- phabricator_date($event->getViewerDateFrom(), $viewer));
- } else {
- $properties->addProperty(
- pht('Starts'),
- phabricator_date($event->getViewerDateFrom(), $viewer));
- $properties->addProperty(
- pht('Ends'),
- phabricator_date($event->getViewerDateTo(), $viewer));
- }
- } else {
- $properties->addProperty(
- pht('Starts'),
- phabricator_datetime($event->getViewerDateFrom(), $viewer));
-
- $properties->addProperty(
- pht('Ends'),
- phabricator_datetime($event->getViewerDateTo(), $viewer));
- }
-
if ($event->getIsRecurring()) {
$properties->addProperty(
pht('Recurs'),
@@ -247,10 +223,6 @@
}
}
- $properties->addProperty(
- pht('Host'),
- $viewer->renderHandle($event->getHostPHID()));
-
$invitees = $event->getInvitees();
foreach ($invitees as $key => $invitee) {
if ($invitee->isUninvited()) {
@@ -389,4 +361,29 @@
return $instance;
}
+ private function buildSubheaderView(PhabricatorCalendarEvent $event) {
+ $viewer = $this->getViewer();
+
+ $host_phid = $event->getHostPHID();
+
+ $handles = $viewer->loadHandles(array($host_phid));
+ $handle = $handles[$host_phid];
+
+ $host = $viewer->renderHandle($host_phid);
+ $host = phutil_tag('strong', array(), $host);
+
+ $image_uri = $handles[$host_phid]->getImageURI();
+ $image_href = $handles[$host_phid]->getURI();
+
+ $date = $event->renderEventDate($viewer, true);
+
+ $content = pht('Hosted by %s on %s.', $host, $date);
+
+ return id(new PHUIHeadThingView())
+ ->setImage($image_uri)
+ ->setImageHref($image_href)
+ ->setContent($content);
+ }
+
+
}
diff --git a/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php b/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php
--- a/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php
+++ b/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php
@@ -264,7 +264,6 @@
$list = new PHUIObjectItemListView();
foreach ($events as $event) {
- $event_date_info = $this->getEventDateLabel($event);
$attendees = array();
foreach ($event->getInvitees() as $invitee) {
@@ -288,7 +287,7 @@
->setObjectName($monogram)
->setHeader($event->getName())
->setHref($event->getURI())
- ->addAttribute($event_date_info);
+ ->addAttribute($event->renderEventDate($viewer, false));
if ($attendees) {
$attending = pht(
@@ -300,13 +299,6 @@
$item->addAttribute($attending);
}
- if ($event->getDuration()) {
- $duration = pht(
- 'Duration: %s',
- $event->getDisplayDuration());
- $item->addIcon('none', $duration);
- }
-
$list->addItem($item);
}
@@ -542,40 +534,4 @@
return false;
}
- private function getEventDateLabel($event) {
- $viewer = $this->requireViewer();
-
- $from_datetime = PhabricatorTime::getDateTimeFromEpoch(
- $event->getViewerDateFrom(),
- $viewer);
- $to_datetime = PhabricatorTime::getDateTimeFromEpoch(
- $event->getViewerDateTo(),
- $viewer);
-
- $from_date_formatted = $from_datetime->format('Y m d');
- $to_date_formatted = $to_datetime->format('Y m d');
-
- if ($event->getIsAllDay()) {
- if ($from_date_formatted == $to_date_formatted) {
- return pht(
- '%s, All Day',
- phabricator_date($event->getViewerDateFrom(), $viewer));
- } else {
- return pht(
- '%s - %s, All Day',
- phabricator_date($event->getViewerDateFrom(), $viewer),
- phabricator_date($event->getViewerDateTo(), $viewer));
- }
- } else if ($from_date_formatted == $to_date_formatted) {
- return pht(
- '%s - %s',
- phabricator_datetime($event->getViewerDateFrom(), $viewer),
- phabricator_time($event->getViewerDateTo(), $viewer));
- } else {
- return pht(
- '%s - %s',
- phabricator_datetime($event->getViewerDateFrom(), $viewer),
- phabricator_datetime($event->getViewerDateTo(), $viewer));
- }
- }
}
diff --git a/src/applications/calendar/storage/PhabricatorCalendarEvent.php b/src/applications/calendar/storage/PhabricatorCalendarEvent.php
--- a/src/applications/calendar/storage/PhabricatorCalendarEvent.php
+++ b/src/applications/calendar/storage/PhabricatorCalendarEvent.php
@@ -454,30 +454,60 @@
return false;
}
- public function getDisplayDuration() {
- $seconds = $this->getDuration();
- $minutes = round($seconds / 60, 1);
- $hours = round($minutes / 60, 3);
- $days = round($hours / 24, 2);
+ public function renderEventDate(
+ PhabricatorUser $viewer,
+ $show_end) {
- $duration = '';
+ if ($show_end) {
+ $min_date = PhabricatorTime::getDateTimeFromEpoch(
+ $this->getViewerDateFrom(),
+ $viewer);
- if ($days >= 1) {
+ $max_date = PhabricatorTime::getDateTimeFromEpoch(
+ $this->getViewerDateTo(),
+ $viewer);
+
+ $min_day = $min_date->format('Y m d');
+ $max_day = $max_date->format('Y m d');
+
+ $show_end_date = ($min_day != $max_day);
+ } else {
+ $show_end_date = false;
+ }
+
+ $min_epoch = $this->getViewerDateFrom();
+ $max_epoch = $this->getViewerDateTo();
+
+ if ($this->getIsAllDay()) {
+ if ($show_end_date) {
+ return pht(
+ '%s - %s, All Day',
+ phabricator_date($min_epoch, $viewer),
+ phabricator_date($max_epoch, $viewer));
+ } else {
+ return pht(
+ '%s, All Day',
+ phabricator_date($min_epoch, $viewer));
+ }
+ } else if ($show_end_date) {
return pht(
- '%s day(s)',
- round($days, 1));
- } else if ($hours >= 1) {
+ '%s - %s',
+ phabricator_datetime($min_epoch, $viewer),
+ phabricator_datetime($max_epoch, $viewer));
+ } else if ($show_end) {
return pht(
- '%s hour(s)',
- round($hours, 1));
- } else if ($minutes >= 1) {
+ '%s - %s',
+ phabricator_datetime($min_epoch, $viewer),
+ phabricator_time($max_epoch, $viewer));
+ } else {
return pht(
- '%s minute(s)',
- round($minutes, 0));
+ '%s',
+ phabricator_datetime($min_epoch, $viewer));
}
}
+
/* -( Markup Interface )--------------------------------------------------- */

File Metadata

Mime Type
text/plain
Expires
Sun, Mar 9, 6:35 PM (3 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7390596
Default Alt Text
D16298.diff (7 KB)

Event Timeline