-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpulldown_menu2.php
More file actions
93 lines (74 loc) · 2.13 KB
/
pulldown_menu2.php
File metadata and controls
93 lines (74 loc) · 2.13 KB
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
<?php session_start();
ini_set('session.cache_limiter', 'private');
// Read JSON file
$file_name = 'json/onap_releases.json';
$readjson = file_get_contents($file_name);
//
//Decode JSON
$data = json_decode($readjson, true);
//
// Option (doc_type) pulldown menu, menu2
// the logic here s that the first release with the select default option
// set will be used. All other "select" options will be ignored
//
$found_selected_rel = 0;
foreach ($data as $rel) {
$option_selected = 0;
$options_count = sizeof ($rel["options"]);
//
// read ahead to check the for selected option on menu 2
// to display on the first page fr the first time
//
echo PHP_EOL;
if ($option_selected == 0 && $found_selected_rel == 0) {
for ( $i = 0; $i < $options_count; $i++) {
if (strcmp($rel["display_default"], "yes") == 0) {
$option_selected = 1;
}
}
}
//echo "option_selected = " . $option_selected . PHP_EOL;
//echo "found_selected_rel = " . $found_selected_rel . PHP_EOL;
if ($option_selected == 1) {
format_select_tag ("inline", $rel["release_value"], "doc_type");
$found_selected_rel = 1;
}
elseif ($found_selected_rel == 1) {
format_select_tag ("none", $rel["release_value"], "");
}
else {
format_select_tag ("none", $rel["release_value"], "");
}
//echo PHP_EOL . "Options Count: " . $options_count . PHP_EOL;
$found_selected_option = 0;
for ( $i = 0; $i < $options_count; $i++)
{
echo " <option value=\"";
echo $rel["options"][$i]["value"] ."\"";
if (strcmp($rel["options"][$i]["display_default"], "yes") == 0 && $found_selected_option == 0) {
echo " selected ";
$found_selected_option = 1;
}
elseif (strcmp($rel["options"][$i]['status'], "disabled") == 0)
echo " disabled ";
echo "> ";
//echo PHP_EOL;
echo $rel["options"][$i]["name"];
//echo PHP_EOL;
echo "</option>" ;
echo PHP_EOL;
}
echo "</select>";
echo PHP_EOL;
}
//
// Format the "select" tag line for menu2
//
function format_select_tag ($display, $rel, $name)
{
echo PHP_EOL . "<select id=";
echo "\"" . $rel . "-doc-type\" ";
echo "name=\"$name\" ";
echo "style=\"display: " . "$display" . "\"" ." >" . PHP_EOL;
}
?>