protected function render_curdate_controls(attforblock_filter_controls $fcontrols) { global $CFG; $curdate_controls = ''; if ($fcontrols->curdatetxt) { $this->page->requires->strings_for_js(array('calclose', 'caltoday'), 'attforblock'); $jsvals = array('cal_months' => explode(',', get_string('calmonths', 'attforblock')), 'cal_week_days' => explode(',', get_string('calweekdays', 'attforblock')), 'cal_start_weekday' => $CFG->calendar_startwday, 'cal_cur_date' => $fcontrols->curdate); $curdate_controls = html_writer::script(js_writer::set_variable('M.attforblock', $jsvals)); $this->page->requires->yui2_lib('container'); $this->page->requires->yui2_lib('calendar'); $this->page->requires->js('/mod/attforblock/calendar.js'); $curdate_controls .= html_writer::link($fcontrols->url(array('curdate' => $fcontrols->prevcur)), $this->output->larrow()); $params = array('title' => get_string('calshow', 'attforblock'), 'id' => 'show', 'type' => 'button'); $button_form = html_writer::tag('button', $fcontrols->curdatetxt, $params); foreach ($fcontrols->url_params(array('curdate' => '')) as $name => $value) { $params = array('type' => 'hidden', 'id' => $name, 'name' => $name, 'value' => $value); $button_form .= html_writer::empty_tag('input', $params); } $params = array('id' => 'currentdate', 'action' => $fcontrols->url_path(), 'method' => 'post'); $button_form = html_writer::tag('form', $button_form, $params); $curdate_controls .= $button_form; $curdate_controls .= html_writer::link($fcontrols->url(array('curdate' => $fcontrols->nextcur)), $this->output->rarrow()); } return $curdate_controls; }
function toHtml() { global $CFG; if ($this->_flagFrozen) { return $this->getFrozenHtml(); } else { $id = $this->getAttribute('id'); $unmask = get_string('unmaskpassword', 'form'); $unmaskjs = html_writer::script(js_writer::set_variable('punmask', array('id' => $id, 'unmaskstr' => $unmask))); $unmaskjs .= html_writer::script('', $CFG->httpswwwroot . '/lib/form/passwordunmask.js'); return $this->_getTabs() . '<input' . $this->_getAttrString($this->_attributes) . ' /><div class="unmask" id="' . $id . 'unmaskdiv"></div>' . $unmaskjs; } }
function print_item($item) { global $textelemid; $name = empty($item->fullname) ? $item->itemname : $item->fullname; if (empty($item->idnumber)) { $item->idnumber = get_string('noidnumber', 'local_eliscore'); } else { $link = true; } echo html_writer::start_tag('li'); if (!empty($link)) { echo html_writer::start_tag('a', array('onclick' => 'return ' . js_writer::function_call('M.local_eliscore.set_value', array($textelemid, $item->idnumber)), 'href' => '')); } echo html_writer::empty_tag('img', array('src' => $item->icon)); echo ' ' . s($name) . ' (' . s($item->idnumber) . ')'; if (!empty($link)) { echo html_writer::end_tag('a'); } echo html_writer::end_tag('li'); }
/** * Returns the recaptcha element in HTML * * @return string */ function toHtml() { global $CFG, $PAGE; require_once $CFG->libdir . '/recaptchalib.php'; $recaptureoptions = array('theme' => 'custom', 'custom_theme_widget' => 'recaptcha_widget'); $html = html_writer::script(js_writer::set_variable('RecaptchaOptions', $recaptureoptions)); $attributes = $this->getAttributes(); if (empty($attributes['error_message'])) { $attributes['error_message'] = null; $this->setAttributes($attributes); } $error = $attributes['error_message']; unset($attributes['error_message']); $strincorrectpleasetryagain = get_string('incorrectpleasetryagain', 'auth'); $strenterthewordsabove = get_string('enterthewordsabove', 'auth'); $strenterthenumbersyouhear = get_string('enterthenumbersyouhear', 'auth'); $strgetanothercaptcha = get_string('getanothercaptcha', 'auth'); $strgetanaudiocaptcha = get_string('getanaudiocaptcha', 'auth'); $strgetanimagecaptcha = get_string('getanimagecaptcha', 'auth'); $html .= ' <div id="recaptcha_widget" style="display:none"> <div id="recaptcha_image"></div> <div class="recaptcha_only_if_incorrect_sol" style="color:red">' . $strincorrectpleasetryagain . '</div> <span class="recaptcha_only_if_image"><label for="recaptcha_response_field">' . $strenterthewordsabove . '</label></span> <span class="recaptcha_only_if_audio"><label for="recaptcha_response_field">' . $strenterthenumbersyouhear . '</label></span> <input type="text" id="recaptcha_response_field" name="recaptcha_response_field" /> <input type="hidden" name="recaptcha_element" value="dummyvalue" /> <!-- Dummy value to fool formslib --> <div><a href="javascript:Recaptcha.reload()">' . $strgetanothercaptcha . '</a></div> <div class="recaptcha_only_if_image"><a href="javascript:Recaptcha.switch_type(\'audio\')">' . $strgetanaudiocaptcha . '</a></div> <div class="recaptcha_only_if_audio"><a href="javascript:Recaptcha.switch_type(\'image\')">' . $strgetanimagecaptcha . '</a></div> </div>'; return $html . recaptcha_get_html($CFG->recaptchapublickey, $error, $this->_https); }
</div> </noscript> <?php if ($result->prerequisites) { if ($scorm->popup != 0 && $displaymode !=='popup') { // Clean the name for the window as IE is fussy $name = preg_replace("/[^A-Za-z0-9]/", "", $scorm->name); if (!$name) { $name = 'DefaultPlayerWindow'; } $name = 'scorm_'.$name; echo html_writer::script('', $CFG->wwwroot.'/mod/scorm/player.js'); $url = new moodle_url($PAGE->url, array('scoid' => $sco->id, 'display' => 'popup')); echo html_writer::script( js_writer::function_call('scorm_openpopup', Array($url->out(false), $name, $scorm->options, $scorm->width, $scorm->height))); ?> <noscript> <!--[if IE]> <iframe id="main" class="scoframe" name="main" src="loadSCO.php?id=<?php echo $cm->id.$scoidstr.$modestr; ?>"></iframe> <![endif]--> <!--[if !IE]> <object id="main" class="scoframe" type="text/html" data="loadSCO.php?id=<?php echo $cm->id.$scoidstr.$modestr; ?>"></object> <![endif]--> </noscript> <?php } } else { echo $OUTPUT->box(get_string('noprerequisites', 'scorm')); }
/** * Replace flv links with flow player. * * @param $link * @return string */ function filter_mediaplugin_flv_callback($link) { static $count = 0; if (filter_mediaplugin_ignore($link[0])) { return $link[0]; } $count++; $id = 'filter_flv_' . time() . '_' . $count; //we need something unique because it might be stored in text cache list($urls, $width, $height) = filter_mediaplugin_parse_alternatives($link[1], 0, 0); $autosize = false; if (!$width and !$height) { $width = FILTER_MEDIAPLUGIN_VIDEO_WIDTH; $height = FILTER_MEDIAPLUGIN_VIDEO_HEIGHT; $autosize = true; } $flashurl = null; $sources = array(); foreach ($urls as $url) { $mimetype = filter_mediaplugin_get_mimetype($url); if (strpos($mimetype, 'video/') !== 0) { continue; } $source = html_writer::tag('source', '', array('src' => $url, 'type' => $mimetype)); if ($mimetype === 'video/mp4') { // better add m4v as first source, it might be a bit more compatible with problematic browsers array_unshift($sources, $source); } else { $sources[] = $source; } if ($flashurl === null) { $flashurl = $url; } } if (!$sources) { return $link[0]; } $info = trim($link[4]); if (empty($info) or strpos($info, 'http') === 0) { $info = get_string('fallbackvideo', 'filter_mediaplugin'); } $printlink = html_writer::link($flashurl . '#', $info, array('class' => 'mediafallbacklink')); // the '#' prevents the QT filter $title = s($info); if (count($sources) > 1) { $sources = implode("\n", $sources); // html 5 fallback $printlink = <<<OET <video controls="true" width="{$width}" height="{$height}" preload="metadata" title="{$title}"> {$sources} {$printlink} </video> <noscript><br /> {$printlink} </noscript> OET; } // note: no need to print "this is flv link" because it is printed automatically if JS or Flash not available $output = html_writer::tag('span', $printlink, array('id' => $id, 'class' => 'mediaplugin mediaplugin_flv')); $output .= html_writer::script(js_writer::function_call('M.util.add_video_player', array($id, addslashes_js($flashurl), $width, $height, $autosize))); // we can not use standard JS init because this may be cached return $output; }
/** * Update the progress bar * * @param int $percent from 1-100 * @param string $msg * @return void Echo's output * @throws coding_exception */ private function _update($percent, $msg) { if (empty($this->time_start)) { throw new coding_exception('You must call create() (or use the $autostart ' . 'argument to the constructor) before you try updating the progress bar.'); } if (CLI_SCRIPT) { return; // Temporary solution for cli scripts. } $estimate = $this->estimate($percent); if ($estimate === null) { // Always do the first and last updates. } else { if ($estimate == 0) { // Always do the last updates. } else { if ($this->lastupdate + 20 < time()) { // We must update otherwise browser would time out. } else { if (round($this->percent, 2) === round($percent, 2)) { // No significant change, no need to update anything. return; } } } } if (is_numeric($estimate)) { $estimate = get_string('secondsleft', 'moodle', round($estimate, 2)); } $this->percent = round($percent, 2); $this->lastupdate = microtime(true); echo html_writer::script(js_writer::function_call('updateProgressBar', array($this->html_id, $this->percent, $msg, $estimate))); flush(); }
function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$scoid='',$mode='normal',$attempt='',$play=false, $tocheader=false) { global $CFG, $DB, $PAGE, $OUTPUT; $modestr = ''; if ($mode == 'browse') { $modestr = '&mode='.$mode; } $result = new stdClass(); if ($tocheader) { $result->toc = '<div id="scorm_layout">'; $result->toc .= '<div id="scorm_toc">'; $result->toc .= '<div id="scorm_tree">'; } $result->toc .= '<ul>'; $tocmenus = array(); $result->prerequisites = true; $incomplete = false; // // Get the current organization infos // if (!empty($currentorg)) { if (($organizationtitle = $DB->get_field('scorm_scoes','title', array('scorm'=>$scorm->id,'identifier'=>$currentorg))) != '') { if ($play) { $result->toctitle = "$organizationtitle"; } else { $result->toc .= "\t<li>$organizationtitle</li>\n"; } $tocmenus[] = $organizationtitle; } } // // If not specified retrieve the last attempt number // if (empty($attempt)) { $attempt = scorm_get_last_attempt($scorm->id, $user->id); } $result->attemptleft = $scorm->maxattempt - $attempt; if ($scoes = scorm_get_scoes($scorm->id, $currentorg)){ // // Retrieve user tracking data for each learning object // $usertracks = array(); foreach ($scoes as $sco) { if (!empty($sco->launch)) { if (empty($scoid)) { $scoid = $sco->id; } if ($usertrack = scorm_get_tracks($sco->id,$user->id,$attempt)) { if ($usertrack->status == '') { $usertrack->status = 'notattempted'; } $usertracks[$sco->identifier] = $usertrack; } } } $level=0; $sublist=1; $previd = 0; $nextid = 0; $findnext = false; $parents[$level]='/'; foreach ($scoes as $pos => $sco) { $isvisible = false; $sco->title = $sco->title; if (!isset($sco->isvisible) || (isset($sco->isvisible) && ($sco->isvisible == 'true'))) { $isvisible = true; } if ($parents[$level]!=$sco->parent) { if ($newlevel = array_search($sco->parent,$parents)) { for ($i=0; $i<($level-$newlevel); $i++) { $result->toc .= "\t\t</li></ul></li>\n"; } $level = $newlevel; } else { $i = $level; $closelist = ''; while (($i > 0) && ($parents[$level] != $sco->parent)) { $closelist .= "\t\t</li></ul></li>\n"; $i--; } if (($i == 0) && ($sco->parent != $currentorg)) { $result->toc .= "\t\t<ul>\n"; $level++; } else { $result->toc .= $closelist; $level = $i; } $parents[$level]=$sco->parent; } } if ($isvisible) { $result->toc .= "\t\t<li>"; } if (isset($scoes[$pos+1])) { $nextsco = $scoes[$pos+1]; } else { $nextsco = false; } $nextisvisible = false; if (!isset($nextsco->isvisible) || (isset($nextsco->isvisible) && ($nextsco->isvisible == 'true'))) { $nextisvisible = true; } if ($nextisvisible && ($nextsco !== false) && ($sco->parent != $nextsco->parent) && (($level==0) || (($level>0) && ($nextsco->parent == $sco->identifier)))) { $sublist++; } if (empty($sco->title)) { $sco->title = $sco->identifier; } if (!empty($sco->launch)) { if ($isvisible) { $score = ''; if (empty($scoid) && ($mode != 'normal')) { $scoid = $sco->id; } if (isset($usertracks[$sco->identifier])) { $usertrack = $usertracks[$sco->identifier]; $strstatus = get_string($usertrack->status,'scorm'); if ($sco->scormtype == 'sco') { $statusicon = '<img src="'.$OUTPUT->pix_url($usertrack->status, 'scorm').'" alt="'.$strstatus.'" title="'.$strstatus.'" />'; } else { $statusicon = '<img src="'.$OUTPUT->pix_url('assetc', 'scorm').'" alt="'.get_string('assetlaunched','scorm').'" title="'.get_string('assetlaunched','scorm').'" />'; } if (($usertrack->status == 'notattempted') || ($usertrack->status == 'incomplete') || ($usertrack->status == 'browsed')) { $incomplete = true; if ($play && empty($scoid)) { $scoid = $sco->id; } } if ($usertrack->score_raw != '' && has_capability('mod/scorm:viewscores', get_context_instance(CONTEXT_MODULE,$cmid))) { $score = '('.get_string('score','scorm').': '.$usertrack->score_raw.')'; } $strsuspended = get_string('suspended','scorm'); if ($incomplete && isset($usertrack->{'cmi.core.exit'}) && ($usertrack->{'cmi.core.exit'} == 'suspend')) { $statusicon = '<img src="'.$OUTPUT->pix_url('suspend', 'scorm').'" alt="'.$strstatus.' - '.$strsuspended.'" title="'.$strstatus.' - '.$strsuspended.'" />'; } } else { if ($play && empty($scoid)) { $scoid = $sco->id; } $incomplete = true; if ($sco->scormtype == 'sco') { $statusicon = '<img src="'.$OUTPUT->pix_url('notattempted', 'scorm').'" alt="'.get_string('notattempted','scorm').'" title="'.get_string('notattempted','scorm').'" />'; } else { $statusicon = '<img src="'.$OUTPUT->pix_url('asset', 'scorm').'" alt="'.get_string('asset','scorm').'" title="'.get_string('asset','scorm').'" />'; } } if ($sco->id == $scoid) { $findnext = true; } if (($nextid == 0) && (scorm_count_launchable($scorm->id,$currentorg) > 1) && ($nextsco!==false) && (!$findnext)) { if (!empty($sco->launch)) { $previd = $sco->id; } } if (empty($sco->prerequisites) || scorm_eval_prerequisites($sco->prerequisites,$usertracks)) { if ($sco->id == $scoid) { $result->prerequisites = true; } $thisscoidstr = '&scoid='.$sco->id; $link = 'a='.$scorm->id.$thisscoidstr.'¤torg='.$currentorg.$modestr.'&attempt='.$attempt; if ($toclink == TOCFULLURL) { //display toc with urls for structure page $url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&currentorg='.$currentorg.$modestr.'&scoid='.$sco->id; $result->toc .= $statusicon.' <a href="'.$url.'">'.format_string($sco->title).'</a>'.$score."\n"; } else { if ($sco->launch) { $result->toc .= '<a title="'.$link.'">'.$statusicon.' '.format_string($sco->title).' '.$score.'</a>'; } else { $result->toc .= '<span>'.$statusicon.' '.format_string($sco->title).'</span>'; } } $tocmenus[$sco->id] = scorm_repeater('−',$level) . '>' . format_string($sco->title); } else { if ($sco->id == $scoid) { $result->prerequisites = false; } if ($play) { // should be disabled $result->toc .= '<span>'.$statusicon.' '.format_string($sco->title).'</span>'; } else { $result->toc .= $statusicon.' '.format_string($sco->title)."\n"; } } if (($nextsco === false) || $nextsco->parent == $sco->parent) { $result->toc .= '</li>'; } } } else { $result->toc .= ' '.format_string($sco->title)."</li>\n"; } if (($nextsco !== false) && ($nextid == 0) && ($findnext)) { if (!empty($nextsco->launch)) { $nextid = $nextsco->id; } } } for ($i=0;$i<$level;$i++) { $result->toc .= "\t\t</ul></li>\n"; } if ($play) { $sco = scorm_get_sco($scoid); $sco->previd = $previd; $sco->nextid = $nextid; $result->sco = $sco; $result->incomplete = $incomplete; } else { $result->incomplete = $incomplete; } } $result->toc .= '</ul>'; // NEW IMS TOC if ($tocheader) { $result->toc .= '</div></div></div>'; $result->toc .= '<div id="scorm_navpanel"></div>'; } if ($scorm->hidetoc == 0) { $result->toc .= html_writer::script(js_writer::set_variable('scormdata', array( 'plusicon' => $OUTPUT->pix_url('plus', 'scorm'), 'minusicon' => $OUTPUT->pix_url('minus', 'scorm')))); $result->toc .= html_writer::script('', $CFG->wwwroot.'/lib/cookies.js'); $result->toc .= html_writer::script('', $CFG->wwwroot.'/mod/scorm/datamodels/scorm_datamodels.js'); } $url = new moodle_url('/mod/scorm/player.php?a='.$scorm->id.'¤torg='.$currentorg.$modestr); $result->tocmenu = $OUTPUT->single_select($url, 'scoid', $tocmenus, $sco->id, null, "tocmenu"); return $result; }
/** * Update the progress bar * * @param int $percent from 1-100 * @param string $msg * @return void Echo's output */ private function _update($percent, $msg) { if (empty($this->time_start)) { throw new coding_exception('You must call create() (or use the $autostart ' . 'argument to the constructor) before you try updating the progress bar.'); } if (CLI_SCRIPT) { return; // temporary solution for cli scripts } $es = $this->estimate($percent); if ($es === null) { // always do the first and last updates $es = "?"; } else { if ($es == 0) { // always do the last updates } else { if ($this->lastupdate + 20 < time()) { // we must update otherwise browser would time out } else { if (round($this->percent, 2) === round($percent, 2)) { // no significant change, no need to update anything return; } } } } $this->percent = $percent; $this->lastupdate = microtime(true); $w = $this->percent / 100 * $this->width; echo html_writer::script(js_writer::function_call('update_progress_bar', array($this->html_id, $w, $this->percent, $msg, $es))); flush(); }
// No Martin(i), No Party ;-) ?> </div> </noscript> <?php if ($result->prerequisites) { if ($scorm->popup != 0) { // Clean the name for the window as IE is fussy $name = preg_replace("/[^A-Za-z0-9]/", "", $scorm->name); if (!$name) { $name = 'DefaultPlayerWindow'; } $name = 'scorm_' . $name; echo html_writer::script('', $CFG->wwwroot . '/mod/scorm/player.js'); echo html_writer::script(js_writer::function_call('scorm_openpopup', array("loadSCO.php?id=" . $cm->id . $scoidpop, $name, $scorm->options, $scorm->width, $scorm->height))); ?> <noscript> <!--[if IE]> <iframe id="main" class="scoframe" name="main" src="loadSCO.php?id=<?php echo $cm->id . $scoidstr . $modestr; ?> "></iframe> <![endif]--> <!--[if !IE]> <object id="main" class="scoframe" type="text/html" data="loadSCO.php?id=<?php echo $cm->id . $scoidstr . $modestr; ?> "></object> <![endif]--> </noscript>
/** * Returns flash video embedding html. * @param string $fullurl * @param string $title * @param string $clicktoopen * @return string html */ function resourcelib_embed_flashvideo($fullurl, $title, $clicktoopen) { global $CFG, $PAGE; if ($fullurl instanceof moodle_url) { $fullurl = $fullurl->out(false); } $id = 'resource_flv_' . time(); //we need something unique because it might be stored in text cache //note: nobody should be adding any dimensions to themes!!! if (preg_match('/\\?d=([\\d]{1,4}%?)x([\\d]{1,4}%?)/', $fullurl, $matches)) { $width = $matches[1]; $height = $matches[2]; $autosize = false; } else { $width = 400; $height = 300; $autosize = true; } $output = '<div class="resourcecontent resourceflv">'; $output .= html_writer::tag('span', $clicktoopen, array('id' => $id, 'class' => 'resourcemediaplugin resourcemediaplugin_flv', 'title' => $title)); $output .= html_writer::script(js_writer::function_call('M.util.add_video_player', array($id, $fullurl, $width, $height, $autosize))); $output .= '</div>'; return $output; }
$table->head[] = 'Filename'; $table->attributes['class'] = 'admintable generaltable'; $table->head[] = 'Time Created'; $table->head[] = get_string('action'); $table->colclasses[] = 'centeralign'; $table->head[] = ""; $table->colclasses[] = 'centeralign'; $table->id = "recorded_data"; foreach ($recordings as $record) { $buttons = array(); $lastcolumn = ''; $row = array(); $row[] = $record->vcsessionname . ' ' . module_get_rename_action($cm, $record); $row[] = userdate($record->timecreated); $playurl = new moodle_url($CFG->wwwroot . '/mod/virtualclass/classroom.php', array('id' => $id, 'vcSid' => $record->id, 'play' => 1)); $playpopup = js_writer::function_call('virtualclass_openpopup', array($playurl->out(false), $popupname, $popupoptions, $popupwidth, $popupheight)); // play button if (has_capability('mod/virtualclass:view', $context)) { $buttons[] = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('e/insert_edit_video'), 'alt' => $strplay, 'class' => 'iconsmall hand', 'onclick' => $playpopup)); } // delete button if (has_capability('mod/virtualclass:addinstance', $context)) { $buttons[] = html_writer::link(new moodle_url($returnurl, array('delete' => $record->id, 'sesskey' => sesskey())), html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('t/delete'), 'alt' => $strdelete, 'class' => 'iconsmall')), array('title' => $strdelete)); } $row[] = implode(' ', $buttons); $row[] = $lastcolumn; $table->data[] = $row; } if (!empty($table->data)) { echo html_writer::start_tag('div', array('class' => 'no-overflow')); echo html_writer::table($table);
/** * Generate any HTML that needs to go at the end of the page. * * @return string the HTML code to to at the end of the page. */ public function get_end_code() { global $CFG; $output = ''; // Call amd init functions. $output .= $this->get_amd_footercode(); // Add other requested modules. $output .= $this->get_extra_modules_code(); // All the other linked scripts - there should be as few as possible. if ($this->jsincludes['footer']) { foreach ($this->jsincludes['footer'] as $url) { $output .= html_writer::script('', $url); } } if (!empty($this->stringsforjs)) { // Add all needed strings. $strings = array(); foreach ($this->stringsforjs as $component => $v) { foreach ($v as $indentifier => $langstring) { $strings[$component][$indentifier] = $langstring->out(); } } // Append don't overwrite. $output .= html_writer::script('require(["jquery"], function($) { M.str = $.extend(true, M.str, ' . json_encode($strings) . '); });'); } // Add variables. if ($this->jsinitvariables['footer']) { $js = ''; foreach ($this->jsinitvariables['footer'] as $data) { list($var, $value) = $data; $js .= js_writer::set_variable($var, $value, true); } $output .= html_writer::script($js); } $inyuijs = $this->get_javascript_code(false); $ondomreadyjs = $this->get_javascript_code(true); // See if this is still needed when we get to the ajax page. $jsinit = $this->get_javascript_init_code(); $handlersjs = $this->get_event_handler_code(); // There is a global Y, make sure it is available in your scope. $js = "(function() {{$inyuijs}{$ondomreadyjs}{$jsinit}{$handlersjs}})();"; $output .= html_writer::script($js); return $output; }
function scorm_get_toc($user, $scorm, $liststyle, $currentorg = '', $scoid = '', $mode = 'normal', $attempt = '', $play = false, $tocheader = false) { global $CFG, $DB, $PAGE, $OUTPUT; $strexpand = get_string('expcoll', 'scorm'); $modestr = ''; if ($mode == 'browse') { $modestr = '&mode=' . $mode; } $result = new stdClass(); //$result->toc = "<ul id='s0' class='$liststyle'>\n"; if ($tocheader) { $result->toc = '<div id="scorm_layout">'; $result->toc .= '<div id="scorm_toc">'; $result->toc .= '<div id="scorm_tree">'; } $result->toc .= '<ul>'; $tocmenus = array(); $result->prerequisites = true; $incomplete = false; // // Get the current organization infos // if (!empty($currentorg)) { if (($organizationtitle = $DB->get_field('scorm_scoes', 'title', array('scorm' => $scorm->id, 'identifier' => $currentorg))) != '') { if ($play) { $result->toctitle = "{$organizationtitle}"; } else { $result->toc .= "\t<li>{$organizationtitle}</li>\n"; } $tocmenus[] = $organizationtitle; } } // // If not specified retrieve the last attempt number // if (empty($attempt)) { $attempt = scorm_get_last_attempt($scorm->id, $user->id); } $result->attemptleft = $scorm->maxattempt - $attempt; if ($scoes = scorm_get_scoes($scorm->id, $currentorg)) { // // Retrieve user tracking data for each learning object // $usertracks = array(); foreach ($scoes as $sco) { if (!empty($sco->launch)) { if (empty($scoid)) { $scoid = $sco->id; } if ($usertrack = scorm_get_tracks($sco->id, $user->id, $attempt)) { if ($usertrack->status == '') { $usertrack->status = 'notattempted'; } $usertracks[$sco->identifier] = $usertrack; } } } $level = 0; $sublist = 1; $previd = 0; $nextid = 0; $findnext = false; $parents[$level] = '/'; foreach ($scoes as $pos => $sco) { $isvisible = false; $sco->title = $sco->title; if (!isset($sco->isvisible) || isset($sco->isvisible) && $sco->isvisible == 'true') { $isvisible = true; } if ($parents[$level] != $sco->parent) { if ($newlevel = array_search($sco->parent, $parents)) { for ($i = 0; $i < $level - $newlevel; $i++) { $result->toc .= "\t\t</li></ul></li>\n"; } $level = $newlevel; } else { $i = $level; $closelist = ''; while ($i > 0 && $parents[$level] != $sco->parent) { $closelist .= "\t\t</li></ul></li>\n"; $i--; } if ($i == 0 && $sco->parent != $currentorg) { $style = ''; if (isset($_COOKIE['hide:SCORMitem' . $sco->id])) { $style = ' style="display: none;"'; } //$result->toc .= "\t\t<li><ul id='s$sublist' class='$liststyle'$style>\n"; $result->toc .= "\t\t<ul>\n"; $level++; } else { $result->toc .= $closelist; $level = $i; } $parents[$level] = $sco->parent; } } if ($isvisible) { $result->toc .= "\t\t<li>"; } if (isset($scoes[$pos + 1])) { $nextsco = $scoes[$pos + 1]; } else { $nextsco = false; } $nextisvisible = false; if (!isset($nextsco->isvisible) || isset($nextsco->isvisible) && $nextsco->isvisible == 'true') { $nextisvisible = true; } if ($nextisvisible && $nextsco !== false && $sco->parent != $nextsco->parent && ($level == 0 || $level > 0 && $nextsco->parent == $sco->identifier)) { $sublist++; $icon = 'minus'; if (isset($_COOKIE['hide:SCORMitem' . $nextsco->id])) { $icon = 'plus'; } //$result->toc .= '<a href="javascript:expandCollide(\'img'.$sublist.'\',\'s'.$sublist.'\','.$nextsco->id.');"><img id="img'.$sublist.'" src="'.$OUTPUT->pix_url($icon, 'scorm').'" alt="'.$strexpand.'" title="'.$strexpand.'"/></a>'; } else { if ($isvisible) { //$result->toc .= '<img src="'.$OUTPUT->pix_url('spacer', 'scorm').'" alt="" />'; } } if (empty($sco->title)) { $sco->title = $sco->identifier; } if (!empty($sco->launch)) { if ($isvisible) { $startbold = ''; $endbold = ''; $score = ''; if (empty($scoid) && $mode != 'normal') { $scoid = $sco->id; } if (isset($usertracks[$sco->identifier])) { $usertrack = $usertracks[$sco->identifier]; $strstatus = get_string($usertrack->status, 'scorm'); if ($sco->scormtype == 'sco') { $statusicon = '<img src="' . $OUTPUT->pix_url($usertrack->status, 'scorm') . '" alt="' . $strstatus . '" title="' . $strstatus . '" />'; } else { $statusicon = '<img src="' . $OUTPUT->pix_url('assetc', 'scorm') . '" alt="' . get_string('assetlaunched', 'scorm') . '" title="' . get_string('assetlaunched', 'scorm') . '" />'; } if ($usertrack->status == 'notattempted' || $usertrack->status == 'incomplete' || $usertrack->status == 'browsed') { $incomplete = true; if ($play && empty($scoid)) { $scoid = $sco->id; } } if ($usertrack->score_raw != '') { $score = '(' . get_string('score', 'scorm') . ': ' . $usertrack->score_raw . ')'; } $strsuspended = get_string('suspended', 'scorm'); if ($incomplete && isset($usertrack->{'cmi.core.exit'}) && $usertrack->{'cmi.core.exit'} == 'suspend') { $statusicon = '<img src="' . $OUTPUT->pix_url('suspend', 'scorm') . '" alt="' . $strstatus . ' - ' . $strsuspended . '" title="' . $strstatus . ' - ' . $strsuspended . '" />'; } } else { if ($play && empty($scoid)) { $scoid = $sco->id; } $incomplete = true; if ($sco->scormtype == 'sco') { $statusicon = '<img src="' . $OUTPUT->pix_url('notattempted', 'scorm') . '" alt="' . get_string('notattempted', 'scorm') . '" title="' . get_string('notattempted', 'scorm') . '" />'; } else { $statusicon = '<img src="' . $OUTPUT->pix_url('asset', 'scorm') . '" alt="' . get_string('asset', 'scorm') . '" title="' . get_string('asset', 'scorm') . '" />'; } } if ($sco->id == $scoid) { $startbold = '<b>'; $endbold = '</b>'; $findnext = true; $shownext = isset($sco->next) ? $sco->next : 0; $showprev = isset($sco->previous) ? $sco->previous : 0; } if ($nextid == 0 && scorm_count_launchable($scorm->id, $currentorg) > 1 && $nextsco !== false && !$findnext) { if (!empty($sco->launch)) { $previd = $sco->id; } } if (empty($sco->prerequisites) || scorm_eval_prerequisites($sco->prerequisites, $usertracks)) { if ($sco->id == $scoid) { $result->prerequisites = true; } $url = $CFG->wwwroot . '/mod/scorm/player.php?a=' . $scorm->id . '&currentorg=' . $currentorg . $modestr . '&scoid=' . $sco->id; $thisscoidstr = '&scoid=' . $sco->id; //$link = $CFG->wwwroot.'/mod/scorm/loadSCO.php?a='.$scorm->id.$thisscoidstr.$modestr; $link = 'a=' . $scorm->id . $thisscoidstr . '¤torg=' . $currentorg . $modestr . '&attempt=' . $attempt; //$result->toc .= $statusicon.' '.$startbold.'<a href="'.$url.'">'.format_string($sco->title).'</a>'.$score.$endbold."</li>\n"; //$result->toc .= '<a title="'.$link.'">'.$statusicon.' '.format_string($sco->title).' '.$score.'</a>'; if ($sco->launch) { $result->toc .= '<a title="' . $link . '">' . $statusicon . ' ' . format_string($sco->title) . ' ' . $score . '</a>'; } else { $result->toc .= '<span>' . $statusicon . ' ' . format_string($sco->title) . '</span>'; } $tocmenus[$sco->id] = scorm_repeater('−', $level) . '>' . format_string($sco->title); } else { if ($sco->id == $scoid) { $result->prerequisites = false; } if ($play) { // should be disabled $result->toc .= '<span>' . $statusicon . ' ' . format_string($sco->title) . '</span>'; } else { $result->toc .= $statusicon . ' ' . format_string($sco->title) . "\n"; } } if ($nextsco === false || $nextsco->parent == $sco->parent) { $result->toc .= '</li>'; } } } else { $result->toc .= ' ' . format_string($sco->title) . "</li>\n"; } if ($nextsco !== false && $nextid == 0 && $findnext) { if (!empty($nextsco->launch)) { $nextid = $nextsco->id; } } } for ($i = 0; $i < $level; $i++) { $result->toc .= "\t\t</ul></li>\n"; } if ($play) { $sco = scorm_get_sco($scoid); $sco->previd = $previd; $sco->nextid = $nextid; $result->sco = $sco; $result->incomplete = $incomplete; } else { $result->incomplete = $incomplete; } } $result->toc .= '</ul>'; // NEW IMS TOC if ($tocheader) { $result->toc .= '</div></div></div>'; $result->toc .= '<div id="scorm_navpanel"></div>'; } if ($scorm->hidetoc == 0) { $result->toc .= html_writer::script(js_writer::set_variable('scormdata', array('plusicon' => $OUTPUT->pix_url('plus', 'scorm'), 'minusicon' => $OUTPUT->pix_url('minus', 'scorm')))); $result->toc .= html_writer::script('', $CFG->wwwroot . '/lib/cookies.js'); $result->toc .= html_writer::script('', $CFG->wwwroot . '/mod/scorm/datamodels/scorm_datamodels.js'); } $url = new moodle_url('/mod/scorm/player.php?a=' . $scorm->id . '¤torg=' . $currentorg . $modestr); $result->tocmenu = $OUTPUT->single_select($url, 'scoid', $tocmenus, $sco->id, null, "tocmenu"); return $result; }
/** * Update the progress bar * * @param int $percent from 1-100 * @param string $msg * @return void Echo's output */ private function _update($percent, $msg) { if (empty($this->time_start)){ $this->time_start = microtime(true); } if (CLI_SCRIPT) { return; // temporary solution for cli scripts } $es = $this->estimate($percent); if ($es === null) { // always do the first and last updates $es = "?"; } else if ($es == 0) { // always do the last updates } else if ($this->lastupdate + 20 < time()) { // we must update otherwise browser would time out } else if (round($this->percent, 2) === round($percent, 2)) { // no significant change, no need to update anything return; } $this->percent = $percent; $this->lastupdate = microtime(true); $w = ($this->percent/100) * $this->width; echo html_writer::script(js_writer::function_call('update_progress_bar', array($this->html_id, $w, $this->percent, $msg, $es))); flush(); }
/** * Generate any HTML that needs to go at the end of the page. * * Normally, this method is called automatically by the code that prints the * page footer. You should not normally need to call it in your own code. * * @return string the HTML code to to at the end of the page. */ public function get_end_code() { global $CFG; // add other requested modules $output = $this->get_extra_modules_code(); // add missing YUI2 YUI - to be removed once we convert everything to YUI3! $output .= $this->get_yui2lib_code(); // all the other linked scripts - there should be as few as possible if ($this->jsincludes['footer']) { foreach ($this->jsincludes['footer'] as $url) { $output .= html_writer::script('', $url); } } // add all needed strings if (!empty($this->stringsforjs)) { $output .= html_writer::script(js_writer::set_variable('M.str', $this->stringsforjs)); } // add variables if ($this->jsinitvariables['footer']) { $js = ''; foreach ($this->jsinitvariables['footer'] as $data) { list($var, $value) = $data; $js .= js_writer::set_variable($var, $value, true); } $output .= html_writer::script($js); } $inyuijs = $this->get_javascript_code(false); $ondomreadyjs = $this->get_javascript_code(true); $jsinit = $this->get_javascript_init_code(); $handlersjs = $this->get_event_handler_code(); // there is no global Y, make sure it is available in your scope $js = "YUI(M.yui.loader).use('node', function(Y) {\n{$inyuijs}{$ondomreadyjs}{$jsinit}{$handlersjs}\n});"; $output .= html_writer::script($js); return $output; }
/** * Renders a custom menu object (located in outputcomponents.php) * * The custom menu this method produces makes use of the YUI3 menunav widget * and requires very specific html elements and classes. * * @staticvar int $menucount * @param custom_menu $menu * @return string */ protected function render_custom_menu(custom_menu $menu) { static $menucount = 0; // If the menu has no children return an empty string if (!$menu->has_children()) { return ''; } // Increment the menu count. This is used for ID's that get worked with // in JavaScript as is essential $menucount++; // Initialise this custom menu (the custom menu object is contained in javascript-static $jscode = js_writer::function_call_with_Y('M.core_custom_menu.init', array('custom_menu_'.$menucount)); $jscode = "(function(){{$jscode}})"; $this->page->requires->yui_module('node-menunav', $jscode); // Build the root nodes as required by YUI $content = html_writer::start_tag('div', array('id'=>'custom_menu_'.$menucount, 'class'=>'yui3-menu yui3-menu-horizontal javascript-disabled custom-menu')); $content .= html_writer::start_tag('div', array('class'=>'yui3-menu-content')); $content .= html_writer::start_tag('ul'); // Render each child foreach ($menu->get_children() as $item) { $content .= $this->render_custom_menu_item($item); } // Close the open tags $content .= html_writer::end_tag('ul'); $content .= html_writer::end_tag('div'); $content .= html_writer::end_tag('div'); // Return the custom menu return $content; }
public function embed($urls, $name, $width, $height, $options) { // Use first url (there can actually be only one unless some idiot // enters two mp3 files as alternatives). $url = reset($urls); // Unique id even across different http requests made at the same time // (for AJAX, iframes). $id = 'core_media_flv_' . md5(time() . '_' . rand()); // Compute width and height. $autosize = false; if (!$width && !$height) { $width = CORE_MEDIA_VIDEO_WIDTH; $height = CORE_MEDIA_VIDEO_HEIGHT; $autosize = true; } // Fallback span (will normally contain link). $output = html_writer::tag('span', core_media_player::PLACEHOLDER, array('id' => $id, 'class' => 'mediaplugin mediaplugin_flv')); // We can not use standard JS init because this may be cached. $output .= html_writer::script(js_writer::function_call('M.util.add_video_player', array($id, addslashes_js($url->out(false)), $width, $height, $autosize))); return $output; }
/** * Generate any HTML that needs to go at the end of the page. * * Normally, this method is called automatically by the code that prints the * page footer. You should not normally need to call it in your own code. * * @return string the HTML code to to at the end of the page. */ public function get_end_code() { global $CFG; // Add other requested modules. $output = $this->get_extra_modules_code(); // All the other linked scripts - there should be as few as possible. if ($this->jsincludes['footer']) { foreach ($this->jsincludes['footer'] as $url) { $output .= html_writer::script('', $url); } } // Add all needed strings. if (!empty($this->stringsforjs)) { $strings = array(); foreach ($this->stringsforjs as $component => $v) { foreach ($v as $indentifier => $langstring) { $strings[$component][$indentifier] = $langstring->out(); } } $output .= html_writer::script(js_writer::set_variable('M.str', $strings)); } // Add variables. if ($this->jsinitvariables['footer']) { $js = ''; foreach ($this->jsinitvariables['footer'] as $data) { list($var, $value) = $data; $js .= js_writer::set_variable($var, $value, true); } $output .= html_writer::script($js); } $inyuijs = $this->get_javascript_code(false); $ondomreadyjs = $this->get_javascript_code(true); $jsinit = $this->get_javascript_init_code(); $handlersjs = $this->get_event_handler_code(); // There is no global Y, make sure it is available in your scope. $js = "YUI().use('node', function(Y) {\n{$inyuijs}{$ondomreadyjs}{$jsinit}{$handlersjs}\n});"; $output .= html_writer::script($js); return $output; }
/** * @todo Document this function */ function forum_print_big_search_form($course) { global $CFG, $DB, $words, $subject, $phrase, $user, $userid, $fullwords, $notwords, $datefrom, $dateto, $PAGE, $OUTPUT; echo $OUTPUT->box(get_string('searchforumintro', 'forum'), 'searchbox boxaligncenter', 'intro'); echo $OUTPUT->box_start('generalbox boxaligncenter'); echo html_writer::script('', $CFG->wwwroot . '/mod/forum/forum.js'); echo '<form id="searchform" action="search.php" method="get">'; echo '<table cellpadding="10" class="searchbox" id="form">'; echo '<tr>'; echo '<td class="c0"><label for="words">' . get_string('searchwords', 'forum') . '</label>'; echo '<input type="hidden" value="' . $course->id . '" name="id" alt="" /></td>'; echo '<td class="c1"><input type="text" size="35" name="words" id="words"value="' . s($words, true) . '" alt="" /></td>'; echo '</tr>'; echo '<tr>'; echo '<td class="c0"><label for="phrase">' . get_string('searchphrase', 'forum') . '</label></td>'; echo '<td class="c1"><input type="text" size="35" name="phrase" id="phrase" value="' . s($phrase, true) . '" alt="" /></td>'; echo '</tr>'; echo '<tr>'; echo '<td class="c0"><label for="notwords">' . get_string('searchnotwords', 'forum') . '</label></td>'; echo '<td class="c1"><input type="text" size="35" name="notwords" id="notwords" value="' . s($notwords, true) . '" alt="" /></td>'; echo '</tr>'; if ($DB->get_dbfamily() == 'mysql' || $DB->get_dbfamily() == 'postgres') { echo '<tr>'; echo '<td class="c0"><label for="fullwords">' . get_string('searchfullwords', 'forum') . '</label></td>'; echo '<td class="c1"><input type="text" size="35" name="fullwords" id="fullwords" value="' . s($fullwords, true) . '" alt="" /></td>'; echo '</tr>'; } echo '<tr>'; echo '<td class="c0">' . get_string('searchdatefrom', 'forum') . '</td>'; echo '<td class="c1">'; if (empty($datefrom)) { $datefromchecked = ''; $datefrom = make_timestamp(2000, 1, 1, 0, 0, 0); } else { $datefromchecked = 'checked="checked"'; } echo '<input name="timefromrestrict" type="checkbox" value="1" alt="' . get_string('searchdatefrom', 'forum') . '" onclick="return lockoptions(\'searchform\', \'timefromrestrict\', timefromitems)" ' . $datefromchecked . ' /> '; $selectors = html_writer::select_time('days', 'fromday', $datefrom) . html_writer::select_time('months', 'frommonth', $datefrom) . html_writer::select_time('years', 'fromyear', $datefrom) . html_writer::select_time('hours', 'fromhour', $datefrom) . html_writer::select_time('minutes', 'fromminute', $datefrom); echo $selectors; echo '<input type="hidden" name="hfromday" value="0" />'; echo '<input type="hidden" name="hfrommonth" value="0" />'; echo '<input type="hidden" name="hfromyear" value="0" />'; echo '<input type="hidden" name="hfromhour" value="0" />'; echo '<input type="hidden" name="hfromminute" value="0" />'; echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td class="c0">' . get_string('searchdateto', 'forum') . '</td>'; echo '<td class="c1">'; if (empty($dateto)) { $datetochecked = ''; $dateto = time() + 3600; } else { $datetochecked = 'checked="checked"'; } echo '<input name="timetorestrict" type="checkbox" value="1" alt="' . get_string('searchdateto', 'forum') . '" onclick="return lockoptions(\'searchform\', \'timetorestrict\', timetoitems)" ' . $datetochecked . ' /> '; $selectors = html_writer::select_time('days', 'today', $dateto) . html_writer::select_time('months', 'tomonth', $dateto) . html_writer::select_time('years', 'toyear', $dateto) . html_writer::select_time('hours', 'tohour', $dateto) . html_writer::select_time('minutes', 'tominute', $dateto); echo $selectors; echo '<input type="hidden" name="htoday" value="0" />'; echo '<input type="hidden" name="htomonth" value="0" />'; echo '<input type="hidden" name="htoyear" value="0" />'; echo '<input type="hidden" name="htohour" value="0" />'; echo '<input type="hidden" name="htominute" value="0" />'; echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td class="c0"><label for="menuforumid">' . get_string('searchwhichforums', 'forum') . '</label></td>'; echo '<td class="c1">'; echo html_writer::select(forum_menu_list($course), 'forumid', '', array('' => get_string('allforums', 'forum'))); echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td class="c0"><label for="subject">' . get_string('searchsubject', 'forum') . '</label></td>'; echo '<td class="c1"><input type="text" size="35" name="subject" id="subject" value="' . s($subject, true) . '" alt="" /></td>'; echo '</tr>'; echo '<tr>'; echo '<td class="c0"><label for="user">' . get_string('searchuser', 'forum') . '</label></td>'; echo '<td class="c1"><input type="text" size="35" name="user" id="user" value="' . s($user, true) . '" alt="" /></td>'; echo '</tr>'; echo '<tr>'; echo '<td class="submit" colspan="2" align="center">'; echo '<input type="submit" value="' . get_string('searchforums', 'forum') . '" alt="" /></td>'; echo '</tr>'; echo '</table>'; echo '</form>'; echo html_writer::script(js_writer::function_call('lockoptions_timetoitems')); echo html_writer::script(js_writer::function_call('lockoptions_timefromitems')); echo $OUTPUT->box_end(); }
/** * print the item at the complete-page of feedback * * @global object * @param object $item * @param string $value * @param bool $highlightrequire * @return void */ function print_item_complete($item, $value = '', $highlightrequire = false) { global $SESSION, $CFG, $DB, $USER; require_once $CFG->libdir . '/recaptchalib.php'; $align = right_to_left() ? 'right' : 'left'; $cmid = 0; $feedbackid = $item->feedback; if ($feedbackid > 0) { $feedback = $DB->get_record('feedback', array('id' => $feedbackid)); if ($cm = get_coursemodule_from_instance("feedback", $feedback->id, $feedback->course)) { $cmid = $cm->id; } } //check if an false value even the value is not required if ($highlightrequire and !$this->check_value($value, $item)) { $falsevalue = true; } else { $falsevalue = false; } if ($falsevalue) { $highlight = 'missingrequire'; } else { $highlight = ''; } $requiredmark = '<span class="feedback_required_mark">*</span>'; if (isset($SESSION->feedback->captchacheck) and $SESSION->feedback->captchacheck == $USER->sesskey and $value == $USER->sesskey) { //print the question and label echo '<div class="feedback_item_label_' . $align . '">'; echo '(' . $item->label . ') '; echo format_text($item->name . $requiredmark, true, false, false); echo '<input type="hidden" value="' . $USER->sesskey . '" name="' . $item->typ . '_' . $item->id . '" />'; echo '</div>'; return; } $strincorrectpleasetryagain = get_string('incorrectpleasetryagain', 'auth'); $strenterthewordsabove = get_string('enterthewordsabove', 'auth'); $strenterthenumbersyouhear = get_string('enterthenumbersyouhear', 'auth'); $strgetanothercaptcha = get_string('getanothercaptcha', 'auth'); $strgetanaudiocaptcha = get_string('getanaudiocaptcha', 'auth'); $strgetanimagecaptcha = get_string('getanimagecaptcha', 'auth'); $recaptureoptions = array('theme' => 'custom', 'custom_theme_widget' => 'recaptcha_widget'); $html = html_writer::script(js_writer::set_variable('RecaptchaOptions', $recaptureoptions)); $html .= ' <div class="' . $highlight . '" id="recaptcha_widget" style="display:none"> <div id="recaptcha_image"></div> <div class="recaptcha_only_if_incorrect_sol" style="color:red">' . $strincorrectpleasetryagain . '</div> <span class="recaptcha_only_if_image"><label for="recaptcha_response_field">' . $strenterthewordsabove . $requiredmark . '</label></span> <span class="recaptcha_only_if_audio"><label for="recaptcha_response_field">' . $strenterthenumbersyouhear . '</label></span> <input type="text" id="recaptcha_response_field" name="' . $item->typ . '_' . $item->id . '" /> <div><a href="javascript:Recaptcha.reload()">' . $strgetanothercaptcha . '</a></div> <div class="recaptcha_only_if_image"><a href="javascript:Recaptcha.switch_type(\'audio\')">' . $strgetanaudiocaptcha . '</a></div> <div class="recaptcha_only_if_audio"><a href="javascript:Recaptcha.switch_type(\'image\')">' . $strgetanimagecaptcha . '</a></div> </div>'; //we have to rename the challengefield $captchahtml = recaptcha_get_html($CFG->recaptchapublickey, NULL); echo $html . $captchahtml; }
/** * Generate any HTML that needs to go at the end of the page. * * Normally, this method is called automatically by the code that prints the * page footer. You should not normally need to call it in your own code. * * @return string the HTML code to to at the end of the page. */ public function get_end_code() { global $CFG; $output = ''; // Set the log level for the JS logging. $logconfig = new stdClass(); $logconfig->level = 'warn'; if ($CFG->debugdeveloper) { $logconfig->level = 'trace'; } $this->js_call_amd('core/log', 'setConfig', array($logconfig)); // Call amd init functions. $output .= $this->get_amd_footercode(); // Add other requested modules. $output .= $this->get_extra_modules_code(); $this->js_init_code('M.util.js_complete("init");', true); // All the other linked scripts - there should be as few as possible. if ($this->jsincludes['footer']) { foreach ($this->jsincludes['footer'] as $url) { $output .= html_writer::script('', $url); } } // Add all needed strings. // First add core strings required for some dialogues. $this->strings_for_js(array('confirm', 'yes', 'no', 'areyousure', 'closebuttontitle', 'unknownerror'), 'moodle'); if (!empty($this->stringsforjs)) { $strings = array(); foreach ($this->stringsforjs as $component => $v) { foreach ($v as $indentifier => $langstring) { $strings[$component][$indentifier] = $langstring->out(); } } $output .= html_writer::script(js_writer::set_variable('M.str', $strings)); } // Add variables. if ($this->jsinitvariables['footer']) { $js = ''; foreach ($this->jsinitvariables['footer'] as $data) { list($var, $value) = $data; $js .= js_writer::set_variable($var, $value, true); } $output .= html_writer::script($js); } $inyuijs = $this->get_javascript_code(false); $ondomreadyjs = $this->get_javascript_code(true); $jsinit = $this->get_javascript_init_code(); $handlersjs = $this->get_event_handler_code(); // There is a global Y, make sure it is available in your scope. $js = "(function() {{$inyuijs}{$ondomreadyjs}{$jsinit}{$handlersjs}})();"; $output .= html_writer::script($js); return $output; }