Passed
Push — master ( d7fd6a...9124ff )
by Robbie
11:58
created

CustomSiteConfig::updateCMSFields()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 42
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 42
rs 8.8571
cc 1
eloc 26
nc 1
nop 1
1
<?php
2
/**
3
 * Adds new global settings.
4
 */
5
class CustomSiteConfig extends DataExtension
6
{
7
	private static $db = array(
0 ignored issues
show
introduced by
The private property $db is not used, and could be removed.
Loading history...
8
		'GACode' => 'Varchar(16)',
9
		'FacebookURL' => 'Varchar(256)', // multitude of ways to link to Facebook accounts, best to leave it open.
10
		'TwitterUsername' => 'Varchar(16)', // max length of Twitter username 15
11
	);
12
13
	public function updateCMSFields(FieldList $fields)
14
	{
15
		$fields->addFieldToTab(
16
			'Root.Main',
17
			$gaCode = TextField::create(
18
				'GACode',
19
				_t('CwpConfig.GaField', 'Google Analytics account')
20
			)
21
		);
22
23
		$gaCode->setRightTitle(
24
			_t(
25
				'CwpConfig.GaFieldDesc',
26
				'Account number to be used all across the site (in the format <strong>UA-XXXXX-X</strong>)'
27
			)
28
		);
29
30
		$fields->findOrMakeTab('Root.SocialMedia', _t('CustomSiteConfig.SocialMediaTab', 'Social Media'));
31
32
		$fields->addFieldToTab(
33
			'Root.SocialMedia',
34
			$facebookURL = TextField::create(
35
				'FacebookURL',
36
				_t('CwpConfig.FbField', 'Facebook UID or username')
37
			)
38
		);
39
		$facebookURL->setRightTitle(
40
			_t(
41
				'CwpConfig.FbFieldDesc',
42
				'Facebook link (everything after the "http://facebook.com/", eg http://facebook.com/<strong>username</strong> or http://facebook.com/<strong>pages/108510539573</strong>)'
43
			)
44
		);
45
46
		$fields->addFieldToTab(
47
			'Root.SocialMedia',
48
			$twitterUsername = TextField::create(
49
				'TwitterUsername',
50
				_t('CwpConfig.TwitterField', 'Twitter username')
51
			)
52
		);
53
		$twitterUsername->setRightTitle(
54
			_t('CwpConfig.TwitterFieldDesc', 'Twitter username (eg, http://twitter.com/<strong>username</strong>)')
55
		);
56
	}
57
}
58