adding some framework bits.
[anyhammer.git] / libanyhammer / lib.php
diff --git a/libanyhammer/lib.php b/libanyhammer/lib.php
new file mode 100644 (file)
index 0000000..38b1a0f
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+
+// i am the main library
+
+/*
+ * 
+ * The Main lib.php file.
+ * 
+ */
+
+//require_once();
+
+// get the lib root, and set include path from it
+$LIB_ROOT_FS = realpath(dirname(__FILE__));
+global $LIB_ROOT_FS;
+
+/*
+ * I shouldnt ever need to do this bit, but its here, just in case
+$adpath = realpath($LIB_ROOT_FS."/../");
+error_log("added libglcas path as $adpath");
+set_include_path(get_include_path().PATH_SEPARATOR.$adpath);
+
+*/
+
+
+require_once("libanyhammer/web.php");
+require_once("libanyhammer/config.php");
+
+function ah_pluginLoader($path="")
+{
+       global $LIB_ROOT_FS;
+       if($path ==  "") {
+               // try and find it
+               $plpath = realpath($LIB_ROOT_FS."/../plugins/");
+               if(file_exists($plpath."/ah_plugin.php")) {
+                       // here it is, load away
+                       error_log("attempting to load plugins from $plpath");
+                       $dh = opendir("$plpath");
+                       if($dh) {
+                               while(($file = readdir($dh))!==false) {
+                                       $mt = preg_match("/.*.php$/", $file);
+                                       if($mt > 0) {
+                                               error_log("loading plugin $file");
+                                               require_once("$plpath/$file");
+                                               //echo "required $basedir/$file\n";
+                                       }
+                               }
+                       }                       
+               }
+       }
+}
+
+
+?>
\ No newline at end of file