r46436 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46435‎ | r46436 | r46437 >
Date:09:30, 28 January 2009
Author:mkroetzsch
Status:deferred
Tags:
Comment:
Support address fields in vCard (contributed by Frank Dengler)
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QP_vCard.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QP_vCard.php
@@ -60,7 +60,26 @@
6161 $birthday = ''; // a date
6262 $url =''; // homepage, a legal URL
6363 $note =''; // any text
64 -
 64+ $workaddress = false;
 65+ $homeaddress = false;
 66+
 67+ $workpostofficebox ='';
 68+ $workextendedaddress ='';
 69+ $workstreet ='';
 70+ $worklocality ='';
 71+ $workregion ='';
 72+ $workpostalcode ='';
 73+ $workcountry ='';
 74+
 75+
 76+ $homepostofficebox ='';
 77+ $homeextendedaddress ='';
 78+ $homestreet ='';
 79+ $homelocality ='';
 80+ $homeregion ='';
 81+ $homepostalcode ='';
 82+ $homecountry ='';
 83+
6584 foreach ($row as $field) {
6685 // later we may add more things like a generic
6786 // mechanism to add non-standard vCard properties as well
@@ -143,9 +162,108 @@
144163 $organization = $value->getShortWikiText();
145164 }
146165 }
147 -
 166+ if ( (strtolower($req->getLabel()) == "workpostofficebox")) {
 167+ $value = current($field->getContent()); // save only the first
 168+ if ($value !== false) {
 169+ $workpostofficebox = $value->getShortWikiText();
 170+ $workaddress = true;
 171+ }
 172+ }
 173+ if ( (strtolower($req->getLabel()) == "workextendedaddress")) {
 174+ $value = current($field->getContent()); // save only the first
 175+ if ($value !== false) {
 176+ $workextendedaddress = $value->getShortWikiText();
 177+ $workaddress = true;
 178+ }
 179+ }
 180+ if ( (strtolower($req->getLabel()) == "workstreet")) {
 181+ $value = current($field->getContent()); // save only the first
 182+ if ($value !== false) {
 183+ $workstreet = $value->getShortWikiText();
 184+ $workaddress = true;
 185+ }
 186+ }
 187+ if ( (strtolower($req->getLabel()) == "worklocality")) {
 188+ $value = current($field->getContent()); // save only the first
 189+ if ($value !== false) {
 190+ $worklocality = $value->getShortWikiText();
 191+ $workaddress = true;
 192+ }
 193+ }
 194+ if ( (strtolower($req->getLabel()) == "workregion")) {
 195+ $value = current($field->getContent()); // save only the first
 196+ if ($value !== false) {
 197+ $workregion = $value->getShortWikiText();
 198+ $workaddress = true;
 199+ }
 200+ }
 201+ if ( (strtolower($req->getLabel()) == "workpostalcode")) {
 202+ $value = current($field->getContent()); // save only the first
 203+ if ($value !== false) {
 204+ $workpostalcode = $value->getShortWikiText();
 205+ $workaddress = true;
 206+ }
 207+ }
 208+ if ( (strtolower($req->getLabel()) == "workcountry")) {
 209+ $value = current($field->getContent()); // save only the first
 210+ if ($value !== false) {
 211+ $workcountry = $value->getShortWikiText();
 212+ $workaddress = true;
 213+ }
 214+ }
 215+ if ( (strtolower($req->getLabel()) == "homepostofficebox")) {
 216+ $value = current($field->getContent()); // save only the first
 217+ if ($value !== false) {
 218+ $homepostofficebox = $value->getShortWikiText();
 219+ $homeaddress = true;
 220+ }
 221+ }
 222+ if ( (strtolower($req->getLabel()) == "homeextendedaddress")) {
 223+ $value = current($field->getContent()); // save only the first
 224+ if ($value !== false) {
 225+ $homeextendedaddress = $value->getShortWikiText();
 226+ $homeaddress = true;
 227+ }
 228+ }
 229+ if ( (strtolower($req->getLabel()) == "homestreet")) {
 230+ $value = current($field->getContent()); // save only the first
 231+ if ($value !== false) {
 232+ $homestreet = $value->getShortWikiText();
 233+ $homeaddress = true;
 234+ }
 235+ }
 236+ if ( (strtolower($req->getLabel()) == "homelocality")) {
 237+ $value = current($field->getContent()); // save only the first
 238+ if ($value !== false) {
 239+ $homelocality = $value->getShortWikiText();
 240+ $homeaddress = true;
 241+ }
 242+ }
 243+ if ( (strtolower($req->getLabel()) == "homeregion")) {
 244+ $value = current($field->getContent()); // save only the first
 245+ if ($value !== false) {
 246+ $homeregion = $value->getShortWikiText();
 247+ $homeaddress = true;
 248+ }
 249+ }
 250+ if ( (strtolower($req->getLabel()) == "homepostalcode")) {
 251+ $value = current($field->getContent()); // save only the first
 252+ if ($value !== false) {
 253+ $homepostalcode = $value->getShortWikiText();
 254+ $homeaddress = true;
 255+ }
 256+ }
 257+ if ( (strtolower($req->getLabel()) == "homecountry")) {
 258+ $value = current($field->getContent()); // save only the first
 259+ if ($value !== false) {
 260+ $homecountry = $value->getShortWikiText();
 261+ $homeaddress = true;
 262+ }
 263+ }
148264 }
149265 $pagetitle = $wikipage->getTitle();
 266+ if ($workaddress) $addresses[] = new SMWvCardAddress ('WORK', $workpostofficebox, $workextendedaddress, $workstreet, $worklocality, $workregion, $workpostalcode, $workcountry);
 267+ if ($homeaddress) $addresses[] = new SMWvCardAddress ('HOME', $homepostofficebox, $homeextendedaddress, $homestreet, $homelocality, $homeregion, $homepostalcode, $homecountry);
150268 $items[] = new SMWvCardEntry($pagetitle, $prefix, $firstname, $lastname, $additionalname, $suffix, $fullname, $tels, $addresses, $emails, $birthday, $jobtitle, $role, $organization, $department, $category, $url, $note);
151269 $row = $res->getNext();
152270 }

Status & tagging log