diff options
author | Andreas Gohr <andi@splitbrain.org> | 2007-05-14 00:24:21 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2007-05-14 00:24:21 +0200 |
commit | 3825ddd38bc5af4afc3ae1a1aea832dde69b21d1 (patch) | |
tree | d783913aee49c3e6432e483a15a69e69ab3371b6 | |
parent | 82938a26ac36e50371bf06400c2e3c86230f7317 (diff) | |
download | rpg-3825ddd38bc5af4afc3ae1a1aea832dde69b21d1.tar.gz rpg-3825ddd38bc5af4afc3ae1a1aea832dde69b21d1.tar.bz2 |
include_once support for javascript
The include syntax was changed and enhanced by a include_once statement.
Syntax:
/* DOKUWIKI:include somefile.js */
/* DOKUWIKI:include_once someotherfile.js */
Note: include_once uses the basename of the inlcuded file to determine if
it was previously loaded. You need to use something unique for it to
make sure it is correctly loaded.
Note: included files are not checked for updates by the cache logic. You
need to touch the master file for updating the cache
Note: includes are *not* supported inside included files to avoid any
circular references
darcs-hash:20070513222421-7ad00-d99d717ba8a428d0af2b3f7d593897e0467cb9c9.gz
-rw-r--r-- | lib/exe/js.php | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/exe/js.php b/lib/exe/js.php index ca9fc68a8..4b78ade4b 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -165,13 +165,24 @@ function js_out(){ /** * Load the given file, handle include calls and print it + * + * @author Andreas Gohr <andi@splitbrain.org> */ function js_load($file){ if(!@file_exists($file)) return; + static $loaded = array(); $data = io_readFile($file); - while(preg_match('#/\*\s*!!include\s+([\w\./]+)\s*\*/#',$data,$match)){ - $ifile = $match[1]; + while(preg_match('#/\*\s*DOKUWIKI:include(_once)\s+([\w\./]+)\s*\*/#',$data,$match)){ + $ifile = $match[2]; + + // is it a include_once? + if($match[1]){ + $base = basename($ifile); + if($loaded[$base]) continue; + $loaded[$base] = true; + } + if($ifile{0} != '/') $ifile = dirname($file).'/'.$ifile; if(@file_exists($ifile)){ |