[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] CVS: addressbook/inc/export Outlook_CSV_-_Dutch,NONE,
From: |
Miles Lott <address@hidden> |
Subject: |
[Phpgroupware-cvs] CVS: addressbook/inc/export Outlook_CSV_-_Dutch,NONE,1.1 Outlook_CSV_-_Espa駉l,NONE,1.1 |
Date: |
Sat, 24 Aug 2002 13:10:32 -0400 |
Update of /cvsroot/phpgroupware/addressbook/inc/export
In directory subversions:/tmp/cvs-serv22405/export
Added Files:
Outlook_CSV_-_Dutch Outlook_CSV_-_Espa帽ol
Log Message:
Remove bad column from spanish import, create Dutch and Spanish export files
--- NEW FILE ---
<?php
// Dit bestand definieert enkele functies en een associatieve array.
// De sleutels van de array komen overeen met een hoofding in het te
// importeren bestand en de waarden van de array zullen gebruikt worden
// bij het aanmaken van het uitvoerbestand.
//
// Een uit Outlook ge毛xporteerd bestand ziet er uit als volgt:
//
// Titel<tab>Voornaam<tab>Middelste naam<tab>Achternaam<tab>...
// <tab>Jan<tab><tab>Janssens<tab>...
//
// Hierin duidt de eerste lijn de betekenis aan van elk (optioneel) veld.
// Dit is wat opgezocht zal worden voor de sleutel.
//
// De array hoeft in geen specifieke volgorde te staan en alle velden die
// niet gedefini毛erd zijn, zullen ook niet worden omgezet.
// Als de waarde gelijk is aan '+', zal ze worden toegevoegd aan het vorige
// veld en alle tekst na de '+' zal worden toegevoegd v贸贸r de waarde.
// Zo zal bijvoorbeeld het volgende een komma en een spatie toevoegen tussen
// Achternaam en Voornaam en het resultaat bewaren in Volledige naam:
//
// array('Achternaam' => 'Volledige naam','Voornaam' => '+, ');
//
// Begin met een '#' symbool om een komma-gescheiden lijst om te zetten naar
// een reeks gelijke velden.
class import_conv
{
var $currentrecord = array(); //used for buffering to allow uid
lines to go first
var $id;
var $type = 'csv';
var $import = array(
'title' => 'Titel',
'n_given' => 'Voornaam',
'n_middle' => 'Middelste naam',
'n_family' => 'Achternaam',
'n_suffix' => 'Achtervoegsel',
'org_name' => 'Bedrijf', //objectclass: organization
'org_unit' => 'Afdeling', //objectclass:
organizationalPerson
'title' => 'Functie', //objectclass:
organizationalPerson
'adr_one_street' => 'Werkadres, straat',
'address2' => 'Werkadres 2, straat',
'address3' => 'Werkadres 3, straat',
'adr_one_locality' => 'Werkadres, plaats',
'adr_one_region' => 'Werkadres, provincie',
'adr_one_postalcode' => 'Werkadres, postcode',
'adr_one_countryname' => 'Werkadres, land',
'adr_two_street' => 'Huisadres, straat',
'adr_two_locality' => 'Huisadres, plaats',
'adr_two_region' => 'Huisadres, provincie',
'adr_two_postalcode' => 'Huisadres, postcode',
'adr_two_countryname' => 'Huisadres, land',
'tel_msg' => 'Telefoon assistent',
'tel_fax' => 'Fax op werk',
'tel_work' => 'Telefoon op werk',
'ophone' => 'Telefoon op werk 2',
'tel_car' => 'Autotelefoon',
'tel_home' => 'Telefoon thuis',
'tel_isdn' => 'ISDN',
'tel_cell' => 'Mobiele telefoon', //newPilotPerson
'tel_pager' => 'Pager',
'bday' => 'Verjaardag',
'email' => 'E-mailadres',
'email_home' => 'E-mailadres 2',
'note' => 'Notities',
'url' => 'Webpagina'
);
function import_start_file($buffer)
{
return $buffer;
}
function import_start_record($buffer)
{
$top=array();
++$this->id;
$this->currentrecord = $top;
return $buffer;
}
function import_new_attrib($buffer,$name,$value)
{
$value = trim($value);
$value = str_replace('\n','<BR>',$value);
$value = str_replace('\r','',$value);
$this->currentrecord += array($name => $value);
return $buffer;
}
function import_end_record($buffer)
{
$buffer[$this->id]='';
while ( list($name, $value) =
each($this->currentrecord))
{
$buffer[$this->id][$name] = $value;
//echo '<br>'.$name.' => '.$value;
}
return $buffer;
}
function import_end_file($buffer,$access='private',$cat_id=0)
{
$contacts = CreateObject('phpgwapi.contacts');
//echo '<br>';
for ($i=1;$i<=count($buffer);$i++)
{
while ( list($name,$value) = @each($buffer[$i])
)
{
//echo '<br>'.$i.': '.$name.' =>
'.$value;
$entry[$i][$name] = $value;
}
$entry[$i]['email_type'] = 'INTERNET';
$entry[$i]['email_home_type'] = 'INTERNET';
$entry[$i]['adr_one_type'] = 'intl';
$entry[$i]['adr_two_type'] = 'intl';
//echo '<br>';
$contacts->add($GLOBALS['phpgw_info']['user']['account_id'],$entry[$i],$access,$cat_id);
}
$num = $i - 1;
return lang('Successfully imported x records into your
addressbook.',$num);
}
}
?>
--- NEW FILE ---
<?php
// This file defines a set of functions and an associative array.
// The key of the array corresponds to a header in the source
// import file and the value of the array item will be used in
// the creation of the output file.
//
// An exported Outlook file looks like this:
//
// Title<tab>First Name<tab>Middle Name<tab>Last Name<tab>...
// <tab>Patrick<tab><tab>Walsh<tab>...
//
// Where the first line explains each optional field. This is what
// will be looked up in the key.
//
// The array need not be in any order and any fields not defined will
// not be transferred. If the val='+', the value will be appended to
// the previous field and any text after the '+' will be appended
// before the value. For example, the following would add a comma and
// a space between LastName and FirstName and store it in FullName:
//
// array('LastName' => 'FullName','FirstName' => '+, ');
//
// Also start with a '#' symbol and a comma separated list will be
// turned into a number of the same entries.
class export_conv
{
var $currentrecord = array(); //used for buffering to allow uid
lines to go first
var $id;
var $type = 'csv';
var $export = array(
'n_prefix' => 'Tratamiento',
'title' => 'Puesto',
'n_given' => 'Nombre',
'n_family' => 'Apellidos',
'n_suffix' => 'Sufijo',
'org_name' => 'Organizaci贸n',
'org_unit' => 'Departamento',
'adr_one_street' => 'Calle del Trabajo',
'address2' => 'Calle del trabajo 2',
'address3' => 'Calle del trabajo 3',
'adr_one_locality' => 'Ciudad de trabajo',
'adr_one_region' => 'Provincia o estado de
trabajo',
'adr_one_postalcode' => 'C贸digo postal del trabajo',
'adr_one_countryname' => 'Pa铆s de trabajo',
'adr_two_street' => 'Calle del domicilio',
'adr_two_locality' => 'Ciudad de residencia' ,
'adr_two_region' => 'Provincia o estado de
residencia',
'adr_two_postalcode' => 'C贸digo postal de residencia',
'adr_two_countryname' => 'Pa铆s de residencia',
'tel_msg' => 'Tel茅fono del ayudante',
'tel_fax' => 'Fax del trabajo',
'tel_work' =>'Tel茅fono del trabajo',
'ophone' => 'Tel茅fono del trabajo 2',
'tel_car' => 'Tel茅fono del autom贸vil',
'tel_home' => 'Particular',
'tel_isdn' => 'RDSI',
'tel_cell' => 'M贸vil',
'tel_pager' => 'Localizador',
'bday' => 'Cumplea帽os',
'email' => 'Direcci贸n de correo electr贸nico',
'email_home' => 'Direcci贸n de correo electr贸nico 2',
'note' => 'Notas',
'url' => 'P谩gina Web'
);
// This will store the contacts object
var $contacts = '';
function export_start_file($buffer,$ncat_id='')
{
$this->id=-1;
if ($ncat_id)
{
$filter = 'tid=n,cat_id='.$ncat_id;
}
else
{
$filter = 'tid=n';
}
$this->contacts = CreateObject('phpgwapi.contacts');
$tmp =
$this->contacts->read('','',array('id'=>'id'),'',$filter);
for ($i=0;$i<count($tmp);$i++)
{
$this->ids[$i] = $tmp[$i]['id'];
}
// $ids is now an array of all id's for this user, e.g.
$ids[0] = 21, etc...
// $buffer is still empty
return $buffer;
}
// Read each entry
function export_start_record($buffer)
{
$this->id++;
$top =
$this->contacts->read_single_entry($this->ids[$this->id],$this->qfields);
$this->currentrecord = $top[0];
return $buffer;
}
// Read each attribute, populate buffer
// name/value are the fields from the export array above
function export_new_attrib($buffer,$name,$value)
{
if ($this->export[$name])
{
$buffer[$this->id][$this->export[$name]] =
$value;
//echo '<br>'.$this->id.' -
'.$this->export[$name].': '.$buffer[$this->id][$this->export[$name]];
}
return $buffer;
}
// Tack on some extra values
function export_end_record($buffer)
{
return $buffer;
}
function export_end_file($buffer)
{
// Build the header for the file (field list)
reset($this->export);
while (list($name,$value)=each($this->export))
{
$entries .= $value . ',';
}
$entries = substr($entries,0,-1);
$entries .= "\r\n";
// Now add all the data
reset($this->ids);
for ($i=0;$i<count($this->ids);$i++)
{
reset($this->export);
while (list($name,$value)=each($this->export))
{
$entries .= $buffer[$i][$value] . ',';
}
$entries = substr($entries,0,-1);
$entries .= "\r\n";
}
$buffer = $entries;
return $buffer;
}
}
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] CVS: addressbook/inc/export Outlook_CSV_-_Dutch,NONE,1.1 Outlook_CSV_-_Espa駉l,NONE,1.1,
Miles Lott <address@hidden> <=