diff options
Diffstat (limited to 'lib/exe/js.php')
-rw-r--r-- | lib/exe/js.php | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/lib/exe/js.php b/lib/exe/js.php index 81afaf053..ae6a6366f 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -6,7 +6,10 @@ * @author Andreas Gohr <andi@splitbrain.org> */ -if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../'); +use dokuwiki\Cache\Cache; +use dokuwiki\Extension\Event; + +if(!defined('DOKU_INC')) define('DOKU_INC', __DIR__ .'/../../'); if(!defined('NOSESSION')) define('NOSESSION',true); // we do not use a session or authentication here (better caching) if(!defined('NL')) define('NL',"\n"); if(!defined('DOKU_DISABLE_GZIP_OUTPUT')) define('DOKU_DISABLE_GZIP_OUTPUT',1); // we gzip ourself here @@ -73,11 +76,11 @@ function js_out(){ } // Let plugins decide to either put more scripts here or to remove some - trigger_event('JS_SCRIPT_LIST', $files); + Event::createAndTrigger('JS_SCRIPT_LIST', $files); // The generated script depends on some dynamic options - $cache = new cache('scripts'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'].md5(serialize($files)),'.js'); - $cache->_event = 'JS_CACHE_USE'; + $cache = new Cache('scripts'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'].md5(serialize($files)),'.js'); + $cache->setEvent('JS_CACHE_USE'); $cache_files = array_merge($files, getConfigFiles('main')); $cache_files[] = __FILE__; @@ -90,18 +93,21 @@ function js_out(){ // start output buffering and build the script ob_start(); - $json = new JSON(); // add some global variables print "var DOKU_BASE = '".DOKU_BASE."';"; print "var DOKU_TPL = '".tpl_basedir($tpl)."';"; - print "var DOKU_COOKIE_PARAM = " . $json->encode( + print "var DOKU_COOKIE_PARAM = " . json_encode( array( 'path' => empty($conf['cookiedir']) ? DOKU_REL : $conf['cookiedir'], 'secure' => $conf['securecookie'] && is_ssl() )).";"; // FIXME: Move those to JSINFO - print "Object.defineProperty(window, 'DOKU_UHN', { get: function() { console.warn('Using DOKU_UHN is deprecated. Please use JSINFO.useHeadingNavigation instead'); return JSINFO.useHeadingNavigation; } });"; - print "Object.defineProperty(window, 'DOKU_UHC', { get: function() { console.warn('Using DOKU_UHC is deprecated. Please use JSINFO.useHeadingContent instead'); return JSINFO.useHeadingContent; } });"; + print "Object.defineProperty(window, 'DOKU_UHN', { get: function() {". + "console.warn('Using DOKU_UHN is deprecated. Please use JSINFO.useHeadingNavigation instead');". + "return JSINFO.useHeadingNavigation; } });"; + print "Object.defineProperty(window, 'DOKU_UHC', { get: function() {". + "console.warn('Using DOKU_UHC is deprecated. Please use JSINFO.useHeadingContent instead');". + "return JSINFO.useHeadingContent; } });"; // load JS specific translations $lang['js']['plugins'] = js_pluginstrings(); @@ -109,7 +115,7 @@ function js_out(){ if(!empty($templatestrings)) { $lang['js']['template'] = $templatestrings; } - echo 'LANG = '.$json->encode($lang['js']).";\n"; + echo 'LANG = '.json_encode($lang['js']).";\n"; // load toolbar toolbar_JSdefines('toolbar'); @@ -170,7 +176,7 @@ function js_load($file){ // is it a include_once? if($match[1]){ - $base = utf8_basename($ifile); + $base = \dokuwiki\Utf8\PhpString::basename($ifile); if(array_key_exists($base, $loaded) && $loaded[$base] === true){ $data = str_replace($match[0], '' ,$data); continue; |