2013-04-17 13:36:34 +02:00
|
|
|
<?php
|
2013-04-24 07:05:56 +02:00
|
|
|
require_once "functions.php";
|
|
|
|
|
2017-05-27 17:52:16 +02:00
|
|
|
spl_autoload_register(function($class) {
|
2018-07-18 12:25:18 +02:00
|
|
|
$namespace = '';
|
|
|
|
$class_name = $class;
|
|
|
|
|
|
|
|
if (strpos($class, '\\') !== FALSE)
|
|
|
|
list ($namespace, $class_name) = explode('\\', $class, 2);
|
2013-04-17 13:36:34 +02:00
|
|
|
|
2018-06-20 13:58:09 +02:00
|
|
|
$root_dir = dirname(__DIR__); // we're in tt-rss/include
|
2013-04-17 13:36:34 +02:00
|
|
|
|
2018-06-20 13:58:09 +02:00
|
|
|
// 1. third party libraries with namespaces are loaded from vendor/
|
|
|
|
// 2. internal tt-rss classes are loaded from classes/ and use special naming logic instead of namespaces
|
|
|
|
// 3. plugin classes are loaded by PluginHandler from plugins.local/ and plugins/ (TODO: use generic autoloader?)
|
|
|
|
|
|
|
|
if ($namespace && $class_name) {
|
|
|
|
$class_file = "$root_dir/vendor/$namespace/" . str_replace('\\', '/', $class_name) . ".php";
|
|
|
|
} else {
|
|
|
|
$class_file = "$root_dir/classes/" . str_replace("_", "/", strtolower($class)) . ".php";
|
2013-04-17 13:36:34 +02:00
|
|
|
}
|
|
|
|
|
2018-06-20 13:58:09 +02:00
|
|
|
if (file_exists($class_file))
|
|
|
|
include $class_file;
|
|
|
|
|
2017-05-27 17:52:16 +02:00
|
|
|
});
|