-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
208 lines (170 loc) · 5.17 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<?php
/******************************************************************************
*
* Copyright © 2010
*
* FreeCode Norway AS
* Nydalsveien 30A, NO-0484 Oslo, Norway
* Norway
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; version 3 of the License.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
******************************************************************************/
require_once('common/index.php');
require_once("model.php");
/**
Default, simple dropdown list for selecting a CI
*/
class DefaultCiSelector
{
function make($name, $selected)
{
$arr = array();
$all_ci_list = ci::fetch();
foreach($all_ci_list as $item) {
$item_id = $item->id;
/*
if ($ci->isDirectDependant($item_id) || $ci->id == $item_id) {
continue;
}*/
$arr[$item_id] = $item->getDescription();
}
return form::makeSelect($name, $arr, null);
}
}
/**
App class for FreeCMDB
*/
class MyApp
extends Application
{
private $ci_selector;
function __construct()
{
$this->addScript('static/FreeCMDB.js');
$this->addStyle('static/FreeCMDB.css');
$this->enableDatePicker();
$this->enableTinyMce();
$this->setCiSelector(new DefaultCiSelector());
}
function makeCiSelector($name, $selected)
{
return $this->ci_selector->make($name, $selected);
}
function setCiSelector($s)
{
$this->ci_selector = $s;
}
function writeHeader($title, $controller)
{
Application::writeHeader($title, $controller);
echo implode("", $controller->getContent("body_pre"));
}
/**
Write out the top menu.
*/
function writeMenu($controller)
{
if(Property::get('tuit.enabled','0')=='1') {
echo "
<div class='menu_boxes no_print'>
<div class='menu_box menu_box1'>
<div class='logo'></div>";
echo implode("",$controller->getContent("main_menu_pre"));
echo "
<div class='endbox'></div>
</div>
<div class='menu_box menu_box2'>
<div class='main_menu_target'></div>
<div class='endbox'></div>
</div>
<div class='menu_box menu_box3'>";
echo implode("",$controller->getContent("main_menu_post"));
echo "
<div class='endbox'></div>
</div>
</div>";
return;
}
$is_admin = $controller->isAdmin();
$is_help = $controller->isHelp();
$is_ci = !$is_admin && !$is_help;
echo "<div class='main_menu'>\n";
echo implode("",$controller->getContent("main_menu_pre"));
echo "<div class='main_menu_inner'>";
echo "<div class='logo'><a href='?'>FreeCMDB</a></div>";
echo "<ul>\n";
echo "<li>";
echo makeLink(makeUrl(array("controller"=>"ciList")), "Items", $is_ci?'selected':null);
echo "</li>\n";
echo "<li>";
echo makeLink(makeUrl(array("controller"=>"admin")), "Administration", $is_admin?'selected':null);
echo "</li>\n";
echo "<li>";
echo makeLink(makeUrl(array("controller"=>"help")), "Help", $is_help?'selected':null);
/*
echo "<li>";
echo makeLink("?controller=logout", "Log out", null);
echo "</li>\n";
*/
echo "</ul></div>";
echo implode("",$controller->getContent("main_menu_post"));
echo "</div>\n";
}
function getDefaultController()
{
return "ciList";
}
function getApplicationName()
{
return "FreeCMDB";
}
function preRun($controller)
{
Event::emit("Startup",array("source"=>$controller));
ciUser::assert_view();
}
function postRun($controller)
{
Event::emit("Shutdown",array("source"=>$controller));
}
function writeFooter() {}
function writeFooter2() {
Application::writeFooter();
}
}
ciUser::init() || die("Login error.");
util::$path = Property::get("core.baseUrl","");
class FreeCMDB
{
function dateTime($tm)
{
return date(Property::get("core.dateTimeFormat","Y-M-D H:i"), $tm);
}
function date($tm)
{
return date(Property::get("core.dateFormat","Y-M-D"), $tm);
}
}
if (Property::get('core.locale',null)!=null){
setlocale(LC_ALL,Property::get('core.locale',null));
// Specify location of translation tables
bindtextdomain("FreeCMDB", "./locale");
bind_textdomain_codeset("FreeCMDB", 'UTF-8');
// Choose domain
textdomain("FreeCMDB");
}
$app = new MyApp();
$app->main();
?>