1 | <?php |
||
16 | trait ContactTrait |
||
17 | { |
||
18 | /** |
||
19 | * this was once needed as the conversion done by COZA was faulty |
||
20 | * the bug has since been fixed but this remains to allow testing |
||
21 | * set true to force ascii usage on type=loc (which should allow UTF8) |
||
22 | * |
||
23 | * @var bool |
||
24 | */ |
||
25 | protected $force_ascii = false; |
||
26 | |||
27 | /** |
||
28 | * set true to skip the generation of type=int (like .MX) |
||
29 | * |
||
30 | * @var bool |
||
31 | */ |
||
32 | protected $skip_int = false; |
||
33 | |||
34 | abstract public function set($path = null, $value = null); |
||
35 | |||
36 | public function forceAscii() |
||
40 | |||
41 | public function skipInt() |
||
45 | |||
46 | public function appendId($path, $id) |
||
50 | |||
51 | public function appendName($path, $name) |
||
52 | { |
||
53 | if ($this->force_ascii) { |
||
54 | $this->set(sprintf($path, 'loc'), Translit::transliterate($name)); |
||
55 | } else { |
||
56 | $this->set(sprintf($path, 'loc'), $name); |
||
57 | } |
||
58 | |||
59 | if (!$this->skip_int) { |
||
60 | $this->set(sprintf($path, 'int'), Translit::transliterate($name)); |
||
61 | } |
||
62 | } |
||
63 | |||
64 | public function appendOrganization($path, $org) |
||
65 | { |
||
66 | if ($this->force_ascii) { |
||
67 | $this->set(sprintf($path, 'loc'), Translit::transliterate($org)); |
||
68 | } else { |
||
69 | $this->set(sprintf($path, 'loc'), $org); |
||
70 | } |
||
71 | |||
72 | if (!$this->skip_int) { |
||
73 | $this->set(sprintf($path, 'int'), Translit::transliterate($org)); |
||
74 | } |
||
75 | } |
||
76 | |||
77 | public function appendStreet($path, $street) |
||
78 | { |
||
79 | if ($this->force_ascii) { |
||
80 | $this->set(sprintf($path, 'loc'), Translit::transliterate($street)); |
||
81 | } else { |
||
82 | $this->set(sprintf($path, 'loc'), $street); |
||
83 | } |
||
84 | |||
85 | if (!$this->skip_int) { |
||
86 | $this->set(sprintf($path, 'int'), Translit::transliterate($street)); |
||
87 | } |
||
88 | } |
||
89 | |||
90 | public function appendCity($path, $city) |
||
91 | { |
||
92 | if ($this->force_ascii) { |
||
93 | $this->set(sprintf($path, 'loc'), Translit::transliterate($city)); |
||
94 | } else { |
||
95 | $this->set(sprintf($path, 'loc'), $city); |
||
96 | } |
||
97 | |||
98 | if (!$this->skip_int) { |
||
99 | $this->set(sprintf($path, 'int'), Translit::transliterate($city)); |
||
100 | } |
||
101 | } |
||
102 | |||
103 | public function appendProvince($path, $sp) |
||
104 | { |
||
105 | if ($this->force_ascii) { |
||
106 | $this->set(sprintf($path, 'loc'), Translit::transliterate($sp)); |
||
107 | } else { |
||
108 | $this->set(sprintf($path, 'loc'), $sp); |
||
109 | } |
||
110 | |||
111 | if (!$this->skip_int) { |
||
112 | $this->set(sprintf($path, 'int'), Translit::transliterate($sp)); |
||
113 | } |
||
114 | } |
||
115 | |||
116 | public function appendPostalCode($path, $pc) |
||
117 | { |
||
118 | if ($this->force_ascii) { |
||
119 | $this->set(sprintf($path, 'loc'), Translit::transliterate($pc)); |
||
120 | } else { |
||
121 | $this->set(sprintf($path, 'loc'), $pc); |
||
122 | } |
||
123 | |||
124 | if (!$this->skip_int) { |
||
125 | $this->set(sprintf($path, 'int'), Translit::transliterate($pc)); |
||
126 | } |
||
127 | } |
||
128 | |||
129 | public function appendCountryCode($path, $cc) |
||
145 | |||
146 | public function appendVoice($path, $voice) |
||
150 | |||
151 | public function appendFax($path, $fax) |
||
155 | |||
156 | public function appendEmail($path, $email) |
||
157 | { |
||
158 | if (!Validator::isEmail($email)) { |
||
159 | throw new Exception(sprintf('%s is not a valid email', $email)); |
||
160 | } |
||
161 | |||
162 | $this->set($path, $email); |
||
163 | } |
||
164 | |||
165 | public function appendAuthInfo($path, $pw = null) |
||
166 | { |
||
167 | if ($pw === null) { |
||
168 | $pw = Random::auth(12); |
||
169 | } |
||
170 | $this->set($path, $pw); |
||
171 | return $pw; |
||
172 | } |
||
173 | |||
174 | public function appendDisclose($path) |
||
178 | } |