1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
<?php
class EGMapBase {
protected static $_counter = 0;
protected $js_name;
protected $options = array();
/**
*
* Sets value of a component property.
* Do not call this method. This is a PHP magic method that we override
* to allow using the following syntax to set a property or attach setProperty method
* to create appropiate setting to specific properties
* <pre>
* $this->propertyName=$value;
* $this->setName($value)
* </pre>
* @param string $name the property name
* @param mixed $value
*/
public function __set($name, $value)
{
$setter = 'set' . $name;
if (method_exists($this, $setter))
return $this->$setter($value);
elseif (array_key_exists($name, $this->options))
{
return $this->options[$name] = $value;
}
if (method_exists($this, 'get' . $name))
throw new CException(Yii::t('EGMap', 'Property "{class}.{property}" is read only.', array('{class}' => get_class($this), '{property}' => $name)));
else
throw new CException(Yii::t('EGMap', 'Property "{class}.{property}" is not defined.', array('{class}' => get_class($this), '{property}' => $name)));
}
/**
*
* Returns a property value, an event handler list or a behavior based on its name.
* Do not call this method. This is a PHP magic method that we override
* to allow using the following syntax to read a property
* <pre>
* $value=$component->propertyName;
* $value=$component->getPropertyName;
* </pre>
* @param string $name
* @throws CException
*/
public function __get($name)
{
$getter = 'get' . ucfirst($name);
if (method_exists($this, $getter))
return $this->$getter();
if (array_key_exists($name, $this->options))
{
return $this->options[$name];
}
throw new CException(Yii::t('EGMap', 'Property "{class}.{property}" is not defined.', array('{class}' => get_class($this), '{property}' => $name)));
}
/**
* Checks if a property value is null.
* Do not call this method. This is a PHP magic method that we override
* to allow using isset() to detect if a component property is set or not.
*
* @param string $name name of the property
*/
public function __isset($name)
{
$getter = 'get' . ucfirst($name);
if (method_exists($this, $getter))
return $this->$getter() !== null;
return isset($this->options[$name]);
}
/**
* Sets a component property to be null.
* Do not call this method. This is a PHP magic method that we override
* to allow using unset() to set a component property to be null.
* @param string $name the property name or the event name
* @throws CException if the property is read only or not exists.
*/
public function __unset($name)
{
$setter = 'set' . $name;
if (method_exists($this, $setter))
return $this->$setter(null);
else if (isset($this->option[$name]))
return $this->option[$name] = null;
else if (method_exists($this, 'get' . $name))
throw new CException(Yii::t('EGMap', 'Property "{class}.{property}" is read only.', array('{class}' => get_class($this), '{property}' => $name)));
else
throw new CException(Yii::t('EGMap', 'Property "{class}.{property}" is not defined.', array('{class}' => get_class($this), '{property}' => $name)));
}
/**
* @return string Javascript name of the renderer service
* @author Antonio Ramirez
* @since 2011-01-24
*/
public function getJsName($autoGenerate=true)
{
if ($this->js_name !== null)
return $this->js_name;
else if ($autoGenerate)
return $this->js_name = get_class($this) . self::$_counter++;
}
/**
*
* Sets the Javascript name of the renderer service
* @param string $name
*/
public function setJsName($name)
{
$this->js_name = $name;
}
/**
* @return array $options
* @author Antonio Ramirez
* @since 2011-01-25
*/
public function getOptions()
{
return $this->options;
}
}
|