Get the additional values to inject while exporting.

@param renderer_base $output The renderer.
@return array Keys are the property names, values are their values.
182877
protected function get_other_values(renderer_base $output) {
        $event = $this->related['event'];

        if (!$event->get_course_module()) {
            // TODO MDL-58866 Only activity modules currently support this callback.
            return ['showitemcount' => false];
        }
        $modulename = $event->get_course_module()->get('modname');
        $component = 'mod_' . $modulename;
        $showitemcountcallback = 'core_calendar_event_action_shows_item_count';
        $mapper = container::get_event_mapper();
        $calevent = $mapper->from_event_to_legacy_event($event);
        $params = [$calevent, $this->data->itemcount];
        $showitemcount = component_callback($component, $showitemcountcallback, $params, false);

        // Prepare other values data.
        $data = [
            'showitemcount' => $showitemcount
        ];
        return $data;
    }
551146
public function export_for_template(renderer_base $output) {

        $data = new stdClass();
        $data->userid = $this->userid;
        $data->competencyid = $this->competencyid;
        $data->planid = $this->planid;
        $data->baseurl = $this->baseurl;

        $plancompetencies = \core_competency\api::list_plan_competencies($data->planid);
        $data->competencies = array();
        $helper = new performance_helper();
        foreach ($plancompetencies as $plancompetency) {
            $context = $helper->get_context_from_competency($plancompetency->competency);
            $exporter = new competency_exporter($plancompetency->competency, array('context' => $context));
            $competency = $exporter->export($output);
            if ($competency->id == $this->competencyid) {
                $competency->selected = true;
            }
            $data->competencies[] = $competency;
        }
        $data->hascompetencies = count($data->competencies);
        return $data;
    }
374247
public function export_for_template(renderer_base $output) {
        global $USER;

        $myparams = [];
        if ($this->isexistinguser && !empty($this->behalfid) && $this->behalfid != $USER->id) {
            $myparams['userid'] = $this->behalfid;
        }
        $data = (object) [
            'pluginbaseurl' => (new moodle_url('/admin/tool/policy'))->out(false),
            'myurl' => (new moodle_url('/admin/tool/policy/index.php', $myparams))->out(false),
            'sesskey' => sesskey(),
        ];

        if (!empty($this->messages)) {
            foreach ($this->messages as $message) {
                switch ($message->type) {
                    case 'error':
                        $data->messages[] = $output->notification($message->text, notification::NOTIFY_ERROR);
                        break;

                    case 'success':
                        $data->messages[] = $output->notification($message->text, notification::NOTIFY_SUCCESS);
                        break;

                    default:
                        $data->messages[] = $output->notification($message->text, notification::NOTIFY_INFO);
                        break;
                }
            }
        }

        // Filter out policies already shown on their own page, keep just policies to be shown here on the consent page.
        $data->policies = array_values(array_filter($this->policies, function ($policy) {
            return $policy->agreementstyle == policy_version::AGREEMENTSTYLE_CONSENTPAGE;
        }));

        // If viewing docs in behalf of other user, get his/her full name and profile link.
        if (!empty($this->behalfuser)) {
            $userfullname = fullname($this->behalfuser, has_capability('moodle/site:viewfullnames', \context_system::instance()) ||
                        has_capability('moodle/site:viewfullnames', \context_user::instance($this->behalfid)));
            $data->behalfuser = html_writer::link(\context_user::instance($this->behalfid)->get_url(), $userfullname);
        }

        // User can cancel accepting policies only if it is a part of signup.
        $data->cancancel = !isloggedin() || isguestuser();

        return $data;
    }
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,
        );
    }
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;
    }
289448
protected function get_other_values(renderer_base $output) {
        $filters = array('competencyframeworkid' => $this->persistent->get('id'));
        $context = $this->persistent->get_context();
        $competenciescount = 0;
        try {
            api::count_competencies($filters);
        } catch (\required_capability_exception $re) {
            $competenciescount = 0;
        }
        return array(
            'canmanage' => has_capability('moodle/competency:competencymanage', $context),
            'competenciescount' => $competenciescount,
            'contextname' => $context->get_context_name(),
            'contextnamenoprefix' => $context->get_context_name(false)
        );
    }
630856
protected function get_other_values(renderer_base $output) {

        $capabilitymanager = $this->related['capabilitymanager'];
        $urlfactory = $this->related['urlfactory'];
        $favouriteids = isset($this->related['favouriteids']) ? $this->related['favouriteids'] : [];

        $forum = $this->related['forum'];
        $forumrecord = $this->get_forum_record();
        $user = $this->related['user'];
        $discussion = $this->discussion;

        $groupdata = null;
        if ($discussion->has_group() && $group = $this->related['groupsbyid'][$discussion->get_group_id()]) {
            $groupdata = [
                'name' => $group->name,
                'urls' => [],
            ];
            $canviewparticipants = $capabilitymanager->can_view_participants($user, $discussion);
            if (!$group->hidepicture) {
                $url = get_group_picture_url($group, $forum->get_course_id());
                if (!empty($url)) {
                    $groupdata['urls']['picture'] = $url;
                }
            }
            if ($canviewparticipants) {
                $groupdata['urls']['userlist'] = (new \moodle_url('/user/index.php', [
                    'id' => $forum->get_course_id(),
                    'group' => $group->id,
                ]));
            }
        }

        $viewfirstunreadurl = $urlfactory->get_discussion_view_first_unread_post_url_from_discussion($discussion);
        $data = [
            'id' => $discussion->get_id(),
            'forumid' => $forum->get_id(),
            'pinned' => $discussion->is_pinned(),
            'locked' => $forum->is_discussion_locked($discussion),
            'istimelocked' => $forum->is_discussion_time_locked($discussion),
            'name' => format_string($discussion->get_name(), true, [
                'context' => $this->related['context']
            ]),
            'firstpostid' => $discussion->get_first_post_id(),
            'times' => [
                'modified' => $discussion->get_time_modified(),
                'start' => $discussion->get_time_start(),
                'end' => $discussion->get_time_end(),
                'locked' => $discussion->get_locked()
            ],
            'userstate' => [
                'subscribed' => \mod_forum\subscriptions::is_subscribed($user->id, $forumrecord, $discussion->get_id()),
                'favourited' => in_array($discussion->get_id(), $favouriteids) ? true : false,
            ],
            'capabilities' => [
                'subscribe' => $capabilitymanager->can_subscribe_to_discussion($user, $discussion),
                'move' => $capabilitymanager->can_move_discussion($user, $discussion),
                'pin' => $capabilitymanager->can_pin_discussion($user, $discussion),
                'post' => $capabilitymanager->can_post_in_discussion($user, $discussion),
                'manage' => $capabilitymanager->can_manage_forum($user),
                'favourite' => $capabilitymanager->can_favourite_discussion($user) // Defaulting to true until we get capabilities sorted
            ],
            'urls' => [
                'view' => $urlfactory->get_discussion_view_url_from_discussion($discussion)->out(false),
                'viewfirstunread' => $viewfirstunreadurl->out(false),
                'markasread' => $urlfactory->get_mark_discussion_as_read_url_from_discussion($forum, $discussion)->out(false),
                'subscribe' => $urlfactory->get_discussion_subscribe_url($discussion)->out(false)
            ]
        ];

        if (!empty($this->related['latestpostid'])) {
            $data['urls']['viewlatest'] = $urlfactory->get_discussion_view_latest_post_url_from_discussion(
                    $discussion,
                    $this->related['latestpostid']
                )->out(false);
        }

        if ($capabilitymanager->can_pin_discussions($user)) {
            $data['urls']['pin'] = $urlfactory->get_pin_discussion_url_from_discussion($discussion)->out(false);
        }

        if ($groupdata) {
            $data['group'] = $groupdata;
        }

        $canviewhiddentimedposts = $capabilitymanager->can_view_hidden_posts($user);
        $canalwaysseetimedpost = $user->id == $discussion->get_user_id() || $canviewhiddentimedposts;
        $data['timed']['istimed'] = $canalwaysseetimedpost ? $discussion->is_timed_discussion() : null;
        $data['timed']['visible'] = $canalwaysseetimedpost ? $discussion->is_timed_discussion_visible() : null;

        return $data;
    }
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,
        ];
    }
1086529
protected function get_other_values(renderer_base $output) {
        $daytimestamp = $this->calendar->time;
        $timestamp = $this->data[0];
        // Need to account for user's timezone.
        $usernow = usergetdate(time());
        $today = new \DateTimeImmutable();
        // The start time should use the day's date but the current
        // time of the day (adjusted for user's timezone).
        $neweventstarttime = $today->setTimestamp($timestamp)->setTime(
            $usernow['hours'],
            $usernow['minutes'],
            $usernow['seconds']
        );

        $return = [
            'timestamp' => $timestamp,
            'neweventtimestamp' => $neweventstarttime->getTimestamp(),
            'previousperiod' => $this->get_previous_day_timestamp($daytimestamp),
            'nextperiod' => $this->get_next_day_timestamp($daytimestamp),
            'navigation' => $this->get_navigation(),
            'viewdaylink' => $this->url->out(false),
        ];


        $cache = $this->related['cache'];
        $eventexporters = array_map(function($event) use ($cache, $output) {
            $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' => $this->url,
                'type' => $this->related['type'],
                'today' => $this->data[0],
            ]);

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

        $return['events'] = array_map(function($exporter) use ($output) {
            return $exporter->export($output);
        }, $eventexporters);

        $return['hasevents'] = !empty($return['events']);

        $return['calendareventtypes'] = array_map(function($exporter) {
            return $exporter->get_calendar_event_type();
        }, $eventexporters);
        $return['calendareventtypes'] = array_values(array_unique($return['calendareventtypes']));

        $return['haslastdayofevent'] = false;
        foreach ($return['events'] as $event) {
            if ($event->islastday) {
                $return['haslastdayofevent'] = true;
                break;
            }
        }

        return $return;
    }
224839
protected function get_other_values(renderer_base $output) {
        $pagecount = ceil($this->recordcount / $this->pagesize);

        $pages = [];
        if ($pagecount > 1) {
            for ($pageno = 1; $pageno <= $pagecount; $pageno++) {
                $pages[] = [
                    'page' => $pageno,
                    'url' => call_user_func_array($this->pageurlcallback, [$pageno, $this->pagesize]),
                    'active' => $pageno === $this->pagenumber,
                    'content' => null,
                ];
            }
        }

        return [
            'itemsperpage' => $this->pagesize,
            'buttons' => [
                'first' => false,
                'previous' => false,
                'next' => false,
                'last' => false,
            ],
            'pages' => $pages,
        ];
    }
1342318
protected function get_other_values(renderer_base $output) {
        global $CFG;

        $values = parent::get_other_values($output);
        $event = $this->event;
        $course = $this->related['course'];
        $hascourse = !empty($course);

        // By default all events that can be edited are
        // draggable.
        $values['draggable'] = $values['canedit'];

        if ($moduleproxy = $event->get_course_module()) {
            $modulename = $moduleproxy->get('modname');
            $moduleid = $moduleproxy->get('id');
            $url = new \moodle_url(sprintf('/mod/%s/view.php', $modulename), ['id' => $moduleid]);

            // Build edit event url for action events.
            $params = array('update' => $moduleid, 'return' => true, 'sesskey' => sesskey());
            $editurl = new \moodle_url('/course/mod.php', $params);
            $values['editurl'] = $editurl->out(false);
        } else if ($event->get_type() == 'category') {
            $url = $event->get_category()->get_proxied_instance()->get_view_link();
        } else {
            // TODO MDL-58866 We do not have any way to find urls for events outside of course modules.
            $url = course_get_url($hascourse ? $course : SITEID);
        }

        $values['url'] = $url->out(false);
        $values['islastday'] = false;
        $today = $this->related['type']->timestamp_to_date_array($this->related['today']);

        $values['popupname'] = $this->event->get_name();

        $times = $this->event->get_times();
        if ($duration = $times->get_duration()) {
            $enddate = $this->related['type']->timestamp_to_date_array($times->get_end_time()->getTimestamp());
            $values['islastday'] = true;
            $values['islastday'] = $values['islastday'] && $enddate['year'] == $today['year'];
            $values['islastday'] = $values['islastday'] && $enddate['mon'] == $today['mon'];
            $values['islastday'] = $values['islastday'] && $enddate['mday'] == $today['mday'];
        }

        $subscription = $this->event->get_subscription();
        if ($subscription && !empty($subscription->get('id')) && $CFG->calendar_showicalsource) {
            $a = (object) [
                'name' => $values['popupname'],
                'source' => $subscription->get('name'),
            ];
            $values['popupname'] = get_string('namewithsource', 'calendar', $a);
        } else {
            if ($values['islastday']) {
                $startdate = $this->related['type']->timestamp_to_date_array($times->get_start_time()->getTimestamp());
                $samedate = true;
                $samedate = $samedate && $startdate['mon'] == $enddate['mon'];
                $samedate = $samedate && $startdate['year'] == $enddate['year'];
                $samedate = $samedate && $startdate['mday'] == $enddate['mday'];

                if (!$samedate) {
                    $values['popupname'] = get_string('eventendtimewrapped', 'calendar', $values['popupname']);
                }
            }
        }

        // Include category name into the event name, if applicable.
        $proxy = $this->event->get_category();
        if ($proxy && $proxy->get('id')) {
            $category = $proxy->get_proxied_instance();
            $eventnameparams = (object) [
                'name' => $values['popupname'],
                'category' => $category->get_formatted_name(),
            ];
            $values['popupname'] = get_string('eventnameandcategory', 'calendar', $eventnameparams);
        }

        // Include course's shortname into the event name, if applicable.
        if ($hascourse && $course->id !== SITEID) {
            $eventnameparams = (object) [
                'name' => $values['popupname'],
                'course' => $values['course']->shortname,
            ];
            $values['popupname'] = get_string('eventnameandcourse', 'calendar', $eventnameparams);
        }

        if ($event->get_course_module()) {
            $values = array_merge($values, $this->get_module_timestamp_limits($event));
        } else if ($hascourse && $course->id != SITEID && empty($event->get_group())) {
            // This is a course event.
            $values = array_merge($values, $this->get_course_timestamp_limits($event));
        }

        return $values;
    }
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),
        );
    }
278996
public function export_for_template(renderer_base $output) {
        $context = parent::export_for_template($output);
        $context['valuechars'] = array_fill(0, strlen($context['value']), 'x');

        return $context;
    }
434669
protected function get_other_values(renderer_base $output) {
        $result = new \stdClass();
        $ancestors = [];
        $nodescount = count($this->related['ancestors']);
        $i = 1;
        $result->showlinks = \core_competency\api::show_links();
        foreach ($this->related['ancestors'] as $competency) {
            $exporter = new path_node_exporter([
                    'id' => $competency->get('id'),
                    'name' => $competency->get('idnumber'),
                    'position' => $i,
                    'first' => $i == 1,
                    'last' => $i == $nodescount
                ], [
                    'context' => $this->related['context'],
                ]
            );
            $ancestors[] = $exporter->export($output);
            $i++;
        }
        $result->ancestors = $ancestors;
        $exporter = new path_node_exporter([
                'id' => $this->related['framework']->get('id'),
                'name' => $this->related['framework']->get('shortname'),
                'first' => 0,
                'last' => 0,
                'position' => -1
            ], [
                'context' => $this->related['context']
            ]
        );
        $result->framework = $exporter->export($output);
        $result->pluginbaseurl = (new moodle_url('/admin/tool/lp'))->out(true);
        $result->pagecontextid = $this->related['context']->id;
        return (array) $result;
    }
457500
protected function get_other_values(renderer_base $output) {
        $related = $this->related;
        $authorsbyid = $this->authorsbyid;
        $authorcontextids = $this->authorcontextids;
        $attachmentsbypostid = $this->attachmentsbypostid;
        $groupsbyauthorid = $this->groupsbyauthorid;
        $tagsbypostid = $this->tagsbypostid;
        $ratingbypostid = $this->ratingbypostid;
        $exportedposts = array_map(
            function($post) use (
                $related,
                $authorsbyid,
                $authorcontextids,
                $attachmentsbypostid,
                $groupsbyauthorid,
                $tagsbypostid,
                $ratingbypostid,
                $output
            ) {
                $authorid = $post->get_author_id();
                $postid = $post->get_id();
                $author = isset($authorsbyid[$authorid]) ? $authorsbyid[$authorid] : [];
                $authorcontextid = isset($authorcontextids[$authorid]) ? $authorcontextids[$authorid] : null;
                $attachments = isset($attachmentsbypostid[$postid]) ? $attachmentsbypostid[$postid] : [];
                $authorgroups = isset($groupsbyauthorid[$authorid]) ? $groupsbyauthorid[$authorid] : [];
                $tags = isset($tagsbypostid[$postid]) ? $tagsbypostid[$postid] : [];
                $rating = isset($ratingbypostid[$postid]) ? $ratingbypostid[$postid] : null;
                $exporter = new post_exporter($post, array_merge($related, [
                    'author' => $author,
                    'authorcontextid' => $authorcontextid,
                    'attachments' => $attachments,
                    'authorgroups' => $authorgroups,
                    'tags' => $tags,
                    'rating' => $rating
                ]));
                return $exporter->export($output);
            },
            $this->posts
        );

        return [
            'posts' => $exportedposts
        ];
    }
112288
public function export_for_template(renderer_base $output) {
        $data = parent::export_for_template($output);
        $data->courseid = $this->course->id;
        return $data;
    }
756284
protected function get_other_values(renderer_base $output) {
        $capabilitymanager = $this->related['capabilitymanager'];
        $forum = $this->related['forum'];
        $user = $this->related['user'];
        $discussion = $this->summary->get_discussion();

        $related = (array) (object) $this->related;
        $related['latestpostid'] = $this->latestpostid;
        $related['groupsbyid'] = $this->groupsbyid;
        $discussionexporter = new discussion($discussion, $related);

        $related = [
            'urlfactory' => $this->related['urlfactory'],
            'context' => $this->related['forum']->get_context(),
        ];

        $firstpostauthor = new author(
            $this->summary->get_first_post_author(),
            $this->firstpostauthorcontextid,
            $this->groupsbyauthorid[$this->summary->get_first_post_author()->get_id()],
            $capabilitymanager->can_view_post(
                $user,
                $discussion,
                $this->summary->get_first_post()
            ),
            $related
        );

        $latestpostauthor = new author(
            $this->summary->get_latest_post_author(),
            $this->latestpostauthorcontextid,
            [],
            $capabilitymanager->can_view_post(
                $user,
                $discussion,
                $this->summary->get_first_post()
            ),
            $related
        );

        return [
            'id' => $discussion->get_id(),
            'discussion' => $discussionexporter->export($output),
            'replies' => $this->replycount,
            'unread' => $this->unreadcount,
            'firstpostauthor' => $firstpostauthor->export($output),
            'latestpostauthor' => $latestpostauthor->export($output),
            'latestpostid' => $this->latestpostid,
        ];
    }