Get the list of week days, ordered into weeks and padded according
to the value of the first day of the week.

@param renderer_base $output
@return array The list of weeks.
439341
protected function get_weeks(renderer_base $output) {
        $weeks = [];
        $alldays = $this->get_days();

        $daysinweek = count($this->related['type']->get_weekdays());

        // Calculate which day number is the first, and last day of the week.
        $firstdayofweek = $this->firstdayofweek;

        // The first week is special as it may have padding at the beginning.
        $day = reset($alldays);
        $firstdayno = $day['wday'];

        $prepadding = ($firstdayno + $daysinweek - $firstdayofweek) % $daysinweek;
        $daysinfirstweek = $daysinweek - $prepadding;
        $days = array_slice($alldays, 0, $daysinfirstweek);
        $week = new week_exporter($this->calendar, $days, $prepadding, ($daysinweek - count($days) - $prepadding), $this->related);
        $weeks[] = $week->export($output);

        // Now chunk up the remaining day. and turn them into weeks.
        $daychunks = array_chunk(array_slice($alldays, $daysinfirstweek), $daysinweek);
        foreach ($daychunks as $days) {
            $week = new week_exporter($this->calendar, $days, 0, ($daysinweek - count($days)), $this->related);
            $weeks[] = $week->export($output);
        }

        return $weeks;
    }
1010456
public function export_for_template(renderer_base $output) : Array {
        return [
            'navigation' => $this->navigationdata,
            'systemname' => $this->systemname,
            'timegenerated' => time(),
            'username' => $this->username,
            'righttoleft' => $this->rtl,
            'siteurl' => $this->siteurl
        ];
    }
252728
public function export_for_template(renderer_base $output) {
        $args = !empty($this->jsfunctionargs) ? json_encode($this->jsfunctionargs) : false;
        return (object) [
            'event' => $this->event,
            'jsfunction' => $this->jsfunction,
            'jsfunctionargs' => $args,
        ];
    }
310453
public function export_for_template(renderer_base $output) {
        $data = new stdClass();
        $data->id = $this->id;
        $data->label = (string) $this->label;
        $data->items = array_map(function($item) use ($output) {
            return $item->export_for_template($output);
        }, array_values($this->items));
        return $data;
    }
209586
public function export_for_template(renderer_base $output) : Array {
        $data = $this->create_navigation($this->tree);
        return ['navigation' => $data];
    }
154868
public function export_for_template(renderer_base $output) {

        $nocoursesurl = $output->image_url('courses', 'block_myoverview')->out();

        $defaultvariables = [
            'nocoursesimg' => $nocoursesurl,
            'grouping' => $this->grouping,
            'sort' => $this->sort == BLOCK_MYOVERVIEW_SORTING_TITLE ? 'fullname' : 'ul.timeaccess desc',
            'view' => $this->view,
            'paging' => $this->paging,
            'displaycategories' => $this->displaycategories,
        ];

        $preferences = $this->get_preferences_as_booleans();
        return array_merge($defaultvariables, $preferences);

    }
1124476
public function export_for_template(renderer_base $output) {
        if ($this->inactive || ($this->selected && !$this->linkedwhenselected) || $this->activated) {
            $link = null;
        } else {
            $link = $this->link;
        }
        $active = $this->activated || $this->selected;

        return (object) [
            'id' => $this->id,
            'link' => is_object($link) ? $link->out(false) : $link,
            'text' => $this->text,
            'title' => $this->title,
            'inactive' => !$active && $this->inactive,
            'active' => $active,
            'level' => $this->level,
        ];
    }
435803
public function export_for_template(\renderer_base $output) {
        if (!$this->editable) {
            return array(
                'displayvalue' => (string)$this->displayvalue
            );
        }

        return array(
            'component' => $this->component,
            'itemtype' => $this->itemtype,
            'itemid' => $this->itemid,
            'displayvalue' => (string)$this->displayvalue,
            'value' => (string)$this->value,
            'edithint' => (string)$this->edithint,
            'editlabel' => (string)$this->editlabel,
            'type' => $this->type,
            'options' => $this->options,
            'linkeverything' => $this->get_linkeverything() ? 1 : 0,
        );
    }
444352
public function export_for_template(renderer_base $output) {
        if (!isset($related['user'])) {
            $related['user'] = core_user::get_user($this->usercompetency->get('userid'));
        }
        if (!isset($related['competency'])) {
            $related['competency'] = $this->usercompetency->get_competency();
        }

        $related += array(
            'usercompetency' => $this->usercompetency,
            'usercompetencyplan' => null,
            'usercompetencycourse' => null,
            'evidence' => api::list_evidence($this->usercompetency->get('userid'), $this->usercompetency->get('competencyid')),
            'relatedcompetencies' => api::list_related_competencies($this->usercompetency->get('competencyid'))
        );
        $exporter = new user_competency_summary_exporter(null, $related);
        $data = $exporter->export($output);

        return $data;
    }
459159
public function export_for_template(renderer_base $output) {
        $data = new stdClass();

        $compstoreview = array();
        foreach ($this->compstoreview['competencies'] as $compdata) {
            $ucexporter = new user_competency_exporter($compdata->usercompetency,
                array('scale' => $compdata->competency->get_scale()));
            $compexporter = new competency_exporter($compdata->competency,
                array('context' => $compdata->competency->get_context()));
            $userexporter = new user_summary_exporter($compdata->user);
            $compstoreview[] = array(
                'usercompetency' => $ucexporter->export($output),
                'competency' => $compexporter->export($output),
                'user' => $userexporter->export($output),
            );
        }

        $data = array(
            'competencies' => $compstoreview,
            'pluginbaseurl' => (new moodle_url('/blocks/lp'))->out(false),
        );

        return $data;
    }
584318
public function export_for_template(renderer_base $output) {
        $data = new stdClass();
        $attributes = $this->attributes;
        $attributesprimary = $this->attributesprimary;
        $attributessecondary = $this->attributessecondary;

        $data->instance = $this->instance;

        $data->classes = isset($attributes['class']) ? $attributes['class'] : '';
        unset($attributes['class']);

        $data->attributes = array_map(function($key, $value) {
            return [ 'name' => $key, 'value' => $value ];
        }, array_keys($attributes), $attributes);

        $primary = new stdClass();
        $primary->title = '';
        $primary->prioritise = $this->prioritise;

        $primary->classes = isset($attributesprimary['class']) ? $attributesprimary['class'] : '';
        unset($attributesprimary['class']);
        $primary->attributes = array_map(function($key, $value) {
            return [ 'name' => $key, 'value' => $value ];
        }, array_keys($attributesprimary), $attributesprimary);

        $actionicon = $this->actionicon;
        if (!empty($this->menutrigger)) {
            $primary->menutrigger = $this->menutrigger;
            $primary->triggerextraclasses = $this->triggerextraclasses;
            if ($this->actionlabel) {
                $primary->title = $this->actionlabel;
            } else if ($this->actiontext) {
                $primary->title = $this->actiontext;
            } else {
                $primary->title = strip_tags($this->menutrigger);
            }
        } else {
            $primary->title = get_string('actionsmenu');
            $iconattributes = ['class' => 'iconsmall actionmenu', 'title' => $primary->title];
            $actionicon = new pix_icon('t/edit_menu', '', 'moodle', $iconattributes);
        }

        if ($actionicon instanceof pix_icon) {
            $primary->icon = $actionicon->export_for_pix();
            if (!empty($actionicon->attributes['alt'])) {
                $primary->title = $actionicon->attributes['alt'];
            }
        } else {
            $primary->iconraw = $actionicon ? $output->render($actionicon) : '';
        }

        $primary->actiontext = $this->actiontext ? (string) $this->actiontext : '';
        $primary->items = array_map(function($item) use ($output) {
            $data = (object) [];
            if ($item instanceof action_menu_link) {
                $data->actionmenulink = $item->export_for_template($output);
            } else if ($item instanceof action_menu_filler) {
                $data->actionmenufiller = $item->export_for_template($output);
            } else if ($item instanceof action_link) {
                $data->actionlink = $item->export_for_template($output);
            } else if ($item instanceof pix_icon) {
                $data->pixicon = $item->export_for_template($output);
            } else {
                $data->rawhtml = ($item instanceof renderable) ? $output->render($item) : $item;
            }
            return $data;
        }, $this->primaryactions);

        $secondary = new stdClass();
        $secondary->classes = isset($attributessecondary['class']) ? $attributessecondary['class'] : '';
        unset($attributessecondary['class']);
        $secondary->attributes = array_map(function($key, $value) {
            return [ 'name' => $key, 'value' => $value ];
        }, array_keys($attributessecondary), $attributessecondary);
        $secondary->items = array_map(function($item) use ($output) {
            $data = (object) [];
            if ($item instanceof action_menu_link) {
                $data->actionmenulink = $item->export_for_template($output);
            } else if ($item instanceof action_menu_filler) {
                $data->actionmenufiller = $item->export_for_template($output);
            } else if ($item instanceof action_link) {
                $data->actionlink = $item->export_for_template($output);
            } else if ($item instanceof pix_icon) {
                $data->pixicon = $item->export_for_template($output);
            } else {
                $data->rawhtml = ($item instanceof renderable) ? $output->render($item) : $item;
            }
            return $data;
        }, $this->secondaryactions);

        $data->primary = $primary;
        $data->secondary = $secondary;

        return $data;
    }
754851
protected function get_other_values(renderer_base $output) {
        $timestamp = $this->calendar->time;

        $cache = $this->related['cache'];
        $url = new moodle_url('/calendar/view.php', [
            'view' => 'day',
            'time' => $timestamp,
        ]);
        if ($this->calendar->course && SITEID !== $this->calendar->course->id) {
            $url->param('course', $this->calendar->course->id);
        } else if ($this->calendar->categoryid) {
            $url->param('category', $this->calendar->categoryid);
        }
        $this->url = $url;
        $return['events'] = array_map(function($event) use ($cache, $output, $url) {
            $context = $cache->get_context($event);
            $course = $cache->get_course($event);
            $moduleinstance = $cache->get_module_instance($event);
            $exporter = new calendar_event_exporter($event, [
                'context' => $context,
                'course' => $course,
                'moduleinstance' => $moduleinstance,
                'daylink' => $url,
                'type' => $this->related['type'],
                'today' => $this->calendar->time,
            ]);

            $data = $exporter->export($output);

            // We need to override default formatted time because it differs from day view.
            // Formatted time for day view adds a link to the day view.
            $legacyevent = container::get_event_mapper()->from_event_to_legacy_event($event);
            $data->formattedtime = calendar_format_event_time($legacyevent, time(), null);

            return $data;
        }, $this->related['events']);

        if ($context = $this->get_default_add_context()) {
            $return['defaulteventcontext'] = $context->id;
        }

        if ($this->calendar->categoryid) {
            $return['categoryid'] = $this->calendar->categoryid;
        }

        $return['filter_selector'] = $this->get_course_filter_selector($output);
        $return['courseid'] = $this->calendar->courseid;

        $previousperiod = $this->get_previous_day_data();
        $nextperiod = $this->get_next_day_data();
        $date = $this->related['type']->timestamp_to_date_array($this->calendar->time);

        $nextperiodlink = new moodle_url($this->url);
        $nextperiodlink->param('time', $nextperiod[0]);

        $previousperiodlink = new moodle_url($this->url);
        $previousperiodlink->param('time', $previousperiod[0]);

        $days = calendar_get_days();
        $return['date'] = (new date_exporter($date))->export($output);
        $return['periodname'] = userdate($this->calendar->time, get_string('strftimedaydate'));
        $return['previousperiod'] = (new date_exporter($previousperiod))->export($output);
        $return['previousperiodname'] = $days[$previousperiod['wday']]['fullname'];
        $return['previousperiodlink'] = $previousperiodlink->out(false);
        $return['nextperiod'] = (new date_exporter($nextperiod))->export($output);
        $return['nextperiodname'] = $days[$nextperiod['wday']]['fullname'];
        $return['nextperiodlink'] = $nextperiodlink->out(false);
        $return['larrow'] = $output->larrow();
        $return['rarrow'] = $output->rarrow();

        // Need to account for user's timezone.
        $usernow = usergetdate(time());
        $today = new \DateTimeImmutable();
        $neweventtimestamp = $today->setTimestamp($date[0])->setTime(
            $usernow['hours'],
            $usernow['minutes'],
            $usernow['seconds']
        );
        $return['neweventtimestamp'] = $neweventtimestamp->getTimestamp();

        return $return;
    }
112288
public function export_for_template(renderer_base $output) {
        $data = parent::export_for_template($output);
        $data->courseid = $this->course->id;
        return $data;
    }
212191
protected function get_other_values(renderer_base $output) {

        $othervalues = [
            'currentversion' => null,
            'draftversions' => [],
            'archivedversions' => [],
        ];

        foreach ($this->related['versions'] as $exporter) {
            $data = $exporter->export($output);

            if ($data->id == $this->data->currentversionid) {
                $othervalues['currentversion'] = $data;

            } else if ($data->archived) {
                $othervalues['archivedversions'][] = $data;

            } else {
                $othervalues['draftversions'][] = $data;
            }
        }

        return $othervalues;
    }
337784
protected function get_other_values(renderer_base $output) {
        global $CFG;
        $return = [
            'prepadding' => [],
            'postpadding' => [],
            'days' => [],
        ];

        for ($i = 0; $i < $this->prepadding; $i++) {
            $return['prepadding'][] = $i;
        }
        for ($i = 0; $i < $this->postpadding; $i++) {
            $return['postpadding'][] = $i;
        }

        $return['days'] = [];
        $today = $this->related['type']->timestamp_to_date_array(time());

        $weekend = CALENDAR_DEFAULT_WEEKEND;
        if (isset($CFG->calendar_weekend)) {
            $weekend = intval($CFG->calendar_weekend);
        }
        $numberofdaysinweek = $this->related['type']->get_num_weekdays();

        foreach ($this->days as $daydata) {
            $events = [];
            foreach ($this->related['events'] as $event) {
                $times = $event->get_times();
                $starttime = $times->get_start_time()->getTimestamp();
                $startdate = $this->related['type']->timestamp_to_date_array($starttime);
                $endtime = $times->get_end_time()->getTimestamp();
                $enddate = $this->related['type']->timestamp_to_date_array($endtime);

                if ((($startdate['year'] * 366) + $startdate['yday']) > ($daydata['year'] * 366) + $daydata['yday']) {
                    // Starts after today.
                    continue;
                }
                if ((($enddate['year'] * 366) + $enddate['yday']) < ($daydata['year'] * 366) + $daydata['yday']) {
                    // Ends before today.
                    continue;
                }
                $events[] = $event;
            }

            $istoday = true;
            $istoday = $istoday && $today['year'] == $daydata['year'];
            $istoday = $istoday && $today['yday'] == $daydata['yday'];
            $daydata['istoday'] = $istoday;

            $daydata['isweekend'] = !!($weekend & (1 << ($daydata['wday'] % $numberofdaysinweek)));

            $day = new week_day_exporter($this->calendar, $daydata, [
                'events' => $events,
                'cache' => $this->related['cache'],
                'type' => $this->related['type'],
            ]);

            $return['days'][] = $day->export($output);
        }

        return $return;
    }
751368
public function export_for_template(renderer_base $output) {
        $data = new stdClass();
        $data->newdatarequesturl = new moodle_url('/admin/tool/dataprivacy/createdatarequest.php');
        $data->newdatarequesturl->param('manage', true);

        if (!is_https()) {
            $httpwarningmessage = get_string('httpwarning', 'tool_dataprivacy');
            $data->httpsite = array('message' => $httpwarningmessage, 'announce' => 1);
        }

        $url = new moodle_url('/admin/tool/dataprivacy/datarequests.php');
        $filteroptions = helper::get_request_filter_options();
        $filter = new request_filter($filteroptions, $this->filters, $url);
        $data->filter = $filter->export_for_template($output);

        ob_start();
        $this->table->out($this->table->get_requests_per_page(), true);
        $requests = ob_get_contents();
        ob_end_clean();

        $data->datarequests = $requests;
        return $data;
    }
217601
public function export_for_template(renderer_base $output) {
        $cnt = count($this->tagset);
        return (object)array(
            'tags' => $this->tagset,
            'tagscount' => $cnt,
            'totalcount' => $this->totalcount,
            'overflow' => ($this->totalcount > $cnt) ? 1 : 0,
        );
    }