Completed
Push — master ( eaf16e...6f8e07 )
by Mohamed
11:01
created

Moo_EditableFieldLiteral   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Test Coverage

Coverage 41.18%

Importance

Changes 0
Metric Value
wmc 5
lcom 2
cbo 3
dl 0
loc 34
ccs 7
cts 17
cp 0.4118
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getFieldConfiguration() 0 14 2
A initFormField() 0 11 3
1
<?php
2
3
/**
4
 * Moo_EditableFieldLiteral is an object representing blank slate where you can add HTML / Images / Flash created by CMS
5
 * admin.
6
 *
7
 * @package editablefield
8
 *
9
 * @author  Mohamed Alsharaf <[email protected]>
10
 */
11
class Moo_EditableFieldLiteral extends Moo_EditableField
12
{
13
    private static $singular_name   = 'HTML Block';
14
    private static $plural_name     = 'HTML Blocks';
15
    protected $customSettingsFields = [
16
        'Content',
17
    ];
18
    public function getFieldConfiguration()
19
    {
20
        $customSettings = unserialize($this->CustomSettings);
21
        $content        = (isset($customSettings['Content'])) ? $customSettings['Content'] : '';
22
        $textAreaField  = new TextareaField(
23
            $this->getSettingName('Content'), 'HTML', $content
24
        );
25
        $textAreaField->setRows(4);
26
        $textAreaField->setColumns(20);
27
28
        return [
29
            $textAreaField,
30
        ];
31
    }
32
33 1
    protected function initFormField()
34
    {
35 1
        $label   = $this->Title ? "<label class='left'>$this->Title</label>" : '';
36 1
        $classes = $this->Title ? '' : ' nolabel';
37
38 1
        return new LiteralField("LiteralField[$this->ID]", "<div id='$this->Name' class='field text$classes'>
39 1
				$label
40 1
				<div class='middleColumn literalFieldArea'>" . $this->getSetting('Content') . '</div>' .
41
                                                         '</div>'
42 1
        );
43
    }
44
}
45