Index: trunk/extensions/SemanticResultFormats/vCard/SRF_vCard.php |
— | — | @@ -7,10 +7,15 @@ |
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Printer class for creating vCard exports |
| 11 | + * |
11 | 12 | * @author Markus Krötzsch |
12 | 13 | * @author Denny Vrandecic |
13 | 14 | * @author Frank Dengler |
| 15 | + * |
14 | 16 | * @ingroup SemanticResultFormats |
| 17 | + * |
| 18 | + * TODO: fix the insane case |
| 19 | + * TODO: make SRFvCardAddress constructor sane |
15 | 20 | */ |
16 | 21 | class SRFvCard extends SMWResultPrinter { |
17 | 22 | protected $m_title = ''; |
— | — | @@ -93,86 +98,86 @@ |
94 | 99 | // mechanism to add non-standard vCard properties as well |
95 | 100 | // (could include funny things like geo, description etc.) |
96 | 101 | $req = $field->getPrintRequest(); |
97 | | - $reqValue = ( strtolower( $req->getLabel() ) ); |
98 | | - switch( $reqValue ) { |
| 102 | + |
| 103 | + switch( strtolower( $req->getLabel() ) ) { |
99 | 104 | case "name": |
100 | | - $value = current( $field->getContent() ); // save only the first |
| 105 | + $value = efSRFGetNextDV( $field ); |
101 | 106 | if ( $value !== false ) { |
102 | 107 | $fullname = $value->getShortWikiText(); |
103 | 108 | } |
104 | 109 | break; |
105 | 110 | |
106 | 111 | case "prefix": |
107 | | - foreach ( $field->getContent() as $value ) { |
| 112 | + while( $value = efSRFGetNextDV( $field ) ) { |
108 | 113 | $prefix .= ( $prefix ? ',':'' ) . $value->getShortWikiText(); |
109 | 114 | } |
110 | 115 | break; |
111 | 116 | |
112 | 117 | case "suffix": |
113 | | - foreach ( $field->getContent() as $value ) { |
| 118 | + while( $value = efSRFGetNextDV( $field ) ) { |
114 | 119 | $suffix .= ( $suffix ? ',':'' ) . $value->getShortWikiText(); |
115 | 120 | } |
116 | 121 | break; |
117 | 122 | |
118 | 123 | case "firstname": |
119 | | - $value = current( $field->getContent() ); // save only the first |
| 124 | + $value = efSRFGetNextDV( $field ); // save only the first |
120 | 125 | if ( $value !== false ) { |
121 | 126 | $firstname = $value->getShortWikiText(); |
122 | 127 | } |
123 | 128 | break; |
124 | 129 | |
125 | 130 | case "extraname": |
126 | | - foreach ( $field->getContent() as $value ) { |
| 131 | + while( $value = efSRFGetNextDV( $field ) ) { |
127 | 132 | $additionalname .= ( $additionalname ? ',':'' ) . $value->getShortWikiText(); |
128 | 133 | } |
129 | 134 | break; |
130 | 135 | |
131 | 136 | case "lastname": |
132 | | - $value = current( $field->getContent() ); // save only the first |
| 137 | + $value = efSRFGetNextDV( $field ); // save only the first |
133 | 138 | if ( $value !== false ) { |
134 | 139 | $lastname = $value->getShortWikiText(); |
135 | 140 | } |
136 | 141 | break; |
137 | 142 | |
138 | 143 | case "note": |
139 | | - foreach ( $field->getContent() as $value ) { |
| 144 | + while( $value = efSRFGetNextDV( $field ) ) { |
140 | 145 | $note .= ( $note ? ', ':'' ) . $value->getShortWikiText(); |
141 | 146 | } |
142 | 147 | break; |
143 | 148 | |
144 | 149 | case "email": |
145 | | - foreach ( $field->getContent() as $entry ) { |
146 | | - $emails[] = new SRFvCardEmail( 'internet', $entry->getShortWikiText() ); |
| 150 | + while( $value = efSRFGetNextDV( $field ) ) { |
| 151 | + $emails[] = new SRFvCardEmail( 'internet', $value->getShortWikiText() ); |
147 | 152 | } |
148 | 153 | break; |
149 | 154 | |
150 | 155 | case "workphone": |
151 | | - foreach ( $field->getContent() as $entry ) { |
152 | | - $tels[] = new SRFvCardTel( 'WORK', $entry->getShortWikiText() ); |
| 156 | + while( $value = efSRFGetNextDV( $field ) ) { |
| 157 | + $tels[] = new SRFvCardTel( 'WORK', $value->getShortWikiText() ); |
153 | 158 | } |
154 | 159 | break; |
155 | 160 | |
156 | 161 | case "cellphone": |
157 | | - foreach ( $field->getContent() as $entry ) { |
158 | | - $tels[] = new SRFvCardTel( 'CELL', $entry->getShortWikiText() ); |
| 162 | + while( $value = efSRFGetNextDV( $field ) ) { |
| 163 | + $tels[] = new SRFvCardTel( 'CELL', $value->getShortWikiText() ); |
159 | 164 | } |
160 | 165 | break; |
161 | 166 | |
162 | 167 | case "homephone": |
163 | | - foreach ( $field->getContent() as $entry ) { |
164 | | - $tels[] = new SRFvCardTel( 'HOME', $entry->getShortWikiText() ); |
| 168 | + while( $value = efSRFGetNextDV( $field ) ) { |
| 169 | + $tels[] = new SRFvCardTel( 'HOME', $value->getShortWikiText() ); |
165 | 170 | } |
166 | 171 | break; |
167 | 172 | |
168 | 173 | case "organization": |
169 | | - $value = current( $field->getContent() ); // save only the first |
| 174 | + $value = efSRFGetNextDV( $field ); |
170 | 175 | if ( $value !== false ) { |
171 | 176 | $organization = $value->getShortWikiText(); |
172 | 177 | } |
173 | 178 | break; |
174 | 179 | |
175 | 180 | case "workpostofficebox": |
176 | | - $value = current( $field->getContent() ); // save only the first |
| 181 | + $value = efSRFGetNextDV( $field ); |
177 | 182 | if ( $value !== false ) { |
178 | 183 | $workpostofficebox = $value->getShortWikiText(); |
179 | 184 | $workaddress = true; |
— | — | @@ -180,7 +185,7 @@ |
181 | 186 | break; |
182 | 187 | |
183 | 188 | case "workextendedaddress": |
184 | | - $value = current( $field->getContent() ); // save only the first |
| 189 | + $value = efSRFGetNextDV( $field ); |
185 | 190 | if ( $value !== false ) { |
186 | 191 | $workextendedaddress = $value->getShortWikiText(); |
187 | 192 | $workaddress = true; |
— | — | @@ -188,7 +193,7 @@ |
189 | 194 | break; |
190 | 195 | |
191 | 196 | case "workstreet": |
192 | | - $value = current( $field->getContent() ); // save only the first |
| 197 | + $value = efSRFGetNextDV( $field ); |
193 | 198 | if ( $value !== false ) { |
194 | 199 | $workstreet = $value->getShortWikiText(); |
195 | 200 | $workaddress = true; |
— | — | @@ -196,7 +201,7 @@ |
197 | 202 | break; |
198 | 203 | |
199 | 204 | case "worklocality": |
200 | | - $value = current( $field->getContent() ); // save only the first |
| 205 | + $value = efSRFGetNextDV( $field ); |
201 | 206 | if ( $value !== false ) { |
202 | 207 | $worklocality = $value->getShortWikiText(); |
203 | 208 | $workaddress = true; |
— | — | @@ -204,7 +209,7 @@ |
205 | 210 | break; |
206 | 211 | |
207 | 212 | case "workregion": |
208 | | - $value = current( $field->getContent() ); // save only the first |
| 213 | + $value = efSRFGetNextDV( $field ); |
209 | 214 | if ( $value !== false ) { |
210 | 215 | $workregion = $value->getShortWikiText(); |
211 | 216 | $workaddress = true; |
— | — | @@ -212,7 +217,7 @@ |
213 | 218 | break; |
214 | 219 | |
215 | 220 | case "workpostalcode": |
216 | | - $value = current( $field->getContent() ); // save only the first |
| 221 | + $value = efSRFGetNextDV( $field ); |
217 | 222 | if ( $value !== false ) { |
218 | 223 | $workpostalcode = $value->getShortWikiText(); |
219 | 224 | $workaddress = true; |
— | — | @@ -220,7 +225,7 @@ |
221 | 226 | break; |
222 | 227 | |
223 | 228 | case "workcountry": |
224 | | - $value = current( $field->getContent() ); // save only the first |
| 229 | + $value = efSRFGetNextDV( $field ); |
225 | 230 | if ( $value !== false ) { |
226 | 231 | $workcountry = $value->getShortWikiText(); |
227 | 232 | $workaddress = true; |
— | — | @@ -228,7 +233,7 @@ |
229 | 234 | break; |
230 | 235 | |
231 | 236 | case "homepostofficebox": |
232 | | - $value = current( $field->getContent() ); // save only the first |
| 237 | + $value = efSRFGetNextDV( $field ); |
233 | 238 | if ( $value !== false ) { |
234 | 239 | $homepostofficebox = $value->getShortWikiText(); |
235 | 240 | $homeaddress = true; |
— | — | @@ -236,7 +241,7 @@ |
237 | 242 | break; |
238 | 243 | |
239 | 244 | case "homeextendedaddress": |
240 | | - $value = current( $field->getContent() ); // save only the first |
| 245 | + $value = efSRFGetNextDV( $field ); |
241 | 246 | if ( $value !== false ) { |
242 | 247 | $homeextendedaddress = $value->getShortWikiText(); |
243 | 248 | $homeaddress = true; |
— | — | @@ -244,7 +249,7 @@ |
245 | 250 | break; |
246 | 251 | |
247 | 252 | case "homestreet": |
248 | | - $value = current( $field->getContent() ); // save only the first |
| 253 | + $value = efSRFGetNextDV( $field ); |
249 | 254 | if ( $value !== false ) { |
250 | 255 | $homestreet = $value->getShortWikiText(); |
251 | 256 | $homeaddress = true; |
— | — | @@ -252,7 +257,7 @@ |
253 | 258 | break; |
254 | 259 | |
255 | 260 | case "homelocality": |
256 | | - $value = current( $field->getContent() ); // save only the first |
| 261 | + $value = efSRFGetNextDV( $field ); |
257 | 262 | if ( $value !== false ) { |
258 | 263 | $homelocality = $value->getShortWikiText(); |
259 | 264 | $homeaddress = true; |
— | — | @@ -260,7 +265,7 @@ |
261 | 266 | break; |
262 | 267 | |
263 | 268 | case "homeregion": |
264 | | - $value = current( $field->getContent() ); // save only the first |
| 269 | + $value = efSRFGetNextDV( $field ); |
265 | 270 | if ( $value !== false ) { |
266 | 271 | $homeregion = $value->getShortWikiText(); |
267 | 272 | $homeaddress = true; |
— | — | @@ -268,7 +273,7 @@ |
269 | 274 | break; |
270 | 275 | |
271 | 276 | case "homepostalcode": |
272 | | - $value = current( $field->getContent() ); // save only the first |
| 277 | + $value = efSRFGetNextDV( $field ); |
273 | 278 | if ( $value !== false ) { |
274 | 279 | $homepostalcode = $value->getShortWikiText(); |
275 | 280 | $homeaddress = true; |
— | — | @@ -276,7 +281,7 @@ |
277 | 282 | break; |
278 | 283 | |
279 | 284 | case "homecountry": |
280 | | - $value = current( $field->getContent() ); // save only the first |
| 285 | + $value = efSRFGetNextDV( $field ); |
281 | 286 | if ( $value !== false ) { |
282 | 287 | $homecountry = $value->getShortWikiText(); |
283 | 288 | $homeaddress = true; |
— | — | @@ -285,7 +290,7 @@ |
286 | 291 | |
287 | 292 | case "birthday": |
288 | 293 | if ( $req->getTypeID() == "_dat" ) { |
289 | | - $value = current( $field->getContent() ); // save only the first |
| 294 | + $value = efSRFGetNextDV( $field ); |
290 | 295 | if ( $value !== false ) { |
291 | 296 | $birthday = $value->getXMLSchemaDate(); |
292 | 297 | } |
— | — | @@ -294,7 +299,7 @@ |
295 | 300 | |
296 | 301 | case "homepage": |
297 | 302 | if ( $req->getTypeID() == "_uri" ) { |
298 | | - $value = current( $field->getContent() ); // save only the first |
| 303 | + $value = efSRFGetNextDV( $field ); |
299 | 304 | if ( $value !== false ) { |
300 | 305 | $url = $value->getWikiValue(); |
301 | 306 | } |
Index: trunk/extensions/SemanticResultFormats/RELEASE-NOTES |
— | — | @@ -5,6 +5,7 @@ |
6 | 6 | == SRF 1.6.2 == |
7 | 7 | |
8 | 8 | * Fixed error in math printer when there are no numerical results. |
| 9 | +* Fixed vCard compatibility with SMW 1.6 and later. |
9 | 10 | |
10 | 11 | == SRF 1.6.1 == |
11 | 12 | |