SideTextWidget::SideText()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
class SideTextWidget extends Widget
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
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
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
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