forked from atosorigin/DevOpsMaturityAssessment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
renderAdvice.php
74 lines (64 loc) · 2.42 KB
/
renderAdvice.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
<?php
/* Copyright 2019 Atos SE and Worldline
* Licensed under MIT (https://github.com/atosorigin/DevOpsMaturityAssessment/blob/master/LICENSE) */
// Load the "next steps" advice from json file
$json = file_get_contents("advice.json");
$advice = json_decode($json, true);
// Routine that renders the advice and links for one section
function RenderAdvice($sectionName, $includeDetailedReportLink)
{
global $advice, $survey;
// If we are providing advice for a section that has sub categories, then include a link to the detailed report
$detailedReportLink = '';
if ($includeDetailedReportLink)
{
if ( $survey->sections[$survey->SectionNameToIndex($sectionName)]['HasSubCategories'] )
{
$detailedReportLink = '</p><p>See also <a href="results-' . SectionNameToURLName($sectionName) . '">detailed report for ' .
$sectionName . '</a>.';
}
}
// If there is "ReadMore" advice included, create a link for this
$readMoreLink = '';
if ( isset($advice[$sectionName]['ReadMore']) )
{
$readMoreAdvice = str_replace('"', '"', $advice[$sectionName]['ReadMore']);
$readMoreAdvice = str_replace("'", '‘', $readMoreAdvice);
$sectionNameNoSpace = str_replace(' ', '', $sectionName);
$readMoreJS = "onclick=\"$('#$sectionNameNoSpace').html('$readMoreAdvice');\"";
$readMoreLink = '</p><p id="' . $sectionNameNoSpace . '"><a href="#/" ' . $readMoreJS . '>Show more advice >></a>';
}
?>
<ul class="list-group list-group-flush">
<li class="list-group-item"><p><?=$advice[$sectionName]['Advice'] . $readMoreLink . $detailedReportLink?></p></li>
<?php foreach ( $advice[$sectionName]['Links'] as $link ) {
$icon = '';
switch ($link['Type']) {
case 'Video':
$icon = 'fa fa-video';
break;
case 'Blog':
$icon = 'fab fa-blogger';
break;
case 'Book':
$icon = 'fas fa-book-open';
break;
case 'Website':
$icon = 'fas fa-link';
break;
case 'Article':
$icon = 'fas fa-file-alt';
break;
}
$paidIcon = '';
if ( isset($link['Paid']) and $link['Paid'] == 'Yes' )
{
$paidIcon = ' <span class="fas fa-dollar-sign text-primary"></span>';
}
?>
<li class="list-group-item"><span class="<?=$icon?> text-primary"></span><?=$paidIcon?> <a class="card-link" target="_blank" href="<?=$link['Href']?>"><?=$link['Text']?></a></li>
<?php } ?>
</ul>
<?php
}
?>