1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Firesphere\GoogleAPI\Extensions; |
4
|
|
|
|
5
|
|
|
use SilverStripe\Forms\DropdownField; |
6
|
|
|
use SilverStripe\Forms\FieldList; |
7
|
|
|
use SilverStripe\Forms\TextField; |
8
|
|
|
use SilverStripe\ORM\DataExtension; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class GoogleAPISiteConfigExtension |
12
|
|
|
* |
13
|
|
|
* @property \SilverStripe\SiteConfig\SiteConfig|\Firesphere\GoogleAPI\Extensions\SiteConfigExtension $owner |
14
|
|
|
* @property string $Viewid |
15
|
|
|
* @property string $DateRange |
16
|
|
|
* @property string $Metric |
17
|
|
|
*/ |
18
|
|
|
class SiteConfigExtension extends DataExtension |
19
|
|
|
{ |
20
|
|
|
private static $db = [ |
|
|
|
|
21
|
|
|
'Viewid' => 'Varchar(50)', |
22
|
|
|
'DateRange' => 'Enum("7,30,60,90")', |
23
|
|
|
'Metric' => 'Enum("ga:pageviews")' |
24
|
|
|
]; |
25
|
|
|
|
26
|
|
|
protected static $date_range = [ |
27
|
|
|
7 => '7 Days', |
28
|
|
|
30 => '30 Days', |
29
|
|
|
60 => '60 Days', |
30
|
|
|
90 => '90 Days' |
31
|
|
|
]; |
32
|
|
|
|
33
|
|
|
protected static $metrics = [ |
34
|
|
|
'ga:pageviews' => 'Pageviews', |
35
|
|
|
]; |
36
|
|
|
|
37
|
|
|
public function updateCMSFields(FieldList $fields) |
38
|
|
|
{ |
39
|
|
|
$fields->addFieldsToTab('Root.GoogleAPI', [ |
40
|
|
|
TextField::create('Viewid', 'View ID from Analytics'), |
|
|
|
|
41
|
|
|
DropdownField::create('DateRange', 'Amount of days to get', static::$date_range), |
42
|
|
|
DropdownField::create('Metric', 'Metrics', static::$metrics) |
43
|
|
|
]); |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|
This check marks private properties in classes that are never used. Those properties can be removed.