|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
*@author nicolaas[at]sunnysideup.co.nz |
|
5
|
|
|
*@description: displays a list of staff profiles |
|
6
|
|
|
* |
|
7
|
|
|
*/ |
|
8
|
|
|
class StaffProfilesPage extends Page |
|
|
|
|
|
|
9
|
|
|
{ |
|
10
|
|
|
private static $icon = "mysite/images/treeicons/StaffProfilesPage"; |
|
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
private static $allowed_children = array("StaffProfilesOnePerson"); //can also be "none"; |
|
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
private static $default_child = "StaffProfilesOnePerson"; |
|
|
|
|
|
|
15
|
|
|
|
|
16
|
|
|
private static $db = array( |
|
|
|
|
|
|
17
|
|
|
"DefaultEmail" => "Varchar(255)", |
|
18
|
|
|
"SubjectLine" => "Varchar(255)" |
|
19
|
|
|
); |
|
20
|
|
|
|
|
21
|
|
|
private static $has_many = array( |
|
|
|
|
|
|
22
|
|
|
"StaffProfiles" => "StaffProfile" |
|
23
|
|
|
); |
|
24
|
|
|
|
|
25
|
|
|
public function getCMSFields() |
|
|
|
|
|
|
26
|
|
|
{ |
|
27
|
|
|
$fields = parent::getCMSFields(); |
|
28
|
|
|
$fields->addFieldToTab("Root.Profiles", $defaultEmailTextField = new TextField("DefaultEmail")); |
|
29
|
|
|
$defaultEmailTextField->setRightTitle( |
|
30
|
|
|
_t( |
|
31
|
|
|
"StaffProfilesPage.DEFAULT_EMAIL_EXPLANATION", |
|
32
|
|
|
"This is the default email that will be used if a staff member does not have a unique email" |
|
33
|
|
|
) |
|
34
|
|
|
); |
|
35
|
|
|
$fields->addFieldToTab("Root.Profiles", $subjectLineTextField = new TextField("SubjectLine")); |
|
36
|
|
|
$subjectLineTextField->setRightTitle( |
|
37
|
|
|
_t( |
|
38
|
|
|
"StaffProfilesPage.SUBJECT_LINE_EXPLANATION", |
|
39
|
|
|
"Subject line for email, you can use [". implode("], [", array_keys(Config::inst()->get("StaffProfile", "subject_place_holders"))). "]" . " as placeholders" |
|
40
|
|
|
) |
|
41
|
|
|
); |
|
42
|
|
|
$fields->addFieldToTab( |
|
43
|
|
|
"Root.Profiles", |
|
44
|
|
|
new GridField( |
|
45
|
|
|
"StaffProfiles", |
|
46
|
|
|
"Staff Profiles", |
|
47
|
|
|
StaffProfile::get(), |
|
48
|
|
|
$config = GridFieldConfig_RelationEditor::create() |
|
49
|
|
|
) |
|
50
|
|
|
); |
|
51
|
|
|
if (class_exists("GridFieldSortableRows")) { |
|
52
|
|
|
$config->addComponent(new GridFieldSortableRows('Sort')); |
|
53
|
|
|
} |
|
54
|
|
|
return $fields; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function StaffProfilesAll() |
|
|
|
|
|
|
58
|
|
|
{ |
|
59
|
|
|
return $this->StaffProfiles(); |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
class StaffProfilesPage_Controller extends Page_Controller |
|
|
|
|
|
|
64
|
|
|
{ |
|
65
|
|
|
public function init() |
|
66
|
|
|
{ |
|
67
|
|
|
parent::init(); |
|
68
|
|
|
Requirements::themedCSS("StaffProfilesPage", "staffprofiles"); |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|
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.