2010-01-31 19:02:14 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Load all internal libraries and setup class autoloader
|
|
|
|
*
|
|
|
|
* @author Andreas Gohr <andi@splitbrain.org>
|
|
|
|
*/
|
|
|
|
|
2019-04-21 19:31:27 +02:00
|
|
|
use dokuwiki\Extension\PluginController;
|
|
|
|
|
2010-01-31 19:02:14 +01:00
|
|
|
// setup class autoloader
|
|
|
|
spl_autoload_register('load_autoload');
|
|
|
|
|
|
|
|
// require all the common libraries
|
2010-03-12 14:09:57 +01:00
|
|
|
// for a few of these order does matter
|
2020-06-04 08:22:16 +02:00
|
|
|
require_once(DOKU_INC.'inc/defines.php');
|
2010-01-31 19:02:14 +01:00
|
|
|
require_once(DOKU_INC.'inc/actions.php');
|
|
|
|
require_once(DOKU_INC.'inc/changelog.php');
|
|
|
|
require_once(DOKU_INC.'inc/common.php');
|
|
|
|
require_once(DOKU_INC.'inc/confutils.php');
|
|
|
|
require_once(DOKU_INC.'inc/pluginutils.php');
|
|
|
|
require_once(DOKU_INC.'inc/form.php');
|
|
|
|
require_once(DOKU_INC.'inc/fulltext.php');
|
|
|
|
require_once(DOKU_INC.'inc/html.php');
|
|
|
|
require_once(DOKU_INC.'inc/httputils.php');
|
|
|
|
require_once(DOKU_INC.'inc/indexer.php');
|
|
|
|
require_once(DOKU_INC.'inc/infoutils.php');
|
|
|
|
require_once(DOKU_INC.'inc/io.php');
|
|
|
|
require_once(DOKU_INC.'inc/mail.php');
|
|
|
|
require_once(DOKU_INC.'inc/media.php');
|
|
|
|
require_once(DOKU_INC.'inc/pageutils.php');
|
|
|
|
require_once(DOKU_INC.'inc/parserutils.php');
|
|
|
|
require_once(DOKU_INC.'inc/search.php');
|
|
|
|
require_once(DOKU_INC.'inc/template.php');
|
|
|
|
require_once(DOKU_INC.'inc/toolbar.php');
|
|
|
|
require_once(DOKU_INC.'inc/utf8.php');
|
|
|
|
require_once(DOKU_INC.'inc/auth.php');
|
2013-10-30 19:44:57 +01:00
|
|
|
require_once(DOKU_INC.'inc/compatibility.php');
|
2018-05-07 22:26:05 +02:00
|
|
|
require_once(DOKU_INC.'inc/deprecated.php');
|
2018-06-15 17:05:16 +02:00
|
|
|
require_once(DOKU_INC.'inc/legacy.php');
|
2010-01-31 19:02:14 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* spl_autoload_register callback
|
|
|
|
*
|
|
|
|
* Contains a static list of DokuWiki's core classes and automatically
|
2010-02-01 15:18:39 +01:00
|
|
|
* require()s their associated php files when an object is instantiated.
|
2010-01-31 19:02:14 +01:00
|
|
|
*
|
|
|
|
* @author Andreas Gohr <andi@splitbrain.org>
|
2011-06-06 16:20:29 +02:00
|
|
|
* @todo add generic loading of renderers and auth backends
|
2017-03-31 04:58:14 +02:00
|
|
|
*
|
|
|
|
* @param string $name
|
|
|
|
*
|
|
|
|
* @return bool
|
2010-01-31 19:02:14 +01:00
|
|
|
*/
|
|
|
|
function load_autoload($name){
|
|
|
|
static $classes = null;
|
2018-06-15 17:05:16 +02:00
|
|
|
if($classes === null) $classes = array(
|
2010-01-31 19:02:14 +01:00
|
|
|
'Diff' => DOKU_INC.'inc/DifferenceEngine.php',
|
|
|
|
'UnifiedDiffFormatter' => DOKU_INC.'inc/DifferenceEngine.php',
|
|
|
|
'TableDiffFormatter' => DOKU_INC.'inc/DifferenceEngine.php',
|
|
|
|
'cache' => DOKU_INC.'inc/cache.php',
|
|
|
|
'cache_parser' => DOKU_INC.'inc/cache.php',
|
|
|
|
'cache_instructions' => DOKU_INC.'inc/cache.php',
|
|
|
|
'cache_renderer' => DOKU_INC.'inc/cache.php',
|
2018-06-15 17:05:16 +02:00
|
|
|
'Input' => DOKU_INC.'inc/Input.class.php',
|
2010-01-31 19:02:14 +01:00
|
|
|
'JpegMeta' => DOKU_INC.'inc/JpegMeta.php',
|
2010-02-01 15:18:39 +01:00
|
|
|
'SimplePie' => DOKU_INC.'inc/SimplePie.php',
|
2010-01-31 19:02:14 +01:00
|
|
|
'FeedParser' => DOKU_INC.'inc/FeedParser.php',
|
|
|
|
'IXR_Server' => DOKU_INC.'inc/IXR_Library.php',
|
|
|
|
'IXR_Client' => DOKU_INC.'inc/IXR_Library.php',
|
2016-10-01 14:00:31 +02:00
|
|
|
'IXR_Error' => DOKU_INC.'inc/IXR_Library.php',
|
2010-03-16 14:50:15 +01:00
|
|
|
'IXR_IntrospectionServer' => DOKU_INC.'inc/IXR_Library.php',
|
2010-04-04 20:28:39 +02:00
|
|
|
'SafeFN' => DOKU_INC.'inc/SafeFN.class.php',
|
2010-06-26 13:33:46 +02:00
|
|
|
'Sitemapper' => DOKU_INC.'inc/Sitemapper.php',
|
2011-11-12 17:52:19 +01:00
|
|
|
'Mailer' => DOKU_INC.'inc/Mailer.class.php',
|
2010-02-01 16:10:25 +01:00
|
|
|
|
2018-04-27 21:33:14 +02:00
|
|
|
'Doku_Handler' => DOKU_INC.'inc/parser/handler.php',
|
2014-02-25 21:32:56 +01:00
|
|
|
'Doku_Renderer' => DOKU_INC.'inc/parser/renderer.php',
|
|
|
|
'Doku_Renderer_xhtml' => DOKU_INC.'inc/parser/xhtml.php',
|
|
|
|
'Doku_Renderer_code' => DOKU_INC.'inc/parser/code.php',
|
|
|
|
'Doku_Renderer_xhtmlsummary' => DOKU_INC.'inc/parser/xhtmlsummary.php',
|
|
|
|
'Doku_Renderer_metadata' => DOKU_INC.'inc/parser/metadata.php',
|
|
|
|
|
2014-03-17 23:03:53 +01:00
|
|
|
'DokuCLI' => DOKU_INC.'inc/cli.php',
|
|
|
|
'DokuCLI_Options' => DOKU_INC.'inc/cli.php',
|
|
|
|
'DokuCLI_Colors' => DOKU_INC.'inc/cli.php',
|
|
|
|
|
2010-01-31 19:02:14 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
if(isset($classes[$name])){
|
2015-10-18 04:45:41 +02:00
|
|
|
require ($classes[$name]);
|
|
|
|
return true;
|
2010-01-31 19:02:14 +01:00
|
|
|
}
|
2011-06-06 16:20:29 +02:00
|
|
|
|
2016-04-18 19:00:07 +02:00
|
|
|
// namespace to directory conversion
|
2015-05-08 16:27:17 +02:00
|
|
|
$name = str_replace('\\', '/', $name);
|
|
|
|
|
2018-04-27 21:31:06 +02:00
|
|
|
// test namespace
|
2019-05-20 08:43:30 +02:00
|
|
|
if(substr($name, 0, 14) === 'dokuwiki/test/') {
|
2018-04-27 21:31:06 +02:00
|
|
|
$file = DOKU_INC . '_test/' . substr($name, 14) . '.php';
|
|
|
|
if(file_exists($file)) {
|
|
|
|
require $file;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-14 23:54:58 +02:00
|
|
|
// plugin namespace
|
2019-05-20 08:43:30 +02:00
|
|
|
if(substr($name, 0, 16) === 'dokuwiki/plugin/') {
|
2016-04-14 23:54:58 +02:00
|
|
|
$name = str_replace('/test/', '/_test/', $name); // no underscore in test namespace
|
2016-04-20 16:32:09 +02:00
|
|
|
$file = DOKU_PLUGIN . substr($name, 16) . '.php';
|
2016-04-14 23:54:58 +02:00
|
|
|
if(file_exists($file)) {
|
2020-07-13 19:48:55 +02:00
|
|
|
try {
|
|
|
|
require $file;
|
|
|
|
} catch (\Throwable $e) {
|
|
|
|
\dokuwiki\ErrorHandler::showExceptionMsg($e, "Error loading plugin $name");
|
|
|
|
}
|
2016-04-14 23:54:58 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-05 07:15:05 +01:00
|
|
|
// template namespace
|
2019-05-20 08:43:30 +02:00
|
|
|
if(substr($name, 0, 18) === 'dokuwiki/template/') {
|
2017-02-05 07:15:05 +01:00
|
|
|
$name = str_replace('/test/', '/_test/', $name); // no underscore in test namespace
|
|
|
|
$file = DOKU_INC.'lib/tpl/' . substr($name, 18) . '.php';
|
|
|
|
if(file_exists($file)) {
|
2020-07-13 19:48:55 +02:00
|
|
|
try {
|
|
|
|
require $file;
|
|
|
|
} catch (\Throwable $e) {
|
|
|
|
\dokuwiki\ErrorHandler::showExceptionMsg($e, "Error loading template $name");
|
|
|
|
}
|
2017-02-05 07:15:05 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-18 19:00:07 +02:00
|
|
|
// our own namespace
|
2019-05-20 08:43:30 +02:00
|
|
|
if(substr($name, 0, 9) === 'dokuwiki/') {
|
2017-03-11 12:12:41 +01:00
|
|
|
$file = DOKU_INC . 'inc/' . substr($name, 9) . '.php';
|
|
|
|
if(file_exists($file)) {
|
|
|
|
require $file;
|
|
|
|
return true;
|
|
|
|
}
|
2016-04-18 19:00:07 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 16:20:29 +02:00
|
|
|
// Plugin loading
|
2018-04-27 19:07:43 +02:00
|
|
|
if(preg_match(
|
2019-04-21 19:31:27 +02:00
|
|
|
'/^(' . implode('|', PluginController::PLUGIN_TYPES) . ')_plugin_(' .
|
2018-04-27 19:07:43 +02:00
|
|
|
DOKU_PLUGIN_NAME_REGEX .
|
|
|
|
')(?:_([^_]+))?$/',
|
|
|
|
$name,
|
|
|
|
$m
|
|
|
|
)) {
|
2012-05-20 09:44:46 +02:00
|
|
|
// try to load the wanted plugin file
|
2011-06-06 16:20:29 +02:00
|
|
|
$c = ((count($m) === 4) ? "/{$m[3]}" : '');
|
2012-05-20 09:44:46 +02:00
|
|
|
$plg = DOKU_PLUGIN . "{$m[2]}/{$m[1]}$c.php";
|
2015-01-07 10:47:45 +01:00
|
|
|
if(file_exists($plg)){
|
2020-07-13 19:48:55 +02:00
|
|
|
try {
|
|
|
|
require $plg;
|
|
|
|
} catch (\Throwable $e) {
|
2020-08-13 20:32:17 +02:00
|
|
|
\dokuwiki\ErrorHandler::showExceptionMsg($e, "Error loading plugin {$m[2]}");
|
2020-07-13 19:48:55 +02:00
|
|
|
}
|
2012-05-20 09:44:46 +02:00
|
|
|
}
|
2015-10-18 04:45:41 +02:00
|
|
|
return true;
|
2011-06-06 16:20:29 +02:00
|
|
|
}
|
2015-11-27 10:02:02 +01:00
|
|
|
return false;
|
2010-01-31 19:02:14 +01:00
|
|
|
}
|
|
|
|
|