diff options
-rw-r--r-- | inc/template.php | 12 | ||||
-rw-r--r-- | inc/toolbar.php | 33 | ||||
-rw-r--r-- | lib/exe/css.php | 4 | ||||
-rw-r--r-- | lib/exe/js.php | 20 | ||||
-rw-r--r-- | lib/scripts/edit.js | 14 |
5 files changed, 34 insertions, 49 deletions
diff --git a/inc/template.php b/inc/template.php index 71bb64b4c..9fee928ae 100644 --- a/inc/template.php +++ b/inc/template.php @@ -201,9 +201,17 @@ function tpl_metaheaders(){ // 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; + if($js_edit && $js_write){ + ptln('<script language="javascript" type="text/javascript" charset="utf-8">',$it); + ptln("NS='".$INFO['namespace']."';",$it+2); + if($conf['useacl'] && $_SERVER['REMOTE_USER']){ + require_once('inc/toolbar.php'); + ptln("SIG='".toolbar_signature()."';",$it+2); + } + ptln('</script>',$it); + } ptln('<script language="javascript" type="text/javascript" charset="utf-8" src="'. - DOKU_BASE.'lib/exe/js.php?edit='.$js_edit.'&write='.$js_write.'&sig='.$js_sig.'"></script>',$it); + DOKU_BASE.'lib/exe/js.php?edit='.$js_edit.'&write='.$js_write.'"></script>',$it); } /** diff --git a/inc/toolbar.php b/inc/toolbar.php index 27e91ee47..29095f9e4 100644 --- a/inc/toolbar.php +++ b/inc/toolbar.php @@ -142,10 +142,10 @@ function toolbar_JSdefines($varname){ 'insert' => '----\n', ), array( - 'type' => 'popup', + 'type' => 'mediapopup', 'title' => $lang['qb_media'], 'icon' => 'image.png', - 'url' => DOKU_BASE.'lib/exe/media.php?ns='.getNS($ID), + 'url' => DOKU_BASE.'lib/exe/media.php?ns=', 'name' => 'mediaselect', 'options'=> 'width=600,height=320,left=70,top=50,scrollbars=yes,resizable=yes', ), @@ -162,6 +162,12 @@ function toolbar_JSdefines($varname){ 'icon' => 'chars.png', 'list' => explode(' ','À à Á á Â â Ã ã Ä ä Ǎ ǎ Ă ă Å å Ā ā Ą ą Æ æ Ć ć Ç ç Č č Ĉ ĉ Ċ ċ Ð đ ð Ď ď È è É é Ê ê Ë ë Ě ě Ē ē Ė ė Ę ę Ģ ģ Ĝ ĝ Ğ ğ Ġ ġ Ĥ ĥ Ì ì Í í Î î Ï ï Ǐ ǐ Ī ī İ ı Į į Ĵ ĵ Ķ ķ Ĺ ĺ Ļ ļ Ľ ľ Ł ł Ŀ ŀ Ń ń Ñ ñ Ņ ņ Ň ň Ò ò Ó ó Ô ô Õ õ Ö ö Ǒ ǒ Ō ō Ő ő Ø ø Ŕ ŕ Ŗ ŗ Ř ř Ś ś Ş ş Š š Ŝ ŝ Ţ ţ Ť ť Ù ù Ú ú Û û Ü ü Ǔ ǔ Ŭ ŭ Ū ū Ů ů ǖ ǘ ǚ ǜ Ų ų Ű ű Ŵ ŵ Ý ý Ÿ ÿ Ŷ ŷ Ź ź Ž ž Ż ż Þ þ ß Ħ ħ ¿ ¡ ¢ £ ¤ ¥ € ¦ § ª ¬ ¯ ° ± ÷ ‰ ¼ ½ ¾ ¹ ² ³ µ ¶ † ‡ · • º ∀ ∂ ∃ Ə ə ∅ ∇ ∈ ∉ ∋ ∏ ∑ ‾ − ∗ √ ∝ ∞ ∠ ∧ ∨ ∩ ∪ ∫ ∴ ∼ ≅ ≈ ≠ ≡ ≤ ≥ ⊂ ⊃ ⊄ ⊆ ⊇ ⊕ ⊗ ⊥ ⋅ ◊ ℘ ℑ ℜ ℵ ♠ ♣ ♥ ♦'), ), + array( + 'type' => 'signature', + 'title' => $lang['qb_sig'], + 'icon' => 'sig.png', + 'key' => 'y', + ), ); // use JSON to build the JavaScript array @@ -183,29 +189,8 @@ function toolbar_signature(){ $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); + $sig = str_replace('\\\\n','\\n',addslashes($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 <andi@splitbrain.org> - */ -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 : diff --git a/lib/exe/css.php b/lib/exe/css.php index 9874299b0..28c06ea47 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -104,8 +104,8 @@ function css_cacheok($cache,$files){ if(!$ctime) return false; //There is no cache // some additional files to check - $files[] = DOKU_CONF.'dokuwiki.conf'; - $files[] = DOKU_CONF.'local.conf'; + $files[] = DOKU_CONF.'dokuwiki.php'; + $files[] = DOKU_CONF.'local.php'; $files[] = DOKU_TPLINC.'style.ini'; $files[] = __FILE__; diff --git a/lib/exe/js.php b/lib/exe/js.php index b8b8c6401..2e3fe8238 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -16,7 +16,6 @@ require_once(DOKU_INC.'inc/io.php'); if(!defined('SIMPLE_TEST')){ header('Content-Type: text/javascript; charset=utf-8'); js_out(); - js_dynamicout(); } @@ -131,21 +130,6 @@ function js_out(){ } /** - * Adds some dynamic JavaScript using the readonly Session - * - * @author Andreas Gohr <andi@splitbrain.org> - */ -function js_dynamicout(){ - $edit = (bool) $_REQUEST['edit']; // edit or preview mode? - $write = (bool) $_REQUEST['write']; // writable? - $sig = (bool) $_REQUEST['sig']; // show sig button? - if($edit && $write && $sig){ - require_once(DOKU_INC.'inc/toolbar.php'); - toolbar_addsigbutton('toolbar'); - } -} - -/** * Checks if a JavaScript Cache file still is valid * * @author Andreas Gohr <andi@splitbrain.org> @@ -155,8 +139,8 @@ function js_cacheok($cache,$files){ if(!$ctime) return false; //There is no cache // some additional files to check - $files[] = DOKU_CONF.'dokuwiki.conf'; - $files[] = DOKU_CONF.'local.conf'; + $files[] = DOKU_CONF.'dokuwiki.php'; + $files[] = DOKU_CONF.'local.php'; $files[] = DOKU_CONF.'userscript.js'; $files[] = __FILE__; diff --git a/lib/scripts/edit.js b/lib/scripts/edit.js index 34bd8113d..cdfed0a84 100644 --- a/lib/scripts/edit.js +++ b/lib/scripts/edit.js @@ -128,7 +128,7 @@ function initToolbar(tbid,edid,tb){ if(!document.getElementById){ return; } var toolbar = document.getElementById(tbid); var cnt = tb.length; - for(i=0; i<cnt; i++){ + for(var i=0; i<cnt; i++){ // create new button and add to the toolbar btn = createToolButton(tb[i]['icon'], tb[i]['title'], @@ -154,6 +154,14 @@ function initToolbar(tbid,edid,tb){ jsEscape(tb[i]['insert'])+ "');return false;}"); break; + case 'signature': + if(SIG!=''){ + eval("btn.onclick = function(){insertAtCarret('"+ + jsEscape(edid)+"','"+ + jsEscape(SIG)+ + "');return false;}"); + } + break; case 'picker': createPicker('picker'+i, tb[i]['list'], @@ -162,9 +170,9 @@ function initToolbar(tbid,edid,tb){ eval("btn.onclick = function(){showPicker('picker"+i+ "',this);return false;}"); break; - case 'popup': + case 'mediapopup': eval("btn.onclick = function(){window.open('"+ - jsEscape(tb[i]['url'])+"','"+ + jsEscape(tb[i]['url']+NS)+"','"+ jsEscape(tb[i]['name'])+"','"+ jsEscape(tb[i]['options'])+ "');return false;}"); |