jquery.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. use dokuwiki\Cache\Cache;
  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. // MAIN
  9. header('Content-Type: application/javascript; charset=utf-8');
  10. jquery_out();
  11. /**
  12. * Delivers the jQuery JavaScript
  13. *
  14. * We do absolutely nothing fancy here but concatenating the different files
  15. * and handling conditional and gzipped requests
  16. *
  17. * uses cache or fills it
  18. */
  19. function jquery_out() {
  20. $cache = new Cache('jquery', '.js');
  21. $files = array(
  22. DOKU_INC . 'lib/scripts/jquery/jquery.min.js',
  23. DOKU_INC . 'lib/scripts/jquery/jquery-ui.min.js',
  24. );
  25. $cache_files = $files;
  26. $cache_files[] = __FILE__;
  27. // check cache age & handle conditional request
  28. // This may exit if a cache can be used
  29. $cache_ok = $cache->useCache(array('files' => $cache_files));
  30. http_cached($cache->cache, $cache_ok);
  31. $js = '';
  32. foreach($files as $file) {
  33. $js .= file_get_contents($file)."\n";
  34. }
  35. stripsourcemaps($js);
  36. http_cached_finish($cache->cache, $js);
  37. }