32 assert(
'$statconfig instanceof SimpleSAML_Configuration');
33 assert(
'$ruleconfig instanceof SimpleSAML_Configuration');
37 $timeresconfigs =
$statconfig->getConfigItem(
'timeres');
38 $this->timeresconfig = $timeresconfigs->getConfigItem(
$timeres);
44 $this->delimiter =
'_';
48 if ($this->timeresconfig->getValue(
'customDateHandler',
'default') ===
'month') {
77 if ($this->delimiter ===
'_') {
86 foreach ($this->results as $slot => &
$res) {
87 if (!array_key_exists($this->delimiter,
$res)) {
90 $maxvalue = max(
$res[$this->delimiter], $maxvalue);
99 $slotsize = $this->timeresconfig->getValue(
'slot');
100 $dateformat_intra = $this->timeresconfig->getValue(
'dateformat-intra');
102 foreach ($this->results as $slot => &
$res) {
103 $debugdata[$slot] =
array(
104 $this->datehandlerTick->prettyDateSlot($slot, $slotsize, $dateformat_intra),
114 $this->summary =
array();
115 foreach ($this->results as $slot =>
$res) {
117 if (array_key_exists(
$key, $this->summary)) {
118 $this->summary[
$key] += $value;
120 $this->summary[
$key] = $value;
124 asort($this->summary);
125 $this->summary = array_reverse($this->summary,
true);
131 $topdelimiters =
array();
134 foreach ($this->summary as
$key => $value) {
136 $topdelimiters[] =
$key;
138 if (
$i++ >= $maxdelimiters) {
142 return $topdelimiters;
147 $availDelimiters =
array();
148 foreach ($this->summary as
$key => $value) {
149 $availDelimiters[
$key] = 1;
151 return array_keys($availDelimiters);
160 foreach ($topdelimiters as $td) {
161 $sum += $this->summary[$td];
162 $piedata[] = number_format(100 * $this->summary[$td] / $this->summary[
'_'], 2);
164 $piedata[] = number_format(100 - 100 * ($sum / $this->summary[
'_']), 2);
185 $slotsize = $this->timeresconfig->getValue(
'slot');
186 $dateformat_period = $this->timeresconfig->getValue(
'dateformat-period');
187 $dateformat_intra = $this->timeresconfig->getValue(
'dateformat-intra');
188 $axislabelint = $this->timeresconfig->getValue(
'axislabelint');
192 $xentries = count($this->results);
196 foreach ($this->results as $slot =>
$res) {
198 if ($slot % $axislabelint == 0) {
199 $axis[] = $this->datehandlerTick->prettyDateSlot($slot, $slotsize, $dateformat_intra);
200 $axispos[] = ((
$i) / ($xentries - 1));
206 $axis[] = $this->datehandlerTick->prettyDateSlot($lastslot + 1, $slotsize, $dateformat_intra);
208 return array(
'axis' =>
$axis,
'axispos' => $axispos);
218 foreach ($this->results as $slot =>
$res) {
219 if (array_key_exists($this->delimiter,
$res)) {
220 if (
$res[$this->delimiter] === null) {
223 $dataset[] = number_format(100 *
$res[$this->delimiter] / $this->max, 2);
242 if ($this->ruleconfig->hasValue(
'fieldPresentation')) {
243 $fieldpresConfig = $this->ruleconfig->getConfigItem(
'fieldPresentation');
245 $fieldpresConfig->getValue(
'class'),
246 'Statistics_FieldPresentation' 248 if (!class_exists($classname)) {
249 throw new Exception(
'Could not find field presentation plugin ['.$classname.
']: No class found');
251 $presentationHandler =
new $classname($availdelimiters, $fieldpresConfig->getValue(
'config'),
$t);
253 return $presentationHandler->getPresentation();
265 foreach ($topdelimiters as
$key) {
267 if (array_key_exists($key, $delimiterPresentation)) {
268 $keyName = $delimiterPresentation[
$key];
270 $pieaxis[] = $keyName;
272 $pieaxis[] =
'Others';
278 $statdir = $this->statconfig->getValue(
'statdir');
281 foreach ($rules as
$rule) {
283 $resultFileName = $statdir.
'/'.$rule.
'-'.$this->timeres.
'-'.$this->fileslot.
'.stat';
284 if (!file_exists($resultFileName)) {
285 throw new Exception(
'Aggregated statitics file ['.$resultFileName.
'] not found.');
287 if (!is_readable($resultFileName)) {
288 throw new Exception(
'Could not read statitics file ['.$resultFileName.
']. Bad file permissions?');
290 $resultfile = file_get_contents($resultFileName);
291 $newres = unserialize($resultfile);
292 if (empty($newres)) {
293 throw new Exception(
'Aggregated statistics in file ['.$resultFileName.
'] was empty.');
295 $resarray[] = $newres;
298 $combined = $resarray[0];
299 $count = count($resarray);
301 for (
$i = 1;
$i < $count;
$i++) {
302 $combined = $this->combine($combined, $resarray[
$i]);
305 $this->results = $combined;
static roof($max)
Takes a input value, and generates a value that suits better as a max value on the Y-axis...
static arrayize($data, $index=0)
Put a non-array variable into an array.
getDelimiterPresentationPie()
foreach($_POST as $key=> $value) $res
__construct($statconfig, $ruleconfig, $ruleid, $timeres, $fileslot)
Constructor.
Create styles array
The data for the language used.
getDelimiterPresentation()
static resolveClass($id, $type, $subclass=null)
Resolve module class.
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
setDelimiter($delimiter='_')