r96231 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96230‎ | r96231 | r96232 >
Date:15:48, 4 September 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Fixed vCard compatibility with SMW 1.6 and later
Modified paths:
  • /trunk/extensions/SemanticResultFormats/RELEASE-NOTES (modified) (history)
  • /trunk/extensions/SemanticResultFormats/vCard/SRF_vCard.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticResultFormats/vCard/SRF_vCard.php
@@ -7,10 +7,15 @@
88
99 /**
1010 * Printer class for creating vCard exports
 11+ *
1112 * @author Markus Krötzsch
1213 * @author Denny Vrandecic
1314 * @author Frank Dengler
 15+ *
1416 * @ingroup SemanticResultFormats
 17+ *
 18+ * TODO: fix the insane case
 19+ * TODO: make SRFvCardAddress constructor sane
1520 */
1621 class SRFvCard extends SMWResultPrinter {
1722 protected $m_title = '';
@@ -93,86 +98,86 @@
9499 // mechanism to add non-standard vCard properties as well
95100 // (could include funny things like geo, description etc.)
96101 $req = $field->getPrintRequest();
97 - $reqValue = ( strtolower( $req->getLabel() ) );
98 - switch( $reqValue ) {
 102+
 103+ switch( strtolower( $req->getLabel() ) ) {
99104 case "name":
100 - $value = current( $field->getContent() ); // save only the first
 105+ $value = efSRFGetNextDV( $field );
101106 if ( $value !== false ) {
102107 $fullname = $value->getShortWikiText();
103108 }
104109 break;
105110
106111 case "prefix":
107 - foreach ( $field->getContent() as $value ) {
 112+ while( $value = efSRFGetNextDV( $field ) ) {
108113 $prefix .= ( $prefix ? ',':'' ) . $value->getShortWikiText();
109114 }
110115 break;
111116
112117 case "suffix":
113 - foreach ( $field->getContent() as $value ) {
 118+ while( $value = efSRFGetNextDV( $field ) ) {
114119 $suffix .= ( $suffix ? ',':'' ) . $value->getShortWikiText();
115120 }
116121 break;
117122
118123 case "firstname":
119 - $value = current( $field->getContent() ); // save only the first
 124+ $value = efSRFGetNextDV( $field ); // save only the first
120125 if ( $value !== false ) {
121126 $firstname = $value->getShortWikiText();
122127 }
123128 break;
124129
125130 case "extraname":
126 - foreach ( $field->getContent() as $value ) {
 131+ while( $value = efSRFGetNextDV( $field ) ) {
127132 $additionalname .= ( $additionalname ? ',':'' ) . $value->getShortWikiText();
128133 }
129134 break;
130135
131136 case "lastname":
132 - $value = current( $field->getContent() ); // save only the first
 137+ $value = efSRFGetNextDV( $field ); // save only the first
133138 if ( $value !== false ) {
134139 $lastname = $value->getShortWikiText();
135140 }
136141 break;
137142
138143 case "note":
139 - foreach ( $field->getContent() as $value ) {
 144+ while( $value = efSRFGetNextDV( $field ) ) {
140145 $note .= ( $note ? ', ':'' ) . $value->getShortWikiText();
141146 }
142147 break;
143148
144149 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() );
147152 }
148153 break;
149154
150155 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() );
153158 }
154159 break;
155160
156161 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() );
159164 }
160165 break;
161166
162167 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() );
165170 }
166171 break;
167172
168173 case "organization":
169 - $value = current( $field->getContent() ); // save only the first
 174+ $value = efSRFGetNextDV( $field );
170175 if ( $value !== false ) {
171176 $organization = $value->getShortWikiText();
172177 }
173178 break;
174179
175180 case "workpostofficebox":
176 - $value = current( $field->getContent() ); // save only the first
 181+ $value = efSRFGetNextDV( $field );
177182 if ( $value !== false ) {
178183 $workpostofficebox = $value->getShortWikiText();
179184 $workaddress = true;
@@ -180,7 +185,7 @@
181186 break;
182187
183188 case "workextendedaddress":
184 - $value = current( $field->getContent() ); // save only the first
 189+ $value = efSRFGetNextDV( $field );
185190 if ( $value !== false ) {
186191 $workextendedaddress = $value->getShortWikiText();
187192 $workaddress = true;
@@ -188,7 +193,7 @@
189194 break;
190195
191196 case "workstreet":
192 - $value = current( $field->getContent() ); // save only the first
 197+ $value = efSRFGetNextDV( $field );
193198 if ( $value !== false ) {
194199 $workstreet = $value->getShortWikiText();
195200 $workaddress = true;
@@ -196,7 +201,7 @@
197202 break;
198203
199204 case "worklocality":
200 - $value = current( $field->getContent() ); // save only the first
 205+ $value = efSRFGetNextDV( $field );
201206 if ( $value !== false ) {
202207 $worklocality = $value->getShortWikiText();
203208 $workaddress = true;
@@ -204,7 +209,7 @@
205210 break;
206211
207212 case "workregion":
208 - $value = current( $field->getContent() ); // save only the first
 213+ $value = efSRFGetNextDV( $field );
209214 if ( $value !== false ) {
210215 $workregion = $value->getShortWikiText();
211216 $workaddress = true;
@@ -212,7 +217,7 @@
213218 break;
214219
215220 case "workpostalcode":
216 - $value = current( $field->getContent() ); // save only the first
 221+ $value = efSRFGetNextDV( $field );
217222 if ( $value !== false ) {
218223 $workpostalcode = $value->getShortWikiText();
219224 $workaddress = true;
@@ -220,7 +225,7 @@
221226 break;
222227
223228 case "workcountry":
224 - $value = current( $field->getContent() ); // save only the first
 229+ $value = efSRFGetNextDV( $field );
225230 if ( $value !== false ) {
226231 $workcountry = $value->getShortWikiText();
227232 $workaddress = true;
@@ -228,7 +233,7 @@
229234 break;
230235
231236 case "homepostofficebox":
232 - $value = current( $field->getContent() ); // save only the first
 237+ $value = efSRFGetNextDV( $field );
233238 if ( $value !== false ) {
234239 $homepostofficebox = $value->getShortWikiText();
235240 $homeaddress = true;
@@ -236,7 +241,7 @@
237242 break;
238243
239244 case "homeextendedaddress":
240 - $value = current( $field->getContent() ); // save only the first
 245+ $value = efSRFGetNextDV( $field );
241246 if ( $value !== false ) {
242247 $homeextendedaddress = $value->getShortWikiText();
243248 $homeaddress = true;
@@ -244,7 +249,7 @@
245250 break;
246251
247252 case "homestreet":
248 - $value = current( $field->getContent() ); // save only the first
 253+ $value = efSRFGetNextDV( $field );
249254 if ( $value !== false ) {
250255 $homestreet = $value->getShortWikiText();
251256 $homeaddress = true;
@@ -252,7 +257,7 @@
253258 break;
254259
255260 case "homelocality":
256 - $value = current( $field->getContent() ); // save only the first
 261+ $value = efSRFGetNextDV( $field );
257262 if ( $value !== false ) {
258263 $homelocality = $value->getShortWikiText();
259264 $homeaddress = true;
@@ -260,7 +265,7 @@
261266 break;
262267
263268 case "homeregion":
264 - $value = current( $field->getContent() ); // save only the first
 269+ $value = efSRFGetNextDV( $field );
265270 if ( $value !== false ) {
266271 $homeregion = $value->getShortWikiText();
267272 $homeaddress = true;
@@ -268,7 +273,7 @@
269274 break;
270275
271276 case "homepostalcode":
272 - $value = current( $field->getContent() ); // save only the first
 277+ $value = efSRFGetNextDV( $field );
273278 if ( $value !== false ) {
274279 $homepostalcode = $value->getShortWikiText();
275280 $homeaddress = true;
@@ -276,7 +281,7 @@
277282 break;
278283
279284 case "homecountry":
280 - $value = current( $field->getContent() ); // save only the first
 285+ $value = efSRFGetNextDV( $field );
281286 if ( $value !== false ) {
282287 $homecountry = $value->getShortWikiText();
283288 $homeaddress = true;
@@ -285,7 +290,7 @@
286291
287292 case "birthday":
288293 if ( $req->getTypeID() == "_dat" ) {
289 - $value = current( $field->getContent() ); // save only the first
 294+ $value = efSRFGetNextDV( $field );
290295 if ( $value !== false ) {
291296 $birthday = $value->getXMLSchemaDate();
292297 }
@@ -294,7 +299,7 @@
295300
296301 case "homepage":
297302 if ( $req->getTypeID() == "_uri" ) {
298 - $value = current( $field->getContent() ); // save only the first
 303+ $value = efSRFGetNextDV( $field );
299304 if ( $value !== false ) {
300305 $url = $value->getWikiValue();
301306 }
Index: trunk/extensions/SemanticResultFormats/RELEASE-NOTES
@@ -5,6 +5,7 @@
66 == SRF 1.6.2 ==
77
88 * Fixed error in math printer when there are no numerical results.
 9+* Fixed vCard compatibility with SMW 1.6 and later.
910
1011 == SRF 1.6.1 ==
1112