9 namespace Fossology\Lib\UI\Component;
16 const FULL_MENU_DEBUG =
'fullmenudebug';
21 const BANNER_COOKIE =
'close_banner';
22 var $MenuTarget =
"treenav";
25 public function __construct(Environment $renderer)
32 menu_insert(
"Main::Help::Documentation", 0, NULL, NULL, NULL,
"<a href='https://github.com/fossology/fossology/wiki'>Documentation</a>");
33 $this->renderer = $renderer;
44 $output =
"<!--[if lt IE 7]><table><tr><td><![endif]-->\n";
45 $output .=
"<ul id='menu-$indent'>\n";
47 foreach ($menu as $menuEntry) {
50 if (!empty($menuEntry->HTML)) {
51 $output .= $menuEntry->HTML;
53 $output .= $this->createHtmlFromMenuEntry($menuEntry, $indent);
56 if (!empty($menuEntry->SubMenu)) {
57 $output .= $this->
menu_html($menuEntry->SubMenu, $indent + 1);
61 $output .=
"<!--[if lt IE 7]></td></tr></table></a><![endif]-->\n";
62 return preg_replace(
"|<li><a href=\"#\"><font color(.*)*?$|m",
'', $output);
65 function createHtmlFromMenuEntry(\
menu $menuEntry, $indent)
67 $isFullMenuDebug = array_key_exists(self::FULL_MENU_DEBUG, $_SESSION) && $_SESSION[self::FULL_MENU_DEBUG] == 1;
69 if (!empty($menuEntry->URI)) {
70 $output .=
'<a id="'. htmlentities($menuEntry->FullName) .
'" href="' .
Traceback_uri() .
"?mod=" . $menuEntry->URI;
71 if (empty($menuEntry->Target) || ($menuEntry->Target ==
"")) {
74 $output .=
'" target="' . $menuEntry->Target .
'">';
76 if ($isFullMenuDebug) {
77 $output .= $menuEntry->FullName .
"(" . $menuEntry->Order .
")";
79 $output .= $menuEntry->Name;
82 $output .=
'<a id="'. htmlentities($menuEntry->FullName) .
'" href="#">';
83 if (empty($menuEntry->SubMenu)) {
84 $output .=
"<font color='#C0C0C0'>";
85 if ($isFullMenuDebug) {
86 $output .= $menuEntry->FullName .
"(" . $menuEntry->Order .
")";
92 if ($isFullMenuDebug) {
93 $output .= $menuEntry->FullName .
"(" . $menuEntry->Order .
")";
95 $output .= $menuEntry->Name;
100 if (!empty($menuEntry->SubMenu) && ($indent > 0)) {
101 $output .=
" <span>»</span>";
113 $output =
"<style type=\"text/css\">\n";
118 $cssBorder =
"border-color:#bee5eb #bee5eb #bee5eb #bee5eb; border-width:1px 1px 1px 1px; border-radius:3px;";
119 $cssPadding =
"padding:4px 0px 4px 4px;";
120 $FOSScolor1 =
"#c50830";
125 $FOSSfg1h = $FOSScolor1;
126 $FOSSbg1h =
"#d1ecf1";
128 $FOSSfg2 =
"#0c5460";
129 $FOSSbg2 =
"#d1ecf1";
130 $FOSSfg2h = $FOSScolor1;
131 $FOSSbg2h =
"#d1ecf1";
133 $FOSSfg3 =
"#0c5460";
134 $FOSSbg3 =
"#d1ecf1";
135 $FOSSfg3h = $FOSScolor1;
136 $FOSSbg3h =
"#d1ecf1";
138 if ($depth < $MenuDepth) {
140 $output .=
"\n/* CSS for Depth $depth */\n";
141 $label =
"ul#menu-" . $depth;
142 $output .= $label .
"\n";
143 $output .=
" { z-index:0; margin:0; padding:0px; list-style:none; background:$FOSSbg1; width:100%; height:24px; font:normal 14px verdana, arial, helvetica; font-weight: bold; }\n";
145 $output .= $label .
"\n";
146 $output .=
" { float:left; margin:0; padding:0px; display:block; position:relative; width:auto; border:0px solid #000; }\n";
147 $output .= $label .
" a:link,\n";
148 $output .= $label .
" a:visited\n";
149 $output .=
" { float:left; padding:4px 10px; text-decoration:none; color:$FOSSfg1; background:$FOSSbg1; width:auto; display:block; }\n";
150 $output .= $label .
":hover a,\n";
151 $output .= $label .
" a:hover,\n";
152 $output .= $label .
" a:active\n";
153 $output .=
" { float:left; padding:4px 10px; color:$FOSSfg1h; background:$FOSSbg1h; $cssBorder width:auto; display:block; }\n";
154 $output .= $label .
" a span\n";
155 $output .=
" { float:left; position:absolute; top:0; left:135px; font-size:12pt; }\n";
160 if ($depth < $MenuDepth) {
161 $output .=
"\n/* CSS for Depth $depth */\n";
162 $output .= $label .
" ul#menu-" . $depth .
"\n";
163 $output .=
" { margin:0; padding:0px 0; list-style:none; display:none; visibility:hidden; left:0px; width:150px; position:absolute; top:24px; font-weight: bold; }\n";
164 $output .= $label .
":hover ul#menu-" . $depth .
"\n";
165 $output .=
" { float:left; display:block; visibility:visible; }\n";
166 $label .=
" ul#menu-" . $depth .
" li";
167 $output .= $label .
"\n";
168 $output .=
" { z-index:$depth; margin:0; padding:0; display:block; visibility:visible; position:relative; width:150px; }\n";
169 $output .= $label .
" a:link,\n";
170 $output .= $label .
" a:visited\n";
171 $output .=
" { z-index:$depth; $cssPadding color:$FOSSfg2; background:$FOSSbg2; border:1px solid #000; $cssBorder width:150px; display:block; visibility:visible; }\n";
172 $output .= $label .
":hover a,\n";
173 $output .= $label .
" a:active,\n";
174 $output .= $label .
" a:hover\n";
175 $output .=
" { z-index:$depth; $cssPadding color:$FOSSfg2h; background:$FOSSbg2h; width:150px; display:block; visibility:visible; }\n";
176 $output .= $label .
" a span\n";
177 $output .=
" { text-align:left; }\n";
182 for (; $depth < $MenuDepth; $depth++) {
183 $output .=
"\n/* CSS for Depth $depth */\n";
184 $output .= $label .
" ul#menu-" . $depth .
"\n";
185 $output .=
" { margin:0; padding:1px 0; list-style:none; display:none; visibility:hidden; left:156px; width:150px; position:absolute; top:-1px; font-weight: bold; }\n";
186 $output .= $label .
":hover ul#menu-" . $depth .
"\n";
187 $output .=
" { float:left; display:block; visibility:visible; }\n";
188 $label .=
" ul#menu-" . $depth .
" li";
189 $output .= $label .
"\n";
190 $output .=
" { z-index:$depth; margin:0; padding:0; display:block; visibility:visible; position:relative; width:150px; margin-left:-6px; }\n";
191 $output .= $label .
" a:link,\n";
192 $output .= $label .
" a:visited\n";
193 $output .=
" { z-index:$depth; $cssPadding color:$FOSSfg3; background:$FOSSbg2h; border:1px solid #000; $cssBorder width:150px; display:block; }\n";
194 $output .= $label .
":hover a,\n";
195 $output .= $label .
" a:active,\n";
196 $output .= $label .
" a:hover\n";
197 $output .=
" { z-index:$depth; $cssPadding color:$FOSSfg3h; background:$FOSSbg3h; width:150px; display:block; visibility:visible; }\n";
198 $output .= $label .
" a span\n";
199 $output .=
" { text-align:left; }\n";
201 $output .=
"</style>\n";
204 $output .=
"<!--[if lt IE 8]>\n";
205 $output .=
"<style type='text/css' media='screen'>\n";
207 $output .=
"body { behavior:url(csshover.htc); }\n";
209 for ($i = 1; $i < $MenuDepth; $i++) {
210 $output .=
"#menu-$i table {height:0px; border-collapse:collapse; margin:0; padding:0; }\n";
211 $output .=
"#menu-$i td {height:0px; border:none; margin:0; padding:0; }\n";
213 $output .=
"</style>\n";
214 $output .=
"<![endif]-->\n";
226 $sysConfig = $SysConf[
'SYSCONFIG'];
228 $hide_banner = (array_key_exists(self::BANNER_COOKIE, $_COOKIE)
229 && $_COOKIE[self::BANNER_COOKIE] == 1);
232 $vars[
'title'] = empty($title) ? _(
"Welcome to FOSSology") : $title;
234 $vars[
'bannerMsg'] =
"";
235 $vars[
'systemLoad'] =
"";
237 $vars[
'bannerMsg'] = @$sysConfig[
'BannerMsg'];
240 $vars[
'logoLink'] = $sysConfig[
'LogoLink']?:
'http://fossology.org';
241 $vars[
'logoImg'] = $sysConfig[
'LogoImage']?:
'images/fossology-logo.gif';
243 if ( array_key_exists(
'SupportEmailLabel',$sysConfig) && !empty($sysConfig[
'SupportEmailLabel'])
244 && array_key_exists(
'SupportEmailAddr',$sysConfig) && !empty($sysConfig[
'SupportEmailAddr'])) {
245 $menuItem =
'<a href="mailto:'.$sysConfig[
'SupportEmailAddr'].
'?subject='.@$sysConfig[
'SupportEmailSubject'].
'">'.$sysConfig[
'SupportEmailLabel'].
'</a>';
246 menu_insert(
"Main::Help::".$sysConfig[
'SupportEmailLabel'], 0, NULL, NULL, NULL, $menuItem);
250 $vars[
'mainMenu'] = $this->
menu_html($menu, 0);
258 if (array_key_exists(
'BUILD', $SysConf)) {
259 $vars[
'versionInfo'] = array(
260 'version' => $SysConf[
'BUILD'][
'VERSION'],
261 'buildDate' => $SysConf[
'BUILD'][
'BUILD_DATE'],
262 'commitHash' => $SysConf[
'BUILD'][
'COMMIT_HASH'],
263 'commitDate' => $SysConf[
'BUILD'][
'COMMIT_DATE'],
264 'branchName' => $SysConf[
'BUILD'][
'BRANCH']
268 if (!$vars[
'isLoggedOut']) {
269 $this->mergeUserLoginVars($vars);
272 return $this->renderer->load(
'components/menu.html.twig')->render($vars);
275 private function mergeUserLoginVars(&$vars)
278 $dbManager = $container->get(
"db.manager");
280 $vars[
'logOutUrl'] =
Traceback_uri() .
'?mod=' . ((plugin_find_id(
'auth')>=0) ?
'auth' :
'smauth');
283 $sql =
'SELECT group_pk, group_name FROM group_user_member LEFT JOIN groups ON group_fk=group_pk WHERE user_fk=$1';
284 $stmt = __METHOD__ .
'.availableGroups';
285 $dbManager->prepare($stmt, $sql);
286 $res = $dbManager->execute($stmt, array($_SESSION[
'UserId']));
287 $allAssignedGroups = array();
288 while ($row = $dbManager->fetchArray($res)) {
289 $allAssignedGroups[$row[
'group_pk']] = $row[
'group_name'];
291 $dbManager->freeResult($res);
292 if (count($allAssignedGroups) > 1) {
295 $vars[
'allAssignedGroups'] = $allAssignedGroups;
297 $vars[
'singleGroup'] = @$_SESSION[
'GroupName'];
Contains the constants and helpers for authentication of user.
Traceback_uri()
Get the URI without query to this location.
Traceback_parm($ShowMod=1)
Get the URI query to this location.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
get_system_load_average()
Get system load average.