From 78a6aeb15ad85c8be4a7e39307b7d9aa0512742c Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 29 Oct 2005 20:52:22 +0200 Subject: More work on Javascript and CSS dispatchers darcs-hash:20051029185222-7ad00-c184ab3496539f3027407c7d17e8770a1849546a.gz --- inc/init.php | 4 +++ inc/pluginutils.php | 2 ++ inc/template.php | 94 ++++------------------------------------------------- inc/toolbar.php | 37 +++++++++++++-------- 4 files changed, 35 insertions(+), 102 deletions(-) (limited to 'inc') diff --git a/inc/init.php b/inc/init.php index 41363f63d..44154a039 100644 --- a/inc/init.php +++ b/inc/init.php @@ -42,6 +42,10 @@ if(!defined('DOKU_TPL')) define('DOKU_TPL', DOKU_BASE.'lib/tpl/'.$conf['template'].'/'); + // define real Template directory + if(!defined('DOKU_TPLINC')) define('DOKU_TPLINC', + DOKU_INC.'lib/tpl/'.$conf['template'].'/'); + // make session rewrites XHTML compliant @ini_set('arg_separator.output', '&'); diff --git a/inc/pluginutils.php b/inc/pluginutils.php index d35b0dbc2..4c81f9abb 100644 --- a/inc/pluginutils.php +++ b/inc/pluginutils.php @@ -8,6 +8,8 @@ /** * prints needed HTML to include plugin CSS and JS files + * + * @deprecated - now handled by the style and script loader in lib/exe */ function plugin_printCSSJS(){ global $conf; diff --git a/inc/template.php b/inc/template.php index 7401c3e62..be0d2f193 100644 --- a/inc/template.php +++ b/inc/template.php @@ -176,7 +176,6 @@ function tpl_metaheaders(){ ptln('',$it); ptln('',$it); ptln('',$it); - ptln('',$it); // setup robot tags apropriate for different modes if( ($ACT=='show' || $ACT=='export_html') && !$REV){ @@ -195,97 +194,16 @@ function tpl_metaheaders(){ ptln('',$it); } -/* - - // include some JavaScript language strings #FIXME still needed? - ptln('',$it); - - // load the default JavaScript files - ptln('',$it); - ptln('',$it); - ptln('',$it); - ptln('',$it); - - - // dom tool tip library, for insitu footnotes - ptln('',$it); - ptln('',$it); - - ptln('',$it); - - // editing functions - if($ACT=='edit' || $ACT=='preview'){ - // add size control - ptln('',$it); - - if($INFO['writable']){ - // load toolbar functions - ptln('',$it); - - // load spellchecker functions if wanted - if($conf['spellchecker']){ - ptln('',$it+2); - } - - ptln('',$it); - } - } -*/ + // load stylesheets + ptln('',$it); + ptln('',$it); + // load javascript $js_edit = ($ACT=='edit' || $ACT=='preview') ? 1 : 0; $js_write = ($INFO['writable']) ? 1 : 0; - + $js_sig = ($conf['useacl'] && $_SERVER['REMOTE_USER']) ? 1 : 0; ptln('',$it); - - - // plugin stylesheets and Scripts - plugin_printCSSJS(); + DOKU_BASE.'lib/exe/js.php?edit='.$js_edit.'&write='.$js_write.'&sig='.$js_sig.'">',$it); } /** diff --git a/inc/toolbar.php b/inc/toolbar.php index aa52868d0..27e91ee47 100644 --- a/inc/toolbar.php +++ b/inc/toolbar.php @@ -164,17 +164,6 @@ function toolbar_JSdefines($varname){ ), ); - // if logged in add sig button - if($conf['useacl'] && $_SERVER['REMOTE_USER']){ - $menu[] = array( - 'type' => 'insert', - 'title' => $lang['qb_sig'], - 'icon' => 'sig.png', - 'key' => 'y', - 'insert' => toolbar_signature(), - ); - } - // use JSON to build the JavaScript array $json = new JSON(); print "var $varname = ".$json->encode($menu).";\n"; @@ -187,16 +176,36 @@ function toolbar_JSdefines($varname){ */ function toolbar_signature(){ global $conf; - global $INFO; $sig = $conf['signature']; $sig = strftime($sig); $sig = str_replace('@USER@',$_SERVER['REMOTE_USER'],$sig); - $sig = str_replace('@NAME@',$INFO['userinfo']['name'],$sig); - $sig = str_replace('@MAIL@',$INFO['userinfo']['mail'],$sig); + $sig = str_replace('@NAME@',$_SESSION[$conf[title]]['auth']['info']['name'],$sig); + $sig = str_replace('@MAIL@',$_SESSION[$conf[title]]['auth']['info']['mail'],$sig); $sig = str_replace('@DATE@',date($conf['dformat']),$sig); return $sig; } +/** + * Adds the signature button to the already prepared Javascript array + * @param string $varname Name of the JS variable to fill + * @author Andreas Gohr + */ +function toolbar_addsigbutton($varname){ + global $lang; + + $menu = array( + 'type' => 'insert', + 'title' => $lang['qb_sig'], + 'icon' => 'sig.png', + 'key' => 'y', + 'insert' => toolbar_signature(), + ); + // use JSON to build the JavaScript array + $json = new JSON(); + print $varname.'['.$varname.'.length] = '.$json->encode($menu).";\n"; + +} + //Setup VIM: ex: et ts=4 enc=utf-8 : -- cgit v1.2.3