1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace CWP\CWP\Extensions; |
4
|
|
|
|
5
|
|
|
use SilverStripe\Forms\FieldList; |
6
|
|
|
use SilverStripe\Forms\TextField; |
7
|
|
|
use SilverStripe\ORM\DataExtension; |
8
|
|
|
use SilverStripe\ORM\FieldType\DBField; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Adds new global settings. |
12
|
|
|
*/ |
13
|
|
|
class CustomSiteConfig extends DataExtension |
14
|
|
|
{ |
15
|
|
|
private static $db = array( |
|
|
|
|
16
|
|
|
'GACode' => 'Varchar(16)', |
17
|
|
|
'FacebookURL' => 'Varchar(256)', // multitude of ways to link to Facebook accounts, best to leave it open. |
18
|
|
|
'TwitterUsername' => 'Varchar(16)', // max length of Twitter username 15 |
19
|
|
|
); |
20
|
|
|
|
21
|
|
|
public function updateCMSFields(FieldList $fields) |
22
|
|
|
{ |
23
|
|
|
$fields->addFieldToTab( |
24
|
|
|
'Root.Main', |
25
|
|
|
$gaCode = TextField::create( |
26
|
|
|
'GACode', |
27
|
|
|
_t(__CLASS__ . '.GaField', 'Google Analytics account') |
28
|
|
|
) |
29
|
|
|
); |
30
|
|
|
|
31
|
|
|
$gaCode->setDescription( |
32
|
|
|
DBField::create_field('HTMLFragment', _t( |
33
|
|
|
__CLASS__ . '.GaFieldDesc', |
34
|
|
|
'Account number to be used all across the site (in the format <strong>UA-XXXXX-X</strong>)' |
35
|
|
|
)) |
36
|
|
|
); |
37
|
|
|
|
38
|
|
|
$fields->findOrMakeTab('Root.SocialMedia', _t(__CLASS__ . '.SocialMediaTab', 'Social Media')); |
39
|
|
|
|
40
|
|
|
$fields->addFieldToTab( |
41
|
|
|
'Root.SocialMedia', |
42
|
|
|
$facebookURL = TextField::create( |
43
|
|
|
'FacebookURL', |
44
|
|
|
_t(__CLASS__ . '.FbField', 'Facebook UID or username') |
45
|
|
|
) |
46
|
|
|
); |
47
|
|
|
$facebookURL->setDescription( |
48
|
|
|
DBField::create_field('HTMLFragment', _t( |
49
|
|
|
__CLASS__ . '.FbFieldDesc', |
50
|
|
|
'Facebook link (everything after the "http://facebook.com/", eg http://facebook.com/' |
51
|
|
|
. '<strong>username</strong> or http://facebook.com/<strong>pages/108510539573</strong>)' |
52
|
|
|
)) |
53
|
|
|
); |
54
|
|
|
|
55
|
|
|
$fields->addFieldToTab( |
56
|
|
|
'Root.SocialMedia', |
57
|
|
|
$twitterUsername = TextField::create( |
58
|
|
|
'TwitterUsername', |
59
|
|
|
_t(__CLASS__ . '.TwitterField', 'Twitter username') |
60
|
|
|
) |
61
|
|
|
); |
62
|
|
|
$twitterUsername->setDescription( |
63
|
|
|
DBField::create_field('HTMLFragment', _t( |
64
|
|
|
__CLASS__ . '.TwitterFieldDesc', |
65
|
|
|
'Twitter username (eg, http://twitter.com/<strong>username</strong>)' |
66
|
|
|
)) |
67
|
|
|
); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|