How to use Translation's".
"Translations enable you to change / adapt the content of each CSV field for your needs.
".
"General syntax is: pattern1 ${ASep} replacement1 ${PSep} ... ${PSep} patternN ${ASep} replacementN
".
"If the pattern-part of a pair is ommited it will match everything ('^.*$'), which is only ".
"usefull for the last pair, as they are worked from left to right.
".
"First example: 1${ASep}private${PSep}public
".
"This will translate a '1' in the CSV field to 'privat' and everything else to 'public'.
".
"Patterns as well as the replacement can be regular expressions (the replacement is done via ereg_replace). ".
"If, after all replacements, the value starts with an '@' the whole value is eval()'ed, so you ".
"may use all php, phpgw plus your own functions. This is quiet powerfull, but circumvents all ACL.
".
"Example using regular expressions and '@'-eval():
$mktime_lotus
".
"It will read a date of the form '2001-05-20 08:00:00.00000000000000000' (and many more, see the regular expr.). ".
"The [ .:-]-separated fields are read and assigned in different order to @mktime(). Please note to use ".
"${VPre} insted of a backslash (I couldn't get backslash through all the involved templates and forms.) ".
"plus the field-number of the pattern.
".
"In addintion to the fields assign by the pattern of the reg.exp. you can use all other CSV-fields, with the ".
"syntax ${CPre}CSV-FIELDNAME$CPos. Here is an example:
".
".+$ASep${CPre}Company$CPos: ${CPre}NFamily$CPos, ${CPre}NGiven$CPos$PSep${CPre}NFamily$CPos, ${CPre}NGiven$CPos
".
"It is used on the CSV-field 'Company' and constructs a something like Company: FamilyName, GivenName or ".
"FamilyName, GivenName if 'Company' is empty.
".
"You can use the 'No CSV #'-fields to assign csv-values to more than on field, the following example uses the ".
"csv-field 'Note' (which gots already assingned to the description) and construct a short subject: ".
"@substr(${CPre}Note$CPos,0,60).' ...'
".
"Their is one important user-function for the Info Log:
".
"@addr_id(${CPre}NFamily$CPos,${CPre}NGiven$CPos,${CPre}Company$CPos) ".
"searches the addressbook for an address and returns the id if it founds an exact match of at least ".
"NFamily AND (NGiven OR Company). This is necessary to link your imported InfoLog-entrys ".
"with the addressbook.
".
"@cat_id(Cat1,...,CatN) returns a (','-separated) list with the cat_id's. If a category isn't found, it ".
"will be automaticaly added.
".
"I hope that helped to understand the features, if not ask.";
$GLOBALS['phpgw']->template->set_var('help_on_trans',lang($help_on_trans)); // I don't think anyone will translate this
break;
case 'import':
$fp=fopen($csvfile,"r");
$csv_fields = fgetcsv($fp,8000,$fieldsep);
$csv_fields[] = 'no CSV 1'; // eg. for static assignments
$csv_fields[] = 'no CSV 2';
$csv_fields[] = 'no CSV 3';
$addr_fields = array_diff($addr_fields,array( '' )); // throw away empty / not assigned entrys
$defaults = array();
while (list($csv_idx,$addr) = each($addr_fields))
{ // convert $trans[$csv_idx] into array of pattern => value
$defaults[$csv_fields[$csv_idx]] = $addr;
if ($trans[$csv_idx])
{
$defaults[$csv_fields[$csv_idx]] .= $PSep.$trans[$csv_idx];
}
}
$GLOBALS['phpgw']->preferences->read_repository();
$GLOBALS['phpgw']->preferences->add('addressbook','cvs_import',$defaults);
$GLOBALS['phpgw']->preferences->save_repository(True);
$log = "