SideTextWidgetDataObject   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 6
dl 0
loc 41
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getCMSFields() 0 18 1
1
<?php
2
3
class SideTextWidgetDataObject extends DataObject
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...
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