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