Merge pull request #2515 from Innovailable/master
[dokuwiki.git] / inc / load.php
blob2131b9d62b14a8f29ea705cf9cdbdc42ab9b4598
1 <?php
2 /**
3 * Load all internal libraries and setup class autoloader
5 * @author Andreas Gohr <andi@splitbrain.org>
6 */
8 // setup class autoloader
9 spl_autoload_register('load_autoload');
11 // require all the common libraries
12 // for a few of these order does matter
13 require_once(DOKU_INC.'inc/actions.php');
14 require_once(DOKU_INC.'inc/changelog.php');
15 require_once(DOKU_INC.'inc/common.php');
16 require_once(DOKU_INC.'inc/confutils.php');
17 require_once(DOKU_INC.'inc/pluginutils.php');
18 require_once(DOKU_INC.'inc/events.php');
19 require_once(DOKU_INC.'inc/form.php');
20 require_once(DOKU_INC.'inc/fulltext.php');
21 require_once(DOKU_INC.'inc/html.php');
22 require_once(DOKU_INC.'inc/httputils.php');
23 require_once(DOKU_INC.'inc/indexer.php');
24 require_once(DOKU_INC.'inc/infoutils.php');
25 require_once(DOKU_INC.'inc/io.php');
26 require_once(DOKU_INC.'inc/mail.php');
27 require_once(DOKU_INC.'inc/media.php');
28 require_once(DOKU_INC.'inc/pageutils.php');
29 require_once(DOKU_INC.'inc/parserutils.php');
30 require_once(DOKU_INC.'inc/search.php');
31 require_once(DOKU_INC.'inc/subscription.php');
32 require_once(DOKU_INC.'inc/template.php');
33 require_once(DOKU_INC.'inc/toolbar.php');
34 require_once(DOKU_INC.'inc/utf8.php');
35 require_once(DOKU_INC.'inc/auth.php');
36 require_once(DOKU_INC.'inc/compatibility.php');
38 /**
39 * spl_autoload_register callback
41 * Contains a static list of DokuWiki's core classes and automatically
42 * require()s their associated php files when an object is instantiated.
44 * @author Andreas Gohr <andi@splitbrain.org>
45 * @todo add generic loading of renderers and auth backends
47 * @param string $name
49 * @return bool
51 function load_autoload($name){
52 static $classes = null;
53 if(is_null($classes)) $classes = array(
54 'DokuHTTPClient' => DOKU_INC.'inc/HTTPClient.php',
55 'HTTPClient' => DOKU_INC.'inc/HTTPClient.php',
56 'JSON' => DOKU_INC.'inc/JSON.php',
57 'Diff' => DOKU_INC.'inc/DifferenceEngine.php',
58 'UnifiedDiffFormatter' => DOKU_INC.'inc/DifferenceEngine.php',
59 'TableDiffFormatter' => DOKU_INC.'inc/DifferenceEngine.php',
60 'cache' => DOKU_INC.'inc/cache.php',
61 'cache_parser' => DOKU_INC.'inc/cache.php',
62 'cache_instructions' => DOKU_INC.'inc/cache.php',
63 'cache_renderer' => DOKU_INC.'inc/cache.php',
64 'Doku_Event' => DOKU_INC.'inc/events.php',
65 'Doku_Event_Handler' => DOKU_INC.'inc/events.php',
66 'Input' => DOKU_INC.'inc/Input.class.php',
67 'JpegMeta' => DOKU_INC.'inc/JpegMeta.php',
68 'SimplePie' => DOKU_INC.'inc/SimplePie.php',
69 'FeedParser' => DOKU_INC.'inc/FeedParser.php',
70 'IXR_Server' => DOKU_INC.'inc/IXR_Library.php',
71 'IXR_Client' => DOKU_INC.'inc/IXR_Library.php',
72 'IXR_Error' => DOKU_INC.'inc/IXR_Library.php',
73 'IXR_IntrospectionServer' => DOKU_INC.'inc/IXR_Library.php',
74 'Doku_Plugin_Controller'=> DOKU_INC.'inc/plugincontroller.class.php',
75 'Doku_Parser_Mode' => DOKU_INC.'inc/parser/parser.php',
76 'Doku_Parser_Mode_Plugin' => DOKU_INC.'inc/parser/parser.php',
77 'SafeFN' => DOKU_INC.'inc/SafeFN.class.php',
78 'Sitemapper' => DOKU_INC.'inc/Sitemapper.php',
79 'PassHash' => DOKU_INC.'inc/PassHash.class.php',
80 'Mailer' => DOKU_INC.'inc/Mailer.class.php',
81 'RemoteAPI' => DOKU_INC.'inc/remote.php',
82 'RemoteAPICore' => DOKU_INC.'inc/RemoteAPICore.php',
83 'Subscription' => DOKU_INC.'inc/subscription.php',
85 'DokuWiki_PluginInterface' => DOKU_INC.'inc/PluginInterface.php',
86 'DokuWiki_PluginTrait' => DOKU_INC.'inc/PluginTrait.php',
87 'DokuWiki_Plugin' => DOKU_INC.'inc/Plugin.php',
90 'DokuWiki_Action_Plugin' => DOKU_PLUGIN.'action.php',
91 'DokuWiki_Admin_Plugin' => DOKU_PLUGIN.'admin.php',
92 'DokuWiki_Syntax_Plugin' => DOKU_PLUGIN.'syntax.php',
93 'DokuWiki_Remote_Plugin' => DOKU_PLUGIN.'remote.php',
94 'DokuWiki_Auth_Plugin' => DOKU_PLUGIN.'auth.php',
95 'DokuWiki_CLI_Plugin' => DOKU_PLUGIN.'cli.php',
97 'Doku_Renderer' => DOKU_INC.'inc/parser/renderer.php',
98 'Doku_Renderer_xhtml' => DOKU_INC.'inc/parser/xhtml.php',
99 'Doku_Renderer_code' => DOKU_INC.'inc/parser/code.php',
100 'Doku_Renderer_xhtmlsummary' => DOKU_INC.'inc/parser/xhtmlsummary.php',
101 'Doku_Renderer_metadata' => DOKU_INC.'inc/parser/metadata.php',
103 'DokuCLI' => DOKU_INC.'inc/cli.php',
104 'DokuCLI_Options' => DOKU_INC.'inc/cli.php',
105 'DokuCLI_Colors' => DOKU_INC.'inc/cli.php',
109 if(isset($classes[$name])){
110 require ($classes[$name]);
111 return true;
114 // namespace to directory conversion
115 $name = str_replace('\\', '/', $name);
117 // plugin namespace
118 if(substr($name, 0, 16) == 'dokuwiki/plugin/') {
119 $name = str_replace('/test/', '/_test/', $name); // no underscore in test namespace
120 $file = DOKU_PLUGIN . substr($name, 16) . '.php';
121 if(file_exists($file)) {
122 require $file;
123 return true;
127 // template namespace
128 if(substr($name, 0, 18) == 'dokuwiki/template/') {
129 $name = str_replace('/test/', '/_test/', $name); // no underscore in test namespace
130 $file = DOKU_INC.'lib/tpl/' . substr($name, 18) . '.php';
131 if(file_exists($file)) {
132 require $file;
133 return true;
137 // our own namespace
138 if(substr($name, 0, 9) == 'dokuwiki/') {
139 $file = DOKU_INC . 'inc/' . substr($name, 9) . '.php';
140 if(file_exists($file)) {
141 require $file;
142 return true;
146 // Plugin loading
147 if(preg_match('/^(auth|helper|syntax|action|admin|renderer|remote|cli)_plugin_('.DOKU_PLUGIN_NAME_REGEX.')(?:_([^_]+))?$/',
148 $name, $m)) {
149 // try to load the wanted plugin file
150 $c = ((count($m) === 4) ? "/{$m[3]}" : '');
151 $plg = DOKU_PLUGIN . "{$m[2]}/{$m[1]}$c.php";
152 if(file_exists($plg)){
153 require $plg;
155 return true;
157 return false;