Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvipsoft <vipsoft@59fd770c-687e-43c8-a1e3-f5a4ff64c105>2009-06-15 06:17:33 +0400
committervipsoft <vipsoft@59fd770c-687e-43c8-a1e3-f5a4ff64c105>2009-06-15 06:17:33 +0400
commit9cb4e9d0276da56cc069c6820289b698febbeace (patch)
treefaac5f8d82d0f02ad9997d8c69fe238c149580a3 /piwik.php
parent60b45d3280f16876bb99145a1b39fe8a0f210f2b (diff)
fixes #801, fixes #620 - implement autoloader; remove require_once
FrontController.php from ./index.php to test autoloader; add "false" parameter to all class_exists() calls to not trigger autoloader
Diffstat (limited to 'piwik.php')
-rw-r--r--piwik.php42
1 files changed, 40 insertions, 2 deletions
diff --git a/piwik.php b/piwik.php
index f03762dfab..3a07e74037 100644
--- a/piwik.php
+++ b/piwik.php
@@ -18,12 +18,51 @@ error_reporting(E_ALL|E_NOTICE);
define('PIWIK_INCLUDE_PATH', dirname(__FILE__));
@ignore_user_abort(true);
-if((@include "Version.php") === false || !class_exists('Piwik_Version')) {
+if((@include "Version.php") === false || !class_exists('Piwik_Version', false))
+{
set_include_path(PIWIK_INCLUDE_PATH . '/core'
. PATH_SEPARATOR . PIWIK_INCLUDE_PATH . '/libs'
. PATH_SEPARATOR . PIWIK_INCLUDE_PATH . '/plugins');
}
+function piwikAutoloader($class)
+{
+ $class = str_replace('_', '/', $class) . '.php';
+ if(substr($class, 0, 6) === 'Piwik/')
+ {
+ $class = substr($class, 6);
+ if(file_exists(PIWIK_INCLUDE_PATH . "/core/" . $class))
+ {
+ include_once PIWIK_INCLUDE_PATH . "/core/" . $class;
+ }
+ else
+ {
+ include_once PIWIK_INCLUDE_PATH . "/plugins/" . $class;
+ }
+ }
+ else
+ {
+ include_once PIWIK_INCLUDE_PATH . "/libs/" . $class;
+ }
+}
+
+// Note: only one __autoload per PHP instance
+if(function_exists('spl_autoload_register'))
+{
+ spl_autoload_register('piwikAutoloader'); // use the SPL autoload stack
+ if(function_exists('__autoload'))
+ {
+ spl_auto_register('__autoload');
+ }
+}
+else
+{
+ function __autoload($class)
+ {
+ piwikAutoloader($class);
+ }
+}
+
require_once "Common.php";
require_once "PluginsManager.php";
require_once "Tracker.php";
@@ -53,4 +92,3 @@ $process = new Piwik_Tracker;
$process->main();
ob_end_flush();
printDebug($_COOKIE);
-