diff --git a/calendar/classes/external/day_exporter.php b/calendar/classes/external/day_exporter.php index 7e888b84d44..377d2cd6e2c 100644 --- a/calendar/classes/external/day_exporter.php +++ b/calendar/classes/external/day_exporter.php @@ -126,6 +126,10 @@ class day_exporter extends exporter { 'type' => PARAM_URL, 'optional' => true, ], + 'viewdaylinktitle' => [ + 'type' => PARAM_RAW, + 'optional' => true, + ], 'events' => [ 'type' => calendar_event_exporter::read_properties_definition(), 'multiple' => true, @@ -183,6 +187,10 @@ class day_exporter extends exporter { 'viewdaylink' => $this->url->out(false), ]; + if ($viewdaylinktitle = $this->get_view_link_title()) { + $return['viewdaylinktitle'] = $viewdaylinktitle; + } + $cache = $this->related['cache']; $eventexporters = array_map(function($event) use ($cache, $output) { @@ -267,4 +275,22 @@ class day_exporter extends exporter { 'time' => $this->calendar->time, ]); } + + /** + * Get the title for view link. + * + * @return string + */ + protected function get_view_link_title() { + $title = null; + + $userdate = userdate($this->data[0], get_string('strftimedayshort')); + if ($this->data['istoday']) { + $title = get_string('todayplustitle', 'calendar', $userdate); + } else if (count($this->related['events'])) { + $title = get_string('eventsfor', 'calendar', $userdate); + } + + return $title; + } } diff --git a/calendar/templates/month_detailed.mustache b/calendar/templates/month_detailed.mustache index d5dbfa4af1b..364397e1389 100644 --- a/calendar/templates/month_detailed.mustache +++ b/calendar/templates/month_detailed.mustache @@ -72,7 +72,7 @@ data-new-event-timestamp="{{neweventtimestamp}}">