ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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.

Definition at line 16 of file BaseRule.php.

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

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  }

Member Function Documentation

◆ availableFileSlots()

sspmod_statistics_Statistics_Rulesets_BaseRule::availableFileSlots (   $timeres)

Definition at line 46 of file BaseRule.php.

References $timeres, and sspmod_statistics_DateHandler\prettyHeader().

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:77
prettyHeader($from, $to, $slotsize, $dateformat)
Definition: DateHandler.php:51
+ Here is the call graph for this function:

◆ availableTimeRes()

sspmod_statistics_Statistics_Rulesets_BaseRule::availableTimeRes ( )

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 
)

Definition at line 111 of file BaseRule.php.

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

112  {
115  $dataset = new sspmod_statistics_StatDataset($this->statconfig, $this->ruleconfig, $this->ruleid, $timeres, $fileslot);
116  return $dataset;
117  }
$fileslot
Definition: showstats.php:78
$timeres
Definition: showstats.php:77
$preferTimeRes
Definition: showstats.php:15
$preferTime
Definition: showstats.php:14
+ Here is the call graph for this function:

◆ getRuleID()

sspmod_statistics_Statistics_Rulesets_BaseRule::getRuleID ( )

Definition at line 30 of file BaseRule.php.

References $ruleid.

◆ getTimeNavigation()

sspmod_statistics_Statistics_Rulesets_BaseRule::getTimeNavigation (   $timeres,
  $preferTime 
)

Definition at line 90 of file BaseRule.php.

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

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  }
$fileslot
Definition: showstats.php:78
$timeres
Definition: showstats.php:77
$preferTime
Definition: showstats.php:14
+ Here is the call graph for this function:

◆ resolveFileSlot()

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

Definition at line 79 of file BaseRule.php.

References $fileslot, $preferTime, and $timeres.

Referenced by getDataSet(), and getTimeNavigation().

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  }
$fileslot
Definition: showstats.php:78
$timeres
Definition: showstats.php:77
$preferTime
Definition: showstats.php:14
+ Here is the caller graph for this function:

◆ resolveTimeRes()

sspmod_statistics_Statistics_Rulesets_BaseRule::resolveTimeRes (   $preferTimeRes)
protected

Definition at line 67 of file BaseRule.php.

References $preferTimeRes, and $timeres.

Referenced by getDataSet().

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  }
$timeres
Definition: showstats.php:77
$preferTimeRes
Definition: showstats.php:15
+ 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: