|
10 | 10 |
|
11 | 11 |
|
12 | 12 | if (array_key_exists("element", $_GET)) { |
13 | | - $title = "Details for '" . htmlspecialchars($_GET['element']) . "'"; |
| 13 | + $title = "Details for '" . htmlspecialchars($_GET['element']) . "'"; |
14 | 14 | } |
15 | 15 | include_once "head.php"; |
16 | 16 | ?> |
|
30 | 30 | * @param unknown $subdimension |
31 | 31 | * @param unknown $activityName |
32 | 32 | * @param unknown $dimensions |
33 | | - * @param unknown $report (optional) |
| 33 | + * @param unknown $report (optional) |
34 | 34 | */ |
35 | | -function printDetail($dimension, $subdimension, $activityName, $dimensions, $report = false) { |
36 | | - $element = $dimensions[$dimension][$subdimension][$activityName] ?? null; |
37 | | - |
38 | | - if ($element == null) { //Whitelist approach for security reasons (deny XSS) |
39 | | - //echo "Sorry, we could not found the element"; |
40 | | - return; |
41 | | - } |
42 | | - if ($report) { |
43 | | - $headerWeight = 3; |
44 | | - } else { |
45 | | - $headerWeight = 1; |
46 | | - } |
47 | | - |
48 | | - $pageH1 = ""; |
49 | | - if (!$report) { |
50 | | - $pageH1 .= $dimension; |
51 | | - |
52 | | - if ($dimension != $subdimension) { |
53 | | - |
54 | | - $pageH1 .= " -> $subdimension"; |
| 35 | +function printDetail($dimension, $subdimension, $activityName, $dimensions, $report = false) |
| 36 | +{ |
| 37 | + $element = $dimensions[$dimension][$subdimension][$activityName] ?? null; |
| 38 | + |
| 39 | + if ($element == null) { //Whitelist approach for security reasons (deny XSS) |
| 40 | + //echo "Sorry, we could not found the element"; |
| 41 | + return; |
| 42 | + } |
| 43 | + if ($report) { |
| 44 | + $headerWeight = 3; |
| 45 | + } else { |
| 46 | + $headerWeight = 1; |
55 | 47 | } |
56 | | - $pageH1 .= ": $activityName"; |
57 | | - } else { |
58 | | - $pageH1 .= "$activityName"; |
59 | | - } |
60 | | - |
61 | | - echo "<h$headerWeight>$pageH1</h$headerWeight>"; |
62 | | - echo build_table_tooltip($element, $headerWeight + 1); |
63 | | - echo "<hr/>"; |
64 | | - |
65 | | - if (array_key_exists("dependsOn", $element) || array_key_exists("implementation", $element) || array_key_exists("comment", $element) || array_key_exists("meta", $element)) { |
66 | | - echo "<h" . ($headerWeight + 1) . ">Additional Information</h" . ($headerWeight + 1) . ">"; |
67 | | - if (array_key_exists("dependsOn", $element)) { |
68 | | - $dependsOn = $element['dependsOn']; |
69 | | - $dependencies = implode(", ", $dependsOn); |
70 | | - echo "<div><b>Dependencies:</b> $dependencies</div>"; |
| 48 | + |
| 49 | + $pageH1 = ""; |
| 50 | + if (!$report) { |
| 51 | + $pageH1 .= $dimension; |
| 52 | + |
| 53 | + if ($dimension != $subdimension) { |
| 54 | + |
| 55 | + $pageH1 .= " -> $subdimension"; |
| 56 | + } |
| 57 | + $pageH1 .= ": $activityName"; |
| 58 | + } else { |
| 59 | + $pageH1 .= "$activityName"; |
71 | 60 | } |
72 | | - echo getElementContentAndCheckExistence($element, "meta"); |
73 | | - } |
74 | | - |
75 | | - |
76 | | - if (array_key_exists("md-description", $element) && !empty($element['md-description'])) { |
77 | | - echo "<div style=\"background: #F5F5F5\""; |
78 | | - echo $element['md-description']; |
79 | | - echo "</div>"; |
80 | | - } |
81 | | - if (array_key_exists("implementation", $element) && !empty($element['implementation'])) { |
82 | | - $implementation = $element['implementation']; |
83 | | - echo "<div><b>Implementation hints:</b> "; |
84 | | - if (is_array($implementation)) { |
85 | | - echo "<ul>"; |
86 | | - foreach ($implementation as $implementationElement) { |
87 | | - echo "<li>$implementationElement</li>"; |
88 | | - } |
89 | | - echo "</ul>"; |
90 | | - }else { |
91 | | - echo $implementation; |
| 61 | + |
| 62 | + echo "<h$headerWeight>$pageH1</h$headerWeight>"; |
| 63 | + echo build_table_tooltip($element, $headerWeight + 1); |
| 64 | + echo "<hr/>"; |
| 65 | + |
| 66 | + if (array_key_exists("dependsOn", $element) || array_key_exists("implementation", $element) || array_key_exists("comment", $element) || array_key_exists("meta", $element)) { |
| 67 | + echo "<h" . ($headerWeight + 1) . ">Additional Information</h" . ($headerWeight + 1) . ">"; |
| 68 | + if (array_key_exists("dependsOn", $element)) { |
| 69 | + $dependsOn = $element['dependsOn']; |
| 70 | + $dependencies = implode(", ", $dependsOn); |
| 71 | + echo "<div><b>Dependencies:</b> $dependencies</div>"; |
| 72 | + } |
| 73 | + echo getElementContentAndCheckExistence($element, "meta"); |
92 | 74 | } |
93 | | - echo "</div>"; |
94 | | - } |
95 | 75 |
|
96 | | - if (array_key_exists("comment", $element) && !empty($element['comment'])) { |
97 | | - $comment = $element['comment']; |
98 | | - echo "<div><b>Comments:</b> $comment</div>"; |
99 | | - } |
100 | 76 |
|
101 | | - printReferences($element); |
| 77 | + if (array_key_exists("md-description", $element) && !empty($element['md-description'])) { |
| 78 | + echo "<div style=\"background: #F5F5F5\">"; |
| 79 | + $Parsedown = new Parsedown(); |
| 80 | + echo $Parsedown->text($element['md-description']); |
| 81 | + echo "</div>"; |
| 82 | + } |
| 83 | + if (array_key_exists("implementation", $element) && !empty($element['implementation'])) { |
| 84 | + $implementation = $element['implementation']; |
| 85 | + echo "<div><b>Implementation hints:</b> "; |
| 86 | + if (is_array($implementation)) { |
| 87 | + echo "<ul>"; |
| 88 | + foreach ($implementation as $implementationElement) { |
| 89 | + if (is_array($implementationElement)) { |
| 90 | + echo $implementationElement['name'] . ', '; |
| 91 | + if (!empty($implementationElement['url'])) { |
| 92 | + echo '<a href="' . $implementationElement['url'] . '\">Link</a>'; |
| 93 | + } |
| 94 | + echo ", Tags: "; |
| 95 | + foreach ($implementationElement['tags'] as $tag) { |
| 96 | + echo $tag . " "; |
| 97 | + } |
| 98 | + } else { |
| 99 | + echo "<li>$implementationElement</li>"; |
| 100 | + } |
| 101 | + |
| 102 | + } |
| 103 | + echo "</ul>"; |
| 104 | + } else { |
| 105 | + echo $implementation; |
| 106 | + } |
| 107 | + echo "</div>"; |
| 108 | + } |
| 109 | + |
| 110 | + if (array_key_exists("comment", $element) && !empty($element['comment'])) { |
| 111 | + $comment = $element['comment']; |
| 112 | + echo "<div><b>Comments:</b> $comment</div>"; |
| 113 | + } |
| 114 | + |
| 115 | + printReferences($element); |
102 | 116 | } |
103 | 117 |
|
104 | 118 |
|
105 | 119 | /** |
106 | 120 | * |
107 | 121 | * @param unknown $element |
108 | 122 | */ |
109 | | -function printReferences($element) { |
110 | | - if (!array_key_exists("references", $element)) { |
111 | | - return; |
112 | | - } |
113 | | - $actionLabels = readYaml("data/strings.yml#/actionLabels"); |
114 | | - |
115 | | - $references = $element['references']; |
116 | | - foreach ($references as $r => $values) { |
117 | | - // if it's not an array, array-ze it. Remove after fixing all yamls. |
118 | | - $values = is_array($values) ? $values : array($values); |
119 | | - |
120 | | - $label = getReferenceLabel($r); |
121 | | - echo "<div><h3>$label</h3></div>"; |
122 | | - echo "<ul><li>". implode("</li><li>", $values) ."</li></ul>"; |
123 | | - } |
| 123 | +function printReferences($element) |
| 124 | +{ |
| 125 | + if (!array_key_exists("references", $element)) { |
| 126 | + return; |
| 127 | + } |
| 128 | + $actionLabels = readYaml("data/strings.yml#/actionLabels"); |
| 129 | + |
| 130 | + $references = $element['references']; |
| 131 | + foreach ($references as $r => $values) { |
| 132 | + // if it's not an array, array-ze it. Remove after fixing all yamls. |
| 133 | + $values = is_array($values) ? $values : array($values); |
| 134 | + |
| 135 | + $label = getReferenceLabel($r); |
| 136 | + echo "<div><h3>$label</h3></div>"; |
| 137 | + echo "<ul><li>" . implode("</li><li>", $values) . "</li></ul>"; |
| 138 | + } |
124 | 139 |
|
125 | 140 |
|
126 | 141 | } |
|
0 commit comments