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'); 37*4cdb6842SAndreas Gohrrequire_once(DOKU_INC.'inc/deprecated.php'); 3816905344SAndreas Gohr 3916905344SAndreas Gohr/** 4016905344SAndreas Gohr * spl_autoload_register callback 4116905344SAndreas Gohr * 4216905344SAndreas Gohr * Contains a static list of DokuWiki's core classes and automatically 432dcde304SAndreas Gohr * require()s their associated php files when an object is instantiated. 4416905344SAndreas Gohr * 4516905344SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 46d54ac877SAdrian Lang * @todo add generic loading of renderers and auth backends 47f50a239bSTakamura * 48f50a239bSTakamura * @param string $name 49f50a239bSTakamura * 50f50a239bSTakamura * @return bool 5116905344SAndreas Gohr */ 5216905344SAndreas Gohrfunction load_autoload($name){ 5316905344SAndreas Gohr static $classes = null; 5416905344SAndreas Gohr if(is_null($classes)) $classes = array( 5516905344SAndreas Gohr 'DokuHTTPClient' => DOKU_INC.'inc/HTTPClient.php', 56a1d9de52SAndreas Gohr 'HTTPClient' => DOKU_INC.'inc/HTTPClient.php', 5716905344SAndreas Gohr 'JSON' => DOKU_INC.'inc/JSON.php', 5816905344SAndreas Gohr 'Diff' => DOKU_INC.'inc/DifferenceEngine.php', 5916905344SAndreas Gohr 'UnifiedDiffFormatter' => DOKU_INC.'inc/DifferenceEngine.php', 6016905344SAndreas Gohr 'TableDiffFormatter' => DOKU_INC.'inc/DifferenceEngine.php', 6116905344SAndreas Gohr 'cache' => DOKU_INC.'inc/cache.php', 6216905344SAndreas Gohr 'cache_parser' => DOKU_INC.'inc/cache.php', 6316905344SAndreas Gohr 'cache_instructions' => DOKU_INC.'inc/cache.php', 6416905344SAndreas Gohr 'cache_renderer' => DOKU_INC.'inc/cache.php', 6516905344SAndreas Gohr 'Doku_Event' => DOKU_INC.'inc/events.php', 6616905344SAndreas Gohr 'Doku_Event_Handler' => DOKU_INC.'inc/events.php', 6789177306SAndreas Gohr 'Input' => DOKU_INC.'inc/Input.class.php', 6816905344SAndreas Gohr 'JpegMeta' => DOKU_INC.'inc/JpegMeta.php', 692dcde304SAndreas Gohr 'SimplePie' => DOKU_INC.'inc/SimplePie.php', 7016905344SAndreas Gohr 'FeedParser' => DOKU_INC.'inc/FeedParser.php', 7116905344SAndreas Gohr 'IXR_Server' => DOKU_INC.'inc/IXR_Library.php', 7216905344SAndreas Gohr 'IXR_Client' => DOKU_INC.'inc/IXR_Library.php', 73b368386fSFlorian Rathgeber 'IXR_Error' => DOKU_INC.'inc/IXR_Library.php', 745ce4ea15SMichael Klier 'IXR_IntrospectionServer' => DOKU_INC.'inc/IXR_Library.php', 7516905344SAndreas Gohr 'Doku_Plugin_Controller'=> DOKU_INC.'inc/plugincontroller.class.php', 76f03fd957SAndreas Gohr 'SafeFN' => DOKU_INC.'inc/SafeFN.class.php', 772897eb23SMichael Hamann 'Sitemapper' => DOKU_INC.'inc/Sitemapper.php', 783a0a2d05SAndreas Gohr 'PassHash' => DOKU_INC.'inc/PassHash.class.php', 79c9a53c46SAndreas Gohr 'Mailer' => DOKU_INC.'inc/Mailer.class.php', 802240ea1fSAndreas Gohr 'Subscription' => DOKU_INC.'inc/subscription.php', 81c2a6d816SAndreas Gohr 8239bceb98SAndreas Gohr 'DokuWiki_PluginInterface' => DOKU_INC.'inc/PluginInterface.php', 8339bceb98SAndreas Gohr 'DokuWiki_PluginTrait' => DOKU_INC.'inc/PluginTrait.php', 8439bceb98SAndreas Gohr 'DokuWiki_Plugin' => DOKU_INC.'inc/Plugin.php', 8539bceb98SAndreas Gohr 8639bceb98SAndreas Gohr 87c2a6d816SAndreas Gohr 'DokuWiki_Action_Plugin' => DOKU_PLUGIN.'action.php', 88c2a6d816SAndreas Gohr 'DokuWiki_Admin_Plugin' => DOKU_PLUGIN.'admin.php', 89c2a6d816SAndreas Gohr 'DokuWiki_Syntax_Plugin' => DOKU_PLUGIN.'syntax.php', 90457ad80aSDominik Eckelmann 'DokuWiki_Remote_Plugin' => DOKU_PLUGIN.'remote.php', 913cbcc653SJan Schumann 'DokuWiki_Auth_Plugin' => DOKU_PLUGIN.'auth.php', 9239bceb98SAndreas Gohr 'DokuWiki_CLI_Plugin' => DOKU_PLUGIN.'cli.php', 93c2a6d816SAndreas Gohr 94d2778ca9SAndreas Gohr 'Doku_Handler' => DOKU_INC.'inc/parser/handler.php', 952ada8709SChristopher Smith 'Doku_Renderer' => DOKU_INC.'inc/parser/renderer.php', 962ada8709SChristopher Smith 'Doku_Renderer_xhtml' => DOKU_INC.'inc/parser/xhtml.php', 972ada8709SChristopher Smith 'Doku_Renderer_code' => DOKU_INC.'inc/parser/code.php', 982ada8709SChristopher Smith 'Doku_Renderer_xhtmlsummary' => DOKU_INC.'inc/parser/xhtmlsummary.php', 992ada8709SChristopher Smith 'Doku_Renderer_metadata' => DOKU_INC.'inc/parser/metadata.php', 1002ada8709SChristopher Smith 101496e3a6fSAndreas Gohr 'DokuCLI' => DOKU_INC.'inc/cli.php', 102496e3a6fSAndreas Gohr 'DokuCLI_Options' => DOKU_INC.'inc/cli.php', 103496e3a6fSAndreas Gohr 'DokuCLI_Colors' => DOKU_INC.'inc/cli.php', 104496e3a6fSAndreas Gohr 10516905344SAndreas Gohr ); 10616905344SAndreas Gohr 10716905344SAndreas Gohr if(isset($classes[$name])){ 1088a58013eSDavid Stone require ($classes[$name]); 1098a58013eSDavid Stone return true; 11016905344SAndreas Gohr } 111d54ac877SAdrian Lang 112b89dfc20SAndreas Gohr // namespace to directory conversion 113e7a32b17SAndreas Gohr $name = str_replace('\\', '/', $name); 114e7a32b17SAndreas Gohr 115a087da71SAndreas Gohr // test namespace 116a087da71SAndreas Gohr if(substr($name, 0, 14) == 'dokuwiki/test/') { 117a087da71SAndreas Gohr $file = DOKU_INC . '_test/' . substr($name, 14) . '.php'; 118a087da71SAndreas Gohr if(file_exists($file)) { 119a087da71SAndreas Gohr require $file; 120a087da71SAndreas Gohr return true; 121a087da71SAndreas Gohr } 122a087da71SAndreas Gohr } 123a087da71SAndreas Gohr 124600fb65eSAndreas Gohr // plugin namespace 125b89dfc20SAndreas Gohr if(substr($name, 0, 16) == 'dokuwiki/plugin/') { 126600fb65eSAndreas Gohr $name = str_replace('/test/', '/_test/', $name); // no underscore in test namespace 127b00eb817SAndreas Gohr $file = DOKU_PLUGIN . substr($name, 16) . '.php'; 128600fb65eSAndreas Gohr if(file_exists($file)) { 129600fb65eSAndreas Gohr require $file; 130600fb65eSAndreas Gohr return true; 131600fb65eSAndreas Gohr } 132600fb65eSAndreas Gohr } 133600fb65eSAndreas Gohr 134f83f0fd0SAndreas Gohr // template namespace 135f83f0fd0SAndreas Gohr if(substr($name, 0, 18) == 'dokuwiki/template/') { 136f83f0fd0SAndreas Gohr $name = str_replace('/test/', '/_test/', $name); // no underscore in test namespace 137f83f0fd0SAndreas Gohr $file = DOKU_INC.'lib/tpl/' . substr($name, 18) . '.php'; 138f83f0fd0SAndreas Gohr if(file_exists($file)) { 139f83f0fd0SAndreas Gohr require $file; 140f83f0fd0SAndreas Gohr return true; 141f83f0fd0SAndreas Gohr } 142f83f0fd0SAndreas Gohr } 143f83f0fd0SAndreas Gohr 144b89dfc20SAndreas Gohr // our own namespace 145b89dfc20SAndreas Gohr if(substr($name, 0, 9) == 'dokuwiki/') { 146b16ddc6eSAndreas Gohr $file = DOKU_INC . 'inc/' . substr($name, 9) . '.php'; 147b16ddc6eSAndreas Gohr if(file_exists($file)) { 148b16ddc6eSAndreas Gohr require $file; 149b89dfc20SAndreas Gohr return true; 150b89dfc20SAndreas Gohr } 151b16ddc6eSAndreas Gohr } 152b89dfc20SAndreas Gohr 153d54ac877SAdrian Lang // Plugin loading 15464159a61SAndreas Gohr if(preg_match( 15564159a61SAndreas Gohr '/^(auth|helper|syntax|action|admin|renderer|remote|cli)_plugin_(' . 15664159a61SAndreas Gohr DOKU_PLUGIN_NAME_REGEX . 15764159a61SAndreas Gohr ')(?:_([^_]+))?$/', 15864159a61SAndreas Gohr $name, 15964159a61SAndreas Gohr $m 16064159a61SAndreas Gohr )) { 161d54ac877SAdrian Lang // try to load the wanted plugin file 162d54ac877SAdrian Lang $c = ((count($m) === 4) ? "/{$m[3]}" : ''); 1635a9866e9SAndreas Gohr $plg = DOKU_PLUGIN . "{$m[2]}/{$m[1]}$c.php"; 16479e79377SAndreas Gohr if(file_exists($plg)){ 165ce949263SAndreas Gohr require $plg; 1665a9866e9SAndreas Gohr } 1678a58013eSDavid Stone return true; 168d54ac877SAdrian Lang } 169ce949263SAndreas Gohr return false; 17016905344SAndreas Gohr} 17116905344SAndreas Gohr 172