Adjust banner, cleanup formatting and use foreach() where possible

This commit is contained in:
Miles Lott 2004-01-31 19:48:34 +00:00
parent a7b2645694
commit 6024c9331b

View File

@ -1,12 +1,9 @@
<?php <?php
/**************************************************************************\ /**************************************************************************\
* phpGroupWare API - VCard import/export class * * eGroupWare API - VCard import/export class *
* This file written by Miles Lott <milosch@phpgroupware.org> * * This file written by Miles Lott <milos@groupwhere.org> *
* Parse vcards->contacts class fields, and vice-versa * * Parse vcards->contacts class fields, and vice-versa *
* Copyright (C) 2001 Miles Lott * * Copyright (C) 2001-2004 Miles Lott *
* -------------------------------------------------------------------------*
* This library is part of the phpGroupWare API *
* http://www.phpgroupware.org/api *
* ------------------------------------------------------------------------ * * ------------------------------------------------------------------------ *
* This library is free software; you can redistribute it and/or modify it * * This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by * * under the terms of the GNU Lesser General Public License as published by *
@ -133,8 +130,7 @@
} }
if($name && $value) if($name && $value)
{ {
reset($this->import); foreach($this->import as $fname => $fvalue)
while ( list($fname,$fvalue) = each($this->import) )
{ {
if(strstr(strtolower($name), $this->import[$fname])) if(strstr(strtolower($name), $this->import[$fname]))
{ {
@ -198,7 +194,7 @@
'address3' => 'address3' 'address3' => 'address3'
); );
while (list($fname,$fvalue) = each($all_fields)) foreach($all_fields as $fname => $fvalue)
{ {
if($buffer[$fname]) if($buffer[$fname])
{ {
@ -217,7 +213,8 @@
function _parse_in($buffer) function _parse_in($buffer)
{ {
/* Following is a lot of pain and little magic */ /* Following is a lot of pain and little magic */
while ( list($name,$value) = @each($buffer) ) settype($buffer,'array');
foreach($buffer as $name => $value)
{ {
$field = split(';',$name); $field = split(';',$name);
$field[0] = ereg_replace("A\.",'',$field[0]); $field[0] = ereg_replace("A\.",'',$field[0]);
@ -417,7 +414,6 @@
case 'TEL': // RB 2001/05/07 added for Lotus Organizer ueses TEL;{WORK|HOME};{VOICE|FAX}[;PREF] case 'TEL': // RB 2001/05/07 added for Lotus Organizer ueses TEL;{WORK|HOME};{VOICE|FAX}[;PREF]
if($field[2] == 'FAX' && ($field[1] == 'WORK' || $field[i] == 'HOME')) if($field[2] == 'FAX' && ($field[1] == 'WORK' || $field[i] == 'HOME'))
{ {
/* TODO This is PHP4 only */
array_shift($field); // --> ignore the WORK or HOME if FAX follows, HOME;FAX and HOME;TEL are maped later array_shift($field); // --> ignore the WORK or HOME if FAX follows, HOME;FAX and HOME;TEL are maped later
} }
switch($field[1]) switch($field[1])
@ -559,9 +555,8 @@
switch($field[0]) switch($field[0])
{ {
case 'N': case 'N':
reset($this->names);
$j=0; $j=0;
while(list($myname,$myval) = each($this->names) ) foreach($this->names as $myname => $myval)
{ {
$namel = 'n_' . $myname; $namel = 'n_' . $myname;
$entry[$namel] = $values[$j]; $entry[$namel] = $values[$j];
@ -629,7 +624,8 @@
// Takes an array of contacts class fields/values, turns it into a vcard string: // Takes an array of contacts class fields/values, turns it into a vcard string:
// //
// for ($i=0;$i<count($buffer);$i++) { // for($i=0;$i<count($buffer);$i++)
// {
// $vcards .= $this->vcard->out($buffer[$i]); // $vcards .= $this->vcard->out($buffer[$i]);
// } // }
// //
@ -640,8 +636,7 @@
$header .= 'VERSION:2.1' . "\n"; $header .= 'VERSION:2.1' . "\n";
$header .= 'X-EGROUPWARE-FILE-AS:eGroupWare.org' . "\n"; $header .= 'X-EGROUPWARE-FILE-AS:eGroupWare.org' . "\n";
reset($this->export); foreach($this->export as $name => $value)
while ( list($name,$value) = each($this->export) )
{ {
if(!empty($buffer[$value])) if(!empty($buffer[$value]))
{ {