*/ if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../../').'/'); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'admin.php'); /** * All DokuWiki plugins to extend the admin function * need to inherit from this class */ class admin_plugin_loadskin extends DokuWiki_Admin_Plugin { /** * Constructor */ public function __construct() { $this->setupLocale(); $this->config = DOKU_CONF.'loadskin.conf'; } /** * return sort order for position in admin menu */ public function getMenuSort() { return 300; } /** * handle user request */ public function handle() { global $INPUT; $data = array(); if($INPUT->str('pattern')) { if (!checkSecurityToken()) return; $id = cleanID($INPUT->str('pattern')); if($INPUT->str('act') == 'add') { if(@file_exists($this->config)) { $data = unserialize(io_readFile($this->config, false)); $data[$id] = $INPUT->str('tpl'); io_saveFile($this->config, serialize($data)); } else { $data[$id] = $INPUT->str('tpl'); io_saveFile($this->config, serialize($data)); } } if($INPUT->str('act') == 'del') { $data = unserialize(io_readFile($this->config, false)); unset($data[$id]); io_saveFile($this->config, serialize($data)); } } } /** * output appropriate html */ public function html() { global $lang; $helper = $this->loadHelper('loadskin', true); print '
' . $this->getLang('pattern') . ' | ' . DOKU_LF; echo '' . $this->getLang('template') . ' | ' . DOKU_LF; echo '' . $this->getLang('action') . ' | ' . DOKU_LF; echo '
---|---|---|
' . $key . ' | ' . DOKU_LF; echo '' . $value . ' | ' . DOKU_LF; echo '' . DOKU_LF; $form = new Doku_Form(array()); $form->addHidden('do','admin'); $form->addHidden('page','loadskin'); $form->addHidden('act','del'); $form->addHidden('id',$ID); $form->addHidden('pattern',$key); $form->addElement(form_makeButton('submit','',$lang['btn_delete'])); $form->printForm(); echo ' | ' . DOKU_LF; echo '