Hi,

This is a followup on my earlier mails in December on this bug 284 and a call for help. I have now created a php script that can read a vcf file and outputs a new vcf with the LABEL field added. The label can be for 33 different countries. So it can output the formatted address for 33 different layouts!

I have created this at the moment as a commandline tool. It consists of 3 files:
the example script labels.php
The actual algorithm: formatlabels.php
and a list of countrycodes vs country names, countrycodes.php


I run into 2 obstacles now that I need to clear.
1) the home country of the user. This is an unknown in the contacts app. But it is needed to format the label when no country is specified in the vcf, and to suppress the country name in the formatted addreslabel, when it is the same as the country where the user lives.

I noticed that the calendar app already has a setting for this. Presumably to get the right timezone for the calendar. I would propose to make this a global parameter, somewhere in the user profile, so more apps can make use of this info. That would at least solve my problem. Alternatively, the contacts app has to be extended with a country field.

2) There is no clear way to get the country from an contact address. The country name is a free format text field, so it can be in any spelling.

My proposal is to use a dropdown list, in order to make this more structured. The names can be localized based on the language setting. I noticed Outlook has the same approach to country entry. And the dropdown list already exists in the Calendar app for the setting I mentioned earlier.

However, I have no idea how to program the UI. And I am sure there are people who are very good at that in this list. I'm looking for help. I have created the formatting algorithm, who can help me incorporate it in the contact app?

Please let me know if you are interested in helping, or have any feedback.

Kind regards,

Bert







On 2014-11-28 11:49, Bert Haverkamp wrote:
Dear Owncloud developers.

Some months ago, I filed bug 284.
(https://github.com/owncloud/contacts/issues/284) It is relating to the way owncloud updates (or doesn't update) the Address Label field in vcards. This field is used by many address-sticker programms like for instance Glabels. I would like to be able to download a subset of my contacts as a vcf file,
import them in to Glabels and print address stickers very easily.

However, the interest in this bug is not very high. (Basically, just me at
the moment:-)
So I'm looking into adding this to owncloud myself. It would greatly enhance the capability of printing address labels and I can't imagine there is no one else with a usecase for this (Hint, christmas card season is coming!)

In order to have this working correctly the address should be formatted
according to the local situation.
I live in the Netherlands and addresses are formatted differently than for
instance in the USA.
Also if an address is in another country, it should pick that up and format
it accordingly.

I already downloaded the evolution sourcecode and found the code that is responsible for constructing the address labels and their country specific formats. They use a address_formats.dat file to list all countries and their
official address layout.

I'd now need to add this to owncloud. There are two possibilities. Do this everytime when updating the address field, and doing this when exporting to
vcf. Which would be best in your view?

Also I'm still struggling to understand the owncloud source. php is not my
strongsuit:-(
Can anyone give some guidance? Where would I need to hook into the code that
saves the vcf files? Or where is the code to store the fields in the
database?

Kind regards,

Bert Haverkamp

P.S. I hope this wont become a double-post. My first post was rejected
because I sent it before subscribing to the mailing-list.



--
View this message in context:
http://owncloud.10557.n7.nabble.com/Owncloud-contacts-and-address-stickers-tp13561.html
Sent from the Developers mailing list archive at Nabble.com.
_______________________________________________
Devel mailing list
[email protected]
http://mailman.owncloud.org/mailman/listinfo/devel
<?php

use Sabre\VObject;
use Sabre\VObject\Reader;
use Sabre\VObject\Splitter\VCard;
include 'vendor/autoload.php';
include 'countrycodes.php';
include 'formatlabel.php';

//$infilename="Addressbook.vcf";
$infilename="Test.vcf";
$infile=fopen($infilename,'r');
if (!$infile) {
  exit("Input file $infilename can not be opened.\n");
}
$outfilename="Relabelled.vcf";
$outfile=fopen($outfilename,"w");
if (!$outfile) {
 
  exit("Output file $outfilename can not be opened.\n");
}

$vcards = new VCard($infile);
$count = 0;
while($vcard=$vcards->getNext()) {
  if(isset($vcard->FN)){
    $n=$vcard->FN;       // Full Name
  } else {
    $n='';
  }
  if(isset($vcard->COMPANY)){
    $m=$vcard->COMPANY;  //Company
  } else {
    $m='';
  }
  if ( isset($vcard->ADR) ) {
    foreach($vcard->ADR as $adr) {
      $adrarray=$adr->getParts();
      $p=$adrarray[0]; //PO box
      $e=$adrarray[1]; //Extended address
      $s=$adrarray[2]; //Street
      $l=$adrarray[3]; //Location or city
      $r=$adrarray[4]; //Region 
      $z=$adrarray[5]; //Zip Code
      $c=$adrarray[6]; //Country
      $t=$adr['TYPE'];
      $hcc="NL"; // fixme default countrycode should be a variable.
      $cc='';
      $c=trim($c);
      if ( empty($c) ) {
	$cc = $hcc;
      } elseif (array_key_exists($c,$countrycodes)) {
	$cc=$countrycodes[$c];
      } else {
	echo "Country $c,  Countrycode not found: $cc\n";
	return;
      }
      echo "Country $c,  Countrycode: $cc, type $t \n";
      $label=formatlabel($n,$m,$p,$e,$s,$l,$r,$z,$c,$t,$cc,$hcc);
      echo "Label type: $t:\n";
      echo"$label\n";

      
      if ( isset($vcard->LABEL[$t]) ) {
	$vcard->LABEL[$t] = $label;
      } else {
	$vcard->add('LABEL',$label,['TYPE' => $t]);
	unset($vcard->LABEL[strtolower($t)]);// just to be sure
      }
    }
  }
  unset($vcard->{'CLASS'});
  unset($vcard->{'UID'});
  unset($vcard->{'PRODID'});
  unset($vcard->{'REV'});
  unset($vcard->{'URL'});
  unset($vcard->{'FBURL'});
  unset($vcard->{'ROLE'});
  if (empty(trim($vcard->{'TITLE'}))) {
    unset($vcard->{'TITLE'});
  }
  unset($vcard->{'NICKNAME'});
  unset($vcard->{'CALURI'});
  unset($vcard->{'FBURI'});
  unset($vcard->{'X-KADDRESSBOOK-MAILPREFEREDFORMATTING'});
  unset($vcard->{'X-MOZILLA-HTML'});
  unset($vcard->{'X-EVOLUTION-FILE-AS'});
  unset($vcard->{'X-EVOLUTION-MANAGER'});
  unset($vcard->{'X-EVOLUTION-SPOUSE'});
  unset($vcard->{'X-EVOLUTION-BLOG-URL'});
  unset($vcard->{'X-EVOLUTION-VIDEO-URL'});
  unset($vcard->{'X-EVOLUTION-ASSISTANT'});
  if ( isset($vcard->TEL)) {
    foreach ($vcard->TEL as $tel) {
      unset($tel['X-EVOLUTION-UI-SLOT']);
    }
  }
  if ( isset($vcard->EMAIL)) {
    foreach ($vcard->EMAIL as $email) {
      unset($email['X-EVOLUTION-UI-SLOT']);
    }
  }
  fwrite($outfile,$vcard->serialize()."\n");
  $count++;
}
echo "Processed ", $count, " Vcards.\n";

?>
<?php
$countrycodes = array (
  'Afghanistan' => 'AF',
  'Albania' => 'AL',
  'Algeria' => 'DZ',
  'American Samoa' => 'AS',
  'Andorra' => 'AD',
  'Angola' => 'AO',
  'Anguilla' => 'AI',
  'Antarctica' => 'AQ',
  'Antigua and Barbuda' => 'AG',
  'Argentina' => 'AR',
  'Armenia' => 'AM',
  'Aruba' => 'AW',
  'Australia' => 'AU',
  'Austria' => 'AT',
  'Azerbaijan' => 'AZ',
  'Bahamas' => 'BS',
  'Bahrain' => 'BH',
  'Bangladesh' => 'BD',
  'Barbados' => 'BB',
  'Belarus' => 'BY',
  'Belgium' => 'BE',
  'Belize' => 'BZ',
  'Benin' => 'BJ',
  'Bermuda' => 'BM',
  'Bhutan' => 'BT',
  'Bolivia, Plurinational State of' => 'BO',
  'Bonaire, Sint Eustatius and Saba' => 'BQ',
  'Bosnia and Herzegovina' => 'BA',
  'Botswana' => 'BW',
  'Bouvet Island' => 'BV',
  'Brazil' => 'BR',
  'British Indian Ocean Territory' => 'IO',
  'Brunei Darussalam' => 'BN',
  'Bulgaria' => 'BG',
  'Burkina Faso' => 'BF',
  'Burundi' => 'BI',
  'Cambodia' => 'KH',
  'Cameroon' => 'CM',
  'Canada' => 'CA',
  'Cape Verde' => 'CV',
  'Cayman Islands' => 'KY',
  'Central African Republic' => 'CF',
  'Chad' => 'TD',
  'Chile' => 'CL',
  'China' => 'CN',
  'Christmas Island' => 'CX',
  'Cocos (Keeling) Islands' => 'CC',
  'Colombia' => 'CO',
  'Comoros' => 'KM',
  'Congo' => 'CG',
  'Congo, the Democratic Republic of the' => 'CD',
  'Cook Islands' => 'CK',
  'Costa Rica' => 'CR',
  'Croatia' => 'HR',
  'Cuba' => 'CU',
  'Curaçao' => 'CW',
  'Cyprus' => 'CY',
  'Czech Republic' => 'CZ',
  'Côte d\'Ivoire' => 'CI',
  'Denmark' => 'DK',
  'Djibouti' => 'DJ',
  'Dominica' => 'DM',
  'Dominican Republic' => 'DO',
  'Ecuador' => 'EC',
  'Egypt' => 'EG',
  'El Salvador' => 'SV',
  'Equatorial Guinea' => 'GQ',
  'Eritrea' => 'ER',
  'Estonia' => 'EE',
  'Ethiopia' => 'ET',
  'Falkland Islands (Malvinas)' => 'FK',
  'Faroe Islands' => 'FO',
  'Fiji' => 'FJ',
  'Finland' => 'FI',
  'France' => 'FR',
  'French Guiana' => 'GF',
  'French Polynesia' => 'PF',
  'French Southern Territories' => 'TF',
  'Gabon' => 'GA',
  'Gambia' => 'GM',
  'Georgia' => 'GE',
  'Germany' => 'DE',
  'Ghana' => 'GH',
  'Gibraltar' => 'GI',
  'Greece' => 'GR',
  'Greenland' => 'GL',
  'Grenada' => 'GD',
  'Guadeloupe' => 'GP',
  'Guam' => 'GU',
  'Guatemala' => 'GT',
  'Guernsey' => 'GG',
  'Guinea' => 'GN',
  'Guinea-Bissau' => 'GW',
  'Guyana' => 'GY',
  'Haiti' => 'HT',
  'Heard Island and McDonald Mcdonald Islands' => 'HM',
  'Holy See (Vatican City State)' => 'VA',
  'Honduras' => 'HN',
  'Hong Kong' => 'HK',
  'Hungary' => 'HU',
  'Iceland' => 'IS',
  'India' => 'IN',
  'Indonesia' => 'ID',
  'Iran, Islamic Republic of' => 'IR',
  'Iraq' => 'IQ',
  'Ireland' => 'IE',
  'Isle of Man' => 'IM',
  'Israel' => 'IL',
  'Italy' => 'IT',
  'Jamaica' => 'JM',
  'Japan' => 'JP',
  'Jersey' => 'JE',
  'Jordan' => 'JO',
  'Kazakhstan' => 'KZ',
  'Kenya' => 'KE',
  'Kiribati' => 'KI',
  'Korea, Democratic People\'s Republic of' => 'KP',
  'Korea, Republic of' => 'KR',
  'Kuwait' => 'KW',
  'Kyrgyzstan' => 'KG',
  'Lao People\'s Democratic Republic' => 'LA',
  'Latvia' => 'LV',
  'Lebanon' => 'LB',
  'Lesotho' => 'LS',
  'Liberia' => 'LR',
  'Libya' => 'LY',
  'Liechtenstein' => 'LI',
  'Lithuania' => 'LT',
  'Luxembourg' => 'LU',
  'Macao' => 'MO',
  'Macedonia, the Former Yugoslav Republic of' => 'MK',
  'Madagascar' => 'MG',
  'Malawi' => 'MW',
  'Malaysia' => 'MY',
  'Maldives' => 'MV',
  'Mali' => 'ML',
  'Malta' => 'MT',
  'Marshall Islands' => 'MH',
  'Martinique' => 'MQ',
  'Mauritania' => 'MR',
  'Mauritius' => 'MU',
  'Mayotte' => 'YT',
  'Mexico' => 'MX',
  'Micronesia, Federated States of' => 'FM',
  'Moldova, Republic of' => 'MD',
  'Monaco' => 'MC',
  'Mongolia' => 'MN',
  'Montenegro' => 'ME',
  'Montserrat' => 'MS',
  'Morocco' => 'MA',
  'Mozambique' => 'MZ',
  'Myanmar' => 'MM',
  'Namibia' => 'NA',
  'Nauru' => 'NR',
  'Nepal' => 'NP',
  'Netherlands' => 'NL',
  'New Caledonia' => 'NC',
  'New Zealand' => 'NZ',
  'Nicaragua' => 'NI',
  'Niger' => 'NE',
  'Nigeria' => 'NG',
  'Niue' => 'NU',
  'Norfolk Island' => 'NF',
  'Northern Mariana Islands' => 'MP',
  'Norway' => 'NO',
  'Oman' => 'OM',
  'Pakistan' => 'PK',
  'Palau' => 'PW',
  'Palestine, State of' => 'PS',
  'Panama' => 'PA',
  'Papua New Guinea' => 'PG',
  'Paraguay' => 'PY',
  'Peru' => 'PE',
  'Philippines' => 'PH',
  'Pitcairn' => 'PN',
  'Poland' => 'PL',
  'Portugal' => 'PT',
  'Puerto Rico' => 'PR',
  'Qatar' => 'QA',
  'Romania' => 'RO',
  'Russian Federation' => 'RU',
  'Rwanda' => 'RW',
  'Réunion' => 'RE',
  'Saint Barthélemy' => 'BL',
  'Saint Helena, Ascension and Tristan da Cunha' => 'SH',
  'Saint Kitts and Nevis' => 'KN',
  'Saint Lucia' => 'LC',
  'Saint Martin (French part)' => 'MF',
  'Saint Pierre and Miquelon' => 'PM',
  'Saint Vincent and the Grenadines' => 'VC',
  'Samoa' => 'WS',
  'San Marino' => 'SM',
  'Sao Tome and Principe' => 'ST',
  'Saudi Arabia' => 'SA',
  'Senegal' => 'SN',
  'Serbia' => 'RS',
  'Seychelles' => 'SC',
  'Sierra Leone' => 'SL',
  'Singapore' => 'SG',
  'Sint Maarten (Dutch part)' => 'SX',
  'Slovakia' => 'SK',
  'Slovenia' => 'SI',
  'Solomon Islands' => 'SB',
  'Somalia' => 'SO',
  'South Africa' => 'ZA',
  'South Georgia and the South Sandwich Islands' => 'GS',
  'South Sudan' => 'SS',
  'Spain' => 'ES',
  'Sri Lanka' => 'LK',
  'Sudan' => 'SD',
  'Suriname' => 'SR',
  'Svalbard and Jan Mayen' => 'SJ',
  'Swaziland' => 'SZ',
  'Sweden' => 'SE',
  'Switzerland' => 'CH',
  'Syrian Arab Republic' => 'SY',
  'Taiwan, Province of China' => 'TW',
  'Tajikistan' => 'TJ',
  'Tanzania, United Republic of' => 'TZ',
  'Thailand' => 'TH',
  'Timor-Leste' => 'TL',
  'Togo' => 'TG',
  'Tokelau' => 'TK',
  'Tonga' => 'TO',
  'Trinidad and Tobago' => 'TT',
  'Tunisia' => 'TN',
  'Turkey' => 'TR',
  'Turkmenistan' => 'TM',
  'Turks and Caicos Islands' => 'TC',
  'Tuvalu' => 'TV',
  'Uganda' => 'UG',
  'Ukraine' => 'UA',
  'United Arab Emirates' => 'AE',
  'United Kingdom' => 'GB',
  'United States' => 'US',
  'United States Minor Outlying Islands' => 'UM',
  'Uruguay' => 'UY',
  'Uzbekistan' => 'UZ',
  'Vanuatu' => 'VU',
  'Venezuela, Bolivarian Republic of' => 'VE',
  'Viet Nam' => 'VN',
  'Virgin Islands, British' => 'VG',
  'Virgin Islands, U.S.' => 'VI',
  'Wallis and Futuna' => 'WF',
  'Western Sahara' => 'EH',
  'Yemen' => 'YE',
  'Zambia' => 'ZM',
  'Zimbabwe' => 'ZW',
  'Åland Islands' => 'AX',
)
?>
<?php

function formatlabel($n,$m,$p,$e,$s,$l,$r,$z,$c,$t,$cc,$hcc) {
  $N=strtoupper($n);
  $M=strtoupper($m);
  $L=strtoupper($l);
  $S=strtoupper($s);
  $R=strtoupper($r);
  switch ($cc) {
  case "AT":
    // Address format: %0(%n\n)%0(%m\n)%0(Postfach %p\n)%0(%s\n)%z%w%l
    $label=(!empty("$n")?"$n\n":"").(!empty("$m")?"$m\n":"").(!empty("$p")?"Postfach $p\n":"").(!empty("$s")?"$s $e\n":"")."$z".((empty("$z") or empty("$l"))?"":" ")."$l";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "AU":
    // Address format: %0(%n\n)%0(%m\n)%0(%s\n)%0(PO BOX %p\n)%L%w%w%R%w%w%z
    $label=(!empty("$n")?"$n\n":"").(!empty("$m")?"$m\n":"").(!empty("$s")?"$s $e\n":"").(!empty("$p")?"PO BOX $p\n":"")."$L".((empty("$l") or empty("$r$z"))?"":"  ")."$r".((empty("$l$r") or empty("$z"))?"":"  ")."$z";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "AX":
    // Address format: %0(%m\n)%0(%n\n)%0(PB %p\n)%0(%s\n)%z%w%L
    $label=(!empty("$m")?"$m\n":"").(!empty("$n")?"$n\n":"").(!empty("$p")?"PB $p\n":"").(!empty("$s")?"$s $e\n":"")."$z".((empty("$z") or empty("$l"))?"":" ")."$L";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "BE":
    // Address format: %0(%n\n)%0(%m\n)%0(Postbus %p\n)%0(%s\n)%z%w%l
    $label=(!empty("$n")?"$n\n":"").(!empty("$m")?"$m\n":"").(!empty("$p")?"Postbus $p\n":"").(!empty("$s")?"$s $e\n":"")."$z".((empty("$z") or empty("$l"))?"":" ")."$l";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "BE_NL":
    // Address format: %0(%n\n)%0(%m\n)%0(Postbus %p\n)%0(%s\n)%z%w%l
    $label=(!empty("$n")?"$n\n":"").(!empty("$m")?"$m\n":"").(!empty("$p")?"Postbus $p\n":"").(!empty("$s")?"$s $e\n":"")."$z".((empty("$z") or empty("$l"))?"":" ")."$l";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "BE_FR":
    // Address format: %0(%n\n)%0(%m\n)%0(Boîte Postale %p\n)%0(%s\n)%z%w%l
    $label=(!empty("$n")?"$n\n":"").(!empty("$m")?"$m\n":"").(!empty("$p")?"Boîte Postale $p\n":"").(!empty("$s")?"$s $e\n":"")."$z".((empty("$z") or empty("$l"))?"":" ")."$l";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "BE_DE":
    // Address format: %0(%n\n)%0(%m\n)%0(Postfach %p\n)%0(%s\n)%z%w%l
    $label=(!empty("$n")?"$n\n":"").(!empty("$m")?"$m\n":"").(!empty("$p")?"Postfach $p\n":"").(!empty("$s")?"$s $e\n":"")."$z".((empty("$z") or empty("$l"))?"":" ")."$l";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "CA":
    // Address format: %0(%N\n)%0(%M\n)%0(%S\n)%0(PO BOX %p\n)%L%w%R%,%w%z
    $label=(!empty("$n")?"$N\n":"").(!empty("$m")?"$M\n":"").(!empty("$s")?"$S $e\n":"").(!empty("$p")?"PO BOX $p\n":"")."$L".((empty("$l") or empty("$r$z"))?"":" ")."$r".((empty("$l$r") or empty("$z"))?"":", ")."$z";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "CH":
    // Address format: %0(%m\n)%0(%n\n)%0(P.O. Box %p\n)%0(%s\n)%z%w%l
    $label=(!empty("$m")?"$m\n":"").(!empty("$n")?"$n\n":"").(!empty("$p")?"P.O. Box $p\n":"").(!empty("$s")?"$s $e\n":"")."$z".((empty("$z") or empty("$l"))?"":" ")."$l";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "CH_DE":
    // Address format: %0(%m\n)%0(%n\n)%0(Postfach %p\n)%0(%s\n)%z%w%l
    $label=(!empty("$m")?"$m\n":"").(!empty("$n")?"$n\n":"").(!empty("$p")?"Postfach $p\n":"").(!empty("$s")?"$s $e\n":"")."$z".((empty("$z") or empty("$l"))?"":" ")."$l";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "CH_FR":
    // Address format: %0(%m\n)%0(%n\n)%0(Case postale %p\n)%0(%s\n)%z%w%l
    $label=(!empty("$m")?"$m\n":"").(!empty("$n")?"$n\n":"").(!empty("$p")?"Case postale $p\n":"").(!empty("$s")?"$s $e\n":"")."$z".((empty("$z") or empty("$l"))?"":" ")."$l";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "CH_IT":
    // Address format: %0(%m\n)%0(%n\n)%0(Casella postale %p\n)%0(%s\n)%z%w%l
    $label=(!empty("$m")?"$m\n":"").(!empty("$n")?"$n\n":"").(!empty("$p")?"Casella postale $p\n":"").(!empty("$s")?"$s $e\n":"")."$z".((empty("$z") or empty("$l"))?"":" ")."$l";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "CZ":
    // Address format: %0(%m\n)%0(%n\n)%0(p. p. %p\n)%0(%s\n)%z%w%w%l
    $label=(!empty("$m")?"$m\n":"").(!empty("$n")?"$n\n":"").(!empty("$p")?"p. p. $p\n":"").(!empty("$s")?"$s $e\n":"")."$z".((empty("$z") or empty("$l"))?"":"  ")."$l";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "DE":
    // Address format: %0(%m\n)%0(%n\n)%0(Postfach %p\n)%0(%s\n)%z%w%l
    $label=(!empty("$m")?"$m\n":"").(!empty("$n")?"$n\n":"").(!empty("$p")?"Postfach $p\n":"").(!empty("$s")?"$s $e\n":"")."$z".((empty("$z") or empty("$l"))?"":" ")."$l";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "DE_NDS":
    // Address format: %0(%n\n)%0(- %m -\n)%0(Postfach %p\n)%0(%s\n)%z%w%l
    $label=(!empty("$n")?"$n\n":"").(!empty("$m")?"- $m -\n":"").(!empty("$p")?"Postfach $p\n":"").(!empty("$s")?"$s $e\n":"")."$z".((empty("$z") or empty("$l"))?"":" ")."$l";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "DK":
    // Address format: %0(%n\n)%0(%m\n)%0(%s\n)%0(Postboks %p\n)%z%w%l
    $label=(!empty("$n")?"$n\n":"").(!empty("$m")?"$m\n":"").(!empty("$s")?"$s $e\n":"").(!empty("$p")?"Postboks $p\n":"")."$z".((empty("$z") or empty("$l"))?"":" ")."$l";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "FI":
    // Address format: %0(%m\n)%0(%n\n)%0(PB %p\n)%0(%s\n)%z%w%L
    $label=(!empty("$m")?"$m\n":"").(!empty("$n")?"$n\n":"").(!empty("$p")?"PB $p\n":"").(!empty("$s")?"$s $e\n":"")."$z".((empty("$z") or empty("$l"))?"":" ")."$L";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "FR":
    // Address format: %0(%m\n)%0(%n\n)%0(%s\n)%0(BP %p\n)%z%w%L
    $label=(!empty("$m")?"$m\n":"").(!empty("$n")?"$n\n":"").(!empty("$s")?"$s $e\n":"").(!empty("$p")?"BP $p\n":"")."$z".((empty("$z") or empty("$l"))?"":" ")."$L";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "GL":
    // Address format: %0(%n\n)%0(%m\n)%0(%s\n)%0(Postboks %p\n)%z%w%l
    $label=(!empty("$n")?"$n\n":"").(!empty("$m")?"$m\n":"").(!empty("$s")?"$s $e\n":"").(!empty("$p")?"Postboks $p\n":"")."$z".((empty("$z") or empty("$l"))?"":" ")."$l";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "HU":
    // Address format: %0(%n\n)%0(%l\n)%0(%s\n)%0(PF. %p\n)%0(%z\n)%0(%r\n)
    $label=(!empty("$n")?"$n\n":"").(!empty("$l")?"$l\n":"").(!empty("$s")?"$s $e\n":"").(!empty("$p")?"PF. $p\n":"").(!empty("$z")?"$z\n":"").(!empty("$r")?"$r\n":"");
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "IL":
    // Address format: %0(%n\n)%0(%m\n)%0(ת.ד. %p\n)%0(%s\n)%l%w%z
    $label=(!empty("$n")?"$n\n":"").(!empty("$m")?"$m\n":"").(!empty("$p")?"ת.ד. $p\n":"").(!empty("$s")?"$s $e\n":"")."$l".((empty("$l") or empty("$z"))?"":" ")."$z";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "IT":
    // Address format: %0(%n\n)%0(%m\n)%0(CASELLA POSTALE %p\n)%0(%s\n)%z%w%l
    $label=(!empty("$n")?"$n\n":"").(!empty("$m")?"$m\n":"").(!empty("$p")?"CASELLA POSTALE $p\n":"").(!empty("$s")?"$s $e\n":"")."$z".((empty("$z") or empty("$l"))?"":" ")."$l";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "JP":
    // Address format: %0(%z%w%r\n)%0(%w%l\n)%0(%s\n)%0(%m\n)%0(%n\n)
    $label=(!empty("$z$r")?"$z".((empty("") or empty("$r"))?"":" ")."$r\n":"").(!empty("$l")?((empty("") or empty("$l"))?"":" ")."$l\n":"").(!empty("$s")?"$s $e\n":"").(!empty("$m")?"$m\n":"").(!empty("$n")?"$n\n":"");
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$c\n$label";
    }
    break;
  case "KH":
    // Address format: %0(%m\n)%0(%n\n)%0(%s\n)%0(P.O. Box %p\n)%0(%z%w%L\n)%r
    $label=(!empty("$m")?"$m\n":"").(!empty("$n")?"$n\n":"").(!empty("$s")?"$s $e\n":"").(!empty("$p")?"P.O. Box $p\n":"").(!empty("$z$l")?"$z".((empty("") or empty("$l"))?"":" ")."$L\n":"")."$r";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "ME":
    // Address format: %0(%m\n)%0(%n\n)%0(%s\n)%0(poštanski fah %p\n)%z%w%l
    $label=(!empty("$m")?"$m\n":"").(!empty("$n")?"$n\n":"").(!empty("$s")?"$s $e\n":"").(!empty("$p")?"poštanski fah $p\n":"")."$z".((empty("$z") or empty("$l"))?"":" ")."$l";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "ME_SR":
    // Address format: %0(%m\n)%0(%n\n)%0(%s\n)%0(поштански фах %p\n)%z%w%l
    $label=(!empty("$m")?"$m\n":"").(!empty("$n")?"$n\n":"").(!empty("$s")?"$s $e\n":"").(!empty("$p")?"поштански фах $p\n":"")."$z".((empty("$z") or empty("$l"))?"":" ")."$l";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "NA":
    // Address format: %0(%m\n)%0(%n\n)%0(P.O. Box %p\n)%l
    $label=(!empty("$m")?"$m\n":"").(!empty("$n")?"$n\n":"").(!empty("$p")?"P.O. Box $p\n":"")."$l";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "NL":
    // Address format: %0(%n\n)%0(%m\n)%0(Postbus %p\n)%0(%s\n)%z%w%w%l
    $label=(!empty("$n")?"$n\n":"").(!empty("$m")?"$m\n":"").(!empty("$p")?"Postbus $p\n":"").(!empty("$s")?"$s $e\n":"")."$z".((empty("$z") or empty("$l"))?"":"  ")."$l";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "NO":
    // Address format: %0(%m\n)%0(%n\n)%0(Postboks %p\n)%0(%s\n)%z%w%w%L
    $label=(!empty("$m")?"$m\n":"").(!empty("$n")?"$n\n":"").(!empty("$p")?"Postboks $p\n":"").(!empty("$s")?"$s $e\n":"")."$z".((empty("$z") or empty("$l"))?"":"  ")."$L";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "RS":
    // Address format: %0(%m\n)%0(%n\n)%0(%s\n)%0(поштански фах %p\n)%z%w%l
    $label=(!empty("$m")?"$m\n":"").(!empty("$n")?"$n\n":"").(!empty("$s")?"$s $e\n":"").(!empty("$p")?"поштански фах $p\n":"")."$z".((empty("$z") or empty("$l"))?"":" ")."$l";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "RS_SR":
    // Address format: %0(%m\n)%0(%n\n)%0(%s\n)%0(poštanski fah %p\n)%z%w%l
    $label=(!empty("$m")?"$m\n":"").(!empty("$n")?"$n\n":"").(!empty("$s")?"$s $e\n":"").(!empty("$p")?"poštanski fah $p\n":"")."$z".((empty("$z") or empty("$l"))?"":" ")."$l";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "SE":
    // Address format: %0(%n\n)%0(%m\n)%0(Box %p\n)%0(%s\n)%z%w%w%L
    $label=(!empty("$n")?"$n\n":"").(!empty("$m")?"$m\n":"").(!empty("$p")?"Box $p\n":"").(!empty("$s")?"$s $e\n":"")."$z".((empty("$z") or empty("$l"))?"":"  ")."$L";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  case "US":
    // Address format: %0(%n\n)%0(%m\n)%0(%s\n)%0(PO BOX %p\n)%l%,%w%r%w%z
    $label=(!empty("$n")?"$n\n":"").(!empty("$m")?"$m\n":"").(!empty("$s")?"$s $e\n":"").(!empty("$p")?"PO BOX $p\n":"")."$l".((empty("$l") or empty("$r$z"))?"":", ")."$r".((empty("$l$r") or empty("$z"))?"":" ")."$z";
    if ((!empty($c)) and ($cc!=$hcc)) {
         $label="$label\n$c";
    }
    break;
  default:
    echo "Unknown countrycode $cc.\n";
    echo "Please add this addressformat.\n";
  }
  return $label;
}
?>
_______________________________________________
Devel mailing list
[email protected]
http://mailman.owncloud.org/mailman/listinfo/devel

Reply via email to