From 23a34583a812bbbe5df0bcdc4a40ba32bc4ce409 Mon Sep 17 00:00:00 2001 From: ben Date: Fri, 15 Feb 2008 12:57:00 +0000 Subject: Simple plugin mechanism git-svn-id: https://code.elgg.org/elgg/trunk@39 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/configuration.php | 44 ++++++++++++++++++++++++++++++++++++++++++ engine/lib/elgglib.php | 2 +- engine/lib/plugins.php | 46 ++++++++++++++++++++++++++++++++++++++++++++ engine/start.php | 6 ++++++ 4 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 engine/lib/configuration.php create mode 100644 engine/lib/plugins.php (limited to 'engine') 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 @@ +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 @@ +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 -- cgit v1.2.3