-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
162 lines (116 loc) · 3.51 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<?php
/*
* TODO
* Add login / auth functionality
* Make new / edit event
* List the available plugins
* When plugin is clicked it calls the plugins admin() method which will setup the correct settings for that plugin, and which will later be sent to the plugin
* Generate an url for the feed.
*
*
*/
//load config.php, it will load all plugins.
require_once('conf/config.php');
class adminInterface
{
public function __construct()
{
logger::log(DEBUG,"ADMIN Mode started.\r\n");
pluginLoader::all();
//if only eventid is set, lets serve some plugins
if(isset($_GET['eventId']) && !isset($_GET['plugin'])){
echo $this->pluginAdmin();
}
else
$this->eventPicker();
}
public function header()
{
$str = '<html>
<head>
<title>Admin</title>
<link rel="stylesheet" href="/admininterface/style.css" type="text/css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
</head>
<body>';
return $str;
}
public function footer()
{
$str = '<script src="/admininterface/admin.js" type="text/javascript"></script>
</div>
</body>
</html>';
return $str;
}
public function getActivePlugins()
{
//This function gets what plugins are active for this event
//later i dont know if this functionality should be here or some where else.
$eventId = $_GET['eventId'];
$sql = "select plugin,parm,value,instance from events_plugins where eventid = ".$eventId;
$activePlugins = array();
foreach( DB::$dbh->query($sql) as $plugin)
{
if( !isset($activePlugins[$plugin['plugin']]) )
{
$activePlugins[$plugin['plugin']] = array();
if( !isset( $activePlugins[$plugin['plugin']][$plugin['instance']] )) // <-- error på den här raden
{
$activePlugins[$plugin['plugin']][$plugin['instance']] = array();
}
$activePlugins[$plugin['plugin']][$plugin['instance']][$plugin['parm']] = $plugin['value'];
}
}
foreach($activePlugins as $name => $plugin)
{
foreach($plugin as $pluginInstance)
{
$curPlug = pluginLoader::getPlugin($name);
logger::log(DEBUG, "PLUGIN TYPE: ".gettype($curPlug));
echo pluginLoader::getPlugin($name)->adminInterface($pluginInstance);
}
}
}
public function pluginAdmin()
{
$this->plugins = pluginLoader::plugins();
echo $this->header();
echo '<div id="main">';
echo ' <section id="activeplugins">';
echo $this->getActivePlugins();
echo ' </section>';
echo '<div class="pluginbuttons">Save / Clear</div>';
echo '</div>';
echo '<aside id="pluginlist">';
foreach($this->plugins as $plugin)
echo $plugin->adminInterface();
echo '</aside>';
echo $this->footer();
}
public function eventPicker()
{
echo $this->header();
echo '<h2>Existing events</h2>
<ul>';
$sql = 'SELECT * FROM `events` LIMIT 0 , 30';
foreach (DB::$dbh->query($sql) as $event) {
echo '<li class="event"><a href="?eventId=' . $event['id'] . '">' . $event['namn'] . '</a></li>';
}
echo '</ul>';
echo $this->footer();
}
public function choosePlugins()
{
echo '<ul>';
foreach(pluginLoader::plugins() as $plugin)
{
echo '<li class="plugin"><a href="?eventId=' . $_GET['eventId'] . '&plugin=' . get_class($plugin) . '">'.get_class($plugin).'</a></li>';
}
echo '</ul>';
}
}
$admin = new adminInterface();
?>