3 * A simple renderer that allows downloading of code and file snippets
5 * @author Andreas Gohr <andi@splitbrain.org>
7 if(!defined('DOKU_INC')) die('meh.');
8 require_once DOKU_INC
. 'inc/parser/renderer.php';
10 class Doku_Renderer_code
extends Doku_Renderer
{
14 * Send the wanted code block to the browser
16 * When the correct block was found it exits the script.
18 function code($text, $language = NULL, $filename='' ) {
19 if(!$language) $language = 'txt';
20 if(!$filename) $filename = 'snippet.'.$language;
21 $filename = basename($filename);
23 if($this->_codeblock
== $_REQUEST['codeblock']){
24 header("Content-Type: text/plain; charset=utf-8");
25 header("Content-Disposition: attachment; filename=$filename");
26 header("X-Robots-Tag: noindex");
27 echo trim($text,"\r\n");
37 function file($text, $language = NULL, $filename='') {
38 $this->code($text, $language, $filename);
42 * This should never be reached, if it is send a 404
44 function document_end() {
45 header("HTTP/1.0 404 Not Found");
46 echo '404 - Not found';
51 * Return the format of the renderer
53 * @returns string 'code'