* @date 2006-06-28 */ 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'); if(!defined('PLUGIN_NAME')) define('PLUGIN_NAME','txtconf'); if(!defined('DOKU_CONF')) define('DOKU_CONF',DOKU_INC.'conf/'); require_once(DOKU_INC.'inc/confutils.php'); define('PLUGIN_TXTCONF',dirname(__FILE__).'/'); require_once(PLUGIN_TXTCONF.'config0.class.php'); // base configuration class and generic settings classes from Chris Smith require_once(PLUGIN_TXTCONF.'txtconfig.class.php'); // Text config class /** * All DokuWiki plugins to extend the admin function * need to inherit from this class */ class admin_plugin_txtconf extends DokuWiki_Admin_Plugin { var $_myconf = null; var $_conftype = null; var $_input = null; var $_changed = false; var $_conf_type_list = array('mime','acronyms','smileys','entities','interwiki'); /** * return some info */ function getInfo(){ return array( 'author' => 'Stephane Chamberland ', 'email' => 'stephane.chamberland@ec.gc.ca', 'date' => '2006-06-09', 'name' => $this->getLang('menu'), 'desc' => $this->getLang('desc'), 'url' => 'http://wiki.splitbrain.org/plugin:'.PLUGIN_NAME, ); } /** * return sort order for position in admin menu */ function getMenuSort() { return 101; } /** * handle user request */ function handle() { global $ID; global $lang; if (isset($_POST['conftype'])) { $this->_myconf = new txtconfiguration(PLUGIN_TXTCONF.'conf/'.$_POST['conftype'].'.metadata.php'); $this->_conftype = $_POST['conftype']; //if (!isset($_POST['txtconf'])) { // ptnl('Ask for confirmation'); //} // don't go any further if the configuration is locked if ($this->_myconf->_locked) return True; } if (isset($_POST['submit'])) { if ($_POST['submit'] == $lang['btn_save']) { $this->_input = $_REQUEST['config']; while (list($key) = each($this->_myconf->setting)) { $input = isset($this->_input[$key]) ? $this->_input[$key] : NULL; if ($input == '') $input = null; if ($this->_myconf->setting[$key]->update($input)) $this->_changed = true; //if ($this->_myconf->setting[$key]->error()) // $this->_error = true; } } if ($_POST['submit'] == $this->getLang('btn_addnew')) { //TODO: check if it already exists if( $this->_myconf->add_local_setting($_POST['newkey'],$_POST['newval'])) $this->_changed = true; } if ($this->_changed && !$this->_error) { if ($this->_myconf->save_settings(PLUGIN_NAME)) { msg('Successfully Saved '.$this->_conftype,1); } else { msg('Problem Saving '.$this->_conftype,-1); } } } return True; } /** * output appropriate html */ function _print_open_form() { global $ID; ptln('
'); if ($msg) ptln($msg); ptln('
'); } ptln(''); ptln(''); ptln(''); ptln('
'); } function _html_choose_conf() { global $ID; global $lang; print $this->locale_xhtml('intro'); $this->_print_open_form(); $this->_print_choose_conf_form($this->getLang('msg_chooseConf')); $this->_print_close_form(); } function _html_edit_conf() { global $ID; global $lang; //print $this->locale_xhtml('intro_'.$this->myconf->type); print $this->locale_xhtml($this->_myconf->_intro); ptln(''.$this->getLang('msg_howto').'
'); //TODO: Once form is updated/saved, print success/error msg $this->_print_open_form(); ptln(' '); ptln(' '); ptln(''.$label.' | '); ptln(''.$value.' | '); ptln('
'); ptln(' '." \n"); ptln(' '."\n"); ptln('
'); ptln(''.$this->getLang('msg_howtoadd').'
'); ptln('');
ptln('');
ptln('
');
ptln(' '."\n");
ptln('
'.$this->getLang('filelocked').'
'); } ptln(''); $this->_print_choose_conf_form($this->getLang('msg_editThisConf')); ptln('
'); $this->_print_close_form(); } function html() { if ($this->_myconf) { $this->_html_edit_conf(); } else { $this->_html_choose_conf(); } } }