[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/Action/ -> Preview.php (source)

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