@@ -150,13 +150,13 @@ public function search(
150150 $ formattedResults = \array_map (function (array $ eventRow ) use ($ calendarsById , $ subscriptionsById ): SearchResultEntry {
151151 $ component = $ this ->getPrimaryComponent ($ eventRow ['calendardata ' ], self ::$ componentType );
152152 $ title = (string )($ component ->SUMMARY ?? $ this ->l10n ->t ('Untitled event ' ));
153- $ subline = $ this ->generateSubline ($ component );
154153
155154 if ($ eventRow ['calendartype ' ] === CalDavBackend::CALENDAR_TYPE_CALENDAR ) {
156155 $ calendar = $ calendarsById [$ eventRow ['calendarid ' ]];
157156 } else {
158157 $ calendar = $ subscriptionsById [$ eventRow ['calendarid ' ]];
159158 }
159+ $ subline = $ this ->generateSubline ($ component , $ calendar );
160160 $ resourceUrl = $ this ->getDeepLinkToCalendarApp ($ calendar ['principaluri ' ], $ calendar ['uri ' ], $ eventRow ['uri ' ]);
161161 $ result = new SearchResultEntry ('' , $ title , $ subline , $ resourceUrl , 'icon-calendar-dark ' , false );
162162
@@ -204,7 +204,7 @@ protected function getDavUrlForCalendarObject(
204204 . $ calendarObjectUri ;
205205 }
206206
207- protected function generateSubline (Component $ eventComponent ): string {
207+ protected function generateSubline (Component $ eventComponent, array $ calendarInfo ): string {
208208 $ dtStart = $ eventComponent ->DTSTART ;
209209 $ dtEnd = $ this ->getDTEndForEvent ($ eventComponent );
210210 $ isAllDayEvent = $ dtStart instanceof Property \ICalendar \Date;
@@ -214,24 +214,31 @@ protected function generateSubline(Component $eventComponent): string {
214214 if ($ isAllDayEvent ) {
215215 $ endDateTime ->modify ('-1 day ' );
216216 if ($ this ->isDayEqual ($ startDateTime , $ endDateTime )) {
217- return $ this ->l10n ->l ('date ' , $ startDateTime , ['width ' => 'medium ' ]);
217+ $ formattedSubline = $ this ->l10n ->l ('date ' , $ startDateTime , ['width ' => 'medium ' ]);
218+ } else {
219+ $ formattedStart = $ this ->l10n ->l ('date ' , $ startDateTime , ['width ' => 'medium ' ]);
220+ $ formattedEnd = $ this ->l10n ->l ('date ' , $ endDateTime , ['width ' => 'medium ' ]);
221+ $ formattedSubline = "$ formattedStart - $ formattedEnd " ;
218222 }
223+ } else {
224+ $ formattedStartDate = $ this ->l10n ->l ('date ' , $ startDateTime , ['width ' => 'medium ' ]);
225+ $ formattedEndDate = $ this ->l10n ->l ('date ' , $ endDateTime , ['width ' => 'medium ' ]);
226+ $ formattedStartTime = $ this ->l10n ->l ('time ' , $ startDateTime , ['width ' => 'short ' ]);
227+ $ formattedEndTime = $ this ->l10n ->l ('time ' , $ endDateTime , ['width ' => 'short ' ]);
219228
220- $ formattedStart = $ this ->l10n ->l ('date ' , $ startDateTime , ['width ' => 'medium ' ]);
221- $ formattedEnd = $ this ->l10n ->l ('date ' , $ endDateTime , ['width ' => 'medium ' ]);
222- return "$ formattedStart - $ formattedEnd " ;
229+ if ($ this ->isDayEqual ($ startDateTime , $ endDateTime )) {
230+ $ formattedSubline = "$ formattedStartDate $ formattedStartTime - $ formattedEndTime " ;
231+ } else {
232+ $ formattedSubline = "$ formattedStartDate $ formattedStartTime - $ formattedEndDate $ formattedEndTime " ;
233+ }
223234 }
224235
225- $ formattedStartDate = $ this ->l10n ->l ('date ' , $ startDateTime , ['width ' => 'medium ' ]);
226- $ formattedEndDate = $ this ->l10n ->l ('date ' , $ endDateTime , ['width ' => 'medium ' ]);
227- $ formattedStartTime = $ this ->l10n ->l ('time ' , $ startDateTime , ['width ' => 'short ' ]);
228- $ formattedEndTime = $ this ->l10n ->l ('time ' , $ endDateTime , ['width ' => 'short ' ]);
229-
230- if ($ this ->isDayEqual ($ startDateTime , $ endDateTime )) {
231- return "$ formattedStartDate $ formattedStartTime - $ formattedEndTime " ;
236+ if (isset ($ calendarInfo ['{DAV:}displayname ' ]) && !empty ($ calendarInfo ['{DAV:}displayname ' ])) {
237+ $ formattedSubline = $ formattedSubline . " ( {$ calendarInfo ['{DAV:}displayname ' ]}) " ;
232238 }
233239
234- return "$ formattedStartDate $ formattedStartTime - $ formattedEndDate $ formattedEndTime " ;
240+ // string cast is just to make psalm happy
241+ return (string )$ formattedSubline ;
235242 }
236243
237244 protected function getDTEndForEvent (Component $ eventComponent ):Property {
0 commit comments