forked from YetiForceCompany/iCalendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IcalendarPropertyGeo.php
44 lines (36 loc) · 980 Bytes
/
IcalendarPropertyGeo.php
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
<?php
class IcalendarPropertyGeo extends IcalendarProperty
{
public $name = 'GEO';
public $val_type = RFC2445_TYPE_TEXT;
public function construct()
{
$this->valid_parameters = [
'ALTREP' => RFC2445_OPTIONAL | RFC2445_ONCE,
'LANGUAGE' => RFC2445_OPTIONAL | RFC2445_ONCE,
RFC2445_XNAME => RFC2445_OPTIONAL,
];
}
public function isValidValue($value)
{
// This MUST be two floats separated by a semicolon
if (!is_string($value)) {
return false;
}
$floats = explode(';', $value);
if (count($floats) != 2) {
return false;
}
return \ICalendarRfc::rfc2445IsValidValue($floats[0], RFC2445_TYPE_FLOAT) && \ICalendarRfc::rfc2445IsValidValue($floats[1], RFC2445_TYPE_FLOAT);
}
public function setValueICal($value)
{
// Must override this, otherwise the semicolon separating
// the two floats would get auto-quoted, which is illegal
if ($this->isValidValue($value)) {
$this->value = $value;
return true;
}
return false;
}
}