aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/elgglib.php
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-12-04 22:51:37 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-12-04 22:51:37 +0000
commit8761800b92a6eb4bf3df361091cb85bb8459e959 (patch)
tree1c06aed6ce149e292dc1204699b99c6057cdf612 /engine/lib/elgglib.php
parent6a634b6ccd0fc8a7c629082e1213708b87f4adaf (diff)
downloadelgg-8761800b92a6eb4bf3df361091cb85bb8459e959.tar.gz
elgg-8761800b92a6eb4bf3df361091cb85bb8459e959.tar.bz2
Fixes #2519 we can now register and load php libraries - blog plugin is using this
git-svn-id: http://code.elgg.org/elgg/trunk@7532 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/elgglib.php')
-rw-r--r--engine/lib/elgglib.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index f41e5fd6a..2184fee41 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -34,6 +34,7 @@ function _elgg_autoload($class) {
* @param string $dir The dir to look in
*
* @return void
+ * @since 1.8.0
*/
function elgg_register_classes($dir) {
$classes = elgg_get_file_list($dir, array(), array(), array('.php'));
@@ -50,6 +51,7 @@ function elgg_register_classes($dir) {
* @param string $location The location of the file
*
* @return void
+ * @since 1.8.0
*/
function elgg_register_class($class, $location) {
global $CONFIG;
@@ -62,6 +64,50 @@ function elgg_register_class($class, $location) {
}
/**
+ * Register a php library.
+ *
+ * @param string $name The name of the library
+ * @param string $location The location of the file
+ *
+ * @return void
+ * @since 1.8.0
+ */
+function elgg_register_library($name, $location) {
+ global $CONFIG;
+
+ if (!isset($CONFIG->libraries)) {
+ $CONFIG->libraries = array();
+ }
+
+ $CONFIG->libraries[$name] = $location;
+}
+
+/**
+ * Load a php library.
+ *
+ * @param string $name The name of the library
+ *
+ * @return void
+ * @throws Exception
+ * @since 1.8.0
+ */
+function elgg_load_library($name) {
+ global $CONFIG;
+
+ if (!isset($CONFIG->libraries)) {
+ $CONFIG->libraries = array();
+ }
+
+ if (!isset($CONFIG->libraries[$name])) {
+ throw new Exception("Failed to load the $name library");
+ }
+
+ if (!include_once($CONFIG->libraries[$name])) {
+ throw new Exception("Failed to load the $name library");
+ }
+}
+
+/**
* Forward to $location.
*
* Sends a 'Location: $location' header and exists. If headers have