48 lines
1.9 KiB
PHP
48 lines
1.9 KiB
PHP
<?php
|
|
|
|
if(!defined('DOKU_INC')) die();
|
|
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC.'lib/plugins/');
|
|
if(!defined('DOKU_LF')) define('DOKU_LF', "\n");
|
|
|
|
require_once(DOKU_PLUGIN.'action.php');
|
|
class action_plugin_usetheme extends DokuWiki_Action_Plugin {
|
|
|
|
// register hook
|
|
public function register(Doku_Event_Handler $controller) {
|
|
$controller->register_hook('DOKUWIKI_STARTED', 'BEFORE', $this, '_handleConf');
|
|
//$controller->register_hook('MEDIAMANAGER_STARTED', 'BEFORE', $this, '_handleConf');
|
|
$controller->register_hook('DETAIL_STARTED', 'BEFORE', $this, '_handleConf');
|
|
//$controller->register_hook('TPL_CONTENT_DISPLAY', 'BEFORE', $this, '_handleContent', array());
|
|
// only needed for not yet up-to-date templates:
|
|
$controller->register_hook('DOKUWIKI_STARTED', 'AFTER', $this, '_defineConstants');
|
|
//$controller->register_hook('MEDIAMANAGER_STARTED', 'AFTER', $this, '_defineConstants');
|
|
$controller->register_hook('DETAIL_STARTED', 'AFTER', $this, '_defineConstants');
|
|
}
|
|
|
|
public function _defineConstants(Doku_Event $event, $param) {
|
|
global $conf;
|
|
// define Template baseURL
|
|
if(!defined('DOKU_TPL'))
|
|
define('DOKU_TPL', DOKU_BASE.'lib/tpl/'.$conf['template'].'/');
|
|
|
|
// define real Template directory
|
|
if(!defined('DOKU_TPLINC'))
|
|
define('DOKU_TPLINC', DOKU_INC.'lib/tpl/'.$conf['template'].'/');
|
|
}
|
|
|
|
public function _handleConf(Doku_Event $event, $param) {
|
|
global $ID, $ACT, $conf;
|
|
$dataFile = wikiFN(cleanID($ID));
|
|
$fp = fopen($dataFile,"r");
|
|
$firstLine = fgets($fp,512);
|
|
fclose($fp);
|
|
preg_match('/~~USETHEME:(.*?)~~/', $firstLine, $match);
|
|
$template = trim($match[1]);
|
|
if($template) {
|
|
$conf['template'] = $template;
|
|
}
|
|
}
|
|
}
|
|
|
|
// vim:ts=4:sw=4:
|