diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/DataTable/Renderer.php | 2 | ||||
-rw-r--r-- | core/Db/Adapter.php | 3 | ||||
-rw-r--r-- | core/Loader.php | 126 | ||||
-rw-r--r-- | core/Plugin/Manager.php | 3 | ||||
-rw-r--r-- | core/Tracker.php | 1 |
5 files changed, 2 insertions, 133 deletions
diff --git a/core/DataTable/Renderer.php b/core/DataTable/Renderer.php index ddcde91cf3..dae970dd5f 100644 --- a/core/DataTable/Renderer.php +++ b/core/DataTable/Renderer.php @@ -10,7 +10,6 @@ namespace Piwik\DataTable; use Exception; use Piwik\DataTable; -use Piwik\Loader; use Piwik\Metrics; use Piwik\Piwik; @@ -168,7 +167,6 @@ abstract class Renderer $className = ucfirst(strtolower($name)); $className = 'Piwik\DataTable\Renderer\\' . $className; try { - Loader::loadClass($className); return new $className; } catch (Exception $e) { $availableRenderers = implode(', ', self::getRenderers()); diff --git a/core/Db/Adapter.php b/core/Db/Adapter.php index 6bafa3a653..342a320d72 100644 --- a/core/Db/Adapter.php +++ b/core/Db/Adapter.php @@ -8,7 +8,6 @@ */ namespace Piwik\Db; -use Piwik\Loader; use Zend_Db_Table; /** @@ -39,8 +38,6 @@ class Adapter } $className = self::getAdapterClassName($adapterName); - Loader::loadClass($className); - $adapter = new $className($dbInfos); if ($connect) { diff --git a/core/Loader.php b/core/Loader.php deleted file mode 100644 index 6e33987f19..0000000000 --- a/core/Loader.php +++ /dev/null @@ -1,126 +0,0 @@ -<?php -/** - * Piwik - free/libre analytics platform - * - * @link http://piwik.org - * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - * - */ - -namespace Piwik; - -use Exception; - -/** - * Piwik auto loader - * - */ -class Loader -{ - // our class search path; current directory is intentionally excluded - protected static $dirs = array('/core/', '/plugins/'); - - /** - * Get class file name - * - * @param string $class Class name - * @return string Class file name - * @throws Exception if class name is invalid - */ - protected static function getClassFileName($class) - { - if (!preg_match('/^[A-Za-z0-9_\\\\]+$/D', $class)) { - throw new Exception("Invalid class name \"$class\"."); - } - - // prefixed class - $class = str_replace('_', '/', $class); - - // namespace \Piwik\Common - $class = str_replace('\\', '/', $class); - - if ($class == 'Piwik') { - return $class; - } - - $class = self::removeFirstMatchingPrefix($class, array('/Piwik/', 'Piwik/')); - $class = self::removeFirstMatchingPrefix($class, array('/Plugins/', 'Plugins/')); - - return $class; - } - - protected static function removeFirstMatchingPrefix($class, $vendorPrefixesToRemove) - { - foreach ($vendorPrefixesToRemove as $prefix) { - if (strpos($class, $prefix) === 0) { - return substr($class, strlen($prefix)); - } - } - - return $class; - } - - private static function isPluginClass($class) - { - return 0 === strpos($class, 'Piwik\Plugins') || 0 === strpos($class, '\Piwik\Plugins'); - } - - private static function usesPiwikNamespace($class) - { - return 0 === strpos($class, 'Piwik\\') || 0 === strpos($class, '\Piwik\\'); - } - - /** - * Load class by name - * - * @param string $class Class name - * @throws Exception if class not found - */ - public static function loadClass($class) - { - $classPath = self::getClassFileName($class); - - if (static::isPluginClass($class)) { - static::tryToLoadClass($class, '/plugins/', $classPath); - } elseif (static::usesPiwikNamespace($class)) { - static::tryToLoadClass($class, '/core/', $classPath); - } else { - // non-Piwik classes (e.g., Zend Framework) are in libs/ - static::tryToLoadClass($class, '/libs/', $classPath); - } - } - - private static function tryToLoadClass($class, $dir, $classPath) - { - $path = PIWIK_INCLUDE_PATH . $dir . $classPath . '.php'; - - if (file_exists($path)) { - require_once $path; // prefixed by PIWIK_INCLUDE_PATH - - return class_exists($class, false) || interface_exists($class, false); - } - - return false; - } - - /** - * Autoloader - * - * @param string $class Class name - */ - public static function autoload($class) - { - try { - self::loadClass($class); - } catch (Exception $e) { - } - } -} - -// use the SPL autoload stack -spl_autoload_register(array('Piwik\Loader', 'autoload')); - -// preserve any existing __autoload -if (function_exists('__autoload')) { - spl_autoload_register('__autoload'); -} diff --git a/core/Plugin/Manager.php b/core/Plugin/Manager.php index c7d0164d5a..114d79a1d6 100644 --- a/core/Plugin/Manager.php +++ b/core/Plugin/Manager.php @@ -22,6 +22,7 @@ use Piwik\Theme; use Piwik\Tracker; use Piwik\Translate; use Piwik\Updater; +use Piwik\SettingsServer; use Piwik\Plugin\Dimension\ActionDimension; use Piwik\Plugin\Dimension\ConversionDimension; use Piwik\Plugin\Dimension\VisitDimension; @@ -957,7 +958,7 @@ class Manager extends Singleton private function loadTranslation($plugin, $langCode) { // we are in Tracker mode if Loader is not (yet) loaded - if (!class_exists('Piwik\\Loader', false)) { + if (SettingsServer::isTrackerApiRequest()) { return false; } diff --git a/core/Tracker.php b/core/Tracker.php index a6ab0225ac..d0502e3ca3 100644 --- a/core/Tracker.php +++ b/core/Tracker.php @@ -407,7 +407,6 @@ class Tracker && self::$initTrackerMode === false ) { self::$initTrackerMode = true; - require_once PIWIK_INCLUDE_PATH . '/core/Loader.php'; require_once PIWIK_INCLUDE_PATH . '/core/Option.php'; Access::getInstance(); |