@@ -204,33 +204,42 @@ private function renderCalendarWidgetPaneContent() {
204204 $ today = $ timestamps ['today ' ];
205205 $ epoch_stamps = $ timestamps ['epoch_stamps ' ];
206206 $ one_day = 24 * 60 * 60 ;
207- foreach ($ epoch_stamps as $ time => $ day ) {
207+ $ is_today = false ;
208+ $ calendar_columns = 0 ;
209+ $ list_days = 0 ;
210+ foreach ($ epoch_stamps as $ day ) {
208211 // build a header for the new day
209- if ($ day ->format ('w ' ) == $ today ->format ('w ' )) {
210- $ active_class = 'today ' ;
212+ if ($ day ->format ('Ymd ' ) == $ today ->format ('Ymd ' )) {
213+ $ active_class = 'today ' ;
214+ $ is_today = true ;
211215 } else {
212- $ active_class = '' ;
216+ $ active_class = '' ;
217+ $ is_today = false ;
213218 }
214219
215- $ content [] = phutil_tag (
216- 'div ' ,
217- array (
218- 'class ' => 'day-header ' .$ active_class
219- ),
220- array (
221- phutil_tag (
222- 'div ' ,
223- array (
224- 'class ' => 'day-name '
225- ),
226- $ day ->format ('l ' )),
227- phutil_tag (
228- 'div ' ,
229- array (
230- 'class ' => 'day-date '
231- ),
232- $ day ->format ('m/d/y ' ))
233- ));
220+ $ should_draw_list = $ list_days < 7 ;
221+ $ list_days ++;
222+
223+ if ($ should_draw_list ) {
224+ $ content [] = phutil_tag (
225+ 'div ' ,
226+ array (
227+ 'class ' => 'day-header ' .$ active_class
228+ ),
229+ array (
230+ phutil_tag (
231+ 'div ' ,
232+ array (
233+ 'class ' => 'day-name '
234+ ),
235+ $ day ->format ('l ' )),
236+ phutil_tag (
237+ 'div ' ,
238+ array (
239+ 'class ' => 'day-date '
240+ ),
241+ $ day ->format ('m/d/y ' ))));
242+ }
234243
235244 $ week_day_number = $ day ->format ('w ' );
236245
@@ -251,81 +260,73 @@ private function renderCalendarWidgetPaneContent() {
251260
252261 if ($ status ->getDateFrom () < $ epoch_end &&
253262 $ status ->getDateTo () > $ epoch_start ) {
254- if (!$ first_status_of_the_day ) {
263+ $ statuses_of_the_day [$ status ->getUserPHID ()] = $ status ;
264+ if ($ should_draw_list ) {
265+ $ top_border = '' ;
266+ if (!$ first_status_of_the_day ) {
267+ $ top_border = ' top-border ' ;
268+ }
269+ $ timespan = $ status ->getDateTo () - $ status ->getDateFrom ();
270+ if ($ timespan > $ one_day ) {
271+ $ time_str = 'm/d ' ;
272+ } else {
273+ $ time_str = 'h:i A ' ;
274+ }
275+ $ epoch_range =
276+ phabricator_format_local_time (
277+ $ status ->getDateFrom (),
278+ $ user ,
279+ $ time_str ) .
280+ ' - ' .
281+ phabricator_format_local_time (
282+ $ status ->getDateTo (),
283+ $ user ,
284+ $ time_str );
285+
286+ $ secondary_info = pht ('%s, %s ' ,
287+ $ handles [$ status ->getUserPHID ()]->getName (), $ epoch_range );
288+
255289 $ content [] = phutil_tag (
256290 'div ' ,
257291 array (
258- 'class ' => 'divider '
292+ 'class ' => 'user-status ' . $ status -> getTextStatus (). $ top_border ,
259293 ),
260- '' );
261- }
262- $ statuses_of_the_day [$ status ->getUserPHID ()] = $ status ;
263- $ timespan = $ status ->getDateTo () - $ status ->getDateFrom ();
264- if ($ timespan > $ one_day ) {
265- $ time_str = 'm/d ' ;
266- } else {
267- $ time_str = 'h:i A ' ;
294+ array (
295+ phutil_tag (
296+ 'div ' ,
297+ array (
298+ 'class ' => 'icon ' ,
299+ ),
300+ '' ),
301+ phutil_tag (
302+ 'div ' ,
303+ array (
304+ 'class ' => 'description '
305+ ),
306+ array (
307+ $ status ->getTerseSummary ($ user ),
308+ phutil_tag (
309+ 'div ' ,
310+ array (
311+ 'class ' => 'participant '
312+ ),
313+ $ secondary_info )))));
268314 }
269- $ epoch_range = phabricator_format_local_time (
270- $ status ->getDateFrom (),
271- $ user ,
272- $ time_str ) . ' - ' . phabricator_format_local_time (
273- $ status ->getDateTo (),
274- $ user ,
275- $ time_str );
276-
277- $ secondary_info = pht ('%s, %s ' ,
278- $ handles [$ status ->getUserPHID ()]->getName (), $ epoch_range );
279-
280- $ content [] = phutil_tag (
281- 'div ' ,
282- array (
283- 'class ' => 'pm user-status ' .$ status ->getTextStatus (),
284- ),
285- array (
286- phutil_tag (
287- 'div ' ,
288- array (
289- 'class ' => 'icon ' ,
290- ),
291- '' ),
292- phutil_tag (
293- 'div ' ,
294- array (
295- 'class ' => 'description '
296- ),
297- array (
298- $ status ->getTerseSummary ($ user ),
299- phutil_tag (
300- 'div ' ,
301- array (
302- 'class ' => 'participant '
303- ),
304- $ secondary_info )))
305- ));
306315 $ first_status_of_the_day = false ;
307- } else {
308- $ content [] = phutil_tag (
309- 'div ' ,
310- array ('class ' => 'no-events pmt pml ' ),
311- pht ('No Events Scheduled. ' ));
312316 }
313317 }
314318
315319 // we didn't get a status on this day so add a spacer
316- if ($ first_status_of_the_day ) {
320+ if ($ first_status_of_the_day && $ should_draw_list ) {
317321 $ content [] = phutil_tag (
318322 'div ' ,
319- array (
320- 'class ' => 'spacer '
321- ),
322- '' );
323+ array ('class ' => 'no-events pm ' ),
324+ pht ('No Events Scheduled. ' ));
323325 }
324- if ($ week_day_number > 0 && $ week_day_number < 6 ) {
325- if ($ week_day_number == $ today ->format ('w ' )) {
326+ if ($ is_today || ($ calendar_columns && $ calendar_columns < 3 )) {
327+ $ active_class = '' ;
328+ if ($ day ->format ('Ymd ' ) == $ today ->format ('Ymd ' )) {
326329 $ active_class = '-active ' ;
327- } else {
328- $ active_class = '' ;
329330 }
330331 $ inner_layout = array ();
331332 foreach ($ participants as $ phid => $ participant ) {
@@ -366,7 +367,8 @@ private function renderCalendarWidgetPaneContent() {
366367 ),
367368 $ day ->format ('j ' )),
368369 $ inner_layout
369- )));
370+ )));
371+ $ calendar_columns ++;
370372 }
371373 }
372374
@@ -381,15 +383,14 @@ private function getCalendarWidgetTimestamps() {
381383 $ user = $ this ->getRequest ()->getUser ();
382384 $ timezone = new DateTimeZone ($ user ->getTimezoneIdentifier ());
383385
384- $ today = id ( new DateTime ('today ' , $ timezone) );
386+ $ first_day = new DateTime ('last sunday ' , $ timezone );
385387 $ timestamps = array ();
386- for ($ day = 0 ; $ day < 3 ; $ day ++) {
387- $ timestamp = clone $ today ;
388+ for ($ day = 0 ; $ day < 8 ; $ day ++) {
389+ $ timestamp = clone $ first_day ;
388390 $ timestamps [] = $ timestamp ->modify (sprintf ('+%d days ' , $ day ));
389391 }
390-
391392 return array (
392- 'today ' => $ today ,
393+ 'today ' => new DateTime ( ' today ' , $ timezone ) ,
393394 'epoch_stamps ' => $ timestamps
394395 );
395396 }
@@ -399,4 +400,4 @@ private function getWidgetURI() {
399400 return $ this ->getApplicationURI ('update/ ' .$ conpherence ->getID ().'/ ' );
400401 }
401402
402- }
403+ }
0 commit comments