summaryrefslogtreecommitdiff
path: root/inc/parser/code.php
diff options
context:
space:
mode:
authorghi <dokuwiki@imz.re>2015-02-17 11:08:15 +0100
committerghi <dokuwiki@imz.re>2015-02-17 11:08:15 +0100
commit7d0b7e5ed7aa0f9c56def8f6c9866aa4fc8315b8 (patch)
tree08330b0a548a402caeb02ee7a185e745386ad45d /inc/parser/code.php
parentd6dc28be40fb3202a3df69458db164e20999ac2b (diff)
parentf8803275a58a05b29e4029cc539a6f8c60ad2ea5 (diff)
downloadrpg-7d0b7e5ed7aa0f9c56def8f6c9866aa4fc8315b8.tar.gz
rpg-7d0b7e5ed7aa0f9c56def8f6c9866aa4fc8315b8.tar.bz2
Merge https://github.com/splitbrain/dokuwiki into html_showrev_output
Diffstat (limited to 'inc/parser/code.php')
-rw-r--r--inc/parser/code.php18
1 files changed, 11 insertions, 7 deletions
diff --git a/inc/parser/code.php b/inc/parser/code.php
index 0b8e3ee02..2353e0dfa 100644
--- a/inc/parser/code.php
+++ b/inc/parser/code.php
@@ -5,28 +5,32 @@
* @author Andreas Gohr <andi@splitbrain.org>
*/
if(!defined('DOKU_INC')) die('meh.');
-require_once DOKU_INC . 'inc/parser/renderer.php';
class Doku_Renderer_code extends Doku_Renderer {
- var $_codeblock=0;
+ var $_codeblock = 0;
/**
* Send the wanted code block to the browser
*
* When the correct block was found it exits the script.
*/
- function code($text, $language = null, $filename='' ) {
+ function code($text, $language = null, $filename = '') {
global $INPUT;
if(!$language) $language = 'txt';
if(!$filename) $filename = 'snippet.'.$language;
$filename = utf8_basename($filename);
$filename = utf8_stripspecials($filename, '_');
- if($this->_codeblock == $INPUT->str('codeblock')){
+ // send CRLF to Windows clients
+ if(strpos($INPUT->server->str('HTTP_USER_AGENT'), 'Windows') !== false) {
+ $text = str_replace("\n", "\r\n", $text);
+ }
+
+ if($this->_codeblock == $INPUT->str('codeblock')) {
header("Content-Type: text/plain; charset=utf-8");
header("Content-Disposition: attachment; filename=$filename");
header("X-Robots-Tag: noindex");
- echo trim($text,"\r\n");
+ echo trim($text, "\r\n");
exit;
}
@@ -36,7 +40,7 @@ class Doku_Renderer_code extends Doku_Renderer {
/**
* Wraps around code()
*/
- function file($text, $language = null, $filename='') {
+ function file($text, $language = null, $filename = '') {
$this->code($text, $language, $filename);
}
@@ -54,7 +58,7 @@ class Doku_Renderer_code extends Doku_Renderer {
*
* @returns string 'code'
*/
- function getFormat(){
+ function getFormat() {
return 'code';
}
}