Skip to content

Commit 63eca62

Browse files
committed
Add mapping
1 parent be42209 commit 63eca62

1 file changed

Lines changed: 101 additions & 20 deletions

File tree

mappings.php

Lines changed: 101 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,111 @@
1111

1212
$mappingExists = array();
1313
$noMappingExists = array();
14+
15+
if(array_key_exists("sort", $_GET)) {
16+
$sort = $_GET["sort"];
17+
}else {
18+
$sort = "activity";
19+
}
20+
21+
?>
22+
23+
<form method="get">
24+
<div class="form-check">
25+
<input class="form-check-input" type="radio" name="sort" id="exampleRadios1" value="activity" checked>
26+
<label class="form-check-label" for="exampleRadios1">
27+
Activity
28+
</label>
29+
</div>
30+
<div class="form-check">
31+
<input class="form-check-input" type="radio" name="sort" id="exampleRadios2" value="samm2">
32+
<label class="form-check-label" for="exampleRadios2">
33+
SAMM 2
34+
</label>
35+
</div>
36+
<div class="form-check">
37+
<input class="form-check-input" type="radio" name="sort" id="exampleRadios3" value="iso27001-2017">
38+
<label class="form-check-label" for="exampleRadios3">
39+
ISO27001:27001
40+
</label>
41+
</div>
42+
<button type="submit" class="btn btn-primary">Submit</button>
43+
</form>
44+
45+
<?php
46+
47+
if($sort == "activity") {
1448
?>
15-
<table class="table">
16-
<thead>
17-
<tr>
18-
<th scope="col">Dimension</th>
19-
<th scope="col">Subdimension</th>
20-
<th scope="col">Actvity</th>
21-
<th scope="col">SAMM 2</th>
22-
<th scope="col">ISO 27001</th>
23-
</tr>
24-
</thead>
25-
<tbody>
49+
<table class="table">
50+
<thead>
51+
<tr>
52+
<th scope="col">Dimension</th>
53+
<th scope="col">Subdimension</th>
54+
<th scope="col">Actvity</th>
55+
<th scope="col">SAMM 2</th>
56+
<th scope="col">ISO 27001</th>
57+
</tr>
58+
</thead>
59+
<tbody>
2660
<?php
61+
foreach ($dimensions as $dimension => $subdimensions) {
62+
foreach ($subdimensions as $subdimension => $activity) {
63+
foreach ($activity as $activityName => $content) {
64+
echo "<tr>";
65+
echo "<td>$dimension</td>";
66+
echo "<td>$subdimension</td>";
67+
$tooltip = "<div class='popoverdetails'>" . build_table_tooltip ( $content ) . "</div>";
68+
echo "<td><div data-toggle=\"popover\" data-title=\"$activityName\" data-content=\"$tooltip\" type=\"button\" data-html=\"true \">" . $activityName . "</div></td>";
69+
echo "<td>" . getFlattenedArray($content, "samm2") . "</td>";
70+
echo "<td>" . getFlattenedArray($content, "iso27001-2017") . "</td>";
71+
}
72+
}
73+
}
74+
} else {
75+
?>
76+
<table class="table">
77+
<thead>
78+
<tr>
79+
<th scope="col"><?php echo $sort;?></th>
80+
<th scope="col">Dimension</th>
81+
<th scope="col">Subdimension</th>
82+
<th scope="col">Actvity</th>
83+
<th scope="col">SAMM 2</th>
84+
<th scope="col">ISO 27001</th>
85+
</tr>
86+
</thead>
87+
<tbody>
88+
<?php
89+
$mapping = array();
90+
foreach ($dimensions as $dimension => $subdimensions) {
91+
foreach ($subdimensions as $subdimension => $activity) {
92+
foreach ($activity as $activityName => $content) {
93+
$content["dimension"] = $dimension;
94+
$content["subdimension"] = $subdimension;
95+
if($sort != "samm2") {
96+
foreach($content[$sort] as $mappingContent)
97+
$mapping[$mappingContent][$activityName] = $content;
98+
}else {
99+
$mappingValue = str_replace("|", "-", $content[$sort]);
100+
$mapping[$mappingValue][$activityName] = $content;
101+
}
102+
103+
}
104+
}
105+
}
106+
//var_dump($mapping);exit;
107+
ksort($mapping);
27108

28-
foreach ($dimensions as $dimension => $subdimensions) {
29-
foreach ($subdimensions as $subdimension => $activity) {
30-
foreach ($activity as $activityName => $content) {
109+
foreach($mapping as $mappingName => $mappingElement) {
110+
foreach($mappingElement as $activityName => $activity) {
31111
echo "<tr>";
32-
echo "<td>$dimension</td>";
33-
echo "<td>$subdimension</td>";
34-
$tooltip = "<div class='popoverdetails'>" . build_table_tooltip ( $content ) . "</div>";
35-
echo "<td><div data-toggle=\"popover\" data-title=\"$activityName\" data-content=\"$tooltip\" type=\"button\" data-html=\"true \">" . $activityName . "</div></td>";
36-
echo "<td>" . getFlattenedArray($content, "samm2") . "</td>";
37-
echo "<td>" . getFlattenedArray($content, "iso27001-2017") . "</td>";
112+
echo "<td>" . $mappingName . "</td>";
113+
echo "<td>" . $activity['dimension'] . "</td>";
114+
echo "<td>" . $activity['subdimension'] . "</td>";
115+
$tooltip = "<div class='popoverdetails'>" . build_table_tooltip ( $activity ) . "</div>";
116+
echo "<td><div data-toggle=\"popover\" data-title=\"$activityName\" data-content=\"$tooltip\" type=\"button\" data-html=\"true \">" . $activityName . "</div></td>";
117+
echo "<td>" . getFlattenedArray($activity, "samm2") . "</td>";
118+
echo "<td>" . getFlattenedArray($content, "iso27001-2017") . "</td>";
38119
}
39120
}
40121
}

0 commit comments

Comments
 (0)