Export the data.

@param renderer_base $output
@return stdClass
552900
public function export_for_template(renderer_base $output) {
        global $CFG;

        $data = new stdClass();

        // Variables that will be passed to the JS helper.
        $data->courseid = $this->courseid;
        $data->wwwroot = $CFG->wwwroot;
        // To be passed to the JS init script in the template. Encode as a JSON string.
        $data->undeletablegroups = json_encode($this->undeletablegroups);

        // Some buttons are enabled if single group selected.
        $data->addmembersdisabled = $this->disableaddedit;
        $data->editgroupsettingsdisabled = $this->disableaddedit;
        $data->deletegroupdisabled = $this->disabledelete;
        $data->groups = $this->groups;
        $data->members = $this->selectedgroupmembers;
        $data->selectedgroup = $this->selectedgroupname;

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

        $data = new stdClass();
        $data->formid = !empty($this->formid) ? $this->formid : html_writer::random_id('url_select_f');
        $data->classes = $this->class;
        $data->label = $this->label;
        $data->disabled = $this->disabled;
        $data->title = $this->tooltip;
        $data->id = !empty($attributes['id']) ? $attributes['id'] : html_writer::random_id('url_select');
        $data->sesskey = sesskey();
        $data->action = (new moodle_url('/course/jumpto.php'))->out(false);

        // Remove attributes passed as property directly.
        unset($attributes['class']);
        unset($attributes['id']);
        unset($attributes['name']);
        unset($attributes['title']);
        unset($attributes['disabled']);

        $data->showbutton = $this->showbutton;

        // Select options.
        $nothing = false;
        if (is_string($this->nothing) && $this->nothing !== '') {
            $nothing = ['' => $this->nothing];
        } else if (is_array($this->nothing)) {
            $nothingvalue = reset($this->nothing);
            if ($nothingvalue === 'choose' || $nothingvalue === 'choosedots') {
                $nothing = [key($this->nothing) => get_string('choosedots')];
            } else {
                $nothing = $this->nothing;
            }
        }
        $data->options = $this->flatten_options($this->urls, $nothing);

        // Label attributes.
        $data->labelattributes = [];
        // Unset label attributes that are already in the template.
        unset($this->labelattributes['for']);
        // Map the label attributes.
        foreach ($this->labelattributes as $key => $value) {
            $data->labelattributes[] = ['name' => $key, 'value' => $value];
        }

        // Help icon.
        $data->helpicon = !empty($this->helpicon) ? $this->helpicon->export_for_template($output) : false;

        // Finally all the remaining attributes.
        $data->attributes = [];
        foreach ($attributes as $key => $value) {
            $data->attributes[] = ['name' => $key, 'value' => $value];
        }

        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;
    }
153072
public function export_for_template(renderer_base $output) {
        if ($this->record->nextpageurl && $this->record->nextpageurl instanceof moodle_url) {
            $this->record->nextpageurl = $this->record->nextpageurl->out(false);
        }
        if ($this->record->prevpageurl && $this->record->prevpageurl instanceof moodle_url) {
            $this->record->prevpageurl = $this->record->prevpageurl->out(false);
        }
        if ($this->record->exclusiveurl && $this->record->exclusiveurl instanceof moodle_url) {
            $this->record->exclusiveurl = $this->record->exclusiveurl->out(false);
        }
        return $this->record;
    }
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;
    }
689814
public function export_for_template(renderer_base $output) {
        $data = new stdClass();

        $data->actionurl = $this->actionurl->out(false);
        $data->instructions = (string) $this->instructions;
        $data->method = $this->method;
        $data->paramname = $this->paramname;
        $data->params = $this->params;
        $data->sesskey = sesskey();
        $data->title = (string) $this->title;

        $data->sections = array_map(function($section) use ($output) {
            return $section->export_for_template($output);
        }, $this->sections);

        return $data;
    }
132182
public function export_for_template(renderer_base $output) {
        static $instance = 1;

        $data = parent::export_for_template($output);
        $data->instance = $instance++;

        // Ignore what the parent did with the attributes, except for ID and class.
        $data->attributes = [];
        $attributes = $this->attributes;
        unset($attributes['id']);
        unset($attributes['class']);

        // Handle text being a renderable.
        if ($this->text instanceof renderable) {
            $data->text = $this->render($this->text);
        }

        $data->showtext = (!$this->icon || $this->primary === false);

        $data->icon = null;
        if ($this->icon) {
            $icon = $this->icon;
            if ($this->primary || !$this->actionmenu->will_be_enhanced()) {
                $attributes['title'] = $data->text;
            }
            $data->icon = $icon ? $icon->export_for_pix() : null;
        }

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

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

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

        require_once($CFG->libdir . '/externallib.php');

        $syscontext = context_system::instance();

        $context = new stdClass();
        $context->text = external_format_string($this->text, $syscontext->id);
        $context->url = $this->url ? $this->url->out() : null;
        $context->title = external_format_string($this->title, $syscontext->id);
        $context->sort = $this->sort;
        $context->children = array();
        if (preg_match("/^#+$/", $this->text)) {
            $context->divider = true;
        }
        $context->haschildren = !empty($this->children) && (count($this->children) > 0);
        foreach ($this->children as $child) {
            $child = $child->export_for_template($output);
            array_push($context->children, $child);
        }

        return $context;
    }
853977
public function export_for_template(\renderer_base $output) {
        $data = new \stdClass();
        $data->action = (new \moodle_url('/admin/tool/policy/acceptances.php'))->out(false);

        $data->filteroptions = [];
        $originalfilteroptions = [];
        list($avilablefilters, $selectedoptions) = $this->build_available_filters();
        foreach ($avilablefilters as $value => $label) {
            $selected = in_array($value, $selectedoptions);
            $filteroption = (object)[
                'value' => $value,
                'label' => $label
            ];
            $originalfilteroptions[] = $filteroption;
            $filteroption->selected = $selected;
            $data->filteroptions[] = $filteroption;
        }
        $data->originaloptionsjson = json_encode($originalfilteroptions);
        return $data;
    }
345964
public function export_for_template(renderer_base $output) {
        $data = new stdClass();

        $data->nostrings = $output->notification(get_string('nostringsfound', 'tool_customlang'));
        $data->formurl = $this->translator->handler;
        $data->currentpage = $this->translator->currentpage;
        $data->sesskey = sesskey();
        $data->strings = [];

        if (!empty($this->translator->strings)) {
            $data->hasstrings = true;
            foreach ($this->translator->strings as $string) {
                // Find strings that use placeholders.
                if (preg_match('/\{\$a(->.+)?\}/', $string->master)) {
                    $string->placeholderhelp = $output->help_icon('placeholder', 'tool_customlang',
                            get_string('placeholderwarning', 'tool_customlang'));
                }
                if (!is_null($string->local) and $string->outdated) {
                    $string->outdatedhelp = $output->help_icon('markinguptodate', 'tool_customlang');
                    $string->checkupdated = true;
                }
                if ($string->original !== $string->master) {
                    $string->showoriginalvsmaster = true;
                }
                $string->local = s($string->local);
                $data->strings[] = $string;
            }
        }
        return $data;
    }
363898
public function export_for_template(\renderer_base $output) {
        $planexporter = new plan_exporter($this->plan, array('template' => $this->plan->get_template()));

        $data = new stdClass();
        $data->plan = $planexporter->export($output);
        $data->competencies = array();
        $data->pluginbaseurl = (new moodle_url('/admin/tool/lp'))->out(false);
        $data->contextid = $this->plan->get_context()->id;

        if ($data->plan->iscompleted) {
            $ucproperty = 'usercompetencyplan';
            $ucexporter = 'core_competency\\external\\user_competency_plan_exporter';
        } else {
            $ucproperty = 'usercompetency';
            $ucexporter = 'core_competency\\external\\user_competency_exporter';
        }

        $helper = new performance_helper();
        $pclist = api::list_plan_competencies($this->plan);
        $proficientcount = 0;
        foreach ($pclist as $pc) {
            $comp = $pc->competency;
            $usercomp = $pc->$ucproperty;

            $compcontext = $helper->get_context_from_competency($comp);
            $framework = $helper->get_framework_from_competency($comp);
            $scale = $helper->get_scale_from_competency($comp);

            // Prepare the data.
            $record = new stdClass();
            $exporter = new competency_exporter($comp, array('context' => $compcontext));
            $record->competency = $exporter->export($output);

            // Competency path.
            $exporter = new competency_path_exporter([
                'ancestors' => $comp->get_ancestors(),
                'framework' => $framework,
                'context' => $compcontext
            ]);
            $record->comppath = $exporter->export($output);

            $exporter = new $ucexporter($usercomp, array('scale' => $scale));
            $record->$ucproperty = $exporter->export($output);

            $data->competencies[] = $record;
            if ($usercomp->get('proficiency')) {
                $proficientcount++;
            }
        }
        $data->competencycount = count($data->competencies);
        $data->proficientcompetencycount = $proficientcount;
        if ($data->competencycount) {
            $data->proficientcompetencypercentage = ((float) $proficientcount / (float) $data->competencycount) * 100.0;
        } else {
            $data->proficientcompetencypercentage = 0.0;
        }
        $data->proficientcompetencypercentageformatted = format_float($data->proficientcompetencypercentage);
        return $data;
    }
1176413
public function export_for_template(renderer_base $output) {
        $attributes = $this->attributes;

        $data = new stdClass();
        $data->name = $this->name;
        $data->method = $this->method;
        $data->action = $this->method === 'get' ? $this->url->out_omit_querystring(true) : $this->url->out_omit_querystring();
        $data->classes = $this->class;
        $data->label = $this->label;
        $data->disabled = $this->disabled;
        $data->title = $this->tooltip;
        $data->formid = !empty($this->formid) ? $this->formid : html_writer::random_id('single_select_f');
        $data->id = !empty($attributes['id']) ? $attributes['id'] : html_writer::random_id('single_select');

        // Select element attributes.
        // Unset attributes that are already predefined in the template.
        unset($attributes['id']);
        unset($attributes['class']);
        unset($attributes['name']);
        unset($attributes['title']);
        unset($attributes['disabled']);

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

        // 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));

        // Select options.
        $hasnothing = false;
        if (is_string($this->nothing) && $this->nothing !== '') {
            $nothing = ['' => $this->nothing];
            $hasnothing = true;
            $nothingkey = '';
        } else if (is_array($this->nothing)) {
            $nothingvalue = reset($this->nothing);
            if ($nothingvalue === 'choose' || $nothingvalue === 'choosedots') {
                $nothing = [key($this->nothing) => get_string('choosedots')];
            } else {
                $nothing = $this->nothing;
            }
            $hasnothing = true;
            $nothingkey = key($this->nothing);
        }
        if ($hasnothing) {
            $options = $nothing + $this->options;
        } else {
            $options = $this->options;
        }

        foreach ($options as $value => $name) {
            if (is_array($options[$value])) {
                foreach ($options[$value] as $optgroupname => $optgroupvalues) {
                    $sublist = [];
                    foreach ($optgroupvalues as $optvalue => $optname) {
                        $option = [
                            'value' => $optvalue,
                            'name' => $optname,
                            'selected' => strval($this->selected) === strval($optvalue),
                        ];

                        if ($hasnothing && $nothingkey === $optvalue) {
                            $option['ignore'] = 'data-ignore';
                        }

                        $sublist[] = $option;
                    }
                    $data->options[] = [
                        'name' => $optgroupname,
                        'optgroup' => true,
                        'options' => $sublist
                    ];
                }
            } else {
                $option = [
                    'value' => $value,
                    'name' => $options[$value],
                    'selected' => strval($this->selected) === strval($value),
                    'optgroup' => false
                ];

                if ($hasnothing && $nothingkey === $value) {
                    $option['ignore'] = 'data-ignore';
                }

                $data->options[] = $option;
            }
        }

        // Label attributes.
        $data->labelattributes = [];
        // Unset label attributes that are already in the template.
        unset($this->labelattributes['for']);
        // Map the label attributes.
        foreach ($this->labelattributes as $key => $value) {
            $data->labelattributes[] = ['name' => $key, 'value' => $value];
        }

        // Help icon.
        $data->helpicon = !empty($this->helpicon) ? $this->helpicon->export_for_template($output) : false;

        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;
    }
1204337
public function export_for_template(\renderer_base $output) {
        $result = (object) [
            'name'  => $this->tour->get_tour_key(),
            'steps' => [],
        ];

        foreach ($this->tour->get_steps() as $step) {
            $result->steps[] = (new step($step))->export_for_template($output);
        }

        return $result;
    }
777
public function export_for_template(renderer_base $output) {
        global $USER, $OUTPUT;

        $data = new \stdClass();

        if (!isset($this->config->display_picture) || $this->config->display_picture == 1) {
            $data->userpicture = $OUTPUT->user_picture($USER, array('class' => 'userpicture'));
        }

        $data->userfullname = fullname($USER);

        if (!isset($this->config->display_country) || $this->config->display_country == 1) {
            $countries = get_string_manager()->get_list_of_countries(true);
            if (isset($countries[$USER->country])) {
                $data->usercountry = $countries[$USER->country];
            }
        }

        if (!isset($this->config->display_city) || $this->config->display_city == 1) {
            $data->usercity = $USER->city;
        }

        if (!isset($this->config->display_email) || $this->config->display_email == 1) {
            $data->useremail = obfuscate_mailto($USER->email, '');
        }

        if (!empty($this->config->display_icq) && !empty($USER->icq)) {
            $data->usericq = s($USER->icq);
        }

        if (!empty($this->config->display_skype) && !empty($USER->skype)) {
            $data->userskype = s($USER->skype);
        }

        if (!empty($this->config->display_yahoo) && !empty($USER->yahoo)) {
            $data->useryahoo = s($USER->yahoo);
        }

        if (!empty($this->config->display_aim) && !empty($USER->aim)) {
            $data->useraim = s($USER->aim);
        }

        if (!empty($this->config->display_msn) && !empty($USER->msn)) {
            $data->usermsn = s($USER->msn);
        }

        if (!empty($this->config->display_phone1) && !empty($USER->phone1)) {
            $data->userphone1 = s($USER->phone1);
        }

        if (!empty($this->config->display_phone2) && !empty($USER->phone2)) {
            $data->userphone2 = s($USER->phone2);
        }

        if (!empty($this->config->display_institution) && !empty($USER->institution)) {
            $data->userinstitution = format_string($USER->institution);
        }

        if (!empty($this->config->display_address) && !empty($USER->address)) {
            $data->useraddress = format_string($USER->address);
        }

        if (!empty($this->config->display_firstaccess) && !empty($USER->firstaccess)) {
            $data->userfirstaccess = userdate($USER->firstaccess);
        }

        if (!empty($this->config->display_lastaccess) && !empty($USER->lastaccess)) {
            $data->userlastaccess = userdate($USER->lastaccess);
        }

        if (!empty($this->config->display_currentlogin) && !empty($USER->currentlogin)) {
            $data->usercurrentlogin = userdate($USER->currentlogin);
        }

        if (!empty($this->config->display_lastip) && !empty($USER->lastip)) {
            $data->userlastip = $USER->lastip;
        }

        return $data;
    }
1050439
public function export_for_template(\renderer_base $output) {
        $data = new \stdClass();
        $data->channellink = clean_param($this->channelurl, PARAM_URL);
        if ($this->manageurl) {
            $data->hasfailedfeeds = true;
            $data->manageurl = clean_param($this->manageurl, PARAM_URL);
        }

        return $data;
    }