public function generateDashboard()
{
$baseHTML = $this->getBasedPage('index');
$tags = array();
$code = array();
// Bloc top left
$hashData = $this->getHashData();
$finalHTML = $this->injectBloc($baseHTML, "BLOCHASHDATA", $hashData);
// bloc Issues
$issues = $this->getIssuesBreakdown();
$finalHTML = $this->injectBloc($finalHTML, "BLOCISSUES", $issues['html']);
$tags[] = 'SCRIPTISSUES';
$code[] = $issues['script'];
// bloc severity
$severity = $this->getSeverityBreakdown();
$finalHTML = $this->injectBloc($finalHTML, "BLOCSEVERITY", $severity['html']);
$tags[] = 'SCRIPTSEVERITY';
$code[] = $severity['script'];
// top 10
$fileHTML = $this->getTopFile();
$finalHTML = $this->injectBloc($finalHTML, "TOPFILE", $fileHTML);
$analyzerHTML = $this->getTopAnalyzers();
$finalHTML = $this->injectBloc($finalHTML, "TOPANALYZER", $analyzerHTML);
$blocjs = <<<JAVASCRIPT
<script>
\$(document).ready(function() {
Morris.Donut({
element: 'donut-chart_issues',
resize: true,
colors: ["#3c8dbc", "#f56954", "#00a65a", "#1424b8"],
data: [SCRIPTISSUES]
});
Morris.Donut({
element: 'donut-chart_severity',
resize: true,
colors: ["#3c8dbc", "#f56954", "#00a65a", "#1424b8"],
data: [SCRIPTSEVERITY]
});
Highcharts.theme = {
colors: ["#F56954", "#f7a35c", "#ffea6f", "#D2D6DE"],
chart: {
backgroundColor: null,
style: {
fontFamily: "Dosis, sans-serif"
}
},
title: {
style: {
fontSize: '16px',
fontWeight: 'bold',
textTransform: 'uppercase'
}
},
tooltip: {
borderWidth: 0,
backgroundColor: 'rgba(219,219,216,0.8)',
shadow: false
},
legend: {
itemStyle: {
fontWeight: 'bold',
fontSize: '13px'
}
},
xAxis: {
gridLineWidth: 1,
labels: {
style: {
fontSize: '12px'
}
}
},
yAxis: {
minorTickInterval: 'auto',
title: {
style: {
textTransform: 'uppercase'
}
},
labels: {
style: {
fontSize: '12px'
}
}
},
plotOptions: {
candlestick: {
lineColor: '#404048'
}
},
// General
background2: '#F0F0EA'
};
// Apply the theme
Highcharts.setOptions(Highcharts.theme);
\$('#filename').highcharts({
credits: {
enabled: false
},
exporting: {
enabled: false
},
chart: {
type: 'column'
},
title: {
text: ''
},
xAxis: {
categories: [SCRIPTDATAFILES]
},
yAxis: {
min: 0,
title: {
text: ''
},
stackLabels: {
enabled: false,
style: {
fontWeight: 'bold',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
}
}
},
legend: {
align: 'right',
x: 0,
verticalAlign: 'top',
y: -10,
floating: false,
backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
borderColor: '#CCC',
borderWidth: 1,
shadow: false
},
tooltip: {
headerFormat: '<b>{point.x}</b><br/>',
pointFormat: '{series.name}: {point.y}<br/>Total: {point.stackTotal}'
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: false,
color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white',
style: {
textShadow: '0 0 3px black'
}
}
}
},
series: [{
name: 'Critical',
data: [SCRIPTDATACRITICAL]
}, {
name: 'Major',
data: [SCRIPTDATAMAJOR]
}, {
name: 'Minor',
data: [SCRIPTDATAMINOR]
}, {
name: 'None',
data: [SCRIPTDATANONE]
}]
});
\$('#container').highcharts({
credits: {
enabled: false
},
exporting: {
enabled: false
},
chart: {
type: 'column'
},
title: {
text: ''
},
xAxis: {
categories: [SCRIPTDATAANALYZERLIST]
},
yAxis: {
min: 0,
title: {
text: ''
},
stackLabels: {
enabled: false,
style: {
fontWeight: 'bold',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
}
}
},
legend: {
align: 'right',
x: 0,
verticalAlign: 'top',
y: -10,
floating: false,
backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
borderColor: '#CCC',
borderWidth: 1,
shadow: false
},
tooltip: {
headerFormat: '<b>{point.x}</b><br/>',
pointFormat: '{series.name}: {point.y}<br/>Total: {point.stackTotal}'
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: false,
color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white',
style: {
textShadow: '0 0 3px black'
}
}
}
},
series: [{
name: 'Critical',
data: [SCRIPTDATAANALYZERCRITICAL]
}, {
name: 'Major',
data: [SCRIPTDATAANALYZERMAJOR]
}, {
name: 'Minor',
data: [SCRIPTDATAANALYZERMINOR]
}, {
name: 'None',
data: [SCRIPTDATAANALYZERNONE]
}]
});
});
</script>
JAVASCRIPT;
// Filename Overview
$fileOverview = $this->getFileOverview();
$tags[] = 'SCRIPTDATAFILES';
$code[] = $fileOverview['scriptDataFiles'];
$tags[] = 'SCRIPTDATAMAJOR';
$code[] = $fileOverview['scriptDataMajor'];
$tags[] = 'SCRIPTDATACRITICAL';
$code[] = $fileOverview['scriptDataCritical'];
$tags[] = 'SCRIPTDATANONE';
$code[] = $fileOverview['scriptDataNone'];
$tags[] = 'SCRIPTDATAMINOR';
$code[] = $fileOverview['scriptDataMinor'];
// Analyzer Overview
$analyzerOverview = $this->getAnalyzerOverview();
$tags[] = 'SCRIPTDATAANALYZERLIST';
$code[] = $analyzerOverview['scriptDataAnalyzer'];
$tags[] = 'SCRIPTDATAANALYZERMAJOR';
$code[] = $analyzerOverview['scriptDataAnalyzerMajor'];
$tags[] = 'SCRIPTDATAANALYZERCRITICAL';
$code[] = $analyzerOverview['scriptDataAnalyzerCritical'];
$tags[] = 'SCRIPTDATAANALYZERNONE';
$code[] = $analyzerOverview['scriptDataAnalyzerNone'];
$tags[] = 'SCRIPTDATAANALYZERMINOR';
$code[] = $analyzerOverview['scriptDataAnalyzerMinor'];
$blocjs = str_replace($tags, $code, $blocjs);
$finalHTML = $this->injectBloc($finalHTML, "BLOC-JS", $blocjs);
$this->putBasedPage('index', $finalHTML);
}