diff options
Diffstat (limited to 'engine')
| -rw-r--r-- | engine/lib/configuration.php | 44 | ||||
| -rw-r--r-- | engine/lib/elgglib.php | 2 | ||||
| -rw-r--r-- | engine/lib/plugins.php | 46 | ||||
| -rw-r--r-- | engine/start.php | 6 | 
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
  | 
