ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
sspmod_statistics_StatDataset Class Reference
+ Inheritance diagram for sspmod_statistics_StatDataset:
+ Collaboration diagram for sspmod_statistics_StatDataset:

Public Member Functions

 __construct ($statconfig, $ruleconfig, $ruleid, $timeres, $fileslot)
 Constructor. More...
 
 getFileSlot ()
 
 getTimeRes ()
 
 setDelimiter ($delimiter='_')
 
 getDelimiter ()
 
 calculateMax ()
 
 getDebugData ()
 
 aggregateSummary ()
 
 getTopDelimiters ()
 
 availDelimiters ()
 
 getPieData ()
 
 getMax ()
 
 getSummary ()
 
 getResults ()
 
 getAxis ()
 
 getPercentValues ()
 
 getDelimiterPresentation ()
 
 getDelimiterPresentationPie ()
 
 loadData ()
 

Protected Attributes

 $statconfig
 
 $ruleconfig
 
 $timeresconfig
 
 $ruleid
 
 $fileslot
 
 $timeres
 
 $delimiter
 
 $results
 
 $summary
 
 $max
 
 $datehandlerFile
 
 $datehandlerTick
 

Detailed Description

Definition at line 8 of file StatDataset.php.

Constructor & Destructor Documentation

◆ __construct()

sspmod_statistics_StatDataset::__construct (   $statconfig,
  $ruleconfig,
  $ruleid,
  $timeres,
  $fileslot 
)

Constructor.

Definition at line 30 of file StatDataset.php.

31 {
32 assert('$statconfig instanceof SimpleSAML_Configuration');
33 assert('$ruleconfig instanceof SimpleSAML_Configuration');
34 $this->statconfig = $statconfig;
35 $this->ruleconfig = $ruleconfig;
36
37 $timeresconfigs = $statconfig->getConfigItem('timeres');
38 $this->timeresconfig = $timeresconfigs->getConfigItem($timeres);
39
40 $this->ruleid = $ruleid;
41 $this->fileslot = $fileslot;
42 $this->timeres = $timeres;
43
44 $this->delimiter = '_';
45 $this->max = 0;
46
47 $this->datehandlerTick = new sspmod_statistics_DateHandler($this->statconfig->getValue('offset', 0));
48 if ($this->timeresconfig->getValue('customDateHandler', 'default') === 'month') {
49 $this->datehandlerFile = new sspmod_statistics_DateHandlerMonth(0);
50 } else {
51 $this->datehandlerFile = $this->datehandlerTick;
52 }
53
54 $this->loadData();
55 }

References $datehandlerTick, $fileslot, $ruleconfig, $ruleid, $statconfig, $timeres, and loadData().

+ Here is the call graph for this function:

Member Function Documentation

◆ aggregateSummary()

sspmod_statistics_StatDataset::aggregateSummary ( )

Reimplemented in sspmod_statistics_RatioDataset.

Definition at line 111 of file StatDataset.php.

112 {
113 // aggregate summary table from dataset. To be used in the table view
114 $this->summary = array();
115 foreach ($this->results as $slot => $res) {
116 foreach ($res as $key => $value) {
117 if (array_key_exists($key, $this->summary)) {
118 $this->summary[$key] += $value;
119 } else {
120 $this->summary[$key] = $value;
121 }
122 }
123 }
124 asort($this->summary);
125 $this->summary = array_reverse($this->summary, true);
126 }
$key
Definition: croninfo.php:18
foreach($_POST as $key=> $value) $res

References $key, and $res.

◆ availDelimiters()

sspmod_statistics_StatDataset::availDelimiters ( )

Definition at line 145 of file StatDataset.php.

146 {
147 $availDelimiters = array();
148 foreach ($this->summary as $key => $value) {
149 $availDelimiters[$key] = 1;
150 }
151 return array_keys($availDelimiters);
152 }

References $key.

Referenced by getDelimiterPresentation().

+ Here is the caller graph for this function:

◆ calculateMax()

sspmod_statistics_StatDataset::calculateMax ( )

Definition at line 83 of file StatDataset.php.

84 {
85 $maxvalue = 0;
86 foreach ($this->results as $slot => &$res) {
87 if (!array_key_exists($this->delimiter, $res)) {
89 }
90 $maxvalue = max($res[$this->delimiter], $maxvalue);
91 }
92 $this->max = sspmod_statistics_Graph_GoogleCharts::roof($maxvalue);
93 }
static roof($max)
Takes a input value, and generates a value that suits better as a max value on the Y-axis.

References $delimiter, $res, and sspmod_statistics_Graph_GoogleCharts\roof().

+ Here is the call graph for this function:

◆ getAxis()

sspmod_statistics_StatDataset::getAxis ( )

Definition at line 183 of file StatDataset.php.

184 {
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');
189
190 $axis = array();
191 $axispos = array();
192 $xentries = count($this->results);
193 $lastslot = 0;
194 $i = 0;
195
196 foreach ($this->results as $slot => $res) {
197 // check if there should be an axis here...
198 if ($slot % $axislabelint == 0) {
199 $axis[] = $this->datehandlerTick->prettyDateSlot($slot, $slotsize, $dateformat_intra);
200 $axispos[] = (($i) / ($xentries - 1));
201 }
202 $lastslot = $slot;
203 $i++;
204 }
205
206 $axis[] = $this->datehandlerTick->prettyDateSlot($lastslot + 1, $slotsize, $dateformat_intra);
207
208 return array('axis' => $axis, 'axispos' => $axispos);
209 }
$i
Definition: disco.tpl.php:19
$axis
Definition: showstats.php:64

References $axis, $i, and $res.

◆ getDebugData()

sspmod_statistics_StatDataset::getDebugData ( )

Definition at line 95 of file StatDataset.php.

96 {
97 $debugdata = array();
98
99 $slotsize = $this->timeresconfig->getValue('slot');
100 $dateformat_intra = $this->timeresconfig->getValue('dateformat-intra');
101
102 foreach ($this->results as $slot => &$res) {
103 $debugdata[$slot] = array(
104 $this->datehandlerTick->prettyDateSlot($slot, $slotsize, $dateformat_intra),
105 $res[$this->delimiter]
106 );
107 }
108 return $debugdata;
109 }

References $res.

◆ getDelimiter()

sspmod_statistics_StatDataset::getDelimiter ( )

Definition at line 75 of file StatDataset.php.

76 {
77 if ($this->delimiter === '_') {
78 return null;
79 }
80 return $this->delimiter;
81 }

References $delimiter.

◆ getDelimiterPresentation()

sspmod_statistics_StatDataset::getDelimiterPresentation ( )

Definition at line 234 of file StatDataset.php.

235 {
237 $t = new SimpleSAML_XHTML_Template($config, 'statistics:statistics.tpl.php');
238
239 $availdelimiters = $this->availDelimiters();
240
241 // create a delimiter presentation filter for this rule...
242 if ($this->ruleconfig->hasValue('fieldPresentation')) {
243 $fieldpresConfig = $this->ruleconfig->getConfigItem('fieldPresentation');
245 $fieldpresConfig->getValue('class'),
246 'Statistics_FieldPresentation'
247 );
248 if (!class_exists($classname)) {
249 throw new Exception('Could not find field presentation plugin ['.$classname.']: No class found');
250 }
251 $presentationHandler = new $classname($availdelimiters, $fieldpresConfig->getValue('config'), $t);
252
253 return $presentationHandler->getPresentation();
254 }
255
256 return array();
257 }
static resolveClass($id, $type, $subclass=null)
Resolve module class.
Definition: Module.php:252
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.

References $config, $t, availDelimiters(), SimpleSAML_Configuration\getInstance(), and SimpleSAML\Module\resolveClass().

Referenced by getDelimiterPresentationPie().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDelimiterPresentationPie()

sspmod_statistics_StatDataset::getDelimiterPresentationPie ( )

Definition at line 259 of file StatDataset.php.

260 {
261 $topdelimiters = $this->getTopDelimiters();
262 $delimiterPresentation = $this->getDelimiterPresentation();
263
264 $pieaxis = array();
265 foreach ($topdelimiters as $key) {
266 $keyName = $key;
267 if (array_key_exists($key, $delimiterPresentation)) {
268 $keyName = $delimiterPresentation[$key];
269 }
270 $pieaxis[] = $keyName;
271 }
272 $pieaxis[] = 'Others';
273 return $pieaxis;
274 }

References $key, getDelimiterPresentation(), and getTopDelimiters().

+ Here is the call graph for this function:

◆ getFileSlot()

sspmod_statistics_StatDataset::getFileSlot ( )

Definition at line 57 of file StatDataset.php.

58 {
59 return $this->fileslot;
60 }

References $fileslot.

◆ getMax()

sspmod_statistics_StatDataset::getMax ( )

Definition at line 168 of file StatDataset.php.

169 {
170 return $this->max;
171 }

References $max.

◆ getPercentValues()

sspmod_statistics_StatDataset::getPercentValues ( )

Definition at line 214 of file StatDataset.php.

215 {
216 $i = 0;
217 $dataset = array();
218 foreach ($this->results as $slot => $res) {
219 if (array_key_exists($this->delimiter, $res)) {
220 if ($res[$this->delimiter] === null) {
221 $dataset[] = -1;
222 } else {
223 $dataset[] = number_format(100 * $res[$this->delimiter] / $this->max, 2);
224 }
225 } else {
226 $dataset[] = '0';
227 }
228 $i++;
229 }
230
231 return $dataset;
232 }
$dataset
Definition: showstats.php:45

References $dataset, $i, and $res.

◆ getPieData()

sspmod_statistics_StatDataset::getPieData ( )

Reimplemented in sspmod_statistics_RatioDataset.

Definition at line 154 of file StatDataset.php.

155 {
156 $piedata = array();
157 $sum = 0;
158 $topdelimiters = $this->getTopDelimiters();
159
160 foreach ($topdelimiters as $td) {
161 $sum += $this->summary[$td];
162 $piedata[] = number_format(100 * $this->summary[$td] / $this->summary['_'], 2);
163 }
164 $piedata[] = number_format(100 - 100 * ($sum / $this->summary['_']), 2);
165 return $piedata;
166 }
$piedata
Definition: showstats.php:59

References $piedata, and getTopDelimiters().

+ Here is the call graph for this function:

◆ getResults()

sspmod_statistics_StatDataset::getResults ( )

Definition at line 178 of file StatDataset.php.

179 {
180 return $this->results;
181 }

References $results.

◆ getSummary()

sspmod_statistics_StatDataset::getSummary ( )

Definition at line 173 of file StatDataset.php.

174 {
175 return $this->summary;
176 }

References $summary.

◆ getTimeRes()

sspmod_statistics_StatDataset::getTimeRes ( )

Definition at line 62 of file StatDataset.php.

63 {
64 return $this->timeres;
65 }

References $timeres.

◆ getTopDelimiters()

sspmod_statistics_StatDataset::getTopDelimiters ( )

Definition at line 128 of file StatDataset.php.

129 {
130 // create a list of delimiter keys that has the highest total summary in this period
131 $topdelimiters = array();
132 $maxdelimiters = 4;
133 $i = 0;
134 foreach ($this->summary as $key => $value) {
135 if ($key !== '_') {
136 $topdelimiters[] = $key;
137 }
138 if ($i++ >= $maxdelimiters) {
139 break;
140 }
141 }
142 return $topdelimiters;
143 }

References $i, and $key.

Referenced by getDelimiterPresentationPie(), and getPieData().

+ Here is the caller graph for this function:

◆ loadData()

sspmod_statistics_StatDataset::loadData ( )

Definition at line 276 of file StatDataset.php.

277 {
278 $statdir = $this->statconfig->getValue('statdir');
279 $resarray = array();
280 $rules = SimpleSAML\Utils\Arrays::arrayize($this->ruleid);
281 foreach ($rules as $rule) {
282 // Get file and extract results.
283 $resultFileName = $statdir.'/'.$rule.'-'.$this->timeres.'-'.$this->fileslot.'.stat';
284 if (!file_exists($resultFileName)) {
285 throw new Exception('Aggregated statitics file ['.$resultFileName.'] not found.');
286 }
287 if (!is_readable($resultFileName)) {
288 throw new Exception('Could not read statitics file ['.$resultFileName.']. Bad file permissions?');
289 }
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.');
294 }
295 $resarray[] = $newres;
296 }
297
298 $combined = $resarray[0];
299 $count = count($resarray);
300 if ($count > 1) {
301 for ($i = 1; $i < $count; $i++) {
302 $combined = $this->combine($combined, $resarray[$i]);
303 }
304 }
305 $this->results = $combined;
306 }
static arrayize($data, $index=0)
Put a non-array variable into an array.
Definition: Arrays.php:24
$rule
Definition: showstats.php:43

References $i, $rule, and SimpleSAML\Utils\Arrays\arrayize().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDelimiter()

sspmod_statistics_StatDataset::setDelimiter (   $delimiter = '_')

Definition at line 67 of file StatDataset.php.

68 {
69 if (empty($delimiter)) {
70 $delimiter = '_';
71 }
72 $this->delimiter = $delimiter;
73 }

References $delimiter.

Field Documentation

◆ $datehandlerFile

sspmod_statistics_StatDataset::$datehandlerFile
protected

Definition at line 23 of file StatDataset.php.

◆ $datehandlerTick

sspmod_statistics_StatDataset::$datehandlerTick
protected

Definition at line 24 of file StatDataset.php.

Referenced by __construct().

◆ $delimiter

sspmod_statistics_StatDataset::$delimiter
protected

Definition at line 18 of file StatDataset.php.

Referenced by calculateMax(), getDelimiter(), and setDelimiter().

◆ $fileslot

sspmod_statistics_StatDataset::$fileslot
protected

Definition at line 15 of file StatDataset.php.

Referenced by __construct(), and getFileSlot().

◆ $max

sspmod_statistics_StatDataset::$max
protected

Definition at line 21 of file StatDataset.php.

Referenced by getMax().

◆ $results

sspmod_statistics_StatDataset::$results
protected

Definition at line 19 of file StatDataset.php.

Referenced by getResults().

◆ $ruleconfig

sspmod_statistics_StatDataset::$ruleconfig
protected

Definition at line 11 of file StatDataset.php.

Referenced by __construct().

◆ $ruleid

sspmod_statistics_StatDataset::$ruleid
protected

Definition at line 13 of file StatDataset.php.

Referenced by __construct().

◆ $statconfig

sspmod_statistics_StatDataset::$statconfig
protected

Definition at line 10 of file StatDataset.php.

Referenced by __construct().

◆ $summary

sspmod_statistics_StatDataset::$summary
protected

Definition at line 20 of file StatDataset.php.

Referenced by getSummary().

◆ $timeres

sspmod_statistics_StatDataset::$timeres
protected

Definition at line 16 of file StatDataset.php.

Referenced by __construct(), and getTimeRes().

◆ $timeresconfig

sspmod_statistics_StatDataset::$timeresconfig
protected

Definition at line 12 of file StatDataset.php.


The documentation for this class was generated from the following file: