Esempio n. 1
0
if ($rev > 0 and file_exists($candidate)) {
    if (!empty($_SERVER['HTTP_IF_NONE_MATCH']) || !empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
        // we do not actually need to verify the etag value because our files
        // never change in cache because we increment the rev parameter
        js_send_unmodified(filemtime($candidate), $etag);
    }
    js_send_cached($candidate, $etag);
}
//=================================================================================
// ok, now we need to start normal moodle script, we need to load all libs and $DB
define('ABORT_AFTER_CONFIG_CANCEL', true);
define('NO_MOODLE_COOKIES', true);
// Session not used here
define('NO_UPGRADE_CHECK', true);
// Ignore upgrade check
require "{$CFG->dirroot}/lib/setup.php";
$theme = theme_config::load($themename);
$themerev = theme_get_revision();
if ($themerev <= 0 or $rev != $themerev) {
    // Do not send caching headers if they do not request current revision,
    // we do not want to pollute browser caches with outdated JS.
    js_send_uncached($theme->javascript_content($type));
}
make_localcache_directory('theme', false);
js_write_cache_file_content($candidate, core_minify::js_files($theme->javascript_files($type)));
// Verify nothing failed in cache file creation.
clearstatcache();
if (file_exists($candidate)) {
    js_send_cached($candidate, $etag);
}
js_send_uncached($theme->javascript_content($type));
Esempio n. 2
0
    }
    $result[$parts[0]][$parts[1]] = $value;
}
// Add subplugin strings, accept only those with proper pluginname prefix with colon.
foreach (get_plugin_list('tinymce') as $component => $ignored) {
    $componentstrings = get_string_manager()->load_component_strings('tinymce_' . $component, $lang);
    foreach ($componentstrings as $key => $value) {
        if (strpos($key, "{$component}:") !== 0) {
            // Ignore normal lang strings.
            continue;
        }
        $parts = explode(':', $key);
        if (count($parts) != 2) {
            // Ignore malformed strings with more colons.
            continue;
        }
        $component = $parts[0];
        $string = $parts[1];
        $result[$component][$string] = $value;
    }
}
$output = 'tinyMCE.addI18n({' . $lang . ':' . json_encode($result) . '});';
if ($rev > -1) {
    js_write_cache_file_content($candidate, $output);
    // verify nothing failed in cache file creation
    clearstatcache();
    if (file_exists($candidate)) {
        js_send_cached($candidate, $etag, 'all_strings.php');
    }
}
js_send_uncached($output, 'all_strings.php');
Esempio n. 3
0
        }
        $content = '';
        foreach ($jsfiles as $modulename => $jsfile) {
            $js = file_get_contents($jsfile) . "\n";
            // Inject the module name into the define.
            $replace = 'define(\'' . $modulename . '\', ';
            $search = 'define(';
            // Replace only the first occurrence.
            $js = implode($replace, explode($search, $js, 2));
            $content .= $js;
        }
        js_write_cache_file_content($candidate, $content);
        // Verify nothing failed in cache file creation.
        clearstatcache();
        if (file_exists($candidate)) {
            js_send_cached($candidate, $etag, 'requirejs.php');
            exit(0);
        }
    }
}
if ($lazyload) {
    $jsfiles = core_requirejs::find_one_amd_module($component, $module, true);
} else {
    $jsfiles = core_requirejs::find_all_amd_modules(true);
}
$content = '';
foreach ($jsfiles as $modulename => $jsfile) {
    $shortfilename = str_replace($CFG->dirroot, '', $jsfile);
    $js = "// ---- {$shortfilename} ----\n";
    $js .= file_get_contents($jsfile) . "\n";
    // Inject the module name into the define.