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

Moo_EditableFieldLiteral::initFormField()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 4
nop 0
crap 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