Differential D15207 Diff 36714 src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php
Show First 20 Lines • Show All 260 Lines • ▼ Show 20 Lines | if ($this->isMonthView($query)) { | ||||
return $this->buildCalendarDayView($events, $query, $handles); | return $this->buildCalendarDayView($events, $query, $handles); | ||||
} | } | ||||
assert_instances_of($events, 'PhabricatorCalendarEvent'); | assert_instances_of($events, 'PhabricatorCalendarEvent'); | ||||
$viewer = $this->requireViewer(); | $viewer = $this->requireViewer(); | ||||
$list = new PHUIObjectItemListView(); | $list = new PHUIObjectItemListView(); | ||||
foreach ($events as $event) { | foreach ($events as $event) { | ||||
$duration = ''; | |||||
$event_date_info = $this->getEventDateLabel($event); | $event_date_info = $this->getEventDateLabel($event); | ||||
jcowgar: Wrong variable name, d'oh! Fixing. | |||||
$creator_handle = $handles[$event->getUserPHID()]; | $creator_handle = $handles[$event->getUserPHID()]; | ||||
$attendees = array(); | $attendees = array(); | ||||
foreach ($event->getInvitees() as $invitee) { | foreach ($event->getInvitees() as $invitee) { | ||||
$attendees[] = $invitee->getInviteePHID(); | $attendees[] = $invitee->getInviteePHID(); | ||||
} | } | ||||
$attendees = pht( | |||||
'Attending: %s', | |||||
$viewer->renderHandleList($attendees) | |||||
->setAsInline(1) | |||||
->render()); | |||||
if (strlen($event->getDuration()) > 0) { | |||||
$duration = pht( | |||||
'Duration: %s', | |||||
$event->getDuration()); | |||||
} | |||||
if ($event->getIsGhostEvent()) { | if ($event->getIsGhostEvent()) { | ||||
Not Done Inline ActionsBy convention in this codebase, prefer if ($attendees) over if (count($attendees) > 0) for testing arrays for the presence of elements. epriestley: By convention in this codebase, prefer `if ($attendees)` over `if (count($attendees) > 0)` for… | |||||
$title_text = $event->getMonogram() | $title_text = $event->getMonogram() | ||||
.' (' | .' (' | ||||
.$event->getSequenceIndex() | .$event->getSequenceIndex() | ||||
.'): ' | .'): ' | ||||
.$event->getName(); | .$event->getName(); | ||||
} else { | } else { | ||||
$title_text = $event->getMonogram().': '.$event->getName(); | $title_text = $event->getMonogram().': '.$event->getName(); | ||||
} | } | ||||
$item = id(new PHUIObjectItemView()) | $item = id(new PHUIObjectItemView()) | ||||
->setUser($viewer) | ->setUser($viewer) | ||||
->setObject($event) | ->setObject($event) | ||||
->setHeader($title_text) | ->setHeader($title_text) | ||||
->setHref($event->getURI()) | ->setHref($event->getURI()) | ||||
->addAttribute($event_date_info) | ->addAttribute($event_date_info); | ||||
Not Done Inline ActionsInstead of adding an empty attribute (which may cause us to render extra space or an extra separator character like a middot (·) now or in the future), prefer to add the attribute conditionally: if ($attendees) { // ... $item->addAttribute(...); epriestley: Instead of adding an empty attribute (which may cause us to render extra space or an extra… | |||||
Not Done Inline ActionsI was actually going to do that, but followed suit with the duration. Should I change the $duration as well or should that be done in a different commit/task/review? I am unsure of project policies here. jcowgar: I was actually going to do that, but followed suit with the duration.
Should I change the… | |||||
->addAttribute($attendees) | |||||
->addIcon('none', $duration); | if ($attendees) { | ||||
$attending = pht( | |||||
'Attending: %s', | |||||
$viewer->renderHandleList($attendees) | |||||
->setAsInline(1) | |||||
->render()); | |||||
$item->addAttribute($attending); | |||||
} | |||||
if (strlen($event->getDuration()) > 0) { | |||||
$duration = pht( | |||||
'Duration: %s', | |||||
$event->getDuration()); | |||||
$item->addIcon('none', $duration); | |||||
} | |||||
$list->addItem($item); | $list->addItem($item); | ||||
} | } | ||||
$result = new PhabricatorApplicationSearchResultView(); | $result = new PhabricatorApplicationSearchResultView(); | ||||
$result->setObjectList($list); | $result->setObjectList($list); | ||||
$result->setNoDataString(pht('No events found.')); | $result->setNoDataString(pht('No events found.')); | ||||
▲ Show 20 Lines • Show All 260 Lines • Show Last 20 Lines |
Wrong variable name, d'oh! Fixing.