Skip to content

Commit fb8f3b0

Browse files
committed
clear tooltip 1
1 parent c46f309 commit fb8f3b0

3 files changed

Lines changed: 58 additions & 39 deletions

File tree

data.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
$files = scandir("data");
99
$dimensions = readYaml("data/dimensions.yaml");
1010

11-
// reorder in-place $dimensions.
11+
// reorder in-place $dimensions. This should wrap readYaml(data/dimensions.yaml)
1212
ksort($dimensions);
1313
foreach ($dimensions as $dimensionName => $subDimension) {
1414
ksort($subDimension);
@@ -184,6 +184,9 @@ function render_risk($risk) {
184184
}
185185
return $risk;
186186
}
187+
/**
188+
* Render an activity in a tooltip.
189+
*/
187190
function build_table_tooltip($array, $headerWeight = 2)
188191
{
189192
$mapKnowLedge = array("Very Low (one discipline)", "Low (one discipline)", "Medium (two disciplines)", "High (two disciplines)", "Very High (three or more disciplines)");
@@ -212,6 +215,7 @@ function build_table_tooltip($array, $headerWeight = 2)
212215
return $html;
213216
}
214217

218+
215219
function getElementByName($dimensions, $name)
216220
{
217221
foreach ($dimensions as $dimensionName => $subDimension) {

functions.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,13 @@ function thead($headings){
4646
.'</th></tr></thead>';
4747
}
4848

49-
49+
function div_tooltip($title, $html_content, $html_tooltip) {
50+
$tooltip = "<div class='popoverdetails'>" .$html_tooltip . "</div>";
51+
return "<div data-toggle=\"popover\"
52+
data-title=\"$title\"
53+
data-activity=\".$html_tooltip\"
54+
type=\"button\" data-html=\"true \">" . $html_content . "</div>";
55+
}
5056
function renderSamm($samm_reference){
5157
return "$samm_reference";
5258
}

mappings.php

Lines changed: 46 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -68,59 +68,68 @@ function formCheck($reference_id, $sort) {
6868

6969
echo '<tbody>';
7070

71-
foreach ($filteredDimensions as $dimension => $subdimensions) {
72-
foreach ($subdimensions as $subdimension => $activity) {
73-
foreach ($activity as $activityName => $content) {
74-
echo "<tr>";
75-
echo "<td>$dimension</td>";
76-
echo "<td>$subdimension</td>";
77-
$tooltip = "<div class='popoverdetails'>" . build_table_tooltip ( $content ) . "</div>";
78-
$activityLink = "detail.php?dimension=" . urlencode ( $dimension ) . "&subdimension=" . urlencode ( $subdimension ) . "&element=" . urlencode ( $activityName );
79-
echo "<td><a href='$activityLink'><div data-toggle=\"popover\" data-title=\"$activityName\" data-content=\"$tooltip\" type=\"button\" data-html=\"true \">" . $activityName . "</div></a></td>";
80-
81-
foreach($referenceLabels as $r => $rLabel){
82-
$rlist = $content["references"][$r] ?? array();
83-
echo "<td>". renderSamms($rlist) ."</td>";
84-
}
71+
foreach(getActions($filteredDimensions) as list($dimension, $subdimension, $activities)) {
72+
foreach ($activities as $activityName => $activity) {
73+
echo "<tr>";
74+
echo "<td>$dimension</td>";
75+
echo "<td>$subdimension</td>";
76+
$activityLink = "detail.php?".
77+
http_build_query(array(
78+
"dimension" => $dimension,
79+
"subdimension"=> $subdimension,
80+
"element"=> $activityName
81+
));
82+
echo "<td><a href='$activityLink'>"
83+
.div_tooltip($activityName, $activityName, build_table_tooltip ( $activity ))
84+
."</a></td>";
85+
86+
foreach($referenceLabels as $r => $rLabel){
87+
$rlist = $activity["references"][$r] ?? array();
88+
echo "<td>". renderSamms($rlist) ."</td>";
8589
}
8690
}
8791
}
88-
} else {
89-
echo '<table class="table">';
90-
$headings = array_merge(array("$sort"), $headings, array_keys(getReferenceLabels()));
91-
thead($headings);
92-
93-
echo '<tbody>';
94-
$mapping = array();
95-
96-
92+
} else { // sort by samm2, iso, samm
9793
// populate mapping:
9894
// mapping = value, activity, content
99-
foreach ($filteredDimensions as $dimension => $subdimensions) {
100-
foreach ($subdimensions as $subdimension => $activity) {
101-
foreach ($activity as $activityName => $content) {
102-
$content["dimension"] = $dimension;
103-
$content["subdimension"] = $subdimension;
104-
105-
$references = $content["references"][$sort] ?? array();
106-
foreach(as_list($references) as $mappingContent) {
107-
$mapping[$mappingContent][$activityName] = $content;
108-
}
95+
$mapping = array();
96+
foreach(getActions($filteredDimensions) as list($dimension, $subdimension, $activities)) {
97+
foreach ($activities as $activityName => $activity) {
98+
$activity["dimension"] = $dimension;
99+
$activity["subdimension"] = $subdimension;
100+
101+
$references = $activity["references"][$sort] ?? array();
102+
foreach(as_list($references) as $mappingContent) {
103+
$mapping[$mappingContent][$activityName] = $activity;
109104
}
110105
}
111106
}
112107

113-
// render
108+
109+
// render table
110+
echo '<table class="table">';
111+
$headings = array_merge(array("$sort"), $headings, array_keys(getReferenceLabels()));
112+
thead($headings);
113+
114+
echo '<tbody>';
115+
116+
// render mappings.
114117
ksort($mapping, SORT_NUMERIC);
115118
foreach($mapping as $mappingName => $mappingElement) {
116119
foreach($mappingElement as $activityName => $activity) {
117120
echo "<tr>";
118121
echo "<td>" . $mappingName . "</td>";
119122
echo "<td>" . $activity['dimension'] . "</td>";
120123
echo "<td>" . $activity['subdimension'] . "</td>";
121-
$tooltip = "<div class='popoverdetails'>" . build_table_tooltip ( $activity ) . "</div>";
122-
$activityLink = "detail.php?dimension=" . urlencode ( $activity['dimension'] ) . "&subdimension=" . urlencode ( $activity['subdimension'] ) . "&element=" . urlencode ( $activityName );
123-
echo "<td><a href='$activityLink'><div data-toggle=\"popover\" data-title=\"$activityName\" data-content=\"$tooltip\" type=\"button\" data-html=\"true \">" . $activityName . "</div></></td>";
124+
$activityLink = "detail.php?".
125+
http_build_query(array(
126+
"dimension" => $dimension,
127+
"subdimension"=> $subdimension,
128+
"element"=> $activityName
129+
));
130+
echo "<td><a href='$activityLink'>"
131+
.div_tooltip($activityName, $activityName, build_table_tooltip ( $activity ))
132+
."</a></td>";
124133

125134
foreach($referenceLabels as $r => $rLabel){
126135
$rlist = $activity["references"][$r] ?? array();

0 commit comments

Comments
 (0)