xref: /dokuwiki/lib/exe/jquery.php (revision e3c3abf1ebade68a06abb03d098d58afda87b317)
161537d47SAndreas Gohr<?php
261537d47SAndreas Gohr
30db5771eSMichael Großeuse dokuwiki\Cache\Cache;
40db5771eSMichael Große
5*e3c3abf1SAndreas Gohrif(!defined('DOKU_INC')) define('DOKU_INC', __DIR__ . '/../../');
661537d47SAndreas Gohrif(!defined('NOSESSION')) define('NOSESSION', true); // we do not use a session or authentication here (better caching)
761537d47SAndreas Gohrif(!defined('NL')) define('NL', "\n");
861537d47SAndreas Gohrif(!defined('DOKU_DISABLE_GZIP_OUTPUT')) define('DOKU_DISABLE_GZIP_OUTPUT', 1); // we gzip ourself here
961537d47SAndreas Gohrrequire_once(DOKU_INC . 'inc/init.php');
1061537d47SAndreas Gohr
1161537d47SAndreas Gohr// MAIN
1232594b01SAndreas Gohrheader('Content-Type: application/javascript; charset=utf-8');
1361537d47SAndreas Gohrjquery_out();
1461537d47SAndreas Gohr
1561537d47SAndreas Gohr/**
1661537d47SAndreas Gohr * Delivers the jQuery JavaScript
1761537d47SAndreas Gohr *
1861537d47SAndreas Gohr * We do absolutely nothing fancy here but concatenating the different files
1961537d47SAndreas Gohr * and handling conditional and gzipped requests
2061537d47SAndreas Gohr *
2161537d47SAndreas Gohr * uses cache or fills it
2261537d47SAndreas Gohr */
2361537d47SAndreas Gohrfunction jquery_out() {
240db5771eSMichael Große    $cache = new Cache('jquery', '.js');
25*e3c3abf1SAndreas Gohr    $files = [
2661537d47SAndreas Gohr        DOKU_INC . 'lib/scripts/jquery/jquery.min.js',
27*e3c3abf1SAndreas Gohr        DOKU_INC . 'lib/scripts/jquery/jquery-ui.min.js'
28*e3c3abf1SAndreas Gohr    ];
2961537d47SAndreas Gohr    $cache_files = $files;
3061537d47SAndreas Gohr    $cache_files[] = __FILE__;
3161537d47SAndreas Gohr
3261537d47SAndreas Gohr    // check cache age & handle conditional request
3361537d47SAndreas Gohr    // This may exit if a cache can be used
34*e3c3abf1SAndreas Gohr    $cache_ok = $cache->useCache(['files' => $cache_files]);
3561537d47SAndreas Gohr    http_cached($cache->cache, $cache_ok);
3661537d47SAndreas Gohr
3761537d47SAndreas Gohr    $js = '';
3861537d47SAndreas Gohr    foreach($files as $file) {
3961537d47SAndreas Gohr        $js .= file_get_contents($file)."\n";
4061537d47SAndreas Gohr    }
4161537d47SAndreas Gohr    stripsourcemaps($js);
4261537d47SAndreas Gohr
4361537d47SAndreas Gohr    http_cached_finish($cache->cache, $js);
4461537d47SAndreas Gohr}
45