aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-02-15 12:57:00 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-02-15 12:57:00 +0000
commit23a34583a812bbbe5df0bcdc4a40ba32bc4ce409 (patch)
treee018e3e1bf3ef1261cf683e965966b01627ec333
parent395fe163c4658dda3b101508b070e30cc6fb6dc1 (diff)
downloadelgg-23a34583a812bbbe5df0bcdc4a40ba32bc4ce409.tar.gz
elgg-23a34583a812bbbe5df0bcdc4a40ba32bc4ce409.tar.bz2
Simple plugin mechanism
git-svn-id: https://code.elgg.org/elgg/trunk@39 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/lib/configuration.php44
-rw-r--r--engine/lib/elgglib.php2
-rw-r--r--engine/lib/plugins.php46
-rw-r--r--engine/start.php6
4 files changed, 97 insertions, 1 deletions
diff --git a/engine/lib/configuration.php b/engine/lib/configuration.php
new file mode 100644
index 000000000..697bd247d
--- /dev/null
+++ b/engine/lib/configuration.php
@@ -0,0 +1,44 @@
+<?php
+
+ /**
+ * Elgg configuration library
+ * Contains functions for managing system configuration
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ /**
+ * If certain configuration elements don't exist, autodetect sensible defaults
+ *
+ * @uses $CONFIG The main configuration global
+ *
+ */
+ function set_default_config() {
+
+ global $CONFIG;
+
+ if (empty($CONFIG->path))
+ $CONFIG->path = str_replace("\\","/",dirname(dirname(dirname(__FILE__)))) . "/";
+
+ if (empty($CONFIG->viewpath))
+ $CONFIG->viewpath = $CONFIG->path . "views/";
+
+ if (empty($CONFIG->pluginspath))
+ $CONFIG->pluginspath = $CONFIG->path . "mod/";
+
+ if (empty($CONFIG->wwwroot)) {
+ $CONFIG->wwwroot = "http://" . $_SERVER['SERVER_NAME'];
+ if (strripos($_SERVER['DOCUMENT_ROOT'],"/") < (sizeof($_SERVER['DOCUMENT_ROOT']) - 1)) {
+ $CONFIG->wwwroot .= "/";
+ }
+ $CONFIG->wwwroot .= str_replace($_SERVER['DOCUMENT_ROOT'],"",$CONFIG->path);
+ }
+
+ }
+
+?> \ No newline at end of file
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index ae5ef951a..ba2156242 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -104,7 +104,7 @@
foreach($viewlist as $view) {
if (!isset($CONFIG->views->locations[$view])) {
- $location = $CONFIG->viewpath . "views/";
+ $location = $CONFIG->viewpath;
} else {
$location = $CONFIG->views->locations[$view];
}
diff --git a/engine/lib/plugins.php b/engine/lib/plugins.php
new file mode 100644
index 000000000..81f5757e9
--- /dev/null
+++ b/engine/lib/plugins.php
@@ -0,0 +1,46 @@
+<?php
+
+ /**
+ * Elgg plugins library
+ * Contains functions for managing plugins
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+
+ /**
+ * For now, loads plugins directly
+ *
+ * @todo Add proper plugin handler that launches plugins in an admin-defined order and activates them on admin request
+ */
+ function load_plugins() {
+
+ global $CONFIG;
+ if (!empty($CONFIG->pluginspath)) {
+
+ if ($handle = opendir($CONFIG->pluginspath)) {
+ while ($mod = readdir($handle)) {
+ if (!in_array($mod,array('.','..','.svn','CVS')) && is_dir($mod)) {
+ if (!@include($ONFIG->pluginspath . $mod . "/start.php"))
+ throw new PluginException("{$mod} is a misconfigured plugin.");
+ }
+ }
+ }
+
+ }
+
+ }
+
+ /**
+ * @class PluginException
+ * A plugin Exception, thrown when an Exception occurs relating to the plugin mechanism. Subclass for specific plugin Exceptions.
+ */
+
+ class PluginException extends Exception {}
+
+?> \ No newline at end of file
diff --git a/engine/start.php b/engine/start.php
index b238966d3..a0ca5d718 100644
--- a/engine/start.php
+++ b/engine/start.php
@@ -81,6 +81,12 @@
if (!@include_once($file))
throw new InstallationException("Could not load {$file}");
}
+
+ // Autodetect some default configuration settings
+ set_default_config();
+
+ // Load plugins
+ load_plugins();
} else { // End portion for sanitised installs only