|
1
|
|
|
<?php |
|
2
|
|
|
namespace BOTK\Model; |
|
3
|
|
|
|
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* An ibrid class that merge the semantic of schema:organization, schema:place and schema:geo, |
|
7
|
|
|
* it is similar to schema:LocalBusiness. |
|
8
|
|
|
* Allows the bulk setup of properties |
|
9
|
|
|
*/ |
|
10
|
|
|
class BusinessContact extends Thing |
|
11
|
|
|
{ |
|
12
|
|
|
|
|
13
|
|
|
protected static $DEFAULT_OPTIONS = array ( |
|
14
|
|
|
'taxID' => array( |
|
15
|
|
|
'filter' => FILTER_CALLBACK, |
|
16
|
|
|
'options' => '\BOTK\Filters::FILTER_SANITIZE_TOKEN', |
|
17
|
|
|
'flags' => FILTER_REQUIRE_SCALAR, |
|
18
|
|
|
), |
|
19
|
|
|
'alternateName' => array( |
|
20
|
|
|
'filter' => FILTER_CALLBACK, |
|
21
|
|
|
'options' => '\BOTK\Filters::FILTER_SANITIZE_PERSON_NAME', |
|
22
|
|
|
'flags' => FILTER_FORCE_ARRAY, |
|
23
|
|
|
), |
|
24
|
|
|
'givenName' => array( |
|
25
|
|
|
'filter' => FILTER_CALLBACK, |
|
26
|
|
|
'options' => '\BOTK\Filters::FILTER_SANITIZE_PERSON_NAME', |
|
27
|
|
|
'flags' => FILTER_REQUIRE_SCALAR, |
|
28
|
|
|
), |
|
29
|
|
|
'familyName' => array( |
|
30
|
|
|
'filter' => FILTER_CALLBACK, |
|
31
|
|
|
'options' => '\BOTK\Filters::FILTER_SANITIZE_PERSON_NAME', |
|
32
|
|
|
'flags' => FILTER_REQUIRE_SCALAR, |
|
33
|
|
|
), |
|
34
|
|
|
'additionalName' => array( |
|
35
|
|
|
'filter' => FILTER_CALLBACK, |
|
36
|
|
|
'options' => '\BOTK\Filters::FILTER_SANITIZE_PERSON_NAME', |
|
37
|
|
|
'flags' => FILTER_REQUIRE_SCALAR, |
|
38
|
|
|
), |
|
39
|
|
|
'jobTitle' => array( |
|
40
|
|
|
'filter' => FILTER_DEFAULT, |
|
41
|
|
|
'flags' => FILTER_FORCE_ARRAY, |
|
42
|
|
|
), |
|
43
|
|
|
'honorificPrefix' => array( |
|
44
|
|
|
'filter' => FILTER_DEFAULT, |
|
45
|
|
|
'flags' => FILTER_FORCE_ARRAY, |
|
46
|
|
|
), |
|
47
|
|
|
'honorificSuffix' => array( |
|
48
|
|
|
'filter' => FILTER_DEFAULT, |
|
49
|
|
|
'flags' => FILTER_FORCE_ARRAY, |
|
50
|
|
|
), |
|
51
|
|
|
'gender' => array( |
|
52
|
|
|
'filter' => FILTER_CALLBACK, |
|
53
|
|
|
'options' => '\BOTK\Filters::FILTER_SANITIZE_GENDER', |
|
54
|
|
|
'flags' => FILTER_REQUIRE_SCALAR, |
|
55
|
|
|
), |
|
56
|
|
|
'worksFor' => array( |
|
57
|
|
|
'filter' => FILTER_CALLBACK, |
|
58
|
|
|
'options' => '\BOTK\Filters::FILTER_VALIDATE_URI', |
|
59
|
|
|
'flags' => FILTER_REQUIRE_SCALAR, |
|
60
|
|
|
), |
|
61
|
|
|
'telephone' => array( |
|
62
|
|
|
'filter' => FILTER_CALLBACK, |
|
63
|
|
|
'options' => '\BOTK\Filters::FILTER_SANITIZE_TELEPHONE', |
|
64
|
|
|
'flags' => FILTER_FORCE_ARRAY, |
|
65
|
|
|
), |
|
66
|
|
|
'email' => array( |
|
67
|
|
|
'filter' => FILTER_CALLBACK, |
|
68
|
|
|
'options' => '\BOTK\Filters::FILTER_SANITIZE_EMAIL', |
|
69
|
|
|
'flags' => FILTER_FORCE_ARRAY, |
|
70
|
|
|
), |
|
71
|
|
|
'spokenLanguage' => array( |
|
72
|
|
|
'filter' => FILTER_CALLBACK, |
|
73
|
|
|
'options' => '\BOTK\Filters::FILTER_SANITIZE_LANGUAGE', |
|
74
|
|
|
'flags' => FILTER_FORCE_ARRAY, |
|
75
|
|
|
), |
|
76
|
|
|
'hasOptInOptOutDate' => array( |
|
77
|
|
|
'filter' => FILTER_CALLBACK, |
|
78
|
|
|
'options' => '\BOTK\Filters::FILTER_SANITIZE_DATETIME', |
|
79
|
|
|
'flags' => FILTER_REQUIRE_SCALAR, |
|
80
|
|
|
), |
|
81
|
|
|
'privacyFlag' => array( |
|
82
|
|
|
'filter' => FILTER_CALLBACK, |
|
83
|
|
|
'options' => '\BOTK\Filters::FILTER_SANITIZE_BOOLEAN', |
|
84
|
|
|
'flags' => FILTER_REQUIRE_SCALAR, |
|
85
|
|
|
), |
|
86
|
|
|
); |
|
87
|
|
|
|
|
88
|
|
|
|
|
89
|
4 |
|
public function asTurtleFragment() |
|
90
|
|
|
{ |
|
91
|
4 |
|
if(is_null($this->rdf)) { |
|
92
|
|
|
|
|
93
|
4 |
|
extract($this->data); |
|
94
|
|
|
|
|
95
|
|
|
// make a default for altenatename (can be empty) before calling parent::asTurtleFragment |
|
96
|
4 |
|
if(empty($alternateName)){ |
|
97
|
3 |
|
$this->data['alternateName'] =''; |
|
98
|
3 |
|
if(!empty($givenName)) { $this->data['alternateName'].= $givenName.' ';} |
|
99
|
3 |
|
if(!empty($additionalName)) { $this->data['alternateName'].= $additionalName.' ';} |
|
100
|
3 |
|
if(!empty($familyName)) { $this->data['alternateName'].= $familyName.' ';} |
|
101
|
|
|
} |
|
102
|
4 |
|
$this->rdf = parent::asTurtleFragment(); |
|
103
|
|
|
|
|
104
|
4 |
|
$personUri = $this->getUri(); |
|
105
|
|
|
|
|
106
|
|
|
// serialize schema:LocalBusiness |
|
107
|
4 |
|
$this->rdf .= "<$personUri> "; |
|
108
|
4 |
|
!empty($aggregateRatingValue)&& $this->addFragment('schema:aggregateRating [a schema:AggregateRating; schema:ratingValue "%s"^^xsd:float];', $aggregateRatingValue); |
|
109
|
4 |
|
!empty($taxID) && $this->addFragment('schema:taxID "%s";', $taxID); |
|
110
|
4 |
|
!empty($givenName) && $this->addFragment('schema:givenName "%s";', $givenName); |
|
111
|
4 |
|
!empty($familyName) && $this->addFragment('schema:familyName "%s";', $familyName); |
|
112
|
4 |
|
!empty($additionalName) && $this->addFragment('schema:additionalName "%s";', $additionalName); |
|
113
|
4 |
|
!empty($telephone) && $this->addFragment('schema:telephone "%s";', $telephone); |
|
114
|
4 |
|
!empty($faxNumber) && $this->addFragment('schema:faxNumber "%s";', $faxNumber); |
|
115
|
4 |
|
!empty($jobTitle) && $this->addFragment('schema:jobTitle "%s";', $jobTitle); |
|
116
|
4 |
|
!empty($honorificPrefix) && $this->addFragment('schema:honorificPrefix "%s";', $honorificPrefix); |
|
117
|
4 |
|
!empty($honorificSuffix) && $this->addFragment('schema:honorificSuffix "%s";', $honorificSuffix); |
|
118
|
4 |
|
!empty($email) && $this->addFragment('schema:email "%s";', $email); |
|
119
|
4 |
|
!empty($gender) && $this->addFragment('schema:gender "%s";', $gender); |
|
120
|
4 |
|
!empty($worksFor) && $this->addFragment('schema:worksFor <%s> ;', $worksFor,false); |
|
121
|
4 |
|
!empty($spokenLanguage) && $this->addFragment('botk:spokenLanguage "%s";', $spokenLanguage); |
|
122
|
4 |
|
!empty($hasOptInOptOutDate) && $this->addFragment('botk:hasOptInOptOutDate "%s"^^xsd:dateTime;', $hasOptInOptOutDate); |
|
123
|
4 |
|
!empty($privacyFlag) && $this->addFragment('botk:privacyFlag %s ;', $privacyFlag); |
|
124
|
4 |
|
$this->addFragment('a schema:Person.', $personUri); |
|
125
|
|
|
|
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
4 |
|
return $this->rdf; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
} |