116905344SAndreas Gohr<?php 216905344SAndreas Gohr/** 316905344SAndreas Gohr * Load all internal libraries and setup class autoloader 416905344SAndreas Gohr * 516905344SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 616905344SAndreas Gohr */ 716905344SAndreas Gohr 816905344SAndreas Gohr// setup class autoloader 916905344SAndreas Gohrspl_autoload_register('load_autoload'); 1016905344SAndreas Gohr 1116905344SAndreas Gohr// require all the common libraries 1205ed2c25SAndreas Gohr// for a few of these order does matter 1316905344SAndreas Gohrrequire_once(DOKU_INC.'inc/actions.php'); 1416905344SAndreas Gohrrequire_once(DOKU_INC.'inc/changelog.php'); 1516905344SAndreas Gohrrequire_once(DOKU_INC.'inc/common.php'); 1616905344SAndreas Gohrrequire_once(DOKU_INC.'inc/confutils.php'); 1716905344SAndreas Gohrrequire_once(DOKU_INC.'inc/pluginutils.php'); 1816905344SAndreas Gohrrequire_once(DOKU_INC.'inc/events.php'); 1916905344SAndreas Gohrrequire_once(DOKU_INC.'inc/form.php'); 2016905344SAndreas Gohrrequire_once(DOKU_INC.'inc/fulltext.php'); 2116905344SAndreas Gohrrequire_once(DOKU_INC.'inc/html.php'); 2216905344SAndreas Gohrrequire_once(DOKU_INC.'inc/httputils.php'); 2316905344SAndreas Gohrrequire_once(DOKU_INC.'inc/indexer.php'); 2416905344SAndreas Gohrrequire_once(DOKU_INC.'inc/infoutils.php'); 2516905344SAndreas Gohrrequire_once(DOKU_INC.'inc/io.php'); 2616905344SAndreas Gohrrequire_once(DOKU_INC.'inc/mail.php'); 2716905344SAndreas Gohrrequire_once(DOKU_INC.'inc/media.php'); 2816905344SAndreas Gohrrequire_once(DOKU_INC.'inc/pageutils.php'); 2916905344SAndreas Gohrrequire_once(DOKU_INC.'inc/parserutils.php'); 3016905344SAndreas Gohrrequire_once(DOKU_INC.'inc/search.php'); 3116905344SAndreas Gohrrequire_once(DOKU_INC.'inc/subscription.php'); 3216905344SAndreas Gohrrequire_once(DOKU_INC.'inc/template.php'); 3316905344SAndreas Gohrrequire_once(DOKU_INC.'inc/toolbar.php'); 3416905344SAndreas Gohrrequire_once(DOKU_INC.'inc/utf8.php'); 3516905344SAndreas Gohrrequire_once(DOKU_INC.'inc/auth.php'); 366589c60cSAndreas Gohrrequire_once(DOKU_INC.'inc/compatibility.php'); 3716905344SAndreas Gohr 3816905344SAndreas Gohr/** 3916905344SAndreas Gohr * spl_autoload_register callback 4016905344SAndreas Gohr * 4116905344SAndreas Gohr * Contains a static list of DokuWiki's core classes and automatically 422dcde304SAndreas Gohr * require()s their associated php files when an object is instantiated. 4316905344SAndreas Gohr * 4416905344SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 45d54ac877SAdrian Lang * @todo add generic loading of renderers and auth backends 46f50a239bSTakamura * 47f50a239bSTakamura * @param string $name 48f50a239bSTakamura * 49f50a239bSTakamura * @return bool 5016905344SAndreas Gohr */ 5116905344SAndreas Gohrfunction load_autoload($name){ 5216905344SAndreas Gohr static $classes = null; 5316905344SAndreas Gohr if(is_null($classes)) $classes = array( 5416905344SAndreas Gohr 'DokuHTTPClient' => DOKU_INC.'inc/HTTPClient.php', 55a1d9de52SAndreas Gohr 'HTTPClient' => DOKU_INC.'inc/HTTPClient.php', 5616905344SAndreas Gohr 'JSON' => DOKU_INC.'inc/JSON.php', 5716905344SAndreas Gohr 'Diff' => DOKU_INC.'inc/DifferenceEngine.php', 5816905344SAndreas Gohr 'UnifiedDiffFormatter' => DOKU_INC.'inc/DifferenceEngine.php', 5916905344SAndreas Gohr 'TableDiffFormatter' => DOKU_INC.'inc/DifferenceEngine.php', 6016905344SAndreas Gohr 'cache' => DOKU_INC.'inc/cache.php', 6116905344SAndreas Gohr 'cache_parser' => DOKU_INC.'inc/cache.php', 6216905344SAndreas Gohr 'cache_instructions' => DOKU_INC.'inc/cache.php', 6316905344SAndreas Gohr 'cache_renderer' => DOKU_INC.'inc/cache.php', 6416905344SAndreas Gohr 'Doku_Event' => DOKU_INC.'inc/events.php', 6516905344SAndreas Gohr 'Doku_Event_Handler' => DOKU_INC.'inc/events.php', 6689177306SAndreas Gohr 'Input' => DOKU_INC.'inc/Input.class.php', 6716905344SAndreas Gohr 'JpegMeta' => DOKU_INC.'inc/JpegMeta.php', 682dcde304SAndreas Gohr 'SimplePie' => DOKU_INC.'inc/SimplePie.php', 6916905344SAndreas Gohr 'FeedParser' => DOKU_INC.'inc/FeedParser.php', 7016905344SAndreas Gohr 'IXR_Server' => DOKU_INC.'inc/IXR_Library.php', 7116905344SAndreas Gohr 'IXR_Client' => DOKU_INC.'inc/IXR_Library.php', 72b368386fSFlorian Rathgeber 'IXR_Error' => DOKU_INC.'inc/IXR_Library.php', 735ce4ea15SMichael Klier 'IXR_IntrospectionServer' => DOKU_INC.'inc/IXR_Library.php', 7416905344SAndreas Gohr 'Doku_Plugin_Controller'=> DOKU_INC.'inc/plugincontroller.class.php', 75bee9f377SAndreas Gohr 'Tar' => DOKU_INC.'inc/Tar.class.php', 7694d621b0SAdrian Lang 'ZipLib' => DOKU_INC.'inc/ZipLib.class.php', 7705ed2c25SAndreas Gohr 'Doku_Parser_Mode' => DOKU_INC.'inc/parser/parser.php', 7836e8c637SAndreas Gohr 'Doku_Parser_Mode_Plugin' => DOKU_INC.'inc/parser/parser.php', 79f03fd957SAndreas Gohr 'SafeFN' => DOKU_INC.'inc/SafeFN.class.php', 802897eb23SMichael Hamann 'Sitemapper' => DOKU_INC.'inc/Sitemapper.php', 813a0a2d05SAndreas Gohr 'PassHash' => DOKU_INC.'inc/PassHash.class.php', 82c9a53c46SAndreas Gohr 'Mailer' => DOKU_INC.'inc/Mailer.class.php', 83457ad80aSDominik Eckelmann 'RemoteAPI' => DOKU_INC.'inc/remote.php', 84b967e5fcSDominik Eckelmann 'RemoteAPICore' => DOKU_INC.'inc/RemoteAPICore.php', 852240ea1fSAndreas Gohr 'Subscription' => DOKU_INC.'inc/subscription.php', 86c2a6d816SAndreas Gohr 87*39bceb98SAndreas Gohr 'DokuWiki_PluginInterface' => DOKU_INC.'inc/PluginInterface.php', 88*39bceb98SAndreas Gohr 'DokuWiki_PluginTrait' => DOKU_INC.'inc/PluginTrait.php', 89*39bceb98SAndreas Gohr 'DokuWiki_Plugin' => DOKU_INC.'inc/Plugin.php', 90*39bceb98SAndreas Gohr 91*39bceb98SAndreas Gohr 92c2a6d816SAndreas Gohr 'DokuWiki_Action_Plugin' => DOKU_PLUGIN.'action.php', 93c2a6d816SAndreas Gohr 'DokuWiki_Admin_Plugin' => DOKU_PLUGIN.'admin.php', 94c2a6d816SAndreas Gohr 'DokuWiki_Syntax_Plugin' => DOKU_PLUGIN.'syntax.php', 95457ad80aSDominik Eckelmann 'DokuWiki_Remote_Plugin' => DOKU_PLUGIN.'remote.php', 963cbcc653SJan Schumann 'DokuWiki_Auth_Plugin' => DOKU_PLUGIN.'auth.php', 97*39bceb98SAndreas Gohr 'DokuWiki_CLI_Plugin' => DOKU_PLUGIN.'cli.php', 98c2a6d816SAndreas Gohr 992ada8709SChristopher Smith 'Doku_Renderer' => DOKU_INC.'inc/parser/renderer.php', 1002ada8709SChristopher Smith 'Doku_Renderer_xhtml' => DOKU_INC.'inc/parser/xhtml.php', 1012ada8709SChristopher Smith 'Doku_Renderer_code' => DOKU_INC.'inc/parser/code.php', 1022ada8709SChristopher Smith 'Doku_Renderer_xhtmlsummary' => DOKU_INC.'inc/parser/xhtmlsummary.php', 1032ada8709SChristopher Smith 'Doku_Renderer_metadata' => DOKU_INC.'inc/parser/metadata.php', 1042ada8709SChristopher Smith 105496e3a6fSAndreas Gohr 'DokuCLI' => DOKU_INC.'inc/cli.php', 106496e3a6fSAndreas Gohr 'DokuCLI_Options' => DOKU_INC.'inc/cli.php', 107496e3a6fSAndreas Gohr 'DokuCLI_Colors' => DOKU_INC.'inc/cli.php', 108496e3a6fSAndreas Gohr 10916905344SAndreas Gohr ); 11016905344SAndreas Gohr 11116905344SAndreas Gohr if(isset($classes[$name])){ 1128a58013eSDavid Stone require ($classes[$name]); 1138a58013eSDavid Stone return true; 11416905344SAndreas Gohr } 115d54ac877SAdrian Lang 116b89dfc20SAndreas Gohr // namespace to directory conversion 117e7a32b17SAndreas Gohr $name = str_replace('\\', '/', $name); 118e7a32b17SAndreas Gohr 119600fb65eSAndreas Gohr // plugin namespace 120b89dfc20SAndreas Gohr if(substr($name, 0, 16) == 'dokuwiki/plugin/') { 121600fb65eSAndreas Gohr $name = str_replace('/test/', '/_test/', $name); // no underscore in test namespace 122b00eb817SAndreas Gohr $file = DOKU_PLUGIN . substr($name, 16) . '.php'; 123600fb65eSAndreas Gohr if(file_exists($file)) { 124600fb65eSAndreas Gohr require $file; 125600fb65eSAndreas Gohr return true; 126600fb65eSAndreas Gohr } 127600fb65eSAndreas Gohr } 128600fb65eSAndreas Gohr 129f83f0fd0SAndreas Gohr // template namespace 130f83f0fd0SAndreas Gohr if(substr($name, 0, 18) == 'dokuwiki/template/') { 131f83f0fd0SAndreas Gohr $name = str_replace('/test/', '/_test/', $name); // no underscore in test namespace 132f83f0fd0SAndreas Gohr $file = DOKU_INC.'lib/tpl/' . substr($name, 18) . '.php'; 133f83f0fd0SAndreas Gohr if(file_exists($file)) { 134f83f0fd0SAndreas Gohr require $file; 135f83f0fd0SAndreas Gohr return true; 136f83f0fd0SAndreas Gohr } 137f83f0fd0SAndreas Gohr } 138f83f0fd0SAndreas Gohr 139b89dfc20SAndreas Gohr // our own namespace 140b89dfc20SAndreas Gohr if(substr($name, 0, 9) == 'dokuwiki/') { 141b16ddc6eSAndreas Gohr $file = DOKU_INC . 'inc/' . substr($name, 9) . '.php'; 142b16ddc6eSAndreas Gohr if(file_exists($file)) { 143b16ddc6eSAndreas Gohr require $file; 144b89dfc20SAndreas Gohr return true; 145b89dfc20SAndreas Gohr } 146b16ddc6eSAndreas Gohr } 147b89dfc20SAndreas Gohr 148d54ac877SAdrian Lang // Plugin loading 149*39bceb98SAndreas Gohr if(preg_match('/^(auth|helper|syntax|action|admin|renderer|remote|cli)_plugin_('.DOKU_PLUGIN_NAME_REGEX.')(?:_([^_]+))?$/', 150d54ac877SAdrian Lang $name, $m)) { 151d54ac877SAdrian Lang // try to load the wanted plugin file 152d54ac877SAdrian Lang $c = ((count($m) === 4) ? "/{$m[3]}" : ''); 1535a9866e9SAndreas Gohr $plg = DOKU_PLUGIN . "{$m[2]}/{$m[1]}$c.php"; 15479e79377SAndreas Gohr if(file_exists($plg)){ 155ce949263SAndreas Gohr require $plg; 1565a9866e9SAndreas Gohr } 1578a58013eSDavid Stone return true; 158d54ac877SAdrian Lang } 159ce949263SAndreas Gohr return false; 16016905344SAndreas Gohr} 16116905344SAndreas Gohr 162