-
-
Notifications
You must be signed in to change notification settings - Fork 261
/
detail.php
169 lines (145 loc) · 5.59 KB
/
detail.php
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<?php
/**
* detail.php
*
* @package default
* @see mappings.php
* @see report-samm.php
* @see report.php
*/
if (array_key_exists("element", $_GET)) {
$title = "Details for '" . htmlspecialchars($_GET['element']) . "'";
}
include_once "head.php";
?>
<body>
<?php
include_once "data.php";
include_once "navi.php";
$dimension = $_GET['dimension'] ?? null;
$subdimension = $_GET['subdimension'] ?? null;
$activityName = $_GET['element'] ?? null;
/**
*
* @param unknown $dimension
* @param unknown $subdimension
* @param unknown $activityName
* @param unknown $dimensions
* @param unknown $report (optional)
*/
function printDetail($dimension, $subdimension, $activityName, $dimensions, $report = false) {
$element = $dimensions[$dimension][$subdimension][$activityName] ?? null;
if ($element == null) { //Whitelist approach for security reasons (deny XSS)
//echo "Sorry, we could not found the element";
return;
}
if ($report) {
$headerWeight = 3;
} else {
$headerWeight = 1;
}
$pageH1 = "";
if (!$report) {
$pageH1 .= $dimension;
if ($dimension != $subdimension) {
$pageH1 .= " -> $subdimension";
}
$pageH1 .= ": $activityName";
} else {
$pageH1 .= "$activityName";
}
echo "<h$headerWeight>$pageH1</h$headerWeight>";
echo build_table_tooltip($element, $headerWeight + 1);
$evidenceContent = getElementContentAndCheckExistence($element, "evidence", true);
if ($evidenceContent == "") {
$evidenceContent = "TODO";
}
if (IS_SHOW_EVIDENCE_TODO || $evidenceContent != "TODO")
echo "<h" .($headerWeight + 2) . ">" . "Evidence" . "</h" .($headerWeight + 2) . ">" . $evidenceContent;
echo "<hr/>";
if (array_key_exists("assessment", $element)) {
$Parsedown = new Parsedown();
echo "<h" . $headerWeight + 1 . ">Assessment</h" . $headerWeight + 1 . ">";
echo $Parsedown->text($element["assessment"]);
}
if (array_key_exists("dependsOn", $element) || array_key_exists("implementation", $element) || array_key_exists("comment", $element) || array_key_exists("meta", $element)) {
echo "<h" . ($headerWeight + 1) . ">Additional Information</h" . ($headerWeight + 1) . ">";
if (array_key_exists("dependsOn", $element)) {
$dependsOn = $element['dependsOn'];
$dependencies = implode(", ", $dependsOn);
echo "<div><b>Dependencies:</b> $dependencies</div>";
}
echo getElementContentAndCheckExistence($element, "meta");
}
if (array_key_exists("md-description", $element) && !empty($element['md-description'])) {
$Parsedown = new Parsedown();
echo $Parsedown->text($element['md-description']);
}
if (array_key_exists("implementation", $element) && !empty($element['implementation'])) {
$implementation = $element['implementation'];
echo "<div><h" . ($headerWeight + 2) . ">Implementation hints</h" . ($headerWeight + 2) . ">";
if (is_array($implementation)) {
echo "<ul>";
foreach ($implementation as $implementationElement) {
echo "<li>";
if (is_array($implementationElement)) {
echo $implementationElement['name'] . ', ';
if (!empty($implementationElement['url'])) {
echo '<a href="' . $implementationElement['url'] . '\">Link</a>';
}
echo ", Tags: ";
foreach ($implementationElement['tags'] as $tag) {
echo $tag . " ";
}
} else {
echo "$implementationElement";
}
echo "</li>";
}
echo "</ul>";
} else {
echo $implementation;
}
echo "</div>";
}
if (array_key_exists("comment", $element) && !empty($element['comment'])) {
$comment = $element['comment'];
echo "<div><b>Comments:</b> $comment</div>";
}
$mapKnowLedge = array("Very Low (one discipline)", "Low (one discipline)", "Medium (two disciplines)", "High (two disciplines)", "Very High (three or more disciplines)");
$mapTime = array("Very Low", "Low", "Medium", "High", "Very High");
$mapResources = $mapTime;
$mapUsefulness = $mapTime;
$html = "<h" . ($headerWeight + 2) . ">Usefulness and Requirements of this Activity</h" . ($headerWeight + 2) . ">";
$html .= "<div><b>Usefullness:</b> " . ucfirst($mapUsefulness[$element['usefulness'] - 1]) . "</div>";
$html .= "<div><b>Required knowledge:</b> " . ucfirst($mapKnowLedge[$element['difficultyOfImplementation']['knowledge'] - 1]) . "</div>";
$html .= "<div><b>Required time:</b> " . ucfirst($mapTime[$element['difficultyOfImplementation']['time'] - 1]) . "</div>";
$html .= "<div><b>Required resources (systems):</b> " . ucfirst($mapResources[$element['difficultyOfImplementation']['resources'] - 1]) . "</div>";
echo $html;
printReferences($element);
if (array_key_exists("credits", $element) && !empty($element['credits'])) {
echo "<h" . ($headerWeight + 2) . ">Credits</h" . ($headerWeight + 2) . ">";
$Parsedown = new Parsedown();
echo "This activity is inspired/copied by/from " . $Parsedown->text($element['credits']);
}
}
/**
*
* @param unknown $element
*/
function printReferences($element) {
if (!array_key_exists("references", $element)) {
return;
}
$actionLabels = readYaml("data/strings.yml#/actionLabels");
$references = $element['references'];
foreach ($references as $r => $values) {
// if it's not an array, array-ze it. Remove after fixing all yamls.
$values = is_array($values) ? $values : array($values);
$label = getReferenceLabel($r);
echo "<div><h3>$label</h3></div>";
echo "<ul><li>" . implode("</li><li>", $values) . "</li></ul>";
}
}
// echo var_dump($dimensions);
printDetail($dimension, $subdimension, $activityName, $dimensions);