Completed
Push — jqsplit ( 61537d )
by Andreas
09:41 queued 06:29
created

jquery.php ➔ jquery_out()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 23
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 15
nc 2
nop 0
dl 0
loc 23
rs 9.0856
c 0
b 0
f 0
1
<?php
2
3
if(!defined('DOKU_INC')) define('DOKU_INC', dirname(__FILE__) . '/../../');
4
if(!defined('NOSESSION')) define('NOSESSION', true); // we do not use a session or authentication here (better caching)
5
if(!defined('NL')) define('NL', "\n");
6
if(!defined('DOKU_DISABLE_GZIP_OUTPUT')) define('DOKU_DISABLE_GZIP_OUTPUT', 1); // we gzip ourself here
7
require_once(DOKU_INC . 'inc/init.php');
8
9
// MAIN
10
jquery_out();
11
12
/**
13
 * Delivers the jQuery JavaScript
14
 *
15
 * We do absolutely nothing fancy here but concatenating the different files
16
 * and handling conditional and gzipped requests
17
 *
18
 * uses cache or fills it
19
 */
20
function jquery_out() {
21
    $cache = new cache('jquery', '.js');
22
    $files = array(
23
        DOKU_INC . 'lib/scripts/jquery/jquery.min.js',
24
        DOKU_INC . 'lib/scripts/jquery/jquery-ui.min.js',
25
        DOKU_INC . 'lib/scripts/jquery/jquery-migrate.min.js',
26
    );
27
    $cache_files = $files;
28
    $cache_files[] = __FILE__;
29
30
    // check cache age & handle conditional request
31
    // This may exit if a cache can be used
32
    $cache_ok = $cache->useCache(array('files' => $cache_files));
33
    http_cached($cache->cache, $cache_ok);
34
35
    $js = '';
36
    foreach($files as $file) {
37
        $js .= file_get_contents($file)."\n";
38
    }
39
    stripsourcemaps($js);
40
41
    http_cached_finish($cache->cache, $js);
42
}
43