Completed
Push — master ( 2bc3ae...eaf16e )
by Mohamed
04:59
created

Moo_EditableFieldHeading   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 39
ccs 0
cts 18
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getFieldConfiguration() 0 18 2
A initFormField() 0 7 1
A getFieldValidationOptions() 0 4 1
1
<?php
2
3
/**
4
 * Moo_EditableFieldHeading is an object representing generic heading created by CMS admin.
5
 *
6
 * @package editablefield
7
 *
8
 * @author  Mohamed Alsharaf <[email protected]>
9
 */
10
class Moo_EditableFieldHeading extends Moo_EditableField
11
{
12
    private static $singular_name   = 'Heading';
13
    private static $plural_name     = 'Headings';
14
    protected $customSettingsFields = [
15
        'Level',
16
    ];
17
    public function getFieldConfiguration()
18
    {
19
        $levels = [
20
            '1' => '1',
21
            '2' => '2',
22
            '3' => '3',
23
            '4' => '4',
24
            '5' => '5',
25
            '6' => '6',
26
        ];
27
28
        $level = ($this->getSetting('Level')) ? $this->getSetting('Level') : 3;
29
        $label = _t('Moo_EditableFieldHeading.LEVEL', 'Select Heading Level');
30
31
        return [
32
            new DropdownField($this->getSettingName('Level'), $label, $levels, $level),
33
        ];
34
    }
35
36
    protected function initFormField()
37
    {
38
        $labelField = new HeaderField($this->Name, $this->Title, $this->getSetting('Level'));
39
        $labelField->addExtraClass('FormHeading');
40
41
        return $labelField;
42
    }
43
44
    public function getFieldValidationOptions()
45
    {
46
        return false;
47
    }
48
}
49