Completed
Pull Request — master (#95)
by
unknown
02:28
created

uiLabel::render()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
ccs 0
cts 14
cp 0
cc 3
eloc 10
nc 4
nop 1
crap 12
1
<?php
2
3
namespace eXpansion\Framework\Gui\Components;
4
5
use FML\Controls\Label;
6
7
class uiLabel extends Label
8
{
9
10
    const TYPE_NORMAL = "normal";
11
    const TYPE_TITLE = "title";
12
    const TYPE_HEADER = "header";
13
14
    /**
15
     * uiLabel constructor.
16
     * @param string $text
17
     * @param string $type
18
     * @param string|null $controlId
19
     */
20
    public function __construct($text = "", $type = self::TYPE_NORMAL, $controlId = null)
21
    {
22
        parent::__construct($controlId);
23
        $this->setText($text)
24
            ->setAreaColor("0000")
25
            ->setAreaFocusColor('0000')
26
            ->setScriptEvents(true);
27
28
        switch ($type) {
29
            case self::TYPE_NORMAL:
30
                $this->setTextSize(2)
31
                    ->setStyle("TextInfo")
32
                    ->setHeight(5);
33
                break;
34
            case self::TYPE_TITLE:
35
                $this->setTextSize(3)
36
                    ->setHeight(5)
37
                    ->setTextFont('file://Media/Font/BiryaniDemiBold.Font.gbx');
38
                break;
39
            case self::TYPE_HEADER:
40
                $this->setTextSize(3)
41
                    ->setHeight(5)
42
                    ->setTextFont('file://Media/Font/BiryaniDemiBold.Font.gbx');
43
                break;
44
            default:
45
                $this->setTextSize(2)
46
                    ->setHeight(5);
47
                break;
48
        }
49
    }
50
51
    /**
52
     * @param DOMDocument $domDocument
53
     * @return DOMElement
54
     */
55
    public function render(\DOMDocument $domDocument)
56
    {
57
        $text = "";
58
        if ($this->getTranslate() === true) {
59
            $text = $this->getText();
60
            $this->setTextId($text);
61
            $this->setText(null);
62
        }
63
64
        $xml = parent::render($domDocument);
65
66
        if ($this->getTranslate() === true) {
67
            $this->setText($text);
68
        }
69
70
        return $xml;
71
    }
72
}
73