Moo_EditableFieldLiteral::getFieldConfiguration()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 0
cts 10
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 9
nc 2
nop 0
crap 6
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
16
    /**
17
     * List of allowed custom settings fields.
18
     *
19
     * @var array
20
     */
21
    protected $customSettingsFields = [
22
        'Content',
23
    ];
24
25
    /**
26
     * Get extra configuration fields.
27
     *
28
     * @return array
29
     */
30
    public function getFieldConfiguration()
31
    {
32
        $customSettings = unserialize($this->CustomSettings);
33
        $content        = (isset($customSettings['Content'])) ? $customSettings['Content'] : '';
34
        $textAreaField  = new TextareaField(
35
            $this->getSettingName('Content'), 'HTML', $content
36
        );
37
        $textAreaField->setRows(4);
38
        $textAreaField->setColumns(20);
39
40
        return [
41
            $textAreaField,
42
        ];
43
    }
44
45 1
    protected function initFormField()
46
    {
47 1
        $label   = $this->Title ? "<label class='left'>$this->Title</label>" : '';
48 1
        $classes = $this->Title ? '' : ' nolabel';
49
50 1
        return new LiteralField(
51 1
            "LiteralField[$this->ID]",
52 1
            "<div id='$this->Name' class='field text$classes'>$label<div class='middleColumn literalFieldArea'>" . $this->getSetting('Content') . '</div></div>'
53 1
        );
54
    }
55
}
56