aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/elgglib.php
diff options
context:
space:
mode:
authorewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-10-14 07:52:31 +0000
committerewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-10-14 07:52:31 +0000
commit30df49bbb363d47b4a3961bb3ec07cdecea7619b (patch)
tree58905f6343a32ed9bf35baa8298f9851e30259e3 /engine/lib/elgglib.php
parentcd33e6a791409bf0898d6d1db5938b09415289fb (diff)
downloadelgg-30df49bbb363d47b4a3961bb3ec07cdecea7619b.tar.gz
elgg-30df49bbb363d47b4a3961bb3ec07cdecea7619b.tar.bz2
Fixes #2547: Plugins can now participate in autoloading classes.
git-svn-id: http://code.elgg.org/elgg/trunk@7074 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/elgglib.php')
-rw-r--r--engine/lib/elgglib.php28
1 files changed, 25 insertions, 3 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index 4376ca53f..5b224e0be 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -2200,8 +2200,30 @@ function js_page_handler($page) {
}
}
-function __autoload($class) {
- require_once dirname(dirname(__FILE__))."/classes/$class.php";
+function __elgg_autoload($class) {
+ global $CONFIG;
+
+ if (!include($CONFIG->classes[$class])) {
+ throw new Exception("Failed to autoload $class");
+ }
+}
+
+function elgg_register_classes($dir) {
+ $classes = elgg_get_file_list($dir, array(), array(), array('.php'));
+
+ foreach ($classes as $class) {
+ elgg_register_class(basename($class, '.php'), $class);
+ }
+}
+
+function elgg_register_class($class, $location) {
+ global $CONFIG;
+
+ if (!isset($CONFIG->classes)) {
+ $CONFIG->classes = array();
+ }
+
+ $CONFIG->classes[$class] = $location;
}
/**
@@ -2233,7 +2255,7 @@ function __elgg_shutdown_hook() {
*/
function elgg_init() {
global $CONFIG;
-
+
register_action('comments/add');
register_action('comments/delete');
register_action('likes/add');