Export the page data for the mustache template.

@param renderer_base $output renderer to be used to render the page elements.
@return stdClass
976038
public function export_for_template(renderer_base $output) {

        $data = (object) [];
        $data->pluginbaseurl = (new moodle_url('/admin/tool/policy'))->out(false);
        $data->canmanage = has_capability('tool/policy:managedocs', \context_system::instance());
        $data->canaddnew = $data->canmanage && !$this->policyid;
        $data->canviewacceptances = has_capability('tool/policy:viewacceptances', \context_system::instance());
        $data->title = get_string('policiesagreements', 'tool_policy');
        $data->policies = [];

        if ($this->policyid) {
            // We are only interested in the archived versions of the given policy.
            $data->backurl = (new moodle_url('/admin/tool/policy/managedocs.php'))->out(false);
            $policy = api::list_policies([$this->policyid], true)[0];
            if ($firstversion = $policy->currentversion ?: (reset($policy->draftversions) ?: reset($policy->archivedversions))) {
                $data->title = get_string('previousversions', 'tool_policy', format_string($firstversion->name));
            }

            foreach ($policy->archivedversions as $i => $version) {
                $data->versions[] = $this->export_version_for_template($output, $policy, $version,
                    false, false, false);
            }
            return $data;
        }

        // List all policies. Display current and all draft versions of each policy in this list.
        // If none found, then show only one archived version.
        $policies = api::list_policies(null, true);
        foreach ($policies as $i => $policy) {

            if (empty($policy->currentversion) && empty($policy->draftversions)) {
                // There is no current and no draft versions, display the first archived version.
                $firstpolicy = array_shift($policy->archivedversions);
                $data->versions[] = $this->export_version_for_template($output, $policy, $firstpolicy,
                    false, $i > 0, $i < count($policies) - 1);
            }

            if (!empty($policy->currentversion)) {

                // Current version of the policy.
                $data->versions[] = $this->export_version_for_template($output, $policy, $policy->currentversion,
                    false, $i > 0, $i < count($policies) - 1);

            } else if ($policy->draftversions) {

                // There is no current version, display the first draft version as the current.
                $firstpolicy = array_shift($policy->draftversions);
                $data->versions[] = $this->export_version_for_template($output, $policy, $firstpolicy,
                    false, $i > 0, $i < count($policies) - 1);
            }

            foreach ($policy->draftversions as $draft) {
                // Show all [other] draft policies indented.
                $data->versions[] = $this->export_version_for_template($output, $policy, $draft,
                    true, false, false);
            }

        }

        return $data;
    }
325811
public function export_for_template(\renderer_base $output) {
        $data = array('feeds' => array());

        foreach ($this->feeds as $feed) {
            $data['feeds'][] = $feed->export_for_template($output);
        }

        return $data;
    }
970576
public function export_for_template(renderer_base $output) {
        $data = new stdClass();
        $data->competencyframeworks = array();
        $data->pagecontextid = $this->pagecontext->id;
        foreach ($this->competencyframeworks as $framework) {
            $exporter = new competency_framework_exporter($framework);
            $data->competencyframeworks[] = $exporter->export($output);
        }
        $data->pluginbaseurl = (new moodle_url('/admin/tool/lp'))->out(true);
        $data->navigation = array();
        foreach ($this->navigation as $button) {
            $data->navigation[] = $output->render($button);
        }

        return $data;
    }
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;
    }
16392
public function export_for_template(renderer_base $output) {

        $data = (object) [
            'pluginbaseurl' => (new moodle_url('/admin/tool/policy'))->out(false),
        ];

        $data->policies = array_values($this->policies);
        if (!empty($this->returnurl)) {
            $data->returnurl = $this->returnurl;
        }

        array_walk($data->policies, function($item, $key) {
            $item->policytypestr = get_string('policydoctype'.$item->type, 'tool_policy');
            $item->policyaudiencestr = get_string('policydocaudience'.$item->audience, 'tool_policy');
        });

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

        if (empty($attributes['id'])) {
            $attributes['id'] = html_writer::random_id('action_link');
        }
        $data->id = $attributes['id'];
        unset($attributes['id']);

        $data->disabled = !empty($attributes['disabled']);
        unset($attributes['disabled']);

        $data->text = $this->text instanceof renderable ? $output->render($this->text) : (string) $this->text;
        $data->url = $this->url ? $this->url->out(false) : '';
        $data->icon = $this->icon ? $this->icon->export_for_pix() : null;
        $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);

        $data->actions = array_map(function($action) use ($output) {
            return $action->export_for_template($output);
        }, !empty($this->actions) ? $this->actions : []);
        $data->hasactions = !empty($this->actions);

        return $data;
    }
757886
public function export_for_template(renderer_base $output) {
        $tabs = [];
        $secondrow = false;

        foreach ($this->subtree as $tab) {
            $tabs[] = $tab->export_for_template($output);
            if (!empty($tab->subtree) && ($tab->level == 0 || $tab->selected || $tab->activated)) {
                $secondrow = new tabtree($tab->subtree);
            }
        }

        return (object) [
            'tabs' => $tabs,
            'secondrow' => $secondrow ? $secondrow->export_for_template($output) : false
        ];
    }
1103766
public function export_for_template(\renderer_base $output) {
        $data = new stdClass();

        $userevidencesummaryexporter = new user_evidence_summary_exporter($this->userevidence, array(
            'context' => $this->context));
        $data->userevidence = $userevidencesummaryexporter->export($output);
        $data->pluginbaseurl = (new moodle_url('/admin/tool/lp'))->out(true);

        return $data;
    }
1293801
public function export_for_template(renderer_base $output) {
        global $PAGE;

        $data = (object) [];
        $data->pluginbaseurl = (new moodle_url('/admin/tool/policy'))->out(true);
        if (strpos(qualified_me(), '/tool/policy/view.php') === false) {
            // Current page is not a policy doc, so returnurl parameter will be it.
            $data->returnurl = qualified_me();
        } else {
            // If current page is also a policy doc to view, get previous returnurl parameter to avoid error.
            $returnurl = $PAGE->url->get_param('returnurl');
            if (isset($returnurl)) {
                $data->returnurl = $returnurl;
            }
        }
        $data->returnurl = urlencode($data->returnurl);

        $policies = api::list_current_versions(policy_version::AUDIENCE_GUESTS);
        $data->policies = array_values($policies);
        $data->haspolicies = !empty($policies);

        return $data;
    }
743741
public function export_for_template(renderer_base $output) {
        global $CFG;
        require_once($CFG->libdir . '/externallib.php');

        $r = new stdClass();
        $r->id = (int)$this->record->id;
        $r->tagcollid = clean_param($this->record->tagcollid, PARAM_INT);
        $r->rawname = clean_param($this->record->rawname, PARAM_TAG);
        $r->name = clean_param($this->record->name, PARAM_TAG);
        $format = clean_param($this->record->descriptionformat, PARAM_INT);
        list($r->description, $r->descriptionformat) = external_format_text($this->record->description,
            $format, \context_system::instance()->id, 'core', 'tag', $r->id);
        $r->flag = clean_param($this->record->flag, PARAM_INT);
        if (isset($this->record->isstandard)) {
            $r->isstandard = clean_param($this->record->isstandard, PARAM_INT) ? 1 : 0;
        }
        $r->official = $r->isstandard; // For backwards compatibility.

        $url = core_tag_tag::make_url($r->tagcollid, $r->rawname);
        $r->viewurl = $url->out(false);

        return $r;
    }
242218
public function export_for_template(renderer_base $output) {
        global $CFG;

        $title = get_string($this->identifier, $this->component);

        if (empty($this->linktext)) {
            $alt = get_string('helpprefix2', '', trim($title, ". \t"));
        } else {
            $alt = get_string('helpwiththis');
        }

        $data = get_formatted_help_string($this->identifier, $this->component, false);

        $data->alt = $alt;
        $data->icon = (new pix_icon('help', $alt, 'core', ['class' => 'iconhelp']))->export_for_template($output);
        $data->linktext = $this->linktext;
        $data->title = get_string('helpprefix2', '', trim($title, ". \t"));

        $options = [
            'component' => $this->component,
            'identifier' => $this->identifier,
            'lang' => current_language()
        ];

        // Debugging feature lets you display string identifier and component.
        if (isset($CFG->debugstringids) && $CFG->debugstringids && optional_param('strings', 0, PARAM_INT)) {
            $options['strings'] = 1;
        }

        $data->url = (new moodle_url('/help.php', $options))->out(false);
        $data->ltr = !right_to_left();
        return $data;
    }
453478
public function export_for_template(renderer_base $output) {
        $data = new stdClass();
        $data->pagecontextid = $this->pagecontext->id;
        $data->templates = array();
        foreach ($this->templates as $template) {
            $exporter = new template_exporter($template);
            $data->templates[] = $exporter->export($output);
        }
        $data->pluginbaseurl = (new moodle_url('/admin/tool/lp'))->out(true);
        $data->navigation = array();
        foreach ($this->navigation as $button) {
            $data->navigation[] = $output->render($button);
        }
        $data->canmanage = template::can_manage_context($this->pagecontext);

        return $data;
    }
1320959
public function export_for_template(renderer_base $output) {

        $nocoursesurl = $output->image_url('courses', 'block_timeline')->out();
        $noeventsurl = $output->image_url('activities', 'block_timeline')->out();

        $requiredproperties = course_summary_exporter::define_properties();
        $fields = join(',', array_keys($requiredproperties));
        $courses = course_get_enrolled_courses_for_logged_in_user(0, 0, null, $fields);
        list($inprogresscourses, $processedcount) = course_filter_courses_by_timeline_classification(
            $courses,
            COURSE_TIMELINE_INPROGRESS,
            self::COURSES_PER_PAGE
        );
        $formattedcourses = array_map(function($course) use ($output) {
            \context_helper::preload_from_record($course);
            $context = \context_course::instance($course->id);
            $exporter = new course_summary_exporter($course, ['context' => $context]);
            return $exporter->export($output);
        }, $inprogresscourses);

        $filters = $this->get_filters_as_booleans();
        $offsets = $this->get_filter_offsets();
        $contextvariables = [
            'midnight' => usergetmidnight(time()),
            'coursepages' => [$formattedcourses],
            'urls' => [
                'nocourses' => $nocoursesurl,
                'noevents' => $noeventsurl
            ],
            'sorttimelinedates' => $this->order == BLOCK_TIMELINE_SORT_BY_DATES,
            'sorttimelinecourses' => $this->order == BLOCK_TIMELINE_SORT_BY_COURSES,
            'selectedfilter' => $this->filter,
            'hasdaysoffset' => true,
            'hasdayslimit' => $offsets['dayslimit'] !== false ,
            'nodayslimit' => $offsets['dayslimit'] === false ,
            'limit' => $this->limit
        ];
        return array_merge($contextvariables, $filters, $offsets);
    }
869774
public function export_for_template(\renderer_base $output) {
        global $DB;
        $data = new stdClass();

        $missingmappings = $this->processor->get_missing_mappings();

        $data->pagecontextid = $this->pagecontext->id;
        $data->expectedccmigrations = $this->processor->get_expected_course_competency_migrations();
        $data->expectedmcmigrations = $this->processor->get_expected_module_competency_migrations();
        $data->ccmigrationscount = $this->processor->get_course_competency_migrations();
        $data->mcmigrationscount = $this->processor->get_module_competency_migrations();
        $data->ccremovalscount = $this->processor->get_course_competency_removals();
        $data->mcremovalscount = $this->processor->get_module_competency_removals();

        $data->unmappedfrom = array();
        $data->unmappedto = array();

        $exporter = new competency_framework_exporter($this->frameworkfrom);
        $data->frameworkfrom = $exporter->export($output);
        $exporter = new competency_framework_exporter($this->frameworkto);
        $data->frameworkto = $exporter->export($output);

        $fromcontext = $this->frameworkfrom->get_context();
        $tocontext = $this->frameworkto->get_context();

        $compcontext = null;
        foreach ($this->unmappedfrom as $comp) {
            $exporter = new competency_exporter($comp, array('context' => $fromcontext));
            $data->unmappedfrom[] = $exporter->export($output);
        }

        foreach ($this->unmappedto as $comp) {
            $exporter = new competency_exporter($comp, array('context' => $tocontext));
            $data->unmappedto[] = $exporter->export($output);
        }

        $data->coursesfound = $this->processor->get_courses_found_count();
        $data->cmsfound = $this->processor->get_cms_found_count();
        $data->mappingsmissingcount = count($missingmappings);
        $data->hasunmappedto = count($data->unmappedto) > 0;
        $data->hasunmappedfrom = count($data->unmappedfrom) > 0;
        $warnings = $this->processor->get_warnings();
        $data->warnings = array();
        $data->warningcount = count($warnings);
        $errors = $this->processor->get_errors();
        $data->errors = array();
        $data->errorcount = count($errors);

        foreach ($warnings as $warning) {
            $cmcontext = !empty($warning['cmid']) ? context_module::instance($warning['cmid']) : null;
            $coursecontext = context_course::instance($warning['courseid']);
            $warning['cm'] = $cmcontext ? $cmcontext->get_context_name() : null;
            $warning['course'] = $coursecontext->get_context_name();
            $warning['competency'] = $DB->get_field(competency::TABLE, 'idnumber', array('id' => $warning['competencyid']));
            $data->warnings[] = $warning;
        }

        foreach ($errors as $error) {
            $cmcontext = !empty($error['cmid']) ? context_module::instance($error['cmid']) : null;
            $coursecontext = context_course::instance($error['courseid']);
            $error['cm'] = $cmcontext ? $cmcontext->get_context_name() : null;
            $error['course'] = $coursecontext->get_context_name();
            $error['competency'] = $DB->get_field(competency::TABLE, 'idnumber', array('id' => $error['competencyid']));
            $data->errors[] = $error;
        }

        $data->pluginbaseurl = (new moodle_url('/admin/tool/lpmigrate'))->out(false);
        $data->frameworksurl = url::frameworks($this->pagecontext->id)->out(false);

        return $data;
    }
1072083
public function export_for_template(renderer_base $output) {
        $data = new stdClass();
        $data->relatedcompetencies = array();
        if ($this->relatedcompetencies) {
            foreach ($this->relatedcompetencies as $competency) {
                $exporter = new competency_exporter($competency, array('context' => $this->context));
                $record = $exporter->export($output);
                $data->relatedcompetencies[] = $record;
            }
        }

        // We checked the user permissions in the constructor.
        $data->showdeleterelatedaction = true;

        return $data;
    }
1091570
public function export_for_template(renderer_base $output) {
        $related = array(
            'context' => $this->framework->get_context(),
            'framework' => $this->framework,
            'linkedcourses' => $this->courses,
            'relatedcompetencies' => $this->relatedcompetencies,
            'competency' => $this->competency
        );

        $exporter = new competency_summary_exporter($this->competency, $related);
        $data = $exporter->export($output);

        return $data;
    }
1359854
public function export_for_template(\renderer_base $output) {
        global $PAGE;
        $step = $this->step;

        $result = (object) [
            'stepid'    => $step->get_id(),
            'title'     => external_format_text(
                    stepsource::get_string_from_input($step->get_title()),
                    FORMAT_HTML,
                    $PAGE->context->id,
                    'tool_usertours'
                )[0],
            'content'   => external_format_text(
                    stepsource::get_string_from_input($step->get_content()),
                    FORMAT_HTML,
                    $PAGE->context->id,
                    'tool_usertours'
                )[0],
            'element'   => $step->get_target()->convert_to_css(),
        ];

        $result->content = str_replace("\n", "<br>\n", $result->content);

        foreach ($step->get_config_keys() as $key) {
            $result->$key = $step->get_config($key);
        }

        return $result;
    }