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

Public Member Functions

 __construct ($statconfig, $ruleconfig, $ruleid, $available)
 Constructor. More...
 
 getRuleID ()
 
 availableTimeRes ()
 
 availableFileSlots ($timeres)
 
 getTimeNavigation ($timeres, $preferTime)
 
 getDataSet ($preferTimeRes, $preferTime)
 

Protected Member Functions

 resolveTimeRes ($preferTimeRes)
 
 resolveFileSlot ($timeres, $preferTime)
 

Protected Attributes

 $statconfig
 
 $ruleconfig
 
 $ruleid
 
 $available
 

Detailed Description

Definition at line 6 of file BaseRule.php.

Constructor & Destructor Documentation

◆ __construct()

sspmod_statistics_Statistics_Rulesets_BaseRule::__construct (   $statconfig,
  $ruleconfig,
  $ruleid,
  $available 
)

Constructor.

Reimplemented in sspmod_statistics_Statistics_Rulesets_Ratio.

Definition at line 16 of file BaseRule.php.

17 {
18 assert('$statconfig instanceof SimpleSAML_Configuration');
19 assert('$ruleconfig instanceof SimpleSAML_Configuration');
20 $this->statconfig = $statconfig;
21 $this->ruleconfig = $ruleconfig;
22 $this->ruleid = $ruleid;
23
24 $this->available = null;
25 if (array_key_exists($ruleid, $available)) {
26 $this->available = $available[$ruleid];
27 }
28 }

References $available, $ruleconfig, $ruleid, and $statconfig.

Member Function Documentation

◆ availableFileSlots()

sspmod_statistics_Statistics_Rulesets_BaseRule::availableFileSlots (   $timeres)

Reimplemented in sspmod_statistics_Statistics_Rulesets_Ratio.

Definition at line 46 of file BaseRule.php.

47 {
48 $timeresConfigs = $this->statconfig->getValue('timeres');
49 $timeresConfig = $timeresConfigs[$timeres];
50
51 if (isset($timeresConfig['customDateHandler']) && $timeresConfig['customDateHandler'] == 'month') {
52 $datehandler = new sspmod_statistics_DateHandlerMonth(0);
53 } else {
54 $datehandler = new sspmod_statistics_DateHandler($this->statconfig->getValue('offset', 0));
55 }
56
57 /*
58 * Get list of avaiable times in current file (rule)
59 */
60 $available_times = array();
61 foreach ($this->available[$timeres] as $slot) {
62 $available_times[$slot] = $datehandler->prettyHeader($slot, $slot + 1, $timeresConfig['fileslot'], $timeresConfig['dateformat-period']);
63 }
64 return $available_times;
65 }
$timeres
Definition: showstats.php:50

References $timeres.

◆ availableTimeRes()

sspmod_statistics_Statistics_Rulesets_BaseRule::availableTimeRes ( )

Reimplemented in sspmod_statistics_Statistics_Rulesets_Ratio.

Definition at line 35 of file BaseRule.php.

35 {
36 $timeresConfigs = $this->statconfig->getValue('timeres');
37 $available_times = array();
38 foreach ($timeresConfigs as $tres => $tresconfig) {
39 if (array_key_exists($tres, $this->available)) {
40 $available_times[$tres] = $tresconfig['name'];
41 }
42 }
43 return $available_times;
44 }

◆ getDataSet()

sspmod_statistics_Statistics_Rulesets_BaseRule::getDataSet (   $preferTimeRes,
  $preferTime 
)

Reimplemented in sspmod_statistics_Statistics_Rulesets_Ratio.

Definition at line 111 of file BaseRule.php.

112 {
115 $dataset = new sspmod_statistics_StatDataset($this->statconfig, $this->ruleconfig, $this->ruleid, $timeres, $fileslot);
116 return $dataset;
117 }
$preferTime
Definition: showstats.php:14
$dataset
Definition: showstats.php:45
$fileslot
Definition: showstats.php:51
$preferTimeRes
Definition: showstats.php:15

References $dataset, $fileslot, $preferTime, $preferTimeRes, $timeres, resolveFileSlot(), and resolveTimeRes().

+ Here is the call graph for this function:

◆ getRuleID()

sspmod_statistics_Statistics_Rulesets_BaseRule::getRuleID ( )

Definition at line 30 of file BaseRule.php.

31 {
32 return $this->ruleid;
33 }

References $ruleid.

◆ getTimeNavigation()

sspmod_statistics_Statistics_Rulesets_BaseRule::getTimeNavigation (   $timeres,
  $preferTime 
)

Reimplemented in sspmod_statistics_Statistics_Rulesets_Ratio.

Definition at line 90 of file BaseRule.php.

91 {
93
94 // Extract previous and next time slots...
95 $available_times_prev = null;
96 $available_times_next = null;
97
98 $timeslots = array_values($this->available[$timeres]);
99 sort($timeslots, SORT_NUMERIC);
100 $timeslotindex = array_flip($timeslots);
101
102 if ($timeslotindex[$fileslot] > 0) {
103 $available_times_prev = $timeslots[$timeslotindex[$fileslot] - 1];
104 }
105 if ($timeslotindex[$fileslot] < (count($timeslotindex) - 1)) {
106 $available_times_next = $timeslots[$timeslotindex[$fileslot] + 1];
107 }
108 return array('prev' => $available_times_prev, 'next' => $available_times_next);
109 }

References $fileslot, $preferTime, $timeres, and resolveFileSlot().

+ Here is the call graph for this function:

◆ resolveFileSlot()

sspmod_statistics_Statistics_Rulesets_BaseRule::resolveFileSlot (   $timeres,
  $preferTime 
)
protected

Reimplemented in sspmod_statistics_Statistics_Rulesets_Ratio.

Definition at line 79 of file BaseRule.php.

80 {
81 // Get which time (fileslot) to use.. First get a default, which is the most recent one.
82 $fileslot = $this->available[$timeres][count($this->available[$timeres]) - 1];
83 // Then check if the user have provided one.
84 if (in_array($preferTime, $this->available[$timeres], true)) {
86 }
87 return $fileslot;
88 }

References $fileslot, $preferTime, and $timeres.

Referenced by getDataSet(), and getTimeNavigation().

+ Here is the caller graph for this function:

◆ resolveTimeRes()

sspmod_statistics_Statistics_Rulesets_BaseRule::resolveTimeRes (   $preferTimeRes)
protected

Reimplemented in sspmod_statistics_Statistics_Rulesets_Ratio.

Definition at line 67 of file BaseRule.php.

68 {
69 $timeresavailable = array_keys($this->available);
70 $timeres = $timeresavailable[0];
71
72 // Then check if the user have provided one that is valid
73 if (in_array($preferTimeRes, $timeresavailable, true)) {
75 }
76 return $timeres;
77 }

References $preferTimeRes, and $timeres.

Referenced by getDataSet().

+ Here is the caller graph for this function:

Field Documentation

◆ $available

sspmod_statistics_Statistics_Rulesets_BaseRule::$available
protected

◆ $ruleconfig

sspmod_statistics_Statistics_Rulesets_BaseRule::$ruleconfig
protected

◆ $ruleid

sspmod_statistics_Statistics_Rulesets_BaseRule::$ruleid
protected

◆ $statconfig

sspmod_statistics_Statistics_Rulesets_BaseRule::$statconfig
protected

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