xref: /dokuwiki/lib/exe/jquery.php (revision 5a5ec053461c2401bdae52ca4bc4bec1245d79d9)
161537d47SAndreas Gohr<?php
261537d47SAndreas Gohr
30db5771eSMichael Großeuse dokuwiki\Cache\Cache;
40db5771eSMichael Große
5e3c3abf1SAndreas 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 */
23*d868eb89SAndreas Gohrfunction jquery_out()
24*d868eb89SAndreas Gohr{
250db5771eSMichael Große    $cache = new Cache('jquery', '.js');
26e3c3abf1SAndreas Gohr    $files = [
2761537d47SAndreas Gohr        DOKU_INC . 'lib/scripts/jquery/jquery.min.js',
28e3c3abf1SAndreas Gohr        DOKU_INC . 'lib/scripts/jquery/jquery-ui.min.js'
29e3c3abf1SAndreas Gohr    ];
3061537d47SAndreas Gohr    $cache_files = $files;
3161537d47SAndreas Gohr    $cache_files[] = __FILE__;
3261537d47SAndreas Gohr
3361537d47SAndreas Gohr    // check cache age & handle conditional request
3461537d47SAndreas Gohr    // This may exit if a cache can be used
35e3c3abf1SAndreas Gohr    $cache_ok = $cache->useCache(['files' => $cache_files]);
3661537d47SAndreas Gohr    http_cached($cache->cache, $cache_ok);
3761537d47SAndreas Gohr
3861537d47SAndreas Gohr    $js = '';
3961537d47SAndreas Gohr    foreach ($files as $file) {
4061537d47SAndreas Gohr        $js .= file_get_contents($file) . "\n";
4161537d47SAndreas Gohr    }
4261537d47SAndreas Gohr    stripsourcemaps($js);
4361537d47SAndreas Gohr
4461537d47SAndreas Gohr    http_cached_finish($cache->cache, $js);
4561537d47SAndreas Gohr}
46