MDL-52258 calendar: show event duration on block
Add class .duration_finish to days when an event with duration finishes. Removes the .muted class from weekend days. Adds $daytime for the popup title. Tests duyrationbyday too in order to report no events for a day. Adds endtime suffix to the finish date of an event with duration.
This commit is contained in:
+31
-5
@@ -347,6 +347,8 @@ function calendar_get_mini($courses, $groups, $users, $calmonth = false, $calyea
|
||||
$eventids = array_unique(array_merge($eventids, $durationbyday[$day]));
|
||||
}
|
||||
|
||||
$finishclass = false;
|
||||
|
||||
if (!empty($eventids)) {
|
||||
// There is at least one event on this day.
|
||||
|
||||
@@ -355,7 +357,7 @@ function calendar_get_mini($courses, $groups, $users, $calmonth = false, $calyea
|
||||
$dayhref = calendar_get_link_href(new moodle_url(CALENDAR_URL . 'view.php', $hrefparams), 0, 0, 0, $daytime);
|
||||
|
||||
$popupcontent = '';
|
||||
foreach($eventids as $eventid) {
|
||||
foreach ($eventids as $eventid) {
|
||||
if (!isset($events[$eventid])) {
|
||||
continue;
|
||||
}
|
||||
@@ -376,26 +378,47 @@ function calendar_get_mini($courses, $groups, $users, $calmonth = false, $calyea
|
||||
$popupicon = 'i/userevent';
|
||||
}
|
||||
|
||||
if ($event->timeduration) {
|
||||
$startdate = $calendartype->timestamp_to_date_array($event->timestart);
|
||||
$enddate = $calendartype->timestamp_to_date_array($event->timestart + $event->timeduration - 1);
|
||||
if ($enddate['mon'] == $m && $enddate['year'] == $y && $enddate['mday'] == $day) {
|
||||
$finishclass = true;
|
||||
}
|
||||
}
|
||||
|
||||
$dayhref->set_anchor('event_'.$event->id);
|
||||
|
||||
$popupcontent .= html_writer::start_tag('div');
|
||||
$popupcontent .= $OUTPUT->pix_icon($popupicon, $popupalt, $component);
|
||||
$name = format_string($event->name, true);
|
||||
// Show ical source if needed.
|
||||
if (!empty($event->subscription) && $CFG->calendar_showicalsource) {
|
||||
$a = new stdClass();
|
||||
$a->name = $name;
|
||||
$a->source = $event->subscription->name;
|
||||
$name = get_string('namewithsource', 'calendar', $a);
|
||||
} else {
|
||||
if ($finishclass) {
|
||||
$samedate = $startdate['mon'] == $enddate['mon'] &&
|
||||
$startdate['year'] == $enddate['year'] &&
|
||||
$startdate['mday'] == $enddate['mday'];
|
||||
|
||||
if ($samedate) {
|
||||
$name = format_string($event->name, true);
|
||||
} else {
|
||||
$name = format_string($event->name, true) . ' (' . get_string('eventendtime', 'calendar') . ')';
|
||||
}
|
||||
} else {
|
||||
$name = format_string($event->name, true);
|
||||
}
|
||||
}
|
||||
$popupcontent .= html_writer::link($dayhref, $name);
|
||||
$popupcontent .= html_writer::end_tag('div');
|
||||
}
|
||||
|
||||
if ($display->thismonth && $day == $d) {
|
||||
$popupdata = calendar_get_popup(true, $events[$eventid]->timestart, $popupcontent);
|
||||
$popupdata = calendar_get_popup(true, $daytime, $popupcontent);
|
||||
} else {
|
||||
$popupdata = calendar_get_popup(false, $events[$eventid]->timestart, $popupcontent);
|
||||
$popupdata = calendar_get_popup(false, $daytime, $popupcontent);
|
||||
}
|
||||
$cellattributes = array_merge($cellattributes, $popupdata);
|
||||
|
||||
@@ -409,6 +432,9 @@ function calendar_get_mini($courses, $groups, $users, $calmonth = false, $calyea
|
||||
} else if(isset($typesbyday[$day]['startuser'])) {
|
||||
$class .= ' calendar_event_user';
|
||||
}
|
||||
if ($finishclass) {
|
||||
$class .= ' duration_finish';
|
||||
}
|
||||
$cell = html_writer::link($dayhref, $day);
|
||||
} else {
|
||||
$cell = $day;
|
||||
@@ -448,7 +474,7 @@ function calendar_get_mini($courses, $groups, $users, $calmonth = false, $calyea
|
||||
$class .= ' today';
|
||||
$today = get_string('today', 'calendar').' '.userdate(time(), get_string('strftimedayshort'));
|
||||
|
||||
if (!isset($eventsbyday[$day])) {
|
||||
if (!isset($eventsbyday[$day]) && !isset($durationbyday[$day])) {
|
||||
$class .= ' eventnone';
|
||||
$popupdata = calendar_get_popup(true, false);
|
||||
$cellattributes = array_merge($cellattributes, $popupdata);
|
||||
|
||||
@@ -20,22 +20,6 @@
|
||||
background-color: @calendarEventUserColor;
|
||||
}
|
||||
|
||||
.duration_global {
|
||||
background-color: @calendarEventGlobalColor;
|
||||
}
|
||||
|
||||
.duration_course {
|
||||
background-color: @calendarEventCourseColor;
|
||||
}
|
||||
|
||||
.duration_group {
|
||||
background-color: @calendarEventGroupColor;
|
||||
}
|
||||
|
||||
.duration_user {
|
||||
background-color: @calendarEventUserColor;
|
||||
}
|
||||
|
||||
// Calendar restyling.
|
||||
.path-calendar {
|
||||
.calendartable {
|
||||
@@ -330,16 +314,40 @@
|
||||
td {
|
||||
&.weekend {
|
||||
.muted;
|
||||
|
||||
a {
|
||||
.muted;
|
||||
}
|
||||
}
|
||||
a {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
}
|
||||
&.duration_global {
|
||||
border-top: 1px solid @calendarEventGlobalColor;
|
||||
border-bottom: 1px solid @calendarEventGlobalColor;
|
||||
&.duration_finish {
|
||||
background-color: @calendarEventGlobalColor;
|
||||
}
|
||||
}
|
||||
&.duration_course {
|
||||
border-top: 1px solid @calendarEventCourseColor;
|
||||
border-bottom: 1px solid @calendarEventCourseColor;
|
||||
&.duration_finish {
|
||||
background-color: @calendarEventCourseColor;
|
||||
}
|
||||
}
|
||||
&.duration_group {
|
||||
border-top: 1px solid @calendarEventGroupColor;
|
||||
border-bottom: 1px solid @calendarEventGroupColor;
|
||||
&.duration_finish {
|
||||
background-color: @calendarEventGroupColor;
|
||||
}
|
||||
}
|
||||
&.duration_user {
|
||||
border-top: 1px solid @calendarEventUserColor;
|
||||
border-bottom: 1px solid @calendarEventUserColor;
|
||||
&.duration_finish {
|
||||
background-color: @calendarEventUserColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
caption {
|
||||
font-size: inherit;
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user