* License: GPL2 * */ class admin_plugin_textmodule extends DokuWiki_Admin_Plugin { function getMenuText($language){ return $this->getLang("text module"); } function forAdminOnly() { return false; } /* Loads the saved textmodules from the file data/modules/modules.txt * * Format: (per line Basis) * Title 1 * Module 1 shortcut:Module t Text * [...] * Module n shortcut: Module n text * [TEXTMODULE DELIMITER] * Title 2 * [...] */ function _loadModules() { if (file_exists('data/meta/modules.txt')) { $t = file_get_contents('data/meta/modules.txt'); $t = explode("\n[TEXT MODULE DELIMITER]\n",$t); foreach ($t as &$m) $m = explode(PHP_EOL,$m); return $t; } return Array(Array('',''),Array('',''),Array('','')); } /* Save the form data */ function handle(){ if (!isset($_REQUEST)) return; if (isset($_REQUEST['Save'])) { $r = $_REQUEST['title1'] . "\n" . trim($_REQUEST['text1']) . "\n[TEXT MODULE DELIMITER]\n" . $_REQUEST['title2'] . "\n" . trim($_REQUEST['text2']) . "\n[TEXT MODULE DELIMITER]\n" . $_REQUEST['title3']. "\n" . trim($_REQUEST['text3']); file_put_contents('data/meta/modules.txt',$r); } } /* Output HTML for the admin section */ function html() { echo '

'.$this->getLang("text module").' Plugin

'; echo $this->getLang("admin help").'
'; $m = $this->_loadModules(); echo '
'; # output hidden values to ensure dokuwiki will return back to this plugin echo ''; echo ''; for ($c=1;$c<4;$c++) { echo '


'; echo $this->getLang("title").' '.$c.':

'; echo ''; } echo '

'; echo '
'; } }