1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Maps\Elements; |
4
|
|
|
|
5
|
|
|
use Maps\Element; |
6
|
|
|
use Maps\ElementOptions; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Base class for objects implementing the @see Element interface. |
10
|
|
|
* |
11
|
|
|
* @since 3.0 |
12
|
|
|
* |
13
|
|
|
* |
14
|
|
|
* @licence GNU GPL v2+ |
15
|
|
|
* @author Kim Eik < [email protected] > |
16
|
|
|
* @author Jeroen De Dauw < [email protected] > |
17
|
|
|
*/ |
18
|
|
|
abstract class BaseElement implements Element, \iBubbleMapElement, \iLinkableMapElement { |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @since 3.0 |
22
|
|
|
* @var ElementOptions |
23
|
|
|
*/ |
24
|
|
|
protected $options; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Constructor. |
28
|
|
|
* |
29
|
|
|
* @since 3.0 |
30
|
|
|
*/ |
31
|
|
|
public function __construct() { |
32
|
|
|
$this->options = new ElementOptions(); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @since 3.0 |
37
|
|
|
* |
38
|
|
|
* @return string |
39
|
|
|
*/ |
40
|
|
|
public function getTitle() { |
41
|
|
|
return $this->options->getOption( 'title' ); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @since 3.0 |
46
|
|
|
* |
47
|
|
|
* @param string $title |
48
|
|
|
*/ |
49
|
|
|
public function setTitle( $title ) { |
50
|
|
|
$this->options->setOption( 'title', $title ); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @since 3.0 |
55
|
|
|
* |
56
|
|
|
* @return string |
57
|
|
|
*/ |
58
|
|
|
public function getText() { |
59
|
|
|
return $this->options->getOption( 'text' ); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @since 3.0 |
64
|
|
|
* |
65
|
|
|
* @param string $text |
66
|
|
|
*/ |
67
|
|
|
public function setText( $text ) { |
68
|
|
|
$this->options->setOption( 'text', $text ); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @since 3.0 |
73
|
|
|
* |
74
|
|
|
* @return string |
75
|
|
|
*/ |
76
|
|
|
public function getLink() { |
77
|
|
|
return $this->options->getOption( 'link' ); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @since 3.0 |
82
|
|
|
* |
83
|
|
|
* @param string $link |
84
|
|
|
*/ |
85
|
|
|
public function setLink( $link ) { |
86
|
|
|
$this->options->setOption( 'link', $link ); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @deprecated |
91
|
|
|
* @param string $defText |
92
|
|
|
* @param string $defTitle |
93
|
|
|
* @return array |
94
|
|
|
*/ |
95
|
|
|
public function getJSONObject( $defText = '' , $defTitle = '' ) { |
96
|
|
|
$array = []; |
97
|
|
|
|
98
|
|
|
$array['text'] = $this->options->hasOption( 'text' ) ? $this->getText() : $defText; |
99
|
|
|
$array['title'] = $this->options->hasOption( 'title' ) ? $this->getTitle() : $defTitle; |
100
|
|
|
$array['link'] = $this->options->hasOption( 'link' ) ? $this->getLink() : ''; |
101
|
|
|
|
102
|
|
|
return $array; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @see Element::getArrayValue |
107
|
|
|
* |
108
|
|
|
* @since 3.0 |
109
|
|
|
* |
110
|
|
|
* @return mixed |
111
|
|
|
*/ |
112
|
|
|
public function getArrayValue() { |
113
|
|
|
return $this->getJSONObject(); |
|
|
|
|
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @see Element::getOptions |
118
|
|
|
* |
119
|
|
|
* @since 3.0 |
120
|
|
|
* |
121
|
|
|
* @return ElementOptions |
122
|
|
|
*/ |
123
|
8 |
|
public function getOptions() { |
124
|
8 |
|
return $this->options; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Sets the elements options. |
129
|
|
|
* |
130
|
|
|
* @since 3.0 |
131
|
|
|
* |
132
|
|
|
* @param ElementOptions $options |
133
|
|
|
*/ |
134
|
4 |
|
public function setOptions( ElementOptions $options ) { |
135
|
4 |
|
$this->options = $options; |
136
|
4 |
|
} |
137
|
|
|
|
138
|
|
|
} |
139
|
|
|
|
This method has been deprecated.