예제 #1
0
/**
 * Initialise a {@link page_requirements_manager} with the bits of JavaScript that every
 * Moodle page should have.
 *
 * @param page_requirements_manager $requires The page_requirements_manager to initialise.
 */
function setup_core_javascript(page_requirements_manager $requires)
{
    global $CFG, $OUTPUT;
    // JavaScript should always work with $CFG->httpswwwroot rather than $CFG->wwwroot.
    // Otherwise, in some situations, users will get warnings about insecure content
    // on sercure pages from their web browser.
    $config = array('wwwroot' => $CFG->httpswwwroot, 'sesskey' => sesskey(), 'loadingicon' => $OUTPUT->old_icon_url('i/loading_small'));
    if (debugging('', DEBUG_DEVELOPER)) {
        $config['developerdebug'] = true;
    }
    $requires->data_for_js('moodle_cfg', $config)->in_head();
    if (debugging('', DEBUG_DEVELOPER)) {
        $requires->yui_lib('logger');
    }
    $requires->skip_link_to('maincontent', get_string('tocontent', 'access'));
    // Note that, as a short-cut, the code
    // $js = "document.body.className += ' jsenabled';\n";
    // is hard-coded in {@link page_requirements_manager::get_top_of_body_code)
    $requires->yui_lib('container');
    $requires->yui_lib('connection');
    $requires->string_for_js('confirmation', 'admin');
    $requires->string_for_js('cancel', 'moodle');
    $requires->string_for_js('yes', 'moodle');
    $requires->js_function_call('init_help_icons');
}
 /**
  * Page fragment constructor.
  */
 public function __construct()
 {
     parent::__construct();
     // As this is a fragment the header should already be done.
     $this->headdone = true;
 }
예제 #3
0
 /**
  * Add the block of text to the page requires so it is appended in the footer. The
  * content of the block can contain further mustache tags which will be resolved.
  *
  * @param string $text The script content of the section.
  * @param \Mustache_LambdaHelper $helper Used to render the content of this block.
  */
 public function help($text, \Mustache_LambdaHelper $helper)
 {
     $this->requires->js_amd_inline($helper->render($text));
 }