|
1
|
|
|
<?php |
|
2
|
|
|
class SideTextWidget extends Widget |
|
|
|
|
|
|
3
|
|
|
{ |
|
4
|
|
|
public static $has_one = array( |
|
5
|
|
|
"SideTextWidgetContent" => "SideTextWidgetDataObject" |
|
6
|
|
|
); |
|
7
|
|
|
|
|
8
|
|
|
public static $title = "Side bar section"; |
|
9
|
|
|
|
|
10
|
|
|
public static $cmsTitle = "Side bar section"; |
|
11
|
|
|
|
|
12
|
|
|
public static $description = "Add a section to your side bar"; |
|
13
|
|
|
|
|
14
|
|
|
public function SideText() |
|
15
|
|
|
{ |
|
16
|
|
|
return DataObject::get_by_id("SideTextWidgetDataObject", $this->SideTextWidgetContentID); |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
public function getCMSFields() |
|
20
|
|
|
{ |
|
21
|
|
|
$source = DataObject::get("SideTextWidgetDataObject"); |
|
22
|
|
|
if ($source && $source->count()) { |
|
23
|
|
|
$list = $source->map("ID", "Title"); |
|
24
|
|
|
$listField = new DropdownField("SideTextWidgetContentID", _t('SideTextWidget.CHOOSE', 'Side Text Widget'), $list); |
|
25
|
|
|
return new FieldList($listField); |
|
26
|
|
|
} |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function getCmsTitle() |
|
30
|
|
|
{ |
|
31
|
|
|
return _t('SideTextWidget.CMSTITLE', $this->stat('cmsTitle')); |
|
32
|
|
|
} |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
class SideTextWidget_CMSHack extends LeftAndMainExtension |
|
|
|
|
|
|
36
|
|
|
{ |
|
37
|
|
|
public function init() |
|
38
|
|
|
{ |
|
39
|
|
|
HtmlEditorConfig::get('cms')->setOption('theme_advanced_blockformats', 'p,h1'); |
|
40
|
|
|
HtmlEditorConfig::get('cms')->setButtonsForLine(1, 'undo, redo, separator, cut, copy, pastetext, separator, ssimage, sslink, unlink, separator, fullscreen, advcode, formatselect'); |
|
41
|
|
|
HtmlEditorConfig::get('cms')->setButtonsForLine(2); |
|
42
|
|
|
HtmlEditorConfig::get('cms')->setButtonsForLine(3); |
|
43
|
|
|
} |
|
44
|
|
|
} |
|
45
|
|
|
|
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.