From 16905344219a6293705b71cd526fad3ba07b04eb Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 31 Jan 2010 19:02:14 +0100 Subject: first attempt to centralize all include loading Classes are loaded throug PHP5's class autoloader, all other includes are just loaded by default. This skips a lot of require_once calls. Parser and Plugin stuff isn't handled by the class loader yet. --- inc/FeedParser.php | 3 -- inc/JSON.php | 1 - inc/actions.php | 2 -- inc/auth.php | 100 ++++++++++++++++++++++++++------------------------- inc/cache.php | 3 -- inc/common.php | 7 ---- inc/events.php | 1 - inc/form.php | 1 - inc/fulltext.php | 2 -- inc/html.php | 2 -- inc/indexer.php | 3 -- inc/infoutils.php | 1 - inc/init.php | 8 +++-- inc/io.php | 4 --- inc/load.php | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++ inc/mail.php | 2 -- inc/media.php | 3 -- inc/parserutils.php | 4 --- inc/pluginutils.php | 1 - inc/search.php | 1 - inc/subscription.php | 2 -- inc/toolbar.php | 2 -- 22 files changed, 155 insertions(+), 96 deletions(-) create mode 100644 inc/load.php (limited to 'inc') diff --git a/inc/FeedParser.php b/inc/FeedParser.php index f37888f01..9d00e7abf 100644 --- a/inc/FeedParser.php +++ b/inc/FeedParser.php @@ -6,9 +6,6 @@ */ if(!defined('DOKU_INC')) die('meh.'); -require_once(DOKU_INC.'inc/HTTPClient.php'); -require_once(DOKU_INC.'inc/SimplePie.php'); - /** * We override some methods of the original SimplePie class here diff --git a/inc/JSON.php b/inc/JSON.php index 7ec400092..332827f4c 100644 --- a/inc/JSON.php +++ b/inc/JSON.php @@ -59,7 +59,6 @@ // for DokuWiki if(!defined('DOKU_INC')) die('meh.'); -require_once(DOKU_INC.'inc/utf8.php'); /** * Marker constant for JSON::decode(), used to flag stack state diff --git a/inc/actions.php b/inc/actions.php index 1fda0584e..7f9cb26d0 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -7,8 +7,6 @@ */ if(!defined('DOKU_INC')) die('meh.'); -require_once(DOKU_INC.'inc/template.php'); - /** * Call the needed action handlers diff --git a/inc/auth.php b/inc/auth.php index c18104487..33626cf80 100644 --- a/inc/auth.php +++ b/inc/auth.php @@ -10,8 +10,6 @@ */ if(!defined('DOKU_INC')) die('meh.'); -require_once(DOKU_INC.'inc/common.php'); -require_once(DOKU_INC.'inc/io.php'); // some ACL level defines define('AUTH_NONE',0); @@ -22,15 +20,23 @@ define('AUTH_UPLOAD',8); define('AUTH_DELETE',16); define('AUTH_ADMIN',255); -global $conf; - -if($conf['useacl']){ - require_once(DOKU_INC.'inc/blowfish.php'); - require_once(DOKU_INC.'inc/mail.php'); - +/** + * Initialize the auth system. + * + * This function is automatically called at the end of init.php + * + * This used to be the main() of the auth.php + * + * @todo backend loading maybe should be handled by the class autoloader + * @todo maybe split into multiple functions at the XXX marked positions + */ +function auth_setup(){ + global $conf; global $auth; - // load the the backend auth functions and instantiate the auth object + if(!$conf['useacl']) return false; + + // load the the backend auth functions and instantiate the auth object XXX if (@file_exists(DOKU_INC.'inc/auth/'.$conf['authtype'].'.class.php')) { require_once(DOKU_INC.'inc/auth/basic.class.php'); require_once(DOKU_INC.'inc/auth/'.$conf['authtype'].'.class.php'); @@ -50,51 +56,49 @@ if($conf['useacl']){ } else { nice_die($lang['authmodfailed']); } -} -// do the login either by cookie or provided credentials -if($conf['useacl']){ - if($auth){ - if (!isset($_REQUEST['u'])) $_REQUEST['u'] = ''; - if (!isset($_REQUEST['p'])) $_REQUEST['p'] = ''; - if (!isset($_REQUEST['r'])) $_REQUEST['r'] = ''; - $_REQUEST['http_credentials'] = false; - if (!$conf['rememberme']) $_REQUEST['r'] = false; - - // streamline HTTP auth credentials (IIS/rewrite -> mod_php) - if(isset($_SERVER['HTTP_AUTHORIZATION'])){ - list($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW']) = - explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6))); - } + if(!$auth) return; - // if no credentials were given try to use HTTP auth (for SSO) - if(empty($_REQUEST['u']) && empty($_COOKIE[DOKU_COOKIE]) && !empty($_SERVER['PHP_AUTH_USER'])){ - $_REQUEST['u'] = $_SERVER['PHP_AUTH_USER']; - $_REQUEST['p'] = $_SERVER['PHP_AUTH_PW']; - $_REQUEST['http_credentials'] = true; - } + // do the login either by cookie or provided credentials XXX + if (!isset($_REQUEST['u'])) $_REQUEST['u'] = ''; + if (!isset($_REQUEST['p'])) $_REQUEST['p'] = ''; + if (!isset($_REQUEST['r'])) $_REQUEST['r'] = ''; + $_REQUEST['http_credentials'] = false; + if (!$conf['rememberme']) $_REQUEST['r'] = false; - // apply cleaning - $_REQUEST['u'] = $auth->cleanUser($_REQUEST['u']); + // streamline HTTP auth credentials (IIS/rewrite -> mod_php) + if(isset($_SERVER['HTTP_AUTHORIZATION'])){ + list($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW']) = + explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6))); + } - if(isset($_REQUEST['authtok'])){ - // when an authentication token is given, trust the session - auth_validateToken($_REQUEST['authtok']); - }elseif(!is_null($auth) && $auth->canDo('external')){ - // external trust mechanism in place - $auth->trustExternal($_REQUEST['u'],$_REQUEST['p'],$_REQUEST['r']); - }else{ - $evdata = array( - 'user' => $_REQUEST['u'], - 'password' => $_REQUEST['p'], - 'sticky' => $_REQUEST['r'], - 'silent' => $_REQUEST['http_credentials'], - ); - trigger_event('AUTH_LOGIN_CHECK', $evdata, 'auth_login_wrapper'); - } + // if no credentials were given try to use HTTP auth (for SSO) + if(empty($_REQUEST['u']) && empty($_COOKIE[DOKU_COOKIE]) && !empty($_SERVER['PHP_AUTH_USER'])){ + $_REQUEST['u'] = $_SERVER['PHP_AUTH_USER']; + $_REQUEST['p'] = $_SERVER['PHP_AUTH_PW']; + $_REQUEST['http_credentials'] = true; + } + + // apply cleaning + $_REQUEST['u'] = $auth->cleanUser($_REQUEST['u']); + + if(isset($_REQUEST['authtok'])){ + // when an authentication token is given, trust the session + auth_validateToken($_REQUEST['authtok']); + }elseif(!is_null($auth) && $auth->canDo('external')){ + // external trust mechanism in place + $auth->trustExternal($_REQUEST['u'],$_REQUEST['p'],$_REQUEST['r']); + }else{ + $evdata = array( + 'user' => $_REQUEST['u'], + 'password' => $_REQUEST['p'], + 'sticky' => $_REQUEST['r'], + 'silent' => $_REQUEST['http_credentials'], + ); + trigger_event('AUTH_LOGIN_CHECK', $evdata, 'auth_login_wrapper'); } - //load ACL into a global array + //load ACL into a global array XXX global $AUTH_ACL; if(is_readable(DOKU_CONF.'acl.auth.php')){ $AUTH_ACL = file(DOKU_CONF.'acl.auth.php'); diff --git a/inc/cache.php b/inc/cache.php index 2e22edfb1..571b314cd 100644 --- a/inc/cache.php +++ b/inc/cache.php @@ -7,9 +7,6 @@ */ if(!defined('DOKU_INC')) die('meh.'); -require_once(DOKU_INC.'inc/io.php'); -require_once(DOKU_INC.'inc/pageutils.php'); -require_once(DOKU_INC.'inc/parserutils.php'); class cache { var $key = ''; // primary identifier for this item diff --git a/inc/common.php b/inc/common.php index 9cadb56fd..ef35ca863 100644 --- a/inc/common.php +++ b/inc/common.php @@ -7,13 +7,6 @@ */ if(!defined('DOKU_INC')) die('meh.'); -require_once(DOKU_INC.'inc/io.php'); -require_once(DOKU_INC.'inc/changelog.php'); -require_once(DOKU_INC.'inc/utf8.php'); -require_once(DOKU_INC.'inc/mail.php'); -require_once(DOKU_INC.'inc/parserutils.php'); -require_once(DOKU_INC.'inc/infoutils.php'); -require_once DOKU_INC.'inc/subscription.php'; /** * These constants are used with the recents function diff --git a/inc/events.php b/inc/events.php index e6b608f20..1c82af003 100644 --- a/inc/events.php +++ b/inc/events.php @@ -7,7 +7,6 @@ */ if(!defined('DOKU_INC')) die('meh.'); -require_once(DOKU_INC.'inc/pluginutils.php'); class Doku_Event { diff --git a/inc/form.php b/inc/form.php index 0a6bc2bba..cebaf4608 100644 --- a/inc/form.php +++ b/inc/form.php @@ -7,7 +7,6 @@ */ if(!defined('DOKU_INC')) die('meh.'); -require_once(DOKU_INC.'inc/html.php'); /** * Class for creating simple HTML forms. diff --git a/inc/fulltext.php b/inc/fulltext.php index 94c68d675..58d17422a 100644 --- a/inc/fulltext.php +++ b/inc/fulltext.php @@ -7,8 +7,6 @@ */ if(!defined('DOKU_INC')) die('meh.'); -require_once(DOKU_INC.'inc/indexer.php'); - /** * The fulltext search diff --git a/inc/html.php b/inc/html.php index 8a215f440..5e1d0bab3 100644 --- a/inc/html.php +++ b/inc/html.php @@ -8,8 +8,6 @@ if(!defined('DOKU_INC')) die('meh.'); if(!defined('NL')) define('NL',"\n"); -require_once(DOKU_INC.'inc/parserutils.php'); -require_once(DOKU_INC.'inc/form.php'); /** * Convenience function to quickly build a wikilink diff --git a/inc/indexer.php b/inc/indexer.php index 39592e8f4..07b67c014 100644 --- a/inc/indexer.php +++ b/inc/indexer.php @@ -7,9 +7,6 @@ */ if(!defined('DOKU_INC')) die('meh.'); -require_once(DOKU_INC.'inc/io.php'); -require_once(DOKU_INC.'inc/utf8.php'); -require_once(DOKU_INC.'inc/parserutils.php'); // set the minimum token length to use in the index (note, this doesn't apply to numeric tokens) if (!defined('IDX_MINWORDLENGTH')) define('IDX_MINWORDLENGTH',2); diff --git a/inc/infoutils.php b/inc/infoutils.php index d5356969b..6f2874fe5 100644 --- a/inc/infoutils.php +++ b/inc/infoutils.php @@ -7,7 +7,6 @@ */ if(!defined('DOKU_INC')) die('meh.'); if(!defined('DOKU_MESSAGEURL')) define('DOKU_MESSAGEURL','http://update.dokuwiki.org/check/'); -require_once(DOKU_INC.'inc/HTTPClient.php'); /** * Check for new messages from upstream diff --git a/inc/init.php b/inc/init.php index 6fb9559ce..3cff40073 100644 --- a/inc/init.php +++ b/inc/init.php @@ -37,6 +37,9 @@ if (!defined('DOKU_E_LEVEL')) { error_reporting(DOKU_E_LEVEL); } +// load libraries +require_once(DOKU_INC.'inc/load.php'); + // init memory caches global $cache_revinfo; $cache_revinfo = array(); @@ -245,6 +248,8 @@ init_files(); scriptify(DOKU_CONF.'users.auth'); scriptify(DOKU_CONF.'acl.auth'); +// setup authentication system +auth_setup(); /** * Checks paths from config file @@ -526,7 +531,6 @@ EOT; exit; } - /** * A realpath() replacement * @@ -588,5 +592,3 @@ function fullpath($path,$exists=false){ return $finalpath; } - - diff --git a/inc/io.php b/inc/io.php index 32a6f7b8e..1d69dabc9 100644 --- a/inc/io.php +++ b/inc/io.php @@ -7,10 +7,6 @@ */ if(!defined('DOKU_INC')) die('meh.'); -require_once(DOKU_INC.'inc/common.php'); -require_once(DOKU_INC.'inc/HTTPClient.php'); -require_once(DOKU_INC.'inc/events.php'); -require_once(DOKU_INC.'inc/utf8.php'); /** * Removes empty directories diff --git a/inc/load.php b/inc/load.php new file mode 100644 index 000000000..9d305e3a9 --- /dev/null +++ b/inc/load.php @@ -0,0 +1,98 @@ + + */ + +// setup class autoloader +spl_autoload_register('load_autoload'); + +// require all the common libraries +// for a e few of these order does matter +require_once(DOKU_INC.'inc/DifferenceEngine.php'); +require_once(DOKU_INC.'inc/EmailAddressValidator.php'); +require_once(DOKU_INC.'inc/SimplePie.php'); +require_once(DOKU_INC.'inc/FeedParser.php'); +require_once(DOKU_INC.'inc/HTTPClient.php'); +require_once(DOKU_INC.'inc/IXR_Library.php'); +require_once(DOKU_INC.'inc/JSON.php'); +require_once(DOKU_INC.'inc/JpegMeta.php'); +require_once(DOKU_INC.'inc/TarLib.class.php'); +require_once(DOKU_INC.'inc/ZipLib.class.php'); +require_once(DOKU_INC.'inc/adLDAP.php'); +require_once(DOKU_INC.'inc/blowfish.php'); +require_once(DOKU_INC.'inc/feedcreator.class.php'); +require_once(DOKU_INC.'inc/geshi.php'); +require_once(DOKU_INC.'inc/actions.php'); +require_once(DOKU_INC.'inc/cache.php'); +require_once(DOKU_INC.'inc/changelog.php'); +require_once(DOKU_INC.'inc/cliopts.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/plugin.php'); +require_once(DOKU_INC.'inc/plugincontroller.class.php'); +require_once(DOKU_INC.'inc/events.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/init.php'); +require_once(DOKU_INC.'inc/io.php'); +require_once(DOKU_INC.'inc/load.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/subscription.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'); + +/** + * spl_autoload_register callback + * + * Contains a static list of DokuWiki's core classes and automatically + * requires their associated php files when an object is instantiated. + * + * @author Andreas Gohr + * @todo add generic loading of plugins here + */ +function load_autoload($name){ + static $classes = null; + if(is_null($classes)) $classes = array( + 'DokuHTTPClient' => DOKU_INC.'inc/HTTPClient.php', + 'DokuEvent' => DOKU_INC.'inc/', + 'JSON' => DOKU_INC.'inc/JSON.php', + 'adLDAP' => DOKU_INC.'inc/adLDAP.php', + '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', + 'Doku_Event' => DOKU_INC.'inc/events.php', + 'Doku_Event_Handler' => DOKU_INC.'inc/events.php', + 'Doku_Form' => DOKU_INC.'inc/form.php', + 'EmailAddressValidator' => DOKU_INC.'inc/EmailAddressValidator.php', + 'JpegMeta' => DOKU_INC.'inc/JpegMeta.php', + 'FeedParser' => DOKU_INC.'inc/FeedParser.php', + 'utf8_entity_decoder' => DOKU_INC.'inc/utf8.php', + 'IXR_Server' => DOKU_INC.'inc/IXR_Library.php', + 'IXR_Client' => DOKU_INC.'inc/IXR_Library.php', + 'Doku_Plugin_Controller'=> DOKU_INC.'inc/plugincontroller.class.php', + 'GeSHi' => DOKU_INC.'inc/geshi.php', + ); + + if(isset($classes[$name])){ + require_once($classes[$name]); + return; + } +} + diff --git a/inc/mail.php b/inc/mail.php index 3b0592b8b..6d1652fc0 100644 --- a/inc/mail.php +++ b/inc/mail.php @@ -7,8 +7,6 @@ */ if(!defined('DOKU_INC')) die('meh.'); -require_once(DOKU_INC.'inc/utf8.php'); -require_once(DOKU_INC.'inc/EmailAddressValidator.php'); // end of line for mail lines - RFC822 says CRLF but postfix (and other MTAs?) // think different diff --git a/inc/media.php b/inc/media.php index 3850f4e33..444e6d432 100644 --- a/inc/media.php +++ b/inc/media.php @@ -8,9 +8,6 @@ if(!defined('DOKU_INC')) die('meh.'); if(!defined('NL')) define('NL',"\n"); -require_once(DOKU_INC.'inc/html.php'); -require_once(DOKU_INC.'inc/search.php'); -require_once(DOKU_INC.'inc/JpegMeta.php'); /** * Lists pages which currently use a media file selected for deletion diff --git a/inc/parserutils.php b/inc/parserutils.php index 471d46903..34d9e5282 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -8,10 +8,6 @@ */ if(!defined('DOKU_INC')) die('meh.'); -require_once(DOKU_INC.'inc/confutils.php'); -require_once(DOKU_INC.'inc/pageutils.php'); -require_once(DOKU_INC.'inc/pluginutils.php'); -require_once(DOKU_INC.'inc/cache.php'); /** * Returns the parsed Wikitext in XHTML for the given id and revision. diff --git a/inc/pluginutils.php b/inc/pluginutils.php index 8294d1ec8..a8656a96a 100644 --- a/inc/pluginutils.php +++ b/inc/pluginutils.php @@ -8,7 +8,6 @@ // plugin related constants if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); -require_once(DOKU_INC.'inc/plugincontroller.class.php'); $plugin_types = array('admin','syntax','action','renderer', 'helper'); diff --git a/inc/search.php b/inc/search.php index 2b9a51fb3..ce4fefe06 100644 --- a/inc/search.php +++ b/inc/search.php @@ -7,7 +7,6 @@ */ if(!defined('DOKU_INC')) die('meh.'); -require_once(DOKU_INC.'inc/common.php'); /** * recurse direcory diff --git a/inc/subscription.php b/inc/subscription.php index f7614014f..e98129b77 100644 --- a/inc/subscription.php +++ b/inc/subscription.php @@ -14,8 +14,6 @@ * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) */ -require_once DOKU_INC.'/inc/pageutils.php'; - /** * Get the name of the metafile tracking subscriptions to target page or * namespace diff --git a/inc/toolbar.php b/inc/toolbar.php index 9140970d1..5d1149df3 100644 --- a/inc/toolbar.php +++ b/inc/toolbar.php @@ -7,8 +7,6 @@ */ if(!defined('DOKU_INC')) die('meh.'); -require_once(DOKU_INC.'inc/JSON.php'); - /** * Prepares and prints an JavaScript array with all toolbar buttons -- cgit v1.2.3 From 2dcde3047b0cbc7cb75b3d9f84fd05a217b7fced Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 1 Feb 2010 15:18:39 +0100 Subject: do not autorequire class only libraries those are loaded on demand through the autoloader mechanism Also cliopts.php is not loaded automatically at all --- inc/load.php | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'inc') diff --git a/inc/load.php b/inc/load.php index 9d305e3a9..792f05e27 100644 --- a/inc/load.php +++ b/inc/load.php @@ -10,29 +10,17 @@ spl_autoload_register('load_autoload'); // require all the common libraries // for a e few of these order does matter -require_once(DOKU_INC.'inc/DifferenceEngine.php'); -require_once(DOKU_INC.'inc/EmailAddressValidator.php'); -require_once(DOKU_INC.'inc/SimplePie.php'); -require_once(DOKU_INC.'inc/FeedParser.php'); -require_once(DOKU_INC.'inc/HTTPClient.php'); require_once(DOKU_INC.'inc/IXR_Library.php'); -require_once(DOKU_INC.'inc/JSON.php'); -require_once(DOKU_INC.'inc/JpegMeta.php'); -require_once(DOKU_INC.'inc/TarLib.class.php'); -require_once(DOKU_INC.'inc/ZipLib.class.php'); require_once(DOKU_INC.'inc/adLDAP.php'); require_once(DOKU_INC.'inc/blowfish.php'); require_once(DOKU_INC.'inc/feedcreator.class.php'); require_once(DOKU_INC.'inc/geshi.php'); require_once(DOKU_INC.'inc/actions.php'); -require_once(DOKU_INC.'inc/cache.php'); require_once(DOKU_INC.'inc/changelog.php'); -require_once(DOKU_INC.'inc/cliopts.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/plugin.php'); -require_once(DOKU_INC.'inc/plugincontroller.class.php'); require_once(DOKU_INC.'inc/events.php'); require_once(DOKU_INC.'inc/form.php'); require_once(DOKU_INC.'inc/fulltext.php'); @@ -58,7 +46,7 @@ require_once(DOKU_INC.'inc/auth.php'); * spl_autoload_register callback * * Contains a static list of DokuWiki's core classes and automatically - * requires their associated php files when an object is instantiated. + * require()s their associated php files when an object is instantiated. * * @author Andreas Gohr * @todo add generic loading of plugins here @@ -67,7 +55,6 @@ function load_autoload($name){ static $classes = null; if(is_null($classes)) $classes = array( 'DokuHTTPClient' => DOKU_INC.'inc/HTTPClient.php', - 'DokuEvent' => DOKU_INC.'inc/', 'JSON' => DOKU_INC.'inc/JSON.php', 'adLDAP' => DOKU_INC.'inc/adLDAP.php', 'Diff' => DOKU_INC.'inc/DifferenceEngine.php', @@ -79,15 +66,16 @@ function load_autoload($name){ 'cache_renderer' => DOKU_INC.'inc/cache.php', 'Doku_Event' => DOKU_INC.'inc/events.php', 'Doku_Event_Handler' => DOKU_INC.'inc/events.php', - 'Doku_Form' => DOKU_INC.'inc/form.php', 'EmailAddressValidator' => DOKU_INC.'inc/EmailAddressValidator.php', 'JpegMeta' => DOKU_INC.'inc/JpegMeta.php', + 'SimplePie' => DOKU_INC.'inc/SimplePie.php', 'FeedParser' => DOKU_INC.'inc/FeedParser.php', - 'utf8_entity_decoder' => DOKU_INC.'inc/utf8.php', 'IXR_Server' => DOKU_INC.'inc/IXR_Library.php', 'IXR_Client' => DOKU_INC.'inc/IXR_Library.php', 'Doku_Plugin_Controller'=> DOKU_INC.'inc/plugincontroller.class.php', 'GeSHi' => DOKU_INC.'inc/geshi.php', + 'TarLib' => DOKU_INC.'inc/TarLib.class.php', + 'ZibLib' => DOKU_INC.'inc/ZipLib.class.php', ); if(isset($classes[$name])){ -- cgit v1.2.3 From 0af14a6e25ba35e88d96762bc73325838868e3fe Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 1 Feb 2010 15:38:41 +0100 Subject: removed more unneeded require_once() calls --- inc/IXR_Library.php | 1 - inc/actions.php | 1 - inc/common.php | 2 -- inc/fulltext.php | 1 - inc/html.php | 5 ----- inc/infoutils.php | 1 - inc/media.php | 2 -- inc/parserutils.php | 2 -- inc/search.php | 2 -- inc/subscription.php | 1 - inc/template.php | 2 -- 11 files changed, 20 deletions(-) (limited to 'inc') diff --git a/inc/IXR_Library.php b/inc/IXR_Library.php index 25d1066b0..afa496aed 100644 --- a/inc/IXR_Library.php +++ b/inc/IXR_Library.php @@ -364,7 +364,6 @@ EOD; #$result = $this->$method($args); $result = call_user_func_array(array(&$this,$method),$args); } elseif (substr($method, 0, 7) == 'plugin:') { - require_once(DOKU_INC.'inc/pluginutils.php'); list($pluginname, $callback) = explode(':', substr($method, 7), 2); if(!plugin_isdisabled($pluginname)) { $plugin = plugin_load('action', $pluginname); diff --git a/inc/actions.php b/inc/actions.php index 7f9cb26d0..91a1d9cdd 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -580,7 +580,6 @@ function act_subscription($act){ $action = $params['action']; // Perform action. - require_once DOKU_INC . 'inc/subscription.php'; if (!subscription_set($_SERVER['REMOTE_USER'], $target, $style, $data)) { throw new Exception(sprintf($lang["subscr_{$action}_error"], hsc($INFO['userinfo']['name']), diff --git a/inc/common.php b/inc/common.php index ef35ca863..c68eb2899 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1003,7 +1003,6 @@ function saveWikiText($id,$text,$summary,$minor=false){ // if useheading is enabled, purge the cache of all linking pages if(useHeading('content')){ - require_once(DOKU_INC.'inc/fulltext.php'); $pages = ft_backlinks($id); foreach ($pages as $page) { $cache = new cache_renderer($page, wikiFN($page), 'xhtml'); @@ -1091,7 +1090,6 @@ function notify($id,$who,$rev='',$summary='',$minor=false,$replace=array()){ }elseif($rev){ $subject = $lang['mail_changed'].' '.$id; $text = str_replace('@OLDPAGE@',wl($id,"rev=$rev",true,'&'),$text); - require_once(DOKU_INC.'inc/DifferenceEngine.php'); $df = new Diff(explode("\n",rawWiki($id,$rev)), explode("\n",rawWiki($id))); $dformat = new UnifiedDiffFormatter(); diff --git a/inc/fulltext.php b/inc/fulltext.php index 58d17422a..76dd01d1f 100644 --- a/inc/fulltext.php +++ b/inc/fulltext.php @@ -133,7 +133,6 @@ function ft_backlinks($id){ $docs = array_keys(ft_resultCombine(array_values($matches))); $docs = array_filter($docs,'isVisiblePage'); // discard hidden pages if(!count($docs)) return $result; - require_once(DOKU_INC.'inc/parserutils.php'); // check metadata for matching links foreach($docs as $match){ diff --git a/inc/html.php b/inc/html.php index 5e1d0bab3..2d6c0a093 100644 --- a/inc/html.php +++ b/inc/html.php @@ -296,8 +296,6 @@ function html_hilight_callback($m) { * @author Andreas Gohr */ function html_search(){ - require_once(DOKU_INC.'inc/search.php'); - require_once(DOKU_INC.'inc/fulltext.php'); global $conf; global $QUERY; global $ID; @@ -690,7 +688,6 @@ function html_recent($first=0){ * @author Andreas Gohr */ function html_index($ns){ - require_once(DOKU_INC.'inc/search.php'); global $conf; global $ID; $dir = $conf['datadir']; @@ -828,7 +825,6 @@ function html_buildlist($data,$class,$func,$lifunc='html_li_default'){ * @author Michael Klier */ function html_backlinks(){ - require_once(DOKU_INC.'inc/fulltext.php'); global $ID; global $conf; global $lang; @@ -856,7 +852,6 @@ function html_backlinks(){ * @author Andreas Gohr */ function html_diff($text='',$intro=true){ - require_once(DOKU_INC.'inc/DifferenceEngine.php'); global $ID; global $REV; global $lang; diff --git a/inc/infoutils.php b/inc/infoutils.php index 6f2874fe5..00a3ad2d3 100644 --- a/inc/infoutils.php +++ b/inc/infoutils.php @@ -222,7 +222,6 @@ function check(){ msg('The current page is not writable by you',0); } - require_once(DOKU_INC.'inc/HTTPClient.php'); $check = wl('','',true).'data/_dummy'; $http = new DokuHTTPClient(); $http->timeout = 6; diff --git a/inc/media.php b/inc/media.php index 444e6d432..668f42d6a 100644 --- a/inc/media.php +++ b/inc/media.php @@ -149,7 +149,6 @@ function media_inuse($id) { global $conf; $mediareferences = array(); if($conf['refcheck']){ - require_once(DOKU_INC.'inc/fulltext.php'); $mediareferences = ft_mediause($id,$conf['refshow']); if(!count($mediareferences)) { return false; @@ -227,7 +226,6 @@ function media_delete($id,$auth){ function media_upload($ns,$auth){ if($auth < AUTH_UPLOAD) return false; if(!checkSecurityToken()) return false; - require_once(DOKU_INC.'inc/confutils.php'); global $lang; global $conf; diff --git a/inc/parserutils.php b/inc/parserutils.php index 34d9e5282..8e2c6e000 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -644,8 +644,6 @@ function p_xhtml_cached_geshi($code, $language, $wrapper='pre') { } else { - require_once(DOKU_INC . 'inc/geshi.php'); - $geshi = new GeSHi($code, $language, DOKU_INC . 'inc/geshi'); $geshi->set_encoding('utf-8'); $geshi->enable_classes(); diff --git a/inc/search.php b/inc/search.php index ce4fefe06..9e0964404 100644 --- a/inc/search.php +++ b/inc/search.php @@ -194,7 +194,6 @@ function search_media(&$data,$base,$file,$type,$lvl,$opts){ $info['writable'] = is_writable($base.'/'.$file); if(preg_match("/\.(jpe?g|gif|png)$/",$file)){ $info['isimg'] = true; - require_once(DOKU_INC.'inc/JpegMeta.php'); $info['meta'] = new JpegMeta($base.'/'.$file); }else{ $info['isimg'] = false; @@ -320,7 +319,6 @@ function search_backlinks(&$data,$base,$file,$type,$lvl,$opts){ } //fetch instructions - require_once(DOKU_INC.'inc/parserutils.php'); $instructions = p_cached_instructions($base.$file,true); if(is_null($instructions)) return false; diff --git a/inc/subscription.php b/inc/subscription.php index e98129b77..280da225d 100644 --- a/inc/subscription.php +++ b/inc/subscription.php @@ -275,7 +275,6 @@ function subscription_send_digest($subscriber_mail, $change, $lastupdate) { if (!is_null($rev)) { $subject = 'changed'; $replaces['OLDPAGE'] = wl($id, "rev=$rev", true, '&'); - require_once DOKU_INC.'inc/DifferenceEngine.php'; $df = new Diff(explode("\n", rawWiki($id, $rev)), explode("\n", rawWiki($id))); $dformat = new UnifiedDiffFormatter(); diff --git a/inc/template.php b/inc/template.php index bab68e549..bd5f58792 100644 --- a/inc/template.php +++ b/inc/template.php @@ -345,11 +345,9 @@ function tpl_metaheaders($alt=true){ 'href'=>DOKU_BASE.'lib/exe/css.php?s=print&t='.$conf['template'].'&tseed='.$tseed); // make $INFO and other vars available to JavaScripts - require_once(DOKU_INC.'inc/JSON.php'); $json = new JSON(); $script = "var NS='".$INFO['namespace']."';"; if($conf['useacl'] && $_SERVER['REMOTE_USER']){ - require_once(DOKU_INC.'inc/toolbar.php'); $script .= "var SIG='".toolbar_signature()."';"; } $script .= 'var JSINFO = '.$json->encode($JSINFO).';'; -- cgit v1.2.3 From c2a6d81662045023bdf1617b6b49f71c274d55ca Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 1 Feb 2010 16:10:25 +0100 Subject: plugin related autoloading This patch moved the place where DOKU_PLUGIN is defined. It no longer can be set from a normal config (only via preload) --- inc/init.php | 5 +++-- inc/load.php | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'inc') diff --git a/inc/init.php b/inc/init.php index 3cff40073..7f4792cfa 100644 --- a/inc/init.php +++ b/inc/init.php @@ -20,6 +20,9 @@ if (@file_exists($preload)) include($preload); // define the include path if(!defined('DOKU_INC')) define('DOKU_INC',fullpath(dirname(__FILE__).'/../').'/'); +// define Plugin dir +if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); + // define config path (packagers may want to change this to /etc/dokuwiki/) if(!defined('DOKU_CONF')) define('DOKU_CONF',DOKU_INC.'conf/'); @@ -158,8 +161,6 @@ if(!defined('DOKU_TAB')) define ('DOKU_TAB',"\t"); // define cookie and session id, append server port when securecookie is configured FS#1664 if (!defined('DOKU_COOKIE')) define('DOKU_COOKIE', 'DW'.md5(DOKU_REL.(($conf['securecookie'])?$_SERVER['SERVER_PORT']:''))); -// define Plugin dir -if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); // define main script if(!defined('DOKU_SCRIPT')) define('DOKU_SCRIPT','doku.php'); diff --git a/inc/load.php b/inc/load.php index 792f05e27..e06a2c63d 100644 --- a/inc/load.php +++ b/inc/load.php @@ -76,6 +76,11 @@ function load_autoload($name){ 'GeSHi' => DOKU_INC.'inc/geshi.php', 'TarLib' => DOKU_INC.'inc/TarLib.class.php', 'ZibLib' => DOKU_INC.'inc/ZipLib.class.php', + + 'DokuWiki_Action_Plugin' => DOKU_PLUGIN.'action.php', + 'DokuWiki_Admin_Plugin' => DOKU_PLUGIN.'admin.php', + 'DokuWiki_Syntax_Plugin' => DOKU_PLUGIN.'syntax.php', + ); if(isset($classes[$name])){ -- cgit v1.2.3 From 05ed2c25ea0dc45eef2af0f9f4176c939af41100 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 12 Mar 2010 14:09:57 +0100 Subject: some more load fixes --- inc/load.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'inc') diff --git a/inc/load.php b/inc/load.php index e06a2c63d..dad03875a 100644 --- a/inc/load.php +++ b/inc/load.php @@ -9,12 +9,8 @@ spl_autoload_register('load_autoload'); // require all the common libraries -// for a e few of these order does matter -require_once(DOKU_INC.'inc/IXR_Library.php'); -require_once(DOKU_INC.'inc/adLDAP.php'); +// for a few of these order does matter require_once(DOKU_INC.'inc/blowfish.php'); -require_once(DOKU_INC.'inc/feedcreator.class.php'); -require_once(DOKU_INC.'inc/geshi.php'); require_once(DOKU_INC.'inc/actions.php'); require_once(DOKU_INC.'inc/changelog.php'); require_once(DOKU_INC.'inc/common.php'); @@ -49,7 +45,7 @@ require_once(DOKU_INC.'inc/auth.php'); * require()s their associated php files when an object is instantiated. * * @author Andreas Gohr - * @todo add generic loading of plugins here + * @todo add generic loading of plugins and other generically named classes */ function load_autoload($name){ static $classes = null; @@ -76,6 +72,8 @@ function load_autoload($name){ 'GeSHi' => DOKU_INC.'inc/geshi.php', 'TarLib' => DOKU_INC.'inc/TarLib.class.php', 'ZibLib' => DOKU_INC.'inc/ZipLib.class.php', + 'DokuWikiFeedCreator' => DOKU_INC.'inc/feedcreator.class.php', + 'Doku_Parser_Mode' => DOKU_INC.'inc/parser/parser.php', 'DokuWiki_Action_Plugin' => DOKU_PLUGIN.'action.php', 'DokuWiki_Admin_Plugin' => DOKU_PLUGIN.'admin.php', -- cgit v1.2.3