/** * This function generates the code that defines the standard moodle_cfg object. * This object has a number of fields that are values that various pieces of * JavaScript code need access too. For example $CFG->wwwroot and $CFG->pixpath. * * @return string a <script> tag that defines the moodle_cfg object. */ function standard_js_config() { global $CFG; $config = array('wwwroot' => $CFG->httpswwwroot, 'pixpath' => $CFG->pixpath, 'modpixpath' => $CFG->modpixpath, 'sesskey' => sesskey()); if (debugging('', DEBUG_DEVELOPER)) { $config['developerdebug'] = true; } return print_js_config($config, 'moodle_cfg', true); }
/** * @return string An inline script that creates a JavaScript object storing * various strings and bits of configuration that the scripts in qengine.js need * to get from PHP. */ function question_init_qenginejs_script() { global $CFG; $config = array('pixpath' => $CFG->pixpath, 'wwwroot' => $CFG->wwwroot, 'flagtooltip' => get_string('clicktoflag', 'question'), 'unflagtooltip' => get_string('clicktounflag', 'question'), 'flaggedalt' => get_string('flagged', 'question'), 'unflaggedalt' => get_string('notflagged', 'question')); return print_js_config($config, 'qengine_config', true); }
<link rel="stylesheet" type="text/css" href="<?php echo $CFG->httpswwwroot; ?> /lib/yui/resize/assets/skins/sam/resize.css" /> <link rel="stylesheet" type="text/css" href="<?php echo $CFG->httpswwwroot; ?> /lib/yui/layout/assets/skins/sam/layout.css" /> <link rel="stylesheet" type="text/css" href="<?php echo $CFG->httpswwwroot; ?> /lib/yui/button/assets/skins/sam/button.css" /> <?php print_js_config(array('home' => $CFG->httpswwwroot . '/mod/chat/view.php?id=' . $cm->id, 'userid' => $USER->id, 'sid' => $chat_sid, 'timer' => 5000, 'chat_lasttime' => 0, 'chat_lastrow' => null, 'header_title' => $str_chat, 'chatroom_name' => $str_title), 'chat_cfg'); print_js_config(array('send' => $str_send, 'sending' => $str_sending, 'inputarea' => $str_inputarea, 'userlist' => $str_userlist), 'chat_lang'); ?> <script type="text/javascript" src="<?php echo $CFG->httpswwwroot; ?> /lib/yui/yahoo-dom-event/yahoo-dom-event.js"></script> <script type="text/javascript" src="<?php echo $CFG->httpswwwroot; ?> /lib/yui/element/element-beta-min.js"></script> <script type="text/javascript" src="<?php echo $CFG->httpswwwroot; ?> /lib/yui/dragdrop/dragdrop-min.js"></script> <script type="text/javascript" src="<?php echo $CFG->httpswwwroot;
$strupdatemodule = has_capability('moodle/course:manageactivities', $contexts->lowest()) ? update_module_button($cm->id, $course->id, get_string('modulename', 'quiz')) : ""; $navigation = build_navigation($pagetitle, $cm); $localcss = '<link rel="stylesheet" type="text/css" href="' . $CFG->wwwroot . '/lib/yui/container/assets/container.css" />'; print_header_simple($pagetitle, '', $navigation, "", $localcss, true, $questionbankmanagement . $strupdatemodule); //TODO: these skip links really need to be right after the opening of the body element, // and preferably implemented in an <ul> element. See MDL-17730. echo '<a href="#questionbank" class="skip">Question bank</a> ' . '<a href="#quizcontentsblock" class="skip">Quiz contents</a>'; // Initialise the JavaScript. $quizeditconfig = new stdClass(); $quizeditconfig->url = $thispageurl->out(false, array('qbanktool' => '0')); $quizeditconfig->dialoglisteners = array(); $numberoflisteners = max(quiz_number_of_pages($quiz->questions), 1); for ($pageiter = 1; $pageiter <= $numberoflisteners; $pageiter++) { $quizeditconfig->dialoglisteners[] = 'addrandomdialoglaunch_' . $pageiter; } print_js_config($quizeditconfig, 'quiz_edit_config'); require_js('mod/quiz/edit.js'); // Print the tabs. $currenttab = 'edit'; $mode = 'editq'; if ($quiz_reordertool) { $mode = 'reorder'; } include 'tabs.php'; if ($quiz_qbanktool) { $bankclass = ''; $quizcontentsclass = ''; } else { $bankclass = 'collapsed'; $quizcontentsclass = 'quizwhenbankcollapsed'; }
// The "Editing On" button will be appearing only in the "main" course screen // (i.e., no breadcrumbs other than the default one added inside this function) $buttons = switchroles_form($course->id); if ($PAGE->user_allowed_editing()) { $buttons .= update_course_icon($course->id); } $title = get_string('course') . ': ' . $course->fullname; $navigation = build_navigation(array()); print_header($title, $course->fullname, $navigation, '', '', true, $buttons, user_login_string($course, $USER), false, $bodytags); $completion = new completion_info($course); if ($completion->is_enabled() && ajaxenabled()) { require_js(array('yui_yahoo', 'yui_event', 'yui_connection', 'yui_dom')); // Need to do this after the header because it requires the YUI stuff // to be loaded already require_js('course/completion.js'); print_js_config(array('completion_strsaved' => get_string('saved', 'completion'), 'completion_strtitley' => get_string('completion-title-manual-y', 'completion'), 'completion_strtitlen' => get_string('completion-title-manual-n', 'completion'), 'completion_stralty' => get_string('completion-alt-manual-y', 'completion'), 'completion_straltn' => get_string('completion-alt-manual-n', 'completion'))); // This value tracks whether there has been a dynamic change to the page. // It is used so that if a user does this - (a) set some tickmarks, (b) // go to another page, (c) clicks Back button - the page will // automatically reload. Otherwise it would start with the wrong tick // values. print '<form action="."><div><input type="hidden" id="completion_dynamic_change" name="completion_dynamic_change" value="0" /></div></form>'; } // Course wrapper start. echo '<div class="course-content">'; $modinfo =& get_fast_modinfo($COURSE); get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused); foreach ($mods as $modid => $unused) { if (!isset($modinfo->cms[$modid])) { rebuild_course_cache($course->id);
/** * Return javascript to create file picker to browse repositories * @global object $CFG * @global object $USER * @param object $context the context * @param string $id unique id for every file picker * @param string $accepted_filetypes * @param string $returnvalue the return value of file picker * @return array */ function repository_get_client($context, $id = '', $accepted_filetypes = '*', $returnvalue = '*') { global $CFG, $USER; $ft = new file_type_to_ext(); $image_file_ext = json_encode($ft->get_file_ext(array('image'))); $video_file_ext = json_encode($ft->get_file_ext(array('video'))); $accepted_file_ext = json_encode($ft->get_file_ext($accepted_filetypes)); $css = ''; $js = ''; if (!isset($CFG->filepickerjsloaded)) { $css .= <<<EOD <style type="text/css"> @import "{$CFG->httpswwwroot}/lib/yui/resize/assets/skins/sam/resize.css"; @import "{$CFG->httpswwwroot}/lib/yui/container/assets/skins/sam/container.css"; @import "{$CFG->httpswwwroot}/lib/yui/layout/assets/skins/sam/layout.css"; @import "{$CFG->httpswwwroot}/lib/yui/button/assets/skins/sam/button.css"; @import "{$CFG->httpswwwroot}/lib/yui/assets/skins/sam/treeview.css"; </style> <style type="text/css"> /* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */ /* copy from yui/examples/treeview/assets/css/folders/tree.css */ /* first or middle sibling, no children */ .ygtvtn { background: url({$CFG->pixpath}/y/tn.gif) 0 0 no-repeat; width:17px; height:22px; } /* first or middle sibling, collapsable */ .ygtvtm { background: url({$CFG->pixpath}/y/tm.gif) 0 0 no-repeat; width:34px; height:22px; cursor:pointer } /* first or middle sibling, collapsable, hover */ .ygtvtmh { background: url({$CFG->pixpath}/y/tmh.gif) 0 0 no-repeat; width:34px; height:22px; cursor:pointer } /* first or middle sibling, expandable */ .ygtvtp { background: url({$CFG->pixpath}/y/tp.gif) 0 0 no-repeat; width:34px; height:22px; cursor:pointer } /* first or middle sibling, expandable, hover */ .ygtvtph { background: url({$CFG->pixpath}/y/tph.gif) 0 0 no-repeat; width:34px; height:22px; cursor:pointer } /* last sibling, no children */ .ygtvln { background: url({$CFG->pixpath}/y/ln.gif) 0 0 no-repeat; width:17px; height:22px; } /* Last sibling, collapsable */ .ygtvlm { background: url({$CFG->pixpath}/y/lm.gif) 0 0 no-repeat; width:34px; height:22px; cursor:pointer } /* Last sibling, collapsable, hover */ .ygtvlmh { background: url({$CFG->pixpath}/y/lmh.gif) 0 0 no-repeat; width:34px; height:22px; cursor:pointer } /* Last sibling, expandable */ .ygtvlp { background: url({$CFG->pixpath}/y/lp.gif) 0 0 no-repeat; width:34px; height:22px; cursor:pointer } /* Last sibling, expandable, hover */ .ygtvlph { background: url({$CFG->pixpath}/y/lph.gif) 0 0 no-repeat; width:34px; height:22px; cursor:pointer } /* Loading icon */ .ygtvloading { background: url({$CFG->pixpath}/y/loading.gif) 0 0 no-repeat; width:16px; height:22px; } /* the style for the empty cells that are used for rendering the depth * of the node */ .ygtvdepthcell { background: url({$CFG->pixpath}/y/vline.gif) 0 0 no-repeat; width:17px; height:22px; } .ygtvblankdepthcell { width:17px; height:22px; } /* the style of the div around each node */ .ygtvitem { } .ygtvitem table{ margin-bottom:0; } .ygtvitem td { border:none;padding:0; } /* the style of the div around each node's collection of children */ .ygtvchildren { } * html .ygtvchildren { height:1%; } /* the style of the text label in ygTextNode */ .ygtvlabel, .ygtvlabel:link, .ygtvlabel:visited, .ygtvlabel:hover { margin-left:2px; text-decoration: none; } .file-picker{font-size:12px;} .file-picker strong{background:#FFFFCC} .file-picker a{color: #336699} .file-picker a:hover{background:#003366;color:white} .fp-panel{padding:0;margin:0; text-align:left;} .fp-login-form{text-align:center} .fp-searchbar{float:right} .fp-viewbar{width:300px;float:left} .fp-toolbar{padding: .8em;background: #FFFFCC;color:white;text-align:center;margin: 3px} .fp-toolbar a{padding: 0 .5em} .fp-list{list-style-type:none;padding:0;float:left;width:100%;margin:0;} .fp-list li{border-bottom:1px dotted gray;margin-bottom: 1em;} .fp-repo-name{display:block;padding: .5em;margin-bottom: .5em} .fp-pathbar{margin: .4em;border-bottom: 1px dotted gray;} .fp-pathbar a{padding: .4em;} .fp-rename-form{text-align:center} .fp-rename-form p{margin: 1em;} .fp-upload-form{margin: 2em 0;text-align:center} .fp-upload-btn a{cursor: default;background: white;border:1px solid gray;color:black;padding: .5em} .fp-upload-btn a:hover {background: grey;color:white} .fp-paging{margin:1em .5em; clear:both;text-align:center;line-height: 2.5em;} .fp-paging a{padding: .5em;border: 1px solid #CCC} .fp-paging a.cur_page{border: 1px solid blue} .fp-popup{text-align:center} .fp-grid{float:left;text-align:center;} .fp-grid div{overflow: hidden} .fp-grid p{margin:0;padding:0;background: #FFFFCC} .fp-grid .label{height:48px;text-align:center} .fp-grid span{color:gray} </style> <!--[if IE 6]> <style type="text/css"> /* Fix for IE6 */ .yui-skin-sam .yui-panel .hd{} </style> <![endif]--> EOD; require_js(array('yui_yahoo', 'yui_dom', 'yui_event', 'yui_element', 'yui_treeview', 'yui_dragdrop', 'yui_container', 'yui_resize', 'yui_layout', 'yui_connection', 'yui_json', 'yui_button', 'yui_selector', 'repository/repository.src.js')); $lang = array(); $lang['title'] = get_string('title', 'repository'); $lang['preview'] = get_string('preview', 'repository'); $lang['add'] = get_string('add', 'repository'); $lang['back'] = get_string('back', 'repository'); $lang['cancel'] = get_string('cancel'); $lang['close'] = get_string('close', 'repository'); $lang['ccache'] = get_string('cleancache', 'repository'); $lang['copying'] = get_string('copying', 'repository'); $lang['downbtn'] = get_string('getfile', 'repository'); $lang['download'] = get_string('downloadsucc', 'repository'); $lang['date'] = get_string('date', 'repository') . ': '; $lang['error'] = get_string('error', 'repository'); $lang['filenotnull'] = get_string('filenotnull', 'repository'); $lang['federatedsearch'] = get_string('federatedsearch', 'repository'); $lang['help'] = get_string('help'); $lang['refresh'] = get_string('refresh', 'repository'); $lang['invalidjson'] = get_string('invalidjson', 'repository'); $lang['listview'] = get_string('listview', 'repository'); $lang['login'] = get_string('login', 'repository'); $lang['logout'] = get_string('logout', 'repository'); $lang['loading'] = get_string('loading', 'repository'); $lang['thumbview'] = get_string('thumbview', 'repository'); $lang['title'] = get_string('title', 'repository'); $lang['noresult'] = get_string('noresult', 'repository'); $lang['mgr'] = get_string('manageurl', 'repository'); $lang['noenter'] = get_string('noenter', 'repository'); $lang['save'] = get_string('save', 'repository'); $lang['saveas'] = get_string('saveas', 'repository') . ': '; $lang['saved'] = get_string('saved', 'repository'); $lang['saving'] = get_string('saving', 'repository'); $lang['size'] = get_string('size', 'repository') . ': '; $lang['sync'] = get_string('sync', 'repository'); $lang['search'] = get_string('search', 'repository'); $lang['searching'] = get_string('searching', 'repository'); $lang['submit'] = get_string('submit', 'repository'); $lang['preview'] = get_string('preview', 'repository'); $lang['popup'] = get_string('popup', 'repository'); $lang['upload'] = get_string('upload', 'repository') . '...'; $lang['uploading'] = get_string('uploading', 'repository'); // fp_lang includes language strings $js .= print_js_config($lang, 'fp_lang', true); $options = array(); $context = get_system_context(); $options['contextid'] = $context->id; // fp_config includes filepicker options $js .= print_js_config($options, 'fp_config', true); $accepted_file_ext = json_encode($ft->get_file_ext($accepted_filetypes)); $js .= <<<EOD <script> file_extensions.image = {$image_file_ext}; file_extensions.media = {$video_file_ext}; </script> EOD; $CFG->filepickerjsloaded = true; } else { // if yui and repository javascript libs are loaded $js = ''; } // print instances listing $user_context = get_context_instance(CONTEXT_USER, $USER->id); if (is_array($accepted_filetypes) && in_array('*', $accepted_filetypes)) { $accepted_filetypes = '*'; } $repos = repository::get_instances(array($user_context, $context, get_system_context()), null, true, null, $accepted_filetypes, $returnvalue); // print repository instances listing $js .= <<<EOD <script> repository_listing['{$id}'] = {}; EOD; foreach ($repos as $repo) { $info = $repo->ajax_info(); $js .= "\r\n"; $js .= 'repository_listing[\'' . $id . '\'][\'' . $info->id . '\']=' . json_encode($repo->ajax_info()) . ';'; $js .= "\n"; } $js .= "\r\n"; $js .= "</script>"; return array('css' => $css, 'js' => $js); }