moved some stuff back to lib from plugins
[glcas.git] / lib / datastore.php
similarity index 68%
rename from lib/plugins/datastore.php
rename to lib/datastore.php
index db51d36..a074cc3 100644 (file)
@@ -3,10 +3,44 @@ global $BASE_URLS, $MENU_ITEMS, $GLOBAL_BASE_URL;
 
 $BASE_URLS["ds"]["base"] = "ds"; // ap for apt-proxy
 $BASE_URLS["ds"]["function"] = "ds_contentUrls"; // the page builder function for us
+
+// the datastore post url
+$BASE_URLS["dsp"]["base"] = "dsp"; // ap for apt-proxy
+$BASE_URLS["dsp"]["function"] = "ds_contentPostUrls"; // the page builder function for us
+
 $MENU_ITEMS["ds"]["title"] = "DataStores";
 $MENU_ITEMS["ds"]["link"] = "/ds/control";
 
 
+function ds_contentPostUrls()
+{
+       $calls["needs_base_page"] = false;
+       $calls["page_builder"] = "ds_postContent";
+       
+       return $calls;
+}
+
+function ds_postContent()
+{
+       global $URL_COMPONENTS;
+       $call = $URL_COMPONENTS[1];
+       
+       switch($call) {
+               case "createds":
+                       $dsname = $_REQUEST["dsname"];
+                       $dsloc = $_REQUEST["dsloc"];
+                       ds_createDS($dsname, $dsloc);
+                       msg_addMessage("#008800", "DataStore, $dsname created at $dsloc");
+                       break;
+       }
+               
+       $loc = urlCreate("/ds/control");
+       header("Location: $loc");
+       
+       return 0;
+       
+}
+
 function ds_contentPane()
 {
        global $URL_COMPONENTS;
@@ -30,13 +64,24 @@ function ds_contentPane()
 
 function ds_controlPane()
 {
-       echo "<table>";
-       echo "<tr><td>DataStore Name</td><td>DataStore Path</td><td>Size</td><td>Usage</td><td>Control</td></tr>";
+       global $GLOBAL_BASE_URL;
+       echo "<h3>DataStores</h3>";
+       $dss = ds_listDS();
        
-       echo "</table>";
-       echo "<form method=\"post\" action=\"".urlCreate("/ds/createds")."\">";
-       echo "DataStore Name: <input type=\"text\" name=\"dsname\">";
-       echo "DataStore Location: <input type=\"text\" name=\"dsloc\">";
+       if($dss != false) {
+               echo "<table border=1>";
+               echo "<tr><td>DataStore Name</td><td>DataStore Path</td><td>Size</td><td>Usage</td><td>Control</td></tr>";
+               foreach($dss as $dsl) {
+                       $dsname = $dsl["dsname"];
+                       $dspath = $dsl["dslocation"];
+                       echo "<tr><td>$dsname</td><td>$dspath</td></tr>";
+               }
+               echo "</table>";
+       }
+       echo "<h3>Create DataStore</h3>";
+       echo "<form method=\"post\" action=\"".urlCreate("/dsp/createds")."\">";
+       echo "DataStore Name: <input type=\"text\" name=\"dsname\"><br>";
+       echo "DataStore Location: <input type=\"text\" name=\"dsloc\"><br>";
        echo "<input type=\"submit\" name=\"create\" value=\"create\">";
        echo "</form>";
        
@@ -45,7 +90,7 @@ function ds_controlPane()
 function ds_leftMenu()
 {
        global $GLOBAL_BASE_URL;
-       echo "<b>Browse</b><br>";
+       echo "<h3>Browse</h3>";
        $dss = ds_listDS();
        //echo "<pre>";
        //print_r($dss);