PageRowCMSFieldsFixes   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 14
lcom 1
cbo 5
dl 0
loc 60
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
C decorateCMSFields() 0 50 14
1
<?php
2
3
class PageRowCMSFieldsFixes extends DataExtension
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
6
    /**
7
     * Update Fields
8
     * @return FieldList
9
     */
10
    public function decorateCMSFields(FieldList $fields)
11
    {
12
        //right titles ...
13
        $list = $fields->dataFields();
14
15
        $rightFieldDescriptions = Config::inst()->get($this->owner->ClassName, 'field_labels_right');
16
        if (is_array($rightFieldDescriptions) && count($rightFieldDescriptions)) {
17
            foreach ($list as $formField) {
18
19
                // right titles ...
20
                $desc = '';
21
                $fieldName = $formField->getName();
22
                if (isset($rightFieldDescriptions[$fieldName])) {
23
                    $desc = $rightFieldDescriptions[$fieldName];
24
                }
25
                if (!$desc) {
26
                    if (isset($rightFieldDescriptions[$fieldName.'ID'])) {
27
                        $desc = $rightFieldDescriptions[$fieldName];
28
                    }
29
                }
30
                if (!$desc) {
31
                    if (substr($fieldName, -2) === 'ID') {
32
                        $fieldName = substr($fieldName, -2);
33
                        if (isset($rightFieldDescriptions[$fieldName])) {
34
                            $desc = $rightFieldDescriptions[$fieldName];
35
                        }
36
                    }
37
                }
38
                if ($desc) {
39
                    if ($formField->hasMethod('setDescription')) {
40
                        $formField->setDescription($desc);
41
                    } else {
42
                        $formField->setRightTitle($desc);
43
                    }
44
                }
45
46
47
                //HTML Editor fields
48
                //HTML
49
                if ($formField instanceof HTMLEditorField) {
50
                    $formField->setRows(12)
51
                        ->setRightTitle('Need more room? Use the FULL SCREEN button (last button above).');
52
                }
53
                if ($formField instanceof DateField) {
54
                    $formField->setConfig('showcalendar', true);
55
                }
56
            }
57
        }
58
        return $fields;
59
    }
60
61
62
}
63