aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine/lib/elgglib.php43
-rw-r--r--engine/start.php35
-rw-r--r--index.php5
3 files changed, 63 insertions, 20 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
new file mode 100644
index 000000000..dce99d0a4
--- /dev/null
+++ b/engine/lib/elgglib.php
@@ -0,0 +1,43 @@
+<?php
+
+ /**
+ * Elgg library
+ * Contains important functionality core to Elgg
+ *
+ * @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/
+ */
+
+ /**
+ * Loading libraries **************************************************************************
+ */
+
+ /**
+ * Recursive function designed to load library files on start
+ *
+ * @param string $directory Full path to the directory to start with
+ * @param string $file_exceptions A list of filenames (with no paths) you don't ever want to include
+ * @param string $file_list A list of files that you know already you want to include
+ * @return array Array of full filenames
+ */
+ function get_library_files($directory, $file_exceptions = array(), $file_list = array()) {
+
+ if (is_file($directory)) {
+ $file_list[] = $directory;
+ } else if ($handle = opendir($directory)) {
+ while ($file = readdir($handle)) {
+ if (!in_array($file,$file_exceptions)) {
+ $file_list = get_library_files($directory . "/" . $file, $file_exceptions, $file_list);
+ }
+ }
+ }
+
+ return $file_list;
+
+ }
+
+?> \ No newline at end of file
diff --git a/engine/start.php b/engine/start.php
index 10d835370..5e82ceae9 100644
--- a/engine/start.php
+++ b/engine/start.php
@@ -16,37 +16,32 @@
* Load important prerequisites
*/
- require_once(dirname(__FILE__) . "/settings.php"); // Global settings
require_once(dirname(__FILE__) . "/lib/elgglib.php"); // Elgg core functions
require_once(dirname(__FILE__) . "/lib/database.php"); // Database connection
-
- /**
- * Load the configuration
- */
-
- global $CONFIG;
+ include(dirname(__FILE__) . "/settings.php"); // Global settings
/**
* Load the remaining libraries from /lib/ in alphabetical order,
* except for a few exceptions
*/
+ // We don't want to load or reload these files
+
$file_exceptions = array(
'.','..',
+ '.svn',
'settings.php','settings.example.php','elgglib.php','database.php'
);
-
- if ($handle = opendir(dirname(__FILE__) . "/lib/")) {
- $files = array();
- while ($file = readdir($handle)) {
- if (!in_array($file,$file_exceptions)) {
- if (!is_dir(dirname(__FILE__) . "/lib/" . $file)) {
- $files[] = dirname(__FILE__) . "/lib/" . $file;
- } else {
-
- }
- }
- }
- }
+ // Get the list of files to include, and alphabetically sort them
+
+ $files = get_library_files(dirname(__FILE__) . "/lib",$file_exceptions);
+ asort($files);
+
+ // Include them
+
+ foreach($files as $file) {
+ include($file);
+ }
+
?> \ No newline at end of file
diff --git a/index.php b/index.php
index 33a41acfa..fa0a0f41b 100644
--- a/index.php
+++ b/index.php
@@ -12,6 +12,11 @@
*/
/**
+ * Start the Elgg engine
+ */
+ require_once(dirname(__FILE__) . "/engine/start.php");
+
+ /**
* @todo Load the front page
*/