Commit 6937704e authored by Evan Prodromou's avatar Evan Prodromou

give plugins a chance to autoload their classes

parent 58f85463
......@@ -134,3 +134,6 @@ StartAccountSettingsNav: Before showing the account settings menu
EndAccountSettingsNav: After showing the account settings menu
- $action: the current action
Autoload: When trying to autoload a class
- $cls: the class being sought. A plugin might require_once the file for the class.
......@@ -381,17 +381,19 @@ require_once INSTALLDIR.'/lib/serverexception.php';
define('NICKNAME_FMT', VALIDATE_NUM.VALIDATE_ALPHA_LOWER);
function __autoload($class)
function __autoload($cls)
{
if ($class == 'OAuthRequest') {
if (file_exists(INSTALLDIR.'/classes/' . $cls . '.php')) {
require_once(INSTALLDIR.'/classes/' . $cls . '.php');
} else if (file_exists(INSTALLDIR.'/lib/' . strtolower($cls) . '.php')) {
require_once(INSTALLDIR.'/lib/' . strtolower($cls) . '.php');
} else if (mb_substr($cls, -6) == 'Action' &&
file_exists(INSTALLDIR.'/actions/' . strtolower(mb_substr($cls, 0, -6)) . '.php')) {
require_once(INSTALLDIR.'/actions/' . strtolower(mb_substr($cls, 0, -6)) . '.php');
} else if ($cls == 'OAuthRequest') {
require_once('OAuth.php');
} else if (file_exists(INSTALLDIR.'/classes/' . $class . '.php')) {
require_once(INSTALLDIR.'/classes/' . $class . '.php');
} else if (file_exists(INSTALLDIR.'/lib/' . strtolower($class) . '.php')) {
require_once(INSTALLDIR.'/lib/' . strtolower($class) . '.php');
} else if (mb_substr($class, -6) == 'Action' &&
file_exists(INSTALLDIR.'/actions/' . strtolower(mb_substr($class, 0, -6)) . '.php')) {
require_once(INSTALLDIR.'/actions/' . strtolower(mb_substr($class, 0, -6)) . '.php');
} else {
Event::handle('Autoload', array(&$cls));
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment