Export this data so it can be used as the context for a mustache template (core/inplace_editable).

@param renderer_base $output typically, the renderer that's calling this function
@return array data context for a mustache template
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,
        );
    }
1218897
public function export_for_template(renderer_base $output) {
        $data = new stdClass();

        $planstoreview = array();
        foreach ($this->planstoreview['plans'] as $plandata) {
            $planexporter = new plan_exporter($plandata->plan, array('template' => $plandata->template));
            $userexporter = new user_summary_exporter($plandata->owner);
            $planstoreview[] = array(
                'plan' => $planexporter->export($output),
                'user' => $userexporter->export($output),
            );
        }

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

        return $data;
    }
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;
    }
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);

    }
952879
public function export_for_template(renderer_base $output) {
        global $USER;

        $data = (object) [
            'pluginbaseurl' => (new moodle_url('/admin/tool/policy'))->out(false),
            'returnurl' => $this->returnurl ? (new moodle_url($this->returnurl))->out(false) : null,
            'numpolicy' => $this->numpolicy ? : null,
            'totalpolicies' => $this->totalpolicies ? : null,
        ];
        if ($this->manage && $this->policy->status != policy_version::STATUS_ARCHIVED) {
            $paramsurl = ['policyid' => $this->policy->policyid, 'versionid' => $this->policy->id];
            $data->editurl = (new moodle_url('/admin/tool/policy/editpolicydoc.php', $paramsurl))->out(false);
        }

        if ($this->policy->agreementstyle == policy_version::AGREEMENTSTYLE_OWNPAGE) {
            if (!api::is_user_version_accepted($USER->id, $this->policy->id)) {
                unset($data->returnurl);
                $data->accepturl = (new moodle_url('/admin/tool/policy/index.php', [
                    'listdoc[]' => $this->policy->id,
                    'status'.$this->policy->id => 1,
                    'submit' => 'accept',
                    'sesskey' => sesskey(),
                ]))->out(false);
                if ($this->policy->optional == policy_version::AGREEMENT_OPTIONAL) {
                    $data->declineurl = (new moodle_url('/admin/tool/policy/index.php', [
                        'listdoc[]' => $this->policy->id,
                        'status'.$this->policy->id => 0,
                        'submit' => 'decline',
                        'sesskey' => sesskey(),
                    ]))->out(false);
                }
            }
        }

        $data->policy = clone($this->policy);

        return $data;
    }
162408
public function export_for_template(\renderer_base $output) {
        return array(
            'message'       => clean_text($this->message),
            'extraclasses'  => implode(' ', $this->extraclasses),
            'announce'      => $this->announce,
            'closebutton'   => $this->closebutton,
            'issuccess'         => $this->messagetype === 'success',
            'isinfo'            => $this->messagetype === 'info',
            'iswarning'         => $this->messagetype === 'warning',
            'iserror'           => $this->messagetype === 'error',
        );
    }
1343151
public function export_for_template(renderer_base $output) {
        $data = new stdClass();
        $data->uninstallurl = $this->uninstallurl;
        $data->sesskey = sesskey();

        $data->installedoptions = [];
        foreach ($this->installedlanguages as $code => $language) {
            $option = new stdClass();
            $option->value = $code;
            $option->text = $language;
            $data->installedoptions[] = $option;
        }

        $data->updateurl = $this->updateurl;

        if (!empty($this->availablelanguages)) {
            $data->toinstalloptions = [];
            foreach ($this->availablelanguages as $code => $language) {
                $option = new stdClass();
                $option->value = $code;
                $option->text = $language;
                $data->toinstalloptions[] = $option;
            }
            $data->installurl = $this->installurl;
            $data->caninstall = true;
        }

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

        $context = \context_system::instance();

        $PAGE->requires->js_call_amd('tool_dataprivacy/purposesactions', 'init');
        $PAGE->requires->js_call_amd('tool_dataprivacy/add_purpose', 'getInstance', [$context->id]);

        $data = new stdClass();

        // Navigation links.
        $data->navigation = [];
        $navigationlinks = $this->get_navigation();
        foreach ($navigationlinks as $navlink) {
            $data->navigation[] = $navlink->export_for_template($output);
        }

        $data->purposes = [];
        foreach ($this->purposes as $purpose) {
            $exporter = new purpose_exporter($purpose, ['context' => \context_system::instance()]);
            $exportedpurpose = $exporter->export($output);

            $actionmenu = $this->action_menu('purpose', $exportedpurpose, $purpose);
            $exportedpurpose->actions = $actionmenu->export_for_template($output);
            $data->purposes[] = $exportedpurpose;
        }

        return $data;
    }
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;
    }
439573
public function export_for_template(renderer_base $output) {
        $url = $this->method === 'get' ? $this->url->out_omit_querystring(true) : $this->url->out_omit_querystring();

        $data = new stdClass();
        $data->id = html_writer::random_id('single_button');
        $data->formid = $this->formid;
        $data->method = $this->method;
        $data->url = $url === '' ? '#' : $url;
        $data->label = $this->label;
        $data->classes = $this->class;
        $data->disabled = $this->disabled;
        $data->tooltip = $this->tooltip;
        $data->primary = $this->primary;

        // Form parameters.
        $params = $this->url->params();
        if ($this->method === 'post') {
            $params['sesskey'] = sesskey();
        }
        $data->params = array_map(function($key) use ($params) {
            return ['name' => $key, 'value' => $params[$key]];
        }, array_keys($params));

        // Button actions.
        $actions = $this->actions;
        $data->actions = array_map(function($action) use ($output) {
            return $action->export_for_template($output);
        }, $actions);
        $data->hasactions = !empty($data->actions);

        return $data;
    }
112288
public function export_for_template(renderer_base $output) {
        $data = parent::export_for_template($output);
        $data->courseid = $this->course->id;
        return $data;
    }
815313
public function export_for_template(renderer_base $output) {
        $contextlevels = [
            'contextlevelname10' => CONTEXT_SYSTEM,
            'contextlevelname30' => CONTEXT_USER,
            'contextlevelname40' => CONTEXT_COURSECAT,
            'contextlevelname50' => CONTEXT_COURSE,
            'contextlevelname70' => CONTEXT_MODULE,
            'contextlevelname80' => CONTEXT_BLOCK
        ];

        $data = [];
        $context = \context_system::instance();

        foreach ($contextlevels as $levelname => $level) {
            $classname = \context_helper::get_class_for_level($level);
            list($purposevar, $categoryvar) = \tool_dataprivacy\data_registry::var_names_from_context($classname);
            $purposeid = get_config('tool_dataprivacy', $purposevar);
            $categoryid = get_config('tool_dataprivacy', $categoryvar);

            $section = [];
            $section['contextname'] = get_string($levelname, 'tool_dataprivacy');

            if (empty($purposeid)) {
                list($purposeid, $categoryid) =
                        \tool_dataprivacy\data_registry::get_effective_default_contextlevel_purpose_and_category($level);
            }
            if ($purposeid == -1) {
                $purposeid = 0;
            }
            $purpose = new \tool_dataprivacy\purpose($purposeid);
            $export = new \tool_dataprivacy\external\purpose_exporter($purpose, ['context' => $context]);
            $purposedata = $export->export($output);
            $section['purpose'] = $purposedata;

            if (empty($categoryid)) {
                list($purposeid, $categoryid) =
                        \tool_dataprivacy\data_registry::get_effective_default_contextlevel_purpose_and_category($level);
            }
            if ($categoryid == -1) {
                $categoryid = 0;
            }
            $category = new \tool_dataprivacy\category($categoryid);
            $export = new \tool_dataprivacy\external\category_exporter($category, ['context' => $context]);
            $categorydata = $export->export($output);
            $section['category'] = $categorydata;
            $data['contexts'][] = $section;
        }

        // Get activity module plugin info.
        $pluginmanager = \core_plugin_manager::instance();
        $modplugins = $pluginmanager->get_enabled_plugins('mod');

        foreach ($modplugins as $name) {
            $classname = \context_helper::get_class_for_level($contextlevels['contextlevelname70']);
            list($purposevar, $categoryvar) = \tool_dataprivacy\data_registry::var_names_from_context($classname, $name);
            $categoryid = get_config('tool_dataprivacy', $categoryvar);
            $purposeid = get_config('tool_dataprivacy', $purposevar);
            if ($categoryid === false && $purposeid === false) {
                // If no purpose and category has been set for this plugin, then there's no need to show this on the list.
                continue;
            }

            $section = [];
            $section['contextname'] = $pluginmanager->plugin_name('mod_' . $name);

            if ($purposeid == -1) {
                $purposeid = 0;
            }
            $purpose = new \tool_dataprivacy\purpose($purposeid);
            $export = new \tool_dataprivacy\external\purpose_exporter($purpose, ['context' => $context]);
            $purposedata = $export->export($output);
            $section['purpose'] = $purposedata;

            if ($categoryid == -1) {
                $categoryid = 0;
            }
            $category = new \tool_dataprivacy\category($categoryid);
            $export = new \tool_dataprivacy\external\category_exporter($category, ['context' => $context]);
            $categorydata = $export->export($output);
            $section['category'] = $categorydata;

            $data['contexts'][] = $section;
        }

        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;
    }
937561
public function export_for_template(\renderer_base $output) {
        global $DB;

        $plan = api::read_plan($this->planid);
        $pc = api::get_plan_competency($plan, $this->competencyid);
        $competency = $pc->competency;
        $usercompetency = $pc->usercompetency;
        $usercompetencyplan = $pc->usercompetencyplan;

        if (empty($competency)) {
            throw new \invalid_parameter_exception('Invalid params. The competency does not belong to the plan.');
        }

        $relatedcompetencies = api::list_related_competencies($competency->get('id'));
        $userid = $plan->get('userid');
        $user = $DB->get_record('user', array('id' => $userid));
        $evidence = api::list_evidence($userid, $this->competencyid, $plan->get('id'));

        $params = array(
            'competency' => $competency,
            'usercompetency' => $usercompetency,
            'usercompetencyplan' => $usercompetencyplan,
            'evidence' => $evidence,
            'user' => $user,
            'plan' => $plan,
            'relatedcompetencies' => $relatedcompetencies
        );
        $exporter = new user_competency_summary_in_plan_exporter(null, $params);
        $data = $exporter->export($output);

        return $data;
    }
571363
public function export_for_template(\renderer_base $output) {
        $listofgroups = [];
        $groupids = json_decode($this->value);
        foreach ($groupids as $id) {
            $listofgroups[] = format_string($this->coursegroups[$id]->name, true, ['context' => $this->context]);
        }

        if (!empty($listofgroups)) {
            $this->displayvalue = implode($listofgroups, ', ');
        } else {
            $this->displayvalue = get_string('groupsnone');
        }
        return parent::export_for_template($output);
    }
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;
    }