1f21dad39SAndreas Gohr<?php 2f21dad39SAndreas Gohr 3f21dad39SAndreas Gohrnamespace dokuwiki\Action; 4f21dad39SAndreas Gohr 5ab583a1bSAndreas Gohr/** 6ab583a1bSAndreas Gohr * Class Preview 7ab583a1bSAndreas Gohr * 8ab583a1bSAndreas Gohr * preview during editing 9ab583a1bSAndreas Gohr * 10ab583a1bSAndreas Gohr * @package dokuwiki\Action 11ab583a1bSAndreas Gohr */ 12f21dad39SAndreas Gohrclass Preview extends Edit { 13f21dad39SAndreas Gohr 14ab583a1bSAndreas Gohr /** @inheritdoc */ 15f21dad39SAndreas Gohr public function preProcess() { 160f9e19d9SAndreas Gohr header('X-XSS-Protection: 0'); 170f9e19d9SAndreas Gohr $this->savedraft(); 18f21dad39SAndreas Gohr parent::preProcess(); 19f21dad39SAndreas Gohr } 20f21dad39SAndreas Gohr 21ab583a1bSAndreas Gohr /** @inheritdoc */ 22f21dad39SAndreas Gohr public function tplContent() { 23f21dad39SAndreas Gohr global $TEXT; 24f21dad39SAndreas Gohr html_edit(); 25f21dad39SAndreas Gohr html_show($TEXT); 26f21dad39SAndreas Gohr } 27f21dad39SAndreas Gohr 280f9e19d9SAndreas Gohr /** 290f9e19d9SAndreas Gohr * Saves a draft on preview 300f9e19d9SAndreas Gohr */ 310f9e19d9SAndreas Gohr protected function savedraft() { 32*0aabe6f8SMichael Große global $ID, $INFO; 33*0aabe6f8SMichael Große $draft = new \dokuwiki\Draft($ID, $INFO['client']); 34*0aabe6f8SMichael Große if (!$draft->saveDraft()) { 35*0aabe6f8SMichael Große $errors = $draft->getErrors(); 36*0aabe6f8SMichael Große foreach ($errors as $error) { 37*0aabe6f8SMichael Große msg(hsc($error), -1); 38*0aabe6f8SMichael Große } 390f9e19d9SAndreas Gohr } 400f9e19d9SAndreas Gohr } 410f9e19d9SAndreas Gohr 42f21dad39SAndreas Gohr} 43