1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @property Text $ThanksMessage |
4
|
|
|
* @property Int $CartEmailRecipientID |
5
|
|
|
* |
6
|
|
|
* @method Member CartEmailRecipient |
7
|
|
|
*/ |
8
|
|
|
class DMSDocumentCartCheckoutPage extends Page |
|
|
|
|
9
|
|
|
{ |
10
|
|
|
private static $db = array( |
|
|
|
|
11
|
|
|
'ThanksMessage' => 'Text', |
12
|
|
|
); |
13
|
|
|
|
14
|
|
|
private static $has_one = array( |
|
|
|
|
15
|
|
|
'CartEmailRecipient' => 'Member' |
16
|
|
|
); |
17
|
|
|
|
18
|
|
|
private static $defaults = array( |
|
|
|
|
19
|
|
|
'URLSegment' => 'checkout', |
20
|
|
|
'ShowInMenus' => false, |
21
|
|
|
); |
22
|
|
|
|
23
|
|
|
public function getCMSFields() |
|
|
|
|
24
|
|
|
{ |
25
|
|
|
$fields = parent::getCMSFields(); |
26
|
|
|
$members = Member::get('Member'); |
27
|
|
|
$recipientDropDown = DropdownField::create( |
28
|
|
|
'CartEmailRecipientID', |
29
|
|
|
_t('DMSDocumentCartCheckoutPage.CART_RECIPIENT', 'Account to receive document print requests'), |
30
|
|
|
$members->Map()->toArray() |
31
|
|
|
)->setEmptyString(_t( |
32
|
|
|
'DMSDocumentCartCheckoutPage.CART_RECIPIENT_EMPTY_STRING', |
33
|
|
|
'Select a member' |
34
|
|
|
)); |
35
|
|
|
$fields->insertBefore('Content', $recipientDropDown); |
36
|
|
|
|
37
|
|
|
$fields->insertBefore( |
38
|
|
|
'Content', |
39
|
|
|
TextareaField::create( |
40
|
|
|
'ThanksMessage', |
41
|
|
|
_t('DMSDocumentCartCheckoutPage.THANK_YOU_MESSAGE', 'Thank you message') |
42
|
|
|
) |
43
|
|
|
); |
44
|
|
|
|
45
|
|
|
return $fields; |
46
|
|
|
} |
47
|
|
|
/** |
48
|
|
|
* Automatically create a CheckoutPage if one is not found |
49
|
|
|
* on the site at the time the database is built (dev/build). |
50
|
|
|
*/ |
51
|
|
|
function requireDefaultRecords() |
|
|
|
|
52
|
|
|
{ |
53
|
|
|
parent::requireDefaultRecords(); |
54
|
|
|
|
55
|
|
|
if (!SiteTree::get_one($this->class)) { |
56
|
|
|
/** @var DMSDocumentCartCheckoutPage $page */ |
57
|
|
|
$page = self::create(); |
58
|
|
|
$page->Title = 'Request a printed copy'; |
59
|
|
|
$page->MenuTitle = 'Document Cart Checkout'; |
60
|
|
|
$page->Content = ''; |
61
|
|
|
$page->URLSegment = 'checkout'; |
62
|
|
|
$page->ShowInMenus = 0; |
63
|
|
|
$page->ThanksMessage = 'Thanks for your request.'; |
64
|
|
|
$page->write(); |
65
|
|
|
$page->publish('Stage', 'Live'); |
66
|
|
|
$page->flushCache(); |
67
|
|
|
DB::alteration_message( |
68
|
|
|
_t( |
69
|
|
|
'DMSDocumentCartCheckoutPage.ALTERATION_MESSAGE', |
70
|
|
|
'Document Cart Checkout page \'Request a printed copy\' created' |
71
|
|
|
), |
72
|
|
|
'created' |
73
|
|
|
); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.