1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class SideTextWidgetDataObject extends DataObject |
|
|
|
|
4
|
|
|
{ |
5
|
|
|
public static $db = array( |
6
|
|
|
"Title" => "Text", |
7
|
|
|
"Body" => "HTMLText", |
8
|
|
|
"Caption" => "Varchar", |
9
|
|
|
"TextLinkExternal" => "Varchar(255)", |
10
|
|
|
"LinkText" => "Varchar(255)" |
11
|
|
|
); |
12
|
|
|
|
13
|
|
|
public static $has_one = array( |
14
|
|
|
"Image" => "Image", |
15
|
|
|
"ImageLink" => "SiteTree", |
16
|
|
|
"TextLinkInternal" => "SiteTree" |
17
|
|
|
); |
18
|
|
|
public static $summary_fields = array("Title" => "Title"); |
19
|
|
|
public static $singular_name = "Sidebar Section"; |
20
|
|
|
public static $plural_name = "Sidebar Sections"; |
21
|
|
|
|
22
|
|
|
//defaults |
23
|
|
|
public static $default_sort = "Title"; |
24
|
|
|
|
25
|
|
|
public function getCMSFields() |
26
|
|
|
{ |
27
|
|
|
$fields = parent::getCMSFields(); |
28
|
|
|
$fields->removeByName("Caption"); |
29
|
|
|
$fields->removeByName("ImageLinkID"); |
30
|
|
|
$fields->removeByName("Image"); |
31
|
|
|
$fields->removeByName("TextLinkInternalID"); |
32
|
|
|
$fields->addFieldToTab("Root.Main", new TextField('Title', _t('SideTextWidgetAdmin.TITLE', "Title"))); |
33
|
|
|
$fields->addFieldToTab("Root.Main", new HTMLEditorField("Body", _t('SideTextWidgetAdmin.TEXT', "Text"))); |
34
|
|
|
$fields->addFieldToTab("Root.Main", new TextField("LinkText", _t('SideTextWidgetAdmin.LINKTEXT', "Link Text"))); |
35
|
|
|
$fields->addFieldToTab("Root.Main", new TextField("TextLinkExternal", _t('SideTextWidgetAdmin.EXTERNALLINK', "External Link"))); |
36
|
|
|
$fields->addFieldToTab("Root.Main", new TreeDropdownField("TextLinkInternalID", _t('SideTextWidgetAdmin.INTERNALLINK', "Internal Link"), "SiteTree")); |
37
|
|
|
$fields->addFieldToTab("Root."._t('SideTextWidgetAdmin.IMAGE', "Image"), new TreeDropdownField("ImageLinkID", _t('SideTextWidgetAdmin.IMAGELINK', "Image Link"), "SiteTree")); |
38
|
|
|
$fields->addFieldToTab("Root."._t('SideTextWidgetAdmin.IMAGE', "Image"), new TextField("Caption", _t('SideTextWidgetAdmin.CAPTION', "Image Caption"))); |
39
|
|
|
$fields->addFieldToTab("Root."._t('SideTextWidgetAdmin.IMAGE', "Image"), new UploadField("Image", _t('SideTextWidgetAdmin.IMAGEHINT', "Image (width will be set to 100pixels)"))); |
40
|
|
|
|
41
|
|
|
return $fields; |
42
|
|
|
} |
43
|
|
|
} |
44
|
|
|
|
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.