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_intra = $this->timeresconfig->getValue(
'dateformat-intra');
187 $axislabelint = $this->timeresconfig->getValue(
'axislabelint');
191 $xentries = count($this->results);
195 foreach ($this->results as $slot =>
$res) {
197 if ($slot % $axislabelint == 0) {
198 $axis[] = $this->datehandlerTick->prettyDateSlot($slot, $slotsize, $dateformat_intra);
199 $axispos[] = ((
$i) / ($xentries - 1));
205 $axis[] = $this->datehandlerTick->prettyDateSlot($lastslot + 1, $slotsize, $dateformat_intra);
207 return array(
'axis' =>
$axis,
'axispos' => $axispos);
217 foreach ($this->results as $slot =>
$res) {
218 if (array_key_exists($this->delimiter,
$res)) {
219 if (
$res[$this->delimiter] === null) {
222 $dataset[] = number_format(100 *
$res[$this->delimiter] / $this->max, 2);
241 if ($this->ruleconfig->hasValue(
'fieldPresentation')) {
242 $fieldpresConfig = $this->ruleconfig->getConfigItem(
'fieldPresentation');
244 $fieldpresConfig->getValue(
'class'),
245 'Statistics_FieldPresentation' 247 if (!class_exists($classname)) {
248 throw new Exception(
'Could not find field presentation plugin ['.$classname.
']: No class found');
250 $presentationHandler =
new $classname($availdelimiters, $fieldpresConfig->getValue(
'config'),
$t);
252 return $presentationHandler->getPresentation();
264 foreach ($topdelimiters as
$key) {
266 if (array_key_exists($key, $delimiterPresentation)) {
267 $keyName = $delimiterPresentation[
$key];
269 $pieaxis[] = $keyName;
271 $pieaxis[] =
'Others';
277 $statdir = $this->statconfig->getValue(
'statdir');
280 foreach ($rules as
$rule) {
282 $resultFileName = $statdir.
'/'.$rule.
'-'.$this->timeres.
'-'.$this->fileslot.
'.stat';
283 if (!file_exists($resultFileName)) {
284 throw new Exception(
'Aggregated statitics file ['.$resultFileName.
'] not found.');
286 if (!is_readable($resultFileName)) {
287 throw new Exception(
'Could not read statitics file ['.$resultFileName.
']. Bad file permissions?');
289 $resultfile = file_get_contents($resultFileName);
290 $newres = unserialize($resultfile);
291 if (empty($newres)) {
292 throw new Exception(
'Aggregated statistics in file ['.$resultFileName.
'] was empty.');
294 $resarray[] = $newres;
297 $combined = $resarray[0];
298 $count = count($resarray);
300 for (
$i = 1;
$i < $count;
$i++) {
301 $combined = $this->combine($combined, $resarray[
$i]);
304 $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.
getDelimiterPresentation()
static resolveClass($id, $type, $subclass=null)
Resolve module class.
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
setDelimiter($delimiter='_')