* @author Michael Klier * @inheritdoc */ public function preProcess() { global $ID; global $REV; global $conf; global $lang; $pre = ''; $post = ''; $headers = array(); // search engines: never cache exported docs! (Google only currently) $headers['X-Robots-Tag'] = 'noindex'; $mode = substr($this->actionname, 7); switch($mode) { case 'raw': $headers['Content-Type'] = 'text/plain; charset=utf-8'; $headers['Content-Disposition'] = 'attachment; filename=' . noNS($ID) . '.txt'; $output = rawWiki($ID, $REV); break; case 'xhtml': $pre .= '' . DOKU_LF; $pre .= '' . DOKU_LF; $pre .= '' . DOKU_LF; $pre .= ' ' . DOKU_LF; // FIXME improve wrapper $pre .= ' ' . $ID . '' . DOKU_LF; // get metaheaders ob_start(); tpl_metaheaders(); $pre .= ob_get_clean(); $pre .= '' . DOKU_LF; $pre .= '' . DOKU_LF; $pre .= '
' . DOKU_LF; // get toc $pre .= tpl_toc(true); $headers['Content-Type'] = 'text/html; charset=utf-8'; $output = p_wiki_xhtml($ID, $REV, false); $post .= '
' . DOKU_LF; $post .= '' . DOKU_LF; $post .= '' . DOKU_LF; break; case 'xhtmlbody': $headers['Content-Type'] = 'text/html; charset=utf-8'; $output = p_wiki_xhtml($ID, $REV, false); break; default: $output = p_cached_output(wikiFN($ID, $REV), $mode, $ID); $headers = p_get_metadata($ID, "format $mode"); break; } // prepare event data $data = array(); $data['id'] = $ID; $data['mode'] = $mode; $data['headers'] = $headers; $data['output'] =& $output; trigger_event('ACTION_EXPORT_POSTPROCESS', $data); if(!empty($data['output'])) { if(is_array($data['headers'])) foreach($data['headers'] as $key => $val) { header("$key: $val"); } print $pre . $data['output'] . $post; exit; } throw new ActionAbort(); } }