Skip to content

Commit dc717ad

Browse files
committed
add filter options
1 parent 80b88b3 commit dc717ad

3 files changed

Lines changed: 66 additions & 22 deletions

File tree

data.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,42 @@ function readYaml($file) {
2727
}
2828
}
2929

30+
if(array_key_exists("performed", $_GET)) {
31+
$showPerformed = $_GET['performed'];
32+
33+
if($showPerformed != "true") $showPerformed = false;
34+
}else {
35+
$showPerformed = false;
36+
}
37+
38+
if(array_key_exists("planned", $_GET)) {
39+
$showPlanned = $_GET['planned'];
40+
41+
if($showPlanned != "true") $showPlanned = false;
42+
}else {
43+
$showPlanned = false;
44+
}
45+
$filteredDimensions = array();
46+
foreach ($dimensions as $dimensionName => $subDimension) {
47+
ksort($subDimension);
48+
foreach ($subDimension as $subDimensionName => $elements) {
49+
$newElements = $elements;
50+
ksort($newElements);
51+
foreach($newElements as $activityName => $activity) {
52+
if(elementIsSelected($activityName) && !$showPerformed) {
53+
continue;
54+
}
55+
56+
if(!elementIsSelected($activityName) && !$showPlanned) {
57+
continue;
58+
}
59+
$filteredDimensions[$dimensionName][$subDimensionName][$activityName] = $activity;
60+
}
61+
62+
}
63+
}
64+
65+
3066
function getDifficultyOfImplementationWithDependencies($dimensions, $elementImplementation, &$allElements)
3167
{
3268
if($elementImplementation == null) {

mappings.php

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,32 @@
2121
?>
2222

2323
<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>
24+
<div class="form-check">
25+
<input class="form-check-input" type="radio" name="sort" id="exampleRadios1" value="activity" <?php if($_GET['sort'] == "activity") echo "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" <?php if($_GET['sort'] == "samm2") echo "checked"; ?>>
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" <?php if($_GET['sort'] == "iso27001-2017") echo "checked"; ?>>
38+
<label class="form-check-label" for="exampleRadios3">
39+
ISO27001:27001
40+
</label>
41+
</div>
42+
<div class="form-check">
43+
<input type="checkbox" class="form-check-input" name="performed" id="exampleCheck1" value="true" <?php if($showPerformed) {echo " checked=checked";}?>>
44+
<label class="form-check-label" for="exampleCheck1">Show performed activities</label>
45+
</div>
46+
<div class="form-check">
47+
<input type="checkbox" class="form-check-input" name="planned" id="exampleCheck2" value="true" <?php if($showPlanned) {echo " checked=checked";} ?>>
48+
<label class="form-check-label" for="exampleCheck2">Show planned activities</label>
49+
</div>
4250
<button type="submit" class="btn btn-primary">Submit</button>
4351
</form>
4452

@@ -58,7 +66,7 @@
5866
</thead>
5967
<tbody>
6068
<?php
61-
foreach ($dimensions as $dimension => $subdimensions) {
69+
foreach ($filteredDimensions as $dimension => $subdimensions) {
6270
foreach ($subdimensions as $subdimension => $activity) {
6371
foreach ($activity as $activityName => $content) {
6472
echo "<tr>";
@@ -94,7 +102,7 @@
94102
<tbody>
95103
<?php
96104
$mapping = array();
97-
foreach ($dimensions as $dimension => $subdimensions) {
105+
foreach ($filteredDimensions as $dimension => $subdimensions) {
98106
foreach ($subdimensions as $subdimension => $activity) {
99107
foreach ($activity as $activityName => $content) {
100108
$content["dimension"] = $dimension;
@@ -110,7 +118,7 @@
110118
}
111119
}
112120
}
113-
ksort($mapping);
121+
ksort($mapping, SORT_NUMERIC);
114122

115123
foreach($mapping as $mappingName => $mappingElement) {
116124
foreach($mappingElement as $activityName => $activity) {

navi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"index.php" => "Matrix",
66
"spiderweb.php" => "Implementation Levels",
77
"scutter.php" => "Ease and Value",
8-
"mappings.php" => "Mappings",
8+
"mappings.php?performed=true&planned=true" => "Mappings",
99
"graph.php" => "Dependencies",
1010
"report.php?performed=true&planned=true" => "Full Report",
1111
//"usefulnessHardness.php" => "Heatmap",

0 commit comments

Comments
 (0)