Lots of little changes, basic structure now looking pretty good
[glcas.git] / plugins / admin.php
1 <?php 
2
3 error_log("admin loaded");
4
5 global $URL_HANDLERS;
6 $URL_HANDLERS["admin.*"] = "GLCASAdmin";
7
8 class GLCASAdmin {
9         function __construct($config)
10         {
11                 $this->config = $config;
12                 error_log("constructor for GLCASAdmin");
13                 
14         }
15         
16         function go($url)
17         {
18                 error_log("repo:go called");
19                 
20                 if(isset($_REQUEST["action"])) {
21                         switch($_REQUEST["action"]) {
22                                 case "addrepo":
23                                         GLCASpageBuilder($this,"doAddRepo");
24                                         return;
25                                         break;
26                                 case "scanrepo":
27                                         break;
28                         }
29                 }
30                 GLCASpageBuilder($this, "body");
31         }
32         
33         function body($url)
34         {
35                 // for the main admin body, we hae the following components
36                 
37                 // 1. list of currently available repos and stuff
38                 
39                 // 2. way to add a repo direct
40                 
41                 // 3. way to scan for a repo given a url
42                 
43                 // so first, lets do the main body
44                 $this->mainBody($url);
45         }
46         
47         function doAddRepo($url)
48         {
49                 $myRep = new GLCASRepo($this->config);
50                 
51                 $glt = $myRep->getRepoDetailsYum($_REQUEST["repourl"]);
52                 
53                 echo "<pre>$glt</pre>";
54         }
55         
56         function mainBody($url)
57         {
58                 // first, list available repos
59                 echo "<h3>Repositories</h3><br><table>";
60                 echo "<tr><th>Name</th><th>Type</th><th>Version</th><th>Browse</th><th>Control</th></tr>";
61                 echo "</table><br><hr>";
62                 
63                 // wrap all this in a table
64                 echo "<table><tr><td valign=\"top\">";
65                 // now, add a repo
66                 echo "<h3>Add A Repo</h3>";
67                 echo "<form method=\"post\" action=\"?action=addrepo\">";
68                 echo "Type <select name=\"repotype\">";
69                         echo "<option value=\"yumbase\">YUM (Base URL)</option>";
70                         echo "<option value=\"yummirrorlist\">YUM (Mirror List)</option>";
71                         echo "<option value=\"apt\">APT</option>";
72                         echo "</select><br>";
73                 echo "URL <input type=\"text\" name=\"repourl\"><br>";
74                 echo "<input type=\"submit\" name=\"Add\" value=\"Add\"><br>";
75                 echo "</form><hr>";
76                 
77                 echo "</td><td valign=\"top\">";
78                 
79                 // now scan for a repo
80                 echo "<h3>Scan For Repos</h3>";
81                 echo "<form method=\"post\" action=\"?action=scanrepo\">";
82                 echo "Hint <select name=\"repohint\">";
83                         echo "<option value=\"fedora\">Fedora</option>";
84                         echo "<option value=\"centos\">Centos</option>";
85                         echo "<option value=\"ubuntu\">Ubuntu</option>";
86                         echo "</select><br>";
87                 echo "URL <input type=\"text\" name=\"repourl\"><br>";
88                 echo "<input type=\"submit\" name=\"Scan\" value=\"Scan\"><br>";
89                 echo "</form>";
90                 
91                 echo "</td></tr></table>";
92         }
93
94         private $config;
95 }
96
97 ?>