Table of Contents

settingstree Plugin

Compatible with DokuWiki

Hrun

plugin DokuWiki helper and admin for setting up settings based on NS/page hierarchy to a plugin

Last updated on
2015-08-10
Provides
Helper
Repository
Source
Requires
config, explorertree, memcache

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Similar to acl, config

Tagged with admin, config, embed, hierarchy, settings

This plugin is currently in RC! Current version is in testing, with a few limitations (only the common settings types are tested/implemented, no special cases yet). Stable version should be out after some more testing.

Installation

The plugin depends on explorertree and config. It also uses memcache if installed.

This plugin requires a html5 browser to work! If you need to use the admin pages via commandline- or pre-html5 browsers (e.g. lynx or ie7), do not use plugins which depends on this one.

Search and install the plugin using the Extension Manager. Refer to Plugins on how to install plugins manually.

Overview

This plugin is for plugin authors, to simply embed an admin page allowing to set settings (aka. plugin configs) based on namespace hierarchy of the wiki.

Demo based on dw2pdf:

The helper can be included to your plugin's admin page, and it displays an area as see in the screenshot. The area have 3 parts:

The settings are borrowed from config, with a bit of update to the interface and functionalities:

Embed

Example:

class admin_plugin_<yourplugin> extends DokuWiki_Admin_Plugin {
	private $settings_helper = null;
	private $settings_registered = false;
	function get_settings_helper(){
		if (!$this->settings_helper){
			$this->settings_helper = plugin_load('helper','settingstree');
		}
		return $this->settings_helper;
	}
	function init_settingstree(){
		if (!($e = $this->get_settings_helper())) return;
		if ($this->settings_registered) return $e;
		$confdir = DOKU_INC.'lib/plugins/<yourplugin>/conf/';
		// check if the already stored version is the same as the current one we offer, and reregister options if the settingstree version is older.
		if ($e->checkSettingsVersion('<yourplugin>',			
			$ver = max(			
				// we're comparing the registered settings versus the configuration files' last change.
				// metadata may have an extra '_ignore_for_settingstree' =>true, in which case it won't be configurable by settingstree
				filemtime($confdir.'metadata.php'),
				filemtime($confdir.'default.php'),
				// extends.php have exactly the same syntax as default.php + metadata.php (in the same file), but these settings are only configurable by settingstree plugin and not by config.
				@filemtime($confdir.'extends.php')
			))){
			$meta = array();
			$conf = array();
			include($confdir.'metadata.php');
			include($confdir.'default.php');
			if (file_exists($confdir.'extends.php')) {include($confdir.'extends.php');}	// this file may not exist
			$e->registerSettings('<yourplugin>',$ver,$meta,$conf);	// (re)register settings for this plugin..
		}
		$this->settings_registered = true;
		return $e;
	}
 
	function __construct(){
		$this->init_settingstree();
    }
	function handle() {
		// changes are handled with ajax, so nothing to do here.
    }
	function html(){
        echo '<h1>'.$this->getLang('admin_set_options').'</h1>'.NL;
		if (!($e = $this->init_settingstree())){
			echo "something's wrong..."; return;
		}
		echo $e->showAdmin('<yourplugin>',':'); // yeah... that's it. we embedded it to our admin. YAAY!!
	}
    function forAdminOnly() {	// for only superusers (true) or also for managers (false)?
        return $this->getConf('admin_only_setoptions');
    }
	function getMenuText($language) {
        return $this->getLang('admin_set_options');
    }
    function getMenuSort() {
        return 100;
    }
}

Configuration and Settings

The plugin uses the same settings meta, defaults and lang structure as config manager plugin.

Development

Current status:

Change Log

Known Bugs and Issues

I currently don't have much time to test with all possible setting-type, and browsers… The current release (07-29) works with Chrome, FF, and IE10.

ToDo/Wish List

Discussion