Export for template.

@param renderer_base $output The renderer.
@return stdClass
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;
    }
1187434
public function export_for_template(\renderer_base $output) {
        return array(
            'url'   => clean_param($this->url, PARAM_URL),
            'title' => $this->title,
            'link'  => clean_param($this->link, PARAM_URL),
        );
    }
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;
    }
799228
public function export_for_template(renderer_base $output) {
        global $OUTPUT;

        $context = context_module::instance($this->cm->id);
        $chapters = book_preload_chapters($this->book);

        $data = new stdClass();
        // Print dialog link.
        $data->printdialoglink = $output->render_print_book_chapter_dialog_link();
        $data->booktitle = $OUTPUT->heading(format_string($this->book->name, true,
                array('context' => $context)), 1);
        if (!$this->book->customtitles) {
            // If the current chapter is a subchapter, get the title of the parent chapter.
            if ($this->chapter->subchapter) {
                $parentchaptertitle = book_get_chapter_title($chapters[$this->chapter->id]->parent, $chapters,
                        $this->book, $context);
                $data->parentchaptertitle = $OUTPUT->heading(format_string($parentchaptertitle, true,
                        array('context' => $context)), 2);
            }
        }

        list($chaptercontent, $chaptervisible) = $output->render_print_book_chapter($this->chapter, $chapters,
                $this->book, $this->cm);
        $chapter = new stdClass();
        $chapter->content = $chaptercontent;
        $chapter->visible = $chaptervisible;
        $data->chapter = $chapter;

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

        $target = $this->model->get_target();

        $data = new \stdClass();
        $data->insightname = format_string($target->get_name());

        $data->showpredictionheading = true;
        if (!$target->is_linear()) {
            $nclasses = count($target::get_classes());
            $nignoredclasses = count($target->ignored_predicted_classes());
            if ($nclasses - $nignoredclasses <= 1) {
                // Hide the prediction heading if there is only 1 class displayed. Otherwise it is redundant with the insight name.
                $data->showpredictionheading = false;
            }
        }

        $total = 0;

        if ($this->model->uses_insights()) {
            $predictionsdata = $this->model->get_predictions($this->context, true, $this->page, $this->perpage);

            if (!$this->model->is_static()) {
                $notification = new \core\output\notification(get_string('justpredictions', 'report_insights'));
                $data->nostaticmodelnotification = $notification->export_for_template($output);
            }

            $data->predictions = array();
            $predictionvalues = array();
            $insights = array();
            if ($predictionsdata) {
                list($total, $predictions) = $predictionsdata;

                foreach ($predictions as $prediction) {
                    $predictedvalue = $prediction->get_prediction_data()->prediction;

                    // Only need to fill this data once.
                    if (!isset($predictionvalues[$predictedvalue])) {
                        $preddata = array();
                        $preddata['predictiondisplayvalue'] = $target->get_display_value($predictedvalue);
                        list($preddata['style'], $preddata['outcomeicon']) =
                            insight::get_calculation_display($target, floatval($predictedvalue), $output);
                        $predictionvalues[$predictedvalue] = $preddata;
                    }

                    $insightrenderable = new \report_insights\output\insight($prediction, $this->model, true);
                    $insights[$predictedvalue][] = $insightrenderable->export_for_template($output);
                }

                // Order predicted values.
                if ($target->is_linear()) {
                    // During regression what we will be interested on most of the time is in low values so let's show them first.
                    ksort($predictionvalues);
                } else {
                    // During classification targets flag "not that important" samples as 0 so let's show them at the end.
                    krsort($predictionvalues);
                }

                // Ok, now we have all the data we want, put it into a format that mustache can handle.
                foreach ($predictionvalues as $key => $prediction) {
                    if (isset($insights[$key])) {
                        $prediction['insights'] = $insights[$key];
                    }

                    $data->predictions[] = $prediction;
                }
            }

            if (empty($insights) && $this->page == 0) {
                if ($this->model->any_prediction_obtained()) {
                    $data->noinsights = get_string('noinsights', 'analytics');
                } else {
                    $data->noinsights = get_string('nopredictionsyet', 'analytics');
                }
            }
        } else {
            $data->noinsights = get_string('noinsights', 'analytics');
        }

        if (!empty($data->noinsights)) {
            $notification = new \core\output\notification($data->noinsights);
            $data->noinsights = $notification->export_for_template($output);
        }

        if ($this->othermodels) {

            $options = array();
            foreach ($this->othermodels as $model) {
                $options[$model->get_id()] = $model->get_target()->get_name();
            }

            // New moodle_url instance returned by magic_get_url.
            $url = $PAGE->url;
            $url->remove_params('modelid');
            $modelselector = new \single_select($url, 'modelid', $options, '',
                array('' => get_string('selectotherinsights', 'report_insights')));
            $data->modelselector = $modelselector->export_for_template($output);
        }

        $data->pagingbar = $output->render(new \paging_bar($total, $this->page, $this->perpage, $PAGE->url));

        return $data;
    }
311048
public function export_for_template(\renderer_base $output) {
        if ($this->value) {
            $this->edithint = get_string('disable');
            $this->displayvalue = $output->pix_icon('i/hide', get_string('disable'));
        } else {
            $this->edithint = get_string('enable');
            $this->displayvalue = $output->pix_icon('i/show', get_string('enable'));
        }

        return parent::export_for_template($output);
    }
957464
public function export_for_template(renderer_base $output) {
        ob_start();
        $this->display();
        $formhtml = ob_get_contents();
        ob_end_clean();
        $context = [
            'formhtml' => $formhtml
        ];
        return $context;
    }
903948
public function export_for_template(renderer_base $output) {
        $data = new stdClass();
        $data->userid = $this->userid;
        $data->pluginbaseurl = (new moodle_url('/admin/tool/lp'))->out(true);
        $data->canreaduserevidence = user_evidence::can_read_user($this->userid);
        $data->canmanageuserplans = plan::can_manage_user($this->userid);

        // Attach standard objects as mustache can not parse \core_competency\plan objects.
        $data->plans = array();
        if ($this->plans) {
            foreach ($this->plans as $plan) {
                $exporter = new plan_exporter($plan, array('template' => $plan->get_template()));
                $record = $exporter->export($output);
                $data->plans[] = $record;
            }
        }

        $data->navigation = array();
        foreach ($this->navigation as $button) {
            $data->navigation[] = $output->render($button);
        }

        return $data;
    }
1084528
public function export_for_template(renderer_base $output) {
        global $SITE, $CFG;

        $sitename = format_string($SITE->fullname);
        $supportname = $CFG->supportname;
        $supportemail = $CFG->supportemail;

        $context = [
            'sitename' => $sitename,
            'supportname' => $supportname,
            'supportemail' => $supportemail,
            'homelink' => new \moodle_url('/')
        ];

        return $context;
    }
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;
    }
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;
    }
533075
public function export_for_template(renderer_base $output) {
        $data = new stdClass();
        $data->template = (new template_exporter($this->template))->export($output);
        $data->pagecontextid = $this->pagecontext->id;
        $data->competencies = array();
        $helper = new performance_helper();
        foreach ($this->competencies as $competency) {
            $context = $helper->get_context_from_competency($competency);
            $framework = $helper->get_framework_from_competency($competency);

            $courses = api::list_courses_using_competency($competency->get('id'));
            $relatedcompetencies = api::list_related_competencies($competency->get('id'));

            $related = array(
                'competency' => $competency,
                'linkedcourses' => $courses,
                'context' => $context,
                'relatedcompetencies' => $relatedcompetencies,
                'framework' => $framework
            );
            $exporter = new competency_summary_exporter(null, $related);
            $record = $exporter->export($output);

            array_push($data->competencies, $record);
        }

        $data->pluginbaseurl = (new moodle_url('/admin/tool/lp'))->out(false);
        $data->canmanagecompetencyframeworks = $this->canmanagecompetencyframeworks;
        $data->canmanagetemplatecompetencies = $this->canmanagetemplatecompetencies;
        $data->manageurl = $this->manageurl->out(true);
        $exporter = new template_statistics_exporter($this->templatestatistics);
        $data->statistics = $exporter->export($output);
        $data->showcompetencylinks = true;

        return $data;
    }
926940
public function export_for_template(renderer_base $output) {
        global $DB;

        $usercompetencycourse = api::get_user_competency_in_course($this->courseid, $this->userid, $this->competencyid);
        $competency = $usercompetencycourse->get_competency();
        if (empty($usercompetencycourse) || empty($competency)) {
            throw new \invalid_parameter_exception('Invalid params. The competency does not belong to the course.');
        }

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

        $params = array(
            'competency' => $competency,
            'usercompetencycourse' => $usercompetencycourse,
            'evidence' => $evidence,
            'user' => $user,
            'course' => $course,
            'scale' => $competency->get_scale(),
            'relatedcompetencies' => $relatedcompetencies
        );
        $exporter = new user_competency_summary_in_course_exporter(null, $params);
        $data = $exporter->export($output);

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