1<?php 2 3namespace dokuwiki\Action; 4 5/** 6 * Class Preview 7 * 8 * preview during editing 9 * 10 * @package dokuwiki\Action 11 */ 12class Preview extends Edit { 13 14 /** @inheritdoc */ 15 public function preProcess() { 16 header('X-XSS-Protection: 0'); 17 $this->savedraft(); 18 parent::preProcess(); 19 } 20 21 /** @inheritdoc */ 22 public function tplContent() { 23 global $TEXT; 24 html_edit(); 25 html_show($TEXT); 26 } 27 28 /** 29 * Saves a draft on preview 30 */ 31 protected function savedraft() { 32 global $ID, $INFO; 33 $draft = new \dokuwiki\Draft($ID, $INFO['client']); 34 if (!$draft->saveDraft()) { 35 $errors = $draft->getErrors(); 36 foreach ($errors as $error) { 37 msg(hsc($error), -1); 38 } 39 } 40 } 41 42} 43