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 81935a891SAndreas Gohruse dokuwiki\Extension\PluginController; 91935a891SAndreas Gohr 1016905344SAndreas Gohr// setup class autoloader 1116905344SAndreas Gohrspl_autoload_register('load_autoload'); 1216905344SAndreas Gohr 1316905344SAndreas Gohr// require all the common libraries 1405ed2c25SAndreas Gohr// for a few of these order does matter 1516905344SAndreas Gohrrequire_once(DOKU_INC.'inc/actions.php'); 1616905344SAndreas Gohrrequire_once(DOKU_INC.'inc/changelog.php'); 1716905344SAndreas Gohrrequire_once(DOKU_INC.'inc/common.php'); 1816905344SAndreas Gohrrequire_once(DOKU_INC.'inc/confutils.php'); 1916905344SAndreas Gohrrequire_once(DOKU_INC.'inc/pluginutils.php'); 2016905344SAndreas Gohrrequire_once(DOKU_INC.'inc/form.php'); 2116905344SAndreas Gohrrequire_once(DOKU_INC.'inc/fulltext.php'); 2216905344SAndreas Gohrrequire_once(DOKU_INC.'inc/html.php'); 2316905344SAndreas Gohrrequire_once(DOKU_INC.'inc/httputils.php'); 2416905344SAndreas Gohrrequire_once(DOKU_INC.'inc/indexer.php'); 2516905344SAndreas Gohrrequire_once(DOKU_INC.'inc/infoutils.php'); 2616905344SAndreas Gohrrequire_once(DOKU_INC.'inc/io.php'); 2716905344SAndreas Gohrrequire_once(DOKU_INC.'inc/mail.php'); 2816905344SAndreas Gohrrequire_once(DOKU_INC.'inc/media.php'); 2916905344SAndreas Gohrrequire_once(DOKU_INC.'inc/pageutils.php'); 3016905344SAndreas Gohrrequire_once(DOKU_INC.'inc/parserutils.php'); 3116905344SAndreas Gohrrequire_once(DOKU_INC.'inc/search.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'); 374cdb6842SAndreas Gohrrequire_once(DOKU_INC.'inc/deprecated.php'); 38e1d9dcc8SAndreas Gohrrequire_once(DOKU_INC.'inc/legacy.php'); 3916905344SAndreas Gohr 4016905344SAndreas Gohr/** 4116905344SAndreas Gohr * spl_autoload_register callback 4216905344SAndreas Gohr * 4316905344SAndreas Gohr * Contains a static list of DokuWiki's core classes and automatically 442dcde304SAndreas Gohr * require()s their associated php files when an object is instantiated. 4516905344SAndreas Gohr * 4616905344SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 47d54ac877SAdrian Lang * @todo add generic loading of renderers and auth backends 48f50a239bSTakamura * 49f50a239bSTakamura * @param string $name 50f50a239bSTakamura * 51f50a239bSTakamura * @return bool 5216905344SAndreas Gohr */ 5316905344SAndreas Gohrfunction load_autoload($name){ 5416905344SAndreas Gohr static $classes = null; 55e1d9dcc8SAndreas Gohr if($classes === null) $classes = array( 5616905344SAndreas Gohr 'Diff' => DOKU_INC.'inc/DifferenceEngine.php', 5716905344SAndreas Gohr 'UnifiedDiffFormatter' => DOKU_INC.'inc/DifferenceEngine.php', 5816905344SAndreas Gohr 'TableDiffFormatter' => DOKU_INC.'inc/DifferenceEngine.php', 5916905344SAndreas Gohr 'cache' => DOKU_INC.'inc/cache.php', 6016905344SAndreas Gohr 'cache_parser' => DOKU_INC.'inc/cache.php', 6116905344SAndreas Gohr 'cache_instructions' => DOKU_INC.'inc/cache.php', 6216905344SAndreas Gohr 'cache_renderer' => DOKU_INC.'inc/cache.php', 63e1d9dcc8SAndreas Gohr 'Input' => DOKU_INC.'inc/Input.class.php', 6416905344SAndreas Gohr 'JpegMeta' => DOKU_INC.'inc/JpegMeta.php', 652dcde304SAndreas Gohr 'SimplePie' => DOKU_INC.'inc/SimplePie.php', 6616905344SAndreas Gohr 'FeedParser' => DOKU_INC.'inc/FeedParser.php', 6716905344SAndreas Gohr 'IXR_Server' => DOKU_INC.'inc/IXR_Library.php', 6816905344SAndreas Gohr 'IXR_Client' => DOKU_INC.'inc/IXR_Library.php', 69b368386fSFlorian Rathgeber 'IXR_Error' => DOKU_INC.'inc/IXR_Library.php', 705ce4ea15SMichael Klier 'IXR_IntrospectionServer' => DOKU_INC.'inc/IXR_Library.php', 71f03fd957SAndreas Gohr 'SafeFN' => DOKU_INC.'inc/SafeFN.class.php', 722897eb23SMichael Hamann 'Sitemapper' => DOKU_INC.'inc/Sitemapper.php', 73c9a53c46SAndreas Gohr 'Mailer' => DOKU_INC.'inc/Mailer.class.php', 74c2a6d816SAndreas Gohr 75d2778ca9SAndreas Gohr 'Doku_Handler' => DOKU_INC.'inc/parser/handler.php', 762ada8709SChristopher Smith 'Doku_Renderer' => DOKU_INC.'inc/parser/renderer.php', 772ada8709SChristopher Smith 'Doku_Renderer_xhtml' => DOKU_INC.'inc/parser/xhtml.php', 782ada8709SChristopher Smith 'Doku_Renderer_code' => DOKU_INC.'inc/parser/code.php', 792ada8709SChristopher Smith 'Doku_Renderer_xhtmlsummary' => DOKU_INC.'inc/parser/xhtmlsummary.php', 802ada8709SChristopher Smith 'Doku_Renderer_metadata' => DOKU_INC.'inc/parser/metadata.php', 812ada8709SChristopher Smith 82496e3a6fSAndreas Gohr 'DokuCLI' => DOKU_INC.'inc/cli.php', 83496e3a6fSAndreas Gohr 'DokuCLI_Options' => DOKU_INC.'inc/cli.php', 84496e3a6fSAndreas Gohr 'DokuCLI_Colors' => DOKU_INC.'inc/cli.php', 85496e3a6fSAndreas Gohr 8616905344SAndreas Gohr ); 8716905344SAndreas Gohr 8816905344SAndreas Gohr if(isset($classes[$name])){ 898a58013eSDavid Stone require ($classes[$name]); 908a58013eSDavid Stone return true; 9116905344SAndreas Gohr } 92d54ac877SAdrian Lang 93b89dfc20SAndreas Gohr // namespace to directory conversion 94e7a32b17SAndreas Gohr $name = str_replace('\\', '/', $name); 95e7a32b17SAndreas Gohr 96a087da71SAndreas Gohr // test namespace 97*68f88d34SAndreas Gohr if(substr($name, 0, 14) === 'dokuwiki/test/') { 98a087da71SAndreas Gohr $file = DOKU_INC . '_test/' . substr($name, 14) . '.php'; 99a087da71SAndreas Gohr if(file_exists($file)) { 100a087da71SAndreas Gohr require $file; 101a087da71SAndreas Gohr return true; 102a087da71SAndreas Gohr } 103a087da71SAndreas Gohr } 104a087da71SAndreas Gohr 105600fb65eSAndreas Gohr // plugin namespace 106*68f88d34SAndreas Gohr if(substr($name, 0, 16) === 'dokuwiki/plugin/') { 107600fb65eSAndreas Gohr $name = str_replace('/test/', '/_test/', $name); // no underscore in test namespace 108b00eb817SAndreas Gohr $file = DOKU_PLUGIN . substr($name, 16) . '.php'; 109600fb65eSAndreas Gohr if(file_exists($file)) { 110600fb65eSAndreas Gohr require $file; 111600fb65eSAndreas Gohr return true; 112600fb65eSAndreas Gohr } 113600fb65eSAndreas Gohr } 114600fb65eSAndreas Gohr 115f83f0fd0SAndreas Gohr // template namespace 116*68f88d34SAndreas Gohr if(substr($name, 0, 18) === 'dokuwiki/template/') { 117f83f0fd0SAndreas Gohr $name = str_replace('/test/', '/_test/', $name); // no underscore in test namespace 118f83f0fd0SAndreas Gohr $file = DOKU_INC.'lib/tpl/' . substr($name, 18) . '.php'; 119f83f0fd0SAndreas Gohr if(file_exists($file)) { 120f83f0fd0SAndreas Gohr require $file; 121f83f0fd0SAndreas Gohr return true; 122f83f0fd0SAndreas Gohr } 123f83f0fd0SAndreas Gohr } 124f83f0fd0SAndreas Gohr 125b89dfc20SAndreas Gohr // our own namespace 126*68f88d34SAndreas Gohr if(substr($name, 0, 9) === 'dokuwiki/') { 127b16ddc6eSAndreas Gohr $file = DOKU_INC . 'inc/' . substr($name, 9) . '.php'; 128b16ddc6eSAndreas Gohr if(file_exists($file)) { 129b16ddc6eSAndreas Gohr require $file; 130b89dfc20SAndreas Gohr return true; 131b89dfc20SAndreas Gohr } 132b16ddc6eSAndreas Gohr } 133b89dfc20SAndreas Gohr 134d54ac877SAdrian Lang // Plugin loading 13564159a61SAndreas Gohr if(preg_match( 1361935a891SAndreas Gohr '/^(' . implode('|', PluginController::PLUGIN_TYPES) . ')_plugin_(' . 13764159a61SAndreas Gohr DOKU_PLUGIN_NAME_REGEX . 13864159a61SAndreas Gohr ')(?:_([^_]+))?$/', 13964159a61SAndreas Gohr $name, 14064159a61SAndreas Gohr $m 14164159a61SAndreas Gohr )) { 142d54ac877SAdrian Lang // try to load the wanted plugin file 143d54ac877SAdrian Lang $c = ((count($m) === 4) ? "/{$m[3]}" : ''); 1445a9866e9SAndreas Gohr $plg = DOKU_PLUGIN . "{$m[2]}/{$m[1]}$c.php"; 14579e79377SAndreas Gohr if(file_exists($plg)){ 146ce949263SAndreas Gohr require $plg; 1475a9866e9SAndreas Gohr } 1488a58013eSDavid Stone return true; 149d54ac877SAdrian Lang } 150ce949263SAndreas Gohr return false; 15116905344SAndreas Gohr} 15216905344SAndreas Gohr 153