-
Notifications
You must be signed in to change notification settings - Fork 0
/
DataContainerStatistic.php
75 lines (61 loc) · 1.95 KB
/
DataContainerStatistic.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
class DataContainerStatistic extends Backend
{
/**
* checks statistic type and returns formatted archive names
* @param DataContainer
* @return Array
*/
public function getStatisticYears(DataContainer $dc)
{
$time = time();
$objArchives = $this->Database->prepare("SELECT id,year
FROM tl_alert_archive
WHERE (start='' OR start<$time)
AND (stop='' OR stop>$time)
AND published=1
ORDER BY year ")
->execute();
$objArchive = $objArchives->fetchAllAssoc();
if($GLOBALS['TL_LANG']['tl_content']['fwm']['statsType']['year'] === $dc->activeRecord->statisticType){
$yearsCount = count($objArchive);
$i = 2;
while($i < $yearsCount){
$yearOpts[] = sprintf($GLOBALS['TL_LANG']['tl_content']['fwm']['statsYear'],$i);
$i++;
}
}else{
$objArchive = $objArchives->fetchAllAssoc();
foreach($objArchive as $option)
{
$yearOpts[$option['id']] = $option['year'];
}
}
return $yearOpts;
}
/**
* returns statistic types, defined in the language file
* @return array
*/
public function statisticTypes()
{
$opts = array();
foreach($GLOBALS['TL_LANG']['tl_content']['fwm']['statsType'] as $option=>$value)
{
$opts[] = $GLOBALS['TL_LANG']['tl_content']['fwm']['statsType'][$option];
}
return $opts;
}
/**
* changes multiple to true of the statistic archives in special cases, returns the selected value
* @param string
* @return string
*/
public function toggleMultiple($value, DataContainer $dc)
{
if($GLOBALS['TL_LANG']['tl_content']['fwm']['statsType']['month'] === $dc->activeRecord->statisticType){
$GLOBALS['TL_DCA']['tl_content']['fields']['statisticYear']['eval']['multiple'] = true;
}
return $value;
}
}