1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Grandstream-XMLApp |
4
|
|
|
* |
5
|
|
|
* Copyright (c) 2017 pudelek.org.pl |
6
|
|
|
* |
7
|
|
|
* @license MIT License (MIT) |
8
|
|
|
* |
9
|
|
|
* For the full copyright and license information, please view source file |
10
|
|
|
* that is bundled with this package in the file LICENSE |
11
|
|
|
* |
12
|
|
|
* @author Marcin Pudełek <[email protected]> |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace mrcnpdlk\Grandstream\XMLApp\Application\Model\Components; |
16
|
|
|
|
17
|
|
|
use mrcnpdlk\Grandstream\XMLApp\Application\ModelInterface; |
18
|
|
|
use mrcnpdlk\Grandstream\XMLApp\Helper\Font; |
19
|
|
|
use mrcnpdlk\Grandstream\XMLApp\Helper\Point; |
20
|
|
|
use mrcnpdlk\Grandstream\XMLApp\Helper\Rectangle; |
21
|
|
|
use mrcnpdlk\Grandstream\XMLApp\MyXML; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Class ElemString |
25
|
|
|
* |
26
|
|
|
* This element is used for displaying string information on the screen |
27
|
|
|
* |
28
|
|
|
* <ElemString font="unifont" width="width of the string" height="height of the string" halign="center/left/right" color="color of the string" bgcolor="color of the background" > |
29
|
|
|
* <X>X location</X> |
30
|
|
|
* <Y>Y location </Y> |
31
|
|
|
* <DisplayStr>Display String</DisplayStr> |
32
|
|
|
* </ElemString> |
33
|
|
|
* |
34
|
|
|
* @package mrcnpdlk\Grandstream\XMLApp\CustomScreen\Model |
35
|
|
|
*/ |
36
|
|
|
class ElemString extends ElemAbstract implements ModelInterface, ElemInterface |
37
|
|
|
{ |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var string |
41
|
|
|
*/ |
42
|
|
|
private $sString; |
43
|
|
|
/** |
44
|
|
|
* Font type |
45
|
|
|
* |
46
|
|
|
* @var Font |
47
|
|
|
*/ |
48
|
|
|
private $oFont; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* ElemString constructor. |
52
|
|
|
* |
53
|
|
|
* @param string $sString |
54
|
|
|
* @param Rectangle $oRectangle |
55
|
|
|
*/ |
56
|
|
|
public function __construct(string $sString, Rectangle $oRectangle = null) |
57
|
|
|
{ |
58
|
|
|
parent::__construct(new Point(0, 0), $oRectangle); |
59
|
|
|
$this->sString = $sString; |
60
|
|
|
$this->setFont(); |
61
|
|
|
|
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @param \mrcnpdlk\Grandstream\XMLApp\Helper\Font|null $oFont |
66
|
|
|
* |
67
|
|
|
* @return \mrcnpdlk\Grandstream\XMLApp\Application\Model\Components\ElemString |
68
|
|
|
*/ |
69
|
|
|
public function setFont(Font $oFont = null) |
70
|
|
|
{ |
71
|
|
|
$this->oFont = $oFont ?? new Font(); |
72
|
|
|
|
73
|
|
|
return $this; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @return MyXML |
78
|
|
|
*/ |
79
|
|
|
public function getXml(): MyXML |
80
|
|
|
{ |
81
|
|
|
$oXml = new MyXML('DisplayString'); |
82
|
|
|
|
83
|
|
|
$oXml->asObject()->addAttribute('font', $this->getFont()->getType()); |
84
|
|
|
if ($this->getRectangle()->getWidth()) { |
85
|
|
|
$oXml->asObject()->addAttribute('width', $this->getRectangle()->getWidth()); |
86
|
|
|
} |
87
|
|
|
if ($this->getRectangle()->getHeight()) { |
88
|
|
|
$oXml->asObject()->addAttribute('height', $this->getRectangle()->getHeight()); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
$oXml->asObject()->addAttribute('halign', $this->getFont()->getHorizontalAlign()); |
92
|
|
|
$oXml->asObject()->addAttribute('color', $this->getFont()->getColor()->get()); |
93
|
|
|
$oXml->asObject()->addAttribute('bgcolor', $this->getColorBg()->get()); |
94
|
|
|
//$oXml->asObject()->addAttribute('renew-rate', 'second'); |
|
|
|
|
95
|
|
|
//$oXml->asObject()->addAttribute('isrenew', 'true'); |
|
|
|
|
96
|
|
|
$oXml->asObject()->addChild('X', $this->getPoint()->getX()); |
97
|
|
|
$oXml->asObject()->addChild('Y', $this->getPoint()->getY()); |
98
|
|
|
$oXml->asObject()->addChild('DisplayStr', $this->sString); |
99
|
|
|
|
100
|
|
|
return $oXml; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @return \mrcnpdlk\Grandstream\XMLApp\Helper\Font |
105
|
|
|
*/ |
106
|
|
|
public function getFont() |
107
|
|
|
{ |
108
|
|
|
return $this->oFont; |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.