diff options
author | andi <andi@splitbrain.org> | 2005-04-19 20:56:03 +0200 |
---|---|---|
committer | andi <andi@splitbrain.org> | 2005-04-19 20:56:03 +0200 |
commit | ac83b9d8ee0da2839787d268e28b1bfe3066c1b7 (patch) | |
tree | 02dd400d04987c77c699a20b2ddf7c56336afd3c | |
parent | 71352def8211fd38eafe887a9ccd0e5365b34962 (diff) | |
download | rpg-ac83b9d8ee0da2839787d268e28b1bfe3066c1b7.tar.gz rpg-ac83b9d8ee0da2839787d268e28b1bfe3066c1b7.tar.bz2 |
fixes for the export
darcs-hash:20050419185603-9977f-4bc9a1ba1878436bd71795c5d7fec2a5582561bf.gz
-rw-r--r-- | inc/actions.php | 36 | ||||
-rw-r--r-- | inc/html.php | 2 | ||||
-rw-r--r-- | inc/parser/xhtml.php | 2 | ||||
-rw-r--r-- | inc/parserutils.php | 18 |
4 files changed, 40 insertions, 18 deletions
diff --git a/inc/actions.php b/inc/actions.php index 7ed171dfb..be44471d4 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -45,7 +45,7 @@ function act_dispatch(){ } //handle export - if(substr($ACT,0,6) == 'export') + if(substr($ACT,0,7) == 'export_') $ACT = act_export($ACT); //display some infos @@ -85,18 +85,22 @@ function act_clean($act){ global $lang; global $conf; + //remove all bad chars + $act = strtolower($act); + $act = preg_replace('/[^a-z_]+/','',$act); + if($act == 'register' && !$conf['openregister']) return 'show'; if($act == $lang['btn_save']) $act = 'save'; if($act == $lang['btn_preview']) $act = 'preview'; if($act == $lang['btn_cancel']) $act = 'show'; - $act = strtolower($act); + if($act == 'export_html') $act = 'export_xhtml'; if(array_search($act,array('login','logout','register','save','edit', - 'preview','export_raw','export_html', - 'search','show','check','index','revisions', - 'diff','recent','backlink','admin',)) === false){ + 'preview','search','show','check','index','revisions', + 'diff','recent','backlink','admin',)) === false + && substr($act,0,7) != 'export_' ) { msg('Unknown command: '.htmlspecialchars($act),-1); return 'show'; } @@ -213,25 +217,37 @@ function act_export($act){ global $ID; global $REV; - if($act == 'export_html'){ + // no renderer for this + if($act == 'export_raw'){ + header('Content-Type: text/plain; charset=utf-8'); + print rawWiki($ID,$REV); + exit; + } + + // html export #FIXME what about the template's style? + if($act == 'export_xhtml'){ header('Content-Type: text/html; charset=utf-8'); ptln('<html>'); ptln('<head>'); tpl_metaheaders(); ptln('</head>'); ptln('<body>'); - print parsedWiki($ID,$REV,false); + print p_wiki_xhtml($ID,$REV,false); ptln('</body>'); ptln('</html>'); exit; } - if($act == 'export_raw'){ - header('Content-Type: text/plain; charset=utf-8'); - print rawWiki($ID,$REV); + // try to run renderer #FIXME use cached instructions + $mode = substr($act,7); + $text = p_render($mode,p_get_instructions(rawWiki($ID,$REV))); + if(!is_null($text)){ + print $text; exit; } + + return 'show'; } diff --git a/inc/html.php b/inc/html.php index 435288688..42aba6965 100644 --- a/inc/html.php +++ b/inc/html.php @@ -276,7 +276,7 @@ function html_show($txt=''){ //PreviewHeader print p_locale_xhtml('preview'); print '<div class="preview">'; - print html_secedit(p_render_xhtml(p_get_instructions($txt)),$secedit); + print html_secedit(p_render('xhtml',p_get_instructions($txt)),$secedit); print '</div>'; }else{ diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index d85d04250..a4bfaa57d 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -23,7 +23,7 @@ require_once DOKU_INC . 'inc/parser/renderer.php'; /** * The Renderer */ -class Doku_Renderer_XHTML extends Doku_Renderer { +class Doku_Renderer_xhtml extends Doku_Renderer { var $doc = ''; diff --git a/inc/parserutils.php b/inc/parserutils.php index f8bec37c1..4e38e0162 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -30,7 +30,7 @@ function p_wiki_xhtml($id, $rev='', $excuse=true){ if($rev){ if(@file_exists($file)){ - $ret = p_render_xhtml(p_get_instructions(io_readfile($file))); //no caching on old revisions + $ret = p_render('xhtml',p_get_instructions(io_readfile($file))); //no caching on old revisions }elseif($excuse){ $ret = p_locale_xhtml('norev'); } @@ -86,7 +86,7 @@ function p_cached_xhtml($file){ $parsed = io_readfile($cache); $parsed .= "\n<!-- cachefile $cache used -->\n"; }else{ - $parsed = p_render_xhtml(p_cached_instructions($file)); //try to use cached instructions + $parsed = p_render('xhtml', p_cached_instructions($file)); //try to use cached instructions io_saveFile($cache,$parsed); //save cachefile $parsed .= "\n<!-- no cachefile used, but created -->\n"; @@ -208,17 +208,23 @@ function p_get_instructions($text){ } /** - * Renders a list of instruction to XHTML + * Renders a list of instruction to the specified output mode * * @author Harry Fuecks <hfuecks@gmail.com> * @author Andreas Gohr <andi@splitbrain.org> */ -function p_render_xhtml($instructions){ +function p_render($mode,$instructions){ if(is_null($instructions)) return ''; // Create the renderer - require_once DOKU_INC . 'inc/parser/xhtml.php'; - $Renderer = & new Doku_Renderer_XHTML(); + if(!@file_exists(DOKU_INC."inc/parser/$mode.php")){ + msg("No renderer for $mode found",-1); + return null; + } + + require_once DOKU_INC."inc/parser/$mode.php"; + $rclass = "Doku_Renderer_$mode"; + $Renderer = & new $rclass(); #FIXME any way to check for class existance? $Renderer->smileys = getSmileys(); $Renderer->entities = getEntities(); |