1<?php 2 3class admin_plugin_infomail extends DokuWiki_Admin_Plugin 4{ 5 6 const TPL = 'wiki:infomail:template'; // FIXME move to helper 7 8 /** @inheritdoc */ 9 public function handle() 10 { 11 global $INPUT; 12 13 // redirect to list page 14 if ($INPUT->filter('trim')->str('infomail_simple_new')) { 15 $newlist = cleanID(":wiki:infomail:list_" . $INPUT->filter('trim')->str('infomail_simple_new')); 16 send_redirect(wl($newlist, '', true, '&')); 17 } 18 19 // redirect to template page, create default when empty 20 if ($INPUT->bool('infomail_edit_tpl')) { 21 if (!page_exists(self::TPL)) { 22 saveWikiText(self::TPL, io_readFile(__DIR__ . '/template.txt'), 'autocreated'); 23 } 24 send_redirect(wl(self::TPL, '', true, '&')); 25 } 26 } 27 28 /** @inheritdoc */ 29 public function html() 30 { 31 global $conf; 32 33 echo $this->locale_xhtml('intro'); 34 35 // FIXME could be changed into new Form mechanism 36 echo '<h2>' . $this->getLang('infomail_listoverview') . '</h2>'; 37 $form = new Doku_Form('infomail_plugin_admin'); 38 $form->addElement(form_makeTextField('infomail_simple_new', '', $this->getLang('newsimplelist'))); 39 $form->addElement(form_makeButton('submit', '', $this->getLang('createnewsimplelist'))); 40 $form->printForm(); 41 42 /** @var helper_plugin_infomail $helper */ 43 $helper = plugin_load('helper', 'infomail'); 44 45 // output the available lists 46 $lists = $helper->getLists(); 47 echo '<ul>'; 48 foreach ($lists as $list) { 49 echo '<li>' . html_wikilink("wiki:infomail:list_$list", $list) . '</li>'; 50 } 51 echo '</ul>'; 52 53 54 // FIXME could be changed to use new Form mechanism 55 echo '<h2>' . $this->getLang('infomail_tpl') . '</h2>'; 56 $form = new Doku_Form('infomail_plugin_admin_tpl'); 57 $form->addHidden('infomail_edit_tpl', "yes"); 58 $form->addElement(form_makeButton('submit', '', $this->getLang('infomail_edit_tpl'))); 59 $form->printForm(); 60 } 61} 62 63