public function export_for_template(\renderer_base $output) { global $USER; $context = clone $this->notification; if ($context->useridto == $USER->id && $context->timeusertodeleted) { $context->deleted = true; } else { $context->deleted = false; } $context->timecreatedpretty = get_string('ago', 'message', format_time(time() - $context->timecreated)); $context->text = message_format_message_text($context); $context->read = $context->timeread ? true : false; $context->shortenedsubject = shorten_text($context->subject, 125); if (!empty($context->component) && substr($context->component, 0, 4) == 'mod_') { $iconurl = $output->pix_url('icon', $context->component); } else { $iconurl = $output->pix_url('i/marker', 'core'); } $context->iconurl = $iconurl->out(); return $context; }
/** * Return the safe config values that get set for javascript in "M.cfg". * * @since 2.9 * @return array List of safe config values that are available to javascript. */ public function get_config_for_javascript(moodle_page $page, renderer_base $renderer) { global $CFG; if (empty($this->M_cfg)) { // JavaScript should always work with $CFG->httpswwwroot rather than $CFG->wwwroot. // Otherwise, in some situations, users will get warnings about insecure content // on secure pages from their web browser. $this->M_cfg = array('wwwroot' => $CFG->httpswwwroot, 'sesskey' => sesskey(), 'loadingicon' => $renderer->pix_url('i/loading_small', 'moodle')->out(false), 'themerev' => theme_get_revision(), 'slasharguments' => (int) (!empty($CFG->slasharguments)), 'theme' => $page->theme->name, 'jsrev' => $this->get_jsrev(), 'admin' => $CFG->admin, 'svgicons' => $page->theme->use_svg_icons()); if ($CFG->debugdeveloper) { $this->M_cfg['developerdebug'] = true; } if (defined('BEHAT_SITE_RUNNING')) { $this->M_cfg['behatsiterunning'] = true; } } return $this->M_cfg; }
/** * Export this data so it can be used as the context for a mustache template. * * @param renderer_base $output Used to do a final render of any components that need to be rendered for export. * @return array */ public function export_for_template(renderer_base $output) { $attributes = $this->attributes; $attributes['src'] = $output->pix_url($this->pix, $this->component); $templatecontext = array(); foreach ($attributes as $name => $value) { $templatecontext[] = array('name' => $name, 'value' => $value); } $data = array('attributes' => $templatecontext); return $data; }
/** * Returns an object containing HTML for the areas affected by settings. * * Do not add mmcmonkwearmouth specific logic in here, child themes should be able to * rely on that function just by declaring settings with similar names. * * @param renderer_base $output Pass in $OUTPUT. * @param moodle_page $page Pass in $PAGE. * @return stdClass An object with the following properties: * - navbarclass A CSS class to use on the navbar. By default ''. * - heading HTML to use for the heading. A logo if one is selected or the default heading. * - footnote HTML to use as a footnote. By default ''. */ function theme_mmcmonkwearmouth_get_html_for_settings(renderer_base $output, moodle_page $page) { global $CFG; $toReturn = new stdClass(); $toReturn->navbarclass = ''; if (!empty($page->theme->settings->logo)) { $toReturn->heading = html_writer::link($CFG->wwwroot, html_writer::img($output->pix_url('logo', 'theme'), 'logo', array('title' => get_string('home'), 'class' => 'logo')) . html_writer::tag('h3', 'Monkwearmouth Academy')); } else { $toReturn->heading = $output->page_heading(); } $toReturn->footnote = ''; if (!empty($page->theme->settings->footnote)) { $toReturn->footnote = '<div class="footnote text-center">' . format_text($page->theme->settings->footnote) . '</div>'; } return $toReturn; }