Skip to content

Commit 8d023da

Browse files
committed
Adjustable report & Beautify
1 parent 049181d commit 8d023da

12 files changed

Lines changed: 94 additions & 56 deletions

bib.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ function readCSV($filename, $delimiter)
2020
return $data;
2121
}
2222

23-
function elementIsSelected($elementName)
23+
function elementIsSelected($activityName)
2424
{
2525
foreach (getCsv() as $element) {
26-
if ($elementName == $element["element"]) {
26+
if ($activityName == $element["element"]) {
2727
return true;
2828
}
2929
}

data-yml.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ function getElementByName($dimensions, $name)
119119
{
120120
foreach ($dimensions as $dimensionName => $subDimension) {
121121
foreach ($subDimension as $subDimensionName => $elements) {
122-
foreach ($elements as $elementName => $element) {
123-
if ($elementName == $name) {
122+
foreach ($elements as $activityName => $element) {
123+
if ($activityName == $name) {
124124
return $element;
125125
}
126126
}

data.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ function getElementByName($dimensions, $name)
119119
{
120120
foreach ($dimensions as $dimensionName => $subDimension) {
121121
foreach ($subDimension as $subDimensionName => $elements) {
122-
foreach ($elements as $elementName => $element) {
123-
if ($elementName == $name) {
122+
foreach ($elements as $activityName => $element) {
123+
if ($activityName == $name) {
124124
return $element;
125125
}
126126
}

detail.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010

1111
$dimension = $_GET['dimension'];
1212
$subdimension = $_GET['subdimension'];
13-
$elementName = $_GET['element'];
13+
$activityName = $_GET['element'];
1414

15-
function printDetail($dimension, $subdimension, $elementName, $dimensions, $report = false)
15+
function printDetail($dimension, $subdimension, $activityName, $dimensions, $report = false)
1616
{
17-
$element = $dimensions[$dimension][$subdimension][$elementName];
17+
$element = $dimensions[$dimension][$subdimension][$activityName];
1818

1919
if ($element == null) { //Whitelist approach for security reasons (deny XSS)
2020
//echo "Sorry, we could not found the element";
@@ -34,9 +34,9 @@ function printDetail($dimension, $subdimension, $elementName, $dimensions, $repo
3434

3535
$pageH1 .= " -> $subdimension";
3636
}
37-
$pageH1 .= ": $elementName";
37+
$pageH1 .= ": $activityName";
3838
} else {
39-
$pageH1 .= "$elementName";
39+
$pageH1 .= "$activityName";
4040
}
4141

4242
echo "<h$headerWeight>$pageH1</h$headerWeight>";
@@ -101,4 +101,4 @@ function printDetail($dimension, $subdimension, $elementName, $dimensions, $repo
101101
}
102102
}
103103

104-
printDetail($dimension, $subdimension, $elementName, $dimensions);
104+
printDetail($dimension, $subdimension, $activityName, $dimensions);

graph.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
include_once "data.php";
1313
function hasElementChildren($element) {
1414
$hasContent = false;
15-
foreach ($element as $elementName => $content) {
15+
foreach ($element as $activityName => $content) {
1616
if (!array_key_exists("dependsOn", $content)) {
1717
continue;
1818
}
@@ -62,9 +62,9 @@ function hasElementChildren($element) {
6262
}
6363
</style>
6464
<?php
65-
function getSourceAndParent($elementName, $subdimension, $parent = "")
65+
function getSourceAndParent($activityName, $subdimension, $parent = "")
6666
{
67-
return "{source: \"$elementName\", target: \"$parent\", type: \"" . base64_encode($subdimension) . "\"}";
67+
return "{source: \"$activityName\", target: \"$parent\", type: \"" . base64_encode($subdimension) . "\"}";
6868
}
6969

7070

@@ -83,7 +83,7 @@ function getSourceAndParent($elementName, $subdimension, $parent = "")
8383
$first = true;
8484

8585
//if($subdimension != "Erzeugung") continue;
86-
foreach ($element as $elementName => $content) {
86+
foreach ($element as $activityName => $content) {
8787
if (!array_key_exists("dependsOn", $content)) {
8888
continue;
8989
}
@@ -98,14 +98,14 @@ function getSourceAndParent($elementName, $subdimension, $parent = "")
9898
echo ",";
9999
}
100100
$first = false;
101-
echo getSourceAndParent($elementName, $subdimension, $dependsOn);
101+
echo getSourceAndParent($activityName, $subdimension, $dependsOn);
102102
}
103103
} else {
104104
if (!$first) {
105105
echo ",";
106106
}
107107
$first = false;
108-
echo getSourceAndParent($elementName, $subdimension, $parent);
108+
echo getSourceAndParent($activityName, $subdimension, $parent);
109109
}
110110

111111
}

head.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ function getTable($dimensions) {
121121

122122
for($i = 1; $i <= NUMBER_LEVELS; $i ++) {
123123
$tableContent .= "<td><ul>";
124-
foreach ( $element as $elementName => $content ) {
125-
$content = getContentForLevelFromSubdimensions ( $i, $content, $elementName );
124+
foreach ( $element as $activityName => $content ) {
125+
$content = getContentForLevelFromSubdimensions ( $i, $content, $activityName );
126126
if ($content != "") {
127-
$elementLink = "detail.php?dimension=" . urlencode ( $dimension ) . "&subdimension=" . urlencode ( $subdimension ) . "&element=" . urlencode ( $elementName );
128-
$tableContent .= "<a href='$elementLink' data-dimension='$dimension' data-subdimension='$subdimension' data-element='$elementName'";
129-
if (elementIsSelected ( $elementName )) {
127+
$elementLink = "detail.php?dimension=" . urlencode ( $dimension ) . "&subdimension=" . urlencode ( $subdimension ) . "&element=" . urlencode ( $activityName );
128+
$tableContent .= "<a href='$elementLink' data-dimension='$dimension' data-subdimension='$subdimension' data-element='$activityName'";
129+
if (elementIsSelected ( $activityName )) {
130130
$tableContent .= "class='selected'";
131131
}
132132
$tableContent .= "><li>" . $content . "</li></a>";
@@ -143,11 +143,11 @@ function getTable($dimensions) {
143143
$table .= "</table>";
144144
return $table;
145145
}
146-
function getContentForLevelFromSubdimensions($level, $subdimension, $elementName) {
146+
function getContentForLevelFromSubdimensions($level, $subdimension, $activityName) {
147147
if ($level != $subdimension ["level"]) {
148148
return "";
149149
}
150150
$tooltip = "<div class='popoverdetails'>" . build_table_tooltip ( $subdimension ) . "</div>";
151-
return "<div data-toggle=\"popover\" data-title=\"$elementName\" data-content=\"$tooltip\" type=\"button\" data-html=\"true \">" . $elementName . "</div>";
151+
return "<div data-toggle=\"popover\" data-title=\"$activityName\" data-content=\"$tooltip\" type=\"button\" data-html=\"true \">" . $activityName . "</div>";
152152
}
153153

mappings.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
?>
1515
<table class="table">
1616
<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>
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>
2424
</thead>
2525
<tbody>
2626
<?php

report-samm.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
echo "<h3 style='color:green;'>With SAMM2 Mapping</h3>";
2222
for ($i = 1; $i <= 4; $i++) {
2323
$tableContent .= "<td><ul>";
24-
foreach ($element as $elementName => $content) {
24+
foreach ($element as $activityName => $content) {
2525
if(array_key_exists("samm2", $content) && !preg_match("/TODO/i", $content["samm2"])) {
26-
$content2 = getContentForLevelFromSubdimensions($i, $content, $elementName);
26+
$content2 = getContentForLevelFromSubdimensions($i, $content, $activityName);
2727

2828
if ($content2 != "") {
29-
printDetail($dimension, $subdimension, $elementName, $dimensions, true);
30-
$mappingExists[$subdimension][$content["samm2"]][$elementName] = $content;
29+
printDetail($dimension, $subdimension, $activityName, $dimensions, true);
30+
$mappingExists[$subdimension][$content["samm2"]][$activityName] = $content;
3131
}
3232
}
3333
}
@@ -36,14 +36,14 @@
3636
echo "<h3 style='color:red;'>Without SAMM2 Mapping</h3>";
3737
for ($i = 1; $i <= 4; $i++) {
3838
$tableContent .= "<td><ul>";
39-
foreach ($element as $elementName => $content) {
39+
foreach ($element as $activityName => $content) {
4040
if(!array_key_exists("samm2", $content) || preg_match("/TODO/i", $content["samm2"])) {
41-
$content2 = getContentForLevelFromSubdimensions($i, $content, $elementName);
41+
$content2 = getContentForLevelFromSubdimensions($i, $content, $activityName);
4242

4343
if ($content2 != "") {
44-
printDetail($dimension, $subdimension, $elementName, $dimensions, true);
45-
$content["name"] = $elementName;
46-
$noMappingExists[$subdimension][$content["samm2"]][$elementName] = $content;
44+
printDetail($dimension, $subdimension, $activityName, $dimensions, true);
45+
$content["name"] = $activityName;
46+
$noMappingExists[$subdimension][$content["samm2"]][$activityName] = $content;
4747
}
4848
}
4949
}
@@ -56,8 +56,8 @@
5656
foreach($category as $category => $content) {
5757
//var_dump($content);exit;
5858
echo $category . " ".count($content) . " ";
59-
foreach($content as $elementName => $content2){
60-
echo "$elementName" . " /"; }
59+
foreach($content as $activityName => $content2){
60+
echo "$activityName" . " /"; }
6161
echo "<br>";
6262
}
6363
}

report.php

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,62 @@
44
<body>
55
<?php
66
include_once "navi.php";
7+
8+
if(array_key_exists("performed", $_GET)) {
9+
$showPerformed = $_GET['performed'];
10+
11+
if($showPerformed != "true") $showPerformed = false;
12+
}else {
13+
$showPerformed = false;
14+
}
15+
16+
if(array_key_exists("planned", $_GET)) {
17+
$showPlanned = $_GET['planned'];
18+
19+
if($showPlanned != "true") $showPlanned = false;
20+
}else {
21+
$showPlanned = false;
22+
}
23+
724
?>
25+
26+
<form method="get">
27+
<div class="form-check">
28+
<input type="checkbox" class="form-check-input" name="performed" id="exampleCheck1" value="true" <?php if($showPerformed) {echo " checked=checked";}?>>
29+
<label class="form-check-label" for="exampleCheck1">Show performed activities</label>
30+
</div>
31+
<div class="form-check">
32+
<input type="checkbox" class="form-check-input" name="planned" id="exampleCheck2" value="true" <?php if($showPlanned) {echo " checked=checked";} ?>>
33+
<label class="form-check-label" for="exampleCheck2">Show planned activities</label>
34+
</div>
35+
<button type="submit" class="btn btn-primary">Submit</button>
36+
</form>
37+
838
<?php
939
include_once "data.php";
1040
include_once "detail.php";
1141

1242

43+
1344
foreach ($dimensions as $dimension => $subdimensions) {
1445
echo "<h1>Dimension $dimension</h1>";
15-
foreach ($subdimensions as $subdimension => $element) {
46+
foreach ($subdimensions as $subdimension => $activity) {
1647
echo "<h2>Sub-Dimension $subdimension</h2>";
1748

1849
for ($i = 1; $i <= 4; $i++) {
1950
$tableContent .= "<td><ul>";
20-
foreach ($element as $elementName => $content) {
21-
$content = getContentForLevelFromSubdimensions($i, $content, $elementName);
51+
foreach ($activity as $activityName => $content) {
52+
if(elementIsSelected($activityName) && !$showPerformed) {
53+
continue;
54+
}
55+
56+
if(!elementIsSelected($activityName) && !$showPlanned) {
57+
continue;
58+
}
59+
$content = getContentForLevelFromSubdimensions($i, $content, $activityName);
2260

2361
if ($content != "") {
24-
printDetail($dimension, $subdimension, $elementName, $dimensions, true);
62+
printDetail($dimension, $subdimension, $activityName, $dimensions, true);
2563
}
2664
}
2765
}

scutter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ function getJson($dimensions)
1616
foreach ($dimensions as $dimension => $subdimensions) {
1717
foreach ($subdimensions as $subdimension => $element) {
1818
$values = array();
19-
foreach ($element as $elementName => $content) {
19+
foreach ($element as $activityName => $content) {
2020
$values[] = array(
2121
"series" => 0,
2222
"shape" => $shapes[$shape],
2323
"size" => 3000,
2424
"x" => getDifficultyOfImplementation($dimensions, $content),
2525
"y" => $content["usefulness"],
26-
"key" => $elementName
26+
"key" => $activityName
2727
);
2828
}
2929
$json[] = array(

0 commit comments

Comments
 (0)