[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/Ui/ -> PageDraft.php (source)

   1  <?php
   2  
   3  namespace dokuwiki\Ui;
   4  
   5  use dokuwiki\Draft;
   6  use dokuwiki\Form\Form;
   7  
   8  /**
   9   * DokuWiki Page Draft Interface
  10   *
  11   * @package dokuwiki\Ui
  12   */
  13  class PageDraft extends Ui
  14  {
  15      /**
  16       * Display the Page Draft Form
  17       * ask the user about how to handle an exisiting draft
  18       *
  19       * @return void
  20       * @author   Andreas Gohr <andi@splitbrain.org>
  21       *
  22       */
  23      public function show()
  24      {
  25          global $INFO;
  26          global $lang;
  27  
  28          $draft = new Draft($INFO['id'], $INFO['client']);
  29          $text = $draft->getDraftText();
  30  
  31          // print intro
  32          echo p_locale_xhtml('draft');
  33  
  34          // print difference
  35          (new PageDiff($INFO['id']))->compareWith($text)->preference('showIntro', false)->show();
  36  
  37          // create the draft form
  38          $form = new Form(['id' => 'dw__editform']);
  39          $form->addTagOpen('div')->addClass('no');
  40          $form->setHiddenField('id', $INFO['id']);
  41          $form->setHiddenField('date', $draft->getDraftDate());
  42          $form->setHiddenField('wikitext', $text);
  43  
  44          $form->addTagOpen('div')->id('draft__status');
  45          $form->addHTML($draft->getDraftMessage());
  46          $form->addTagClose('div');
  47          $form->addButton('do[recover]', $lang['btn_recover'])->attrs(['type' => 'submit', 'tabindex' => '1']);
  48          $form->addButton('do[draftdel]', $lang['btn_draftdel'])->attrs(['type' => 'submit', 'tabindex' => '2']);
  49          $form->addButton('do[show]', $lang['btn_cancel'])->attrs(['type' => 'submit', 'tabindex' => '3']);
  50          $form->addTagClose('div');
  51  
  52          echo $form->toHTML('Draft');
  53      }
  54  }