- adopted export plugin to new interface

- extended outlook export definitions
This commit is contained in:
Cornelius Weiß 2007-06-09 15:38:30 +00:00
parent 7a3e571376
commit e34fb944a5
7 changed files with 41 additions and 37 deletions

View File

@ -27,8 +27,8 @@ class export_contacts_csv implements iface_export_plugin {
* *
* @param egw_record $_definition * @param egw_record $_definition
*/ */
public static function export( $_stream, $_charset, definition $_definition) { public function export( $_stream, definition $_definition) {
$options = $_definition->options; $options = $_definition->plugin_options;
$uicontacts = new uicontacts(); $uicontacts = new uicontacts();
$selection = array(); $selection = array();
@ -41,8 +41,7 @@ class export_contacts_csv implements iface_export_plugin {
$selection = explode(',',$options['selection']); $selection = explode(',',$options['selection']);
} }
$options['begin_with_fieldnames'] = true; $export_object = new export_csv($_stream, (array)$options);
$export_object = new export_csv($_stream, $_charset, (array)$options);
$export_object->set_mapping($options['mapping']); $export_object->set_mapping($options['mapping']);
// $options['selection'] is array of identifiers as this plugin doesn't // $options['selection'] is array of identifiers as this plugin doesn't
@ -87,7 +86,7 @@ class export_contacts_csv implements iface_export_plugin {
* *
* @return string html * @return string html
*/ */
public static function get_options_etpl() { public function get_options_etpl() {
return 'addressbook.export_csv_options'; return 'addressbook.export_csv_options';
} }
@ -95,7 +94,7 @@ class export_contacts_csv implements iface_export_plugin {
* returns slectors of this plugin via xajax * returns slectors of this plugin via xajax
* *
*/ */
public static function get_selectors_etpl() { public function get_selectors_etpl() {
return '<b>Selectors:</b>'; return '<b>Selectors:</b>';
} }
} }

View File

@ -22,13 +22,10 @@ class import_contacts_csv implements iface_import_plugin {
private static $plugin_options = array( private static $plugin_options = array(
'fieldsep', // char 'fieldsep', // char
'charset', // string 'charset', // string
'addressbook', //char 'contact_owner', // int
'owner', // comma seperated list of int 'field_conversion', // array( $csv_col_num => conversion)
'csv_fields', // array( $csv_col_num => csv_field_name)
'field_mapping', // array( $csv_col_num => adb_filed) 'field_mapping', // array( $csv_col_num => adb_filed)
'field_translation', // array( $csv_col_num => translation)
'has_header_line', //bool 'has_header_line', //bool
'max', // int
'conditions', /* => array containing condition arrays: 'conditions', /* => array containing condition arrays:
'type' => 0, // exists 'type' => 0, // exists
'string' => '#kundennummer', 'string' => '#kundennummer',
@ -46,7 +43,7 @@ class import_contacts_csv implements iface_import_plugin {
/** /**
* actions wich could be done to data entries * actions wich could be done to data entries
*/ */
private static $actions = array( 'none', 'update', 'insert', 'delte', ); private static $actions = array( 'none', 'update', 'insert', 'delete', );
/** /**
* conditions for actions * conditions for actions
@ -73,7 +70,7 @@ class import_contacts_csv implements iface_import_plugin {
* @param string $_charset * @param string $_charset
* @param definition $_definition * @param definition $_definition
*/ */
public function import( $_stream, $_charset, definition $_definition ) { public function import( $_stream, definition $_definition ) {
$import_csv = new import_csv( $_stream, array( $import_csv = new import_csv( $_stream, array(
'fieldsep' => $_definition->plugin_options['fieldsep'], 'fieldsep' => $_definition->plugin_options['fieldsep'],
'charset' => $_definition->plugin_options['charset'], 'charset' => $_definition->plugin_options['charset'],
@ -82,23 +79,22 @@ class import_contacts_csv implements iface_import_plugin {
// fetch the addressbook bo // fetch the addressbook bo
$this->bocontacts = CreateObject('addressbook.bocontacts'); $this->bocontacts = CreateObject('addressbook.bocontacts');
// set FieldMapping. Throw away empty / not assigned entrys // set FieldMapping.
$import_csv->mapping = array_diff($_definition->plugin_options['field_mapping'],array('')); $import_csv->mapping = $_definition->plugin_options['field_mapping'];
// renamed from translation to conversion // set FieldConversion
$import_csv->conversion = $_definition->plugin_options['field_conversion'] ? $import_csv->conversion = $_definition->plugin_options['field_conversion'];
$_definition->plugin_options['field_conversion'] :
$_definition->plugin_options['field_translation'];
//check if file has a header line //check if file has a header line
if ($_definition->plugin_options['has_header_line']) { if ($_definition->plugin_options['has_header_line']) {
$record = $import_csv->get_record(); $record = $import_csv->get_record();
} }
// TODO: Throw away spechial chars ? // set contactOwner
// TODO: check conversion: if ( isset( $_definition->plugin_options['contact_owner'] )
// - is not existing cat created? && abs( $_definition->plugin_options['contact_owner'] > 0 ) ) {
// - usermapping? $record['contact_owner'] = $_definition->plugin_options['contact_owner'];
}
while ( $record = $import_csv->get_record() ) { while ( $record = $import_csv->get_record() ) {
@ -136,7 +132,7 @@ class import_contacts_csv implements iface_import_plugin {
} }
} else { } else {
// unconditional insert // unconditional insert
$this->action( 'insert', $values ); $this->action( 'insert', $record );
} }
} }
} }
@ -149,7 +145,6 @@ class import_contacts_csv implements iface_import_plugin {
* @return bool success or not * @return bool success or not
*/ */
private function action ( $_action, $_data ) { private function action ( $_action, $_data ) {
print_r($_data);
switch ($_action) { switch ($_action) {
case 'none' : case 'none' :
return true; return true;

View File

@ -12,9 +12,11 @@
<entry type="string" name="plugin">export_contacts_csv</entry> <entry type="string" name="plugin">export_contacts_csv</entry>
<entry type="string" name="type">export</entry> <entry type="string" name="type">export</entry>
<entry type="array" name="allowed_users"> <entry type="array" name="allowed_users">
<entry type="string" name="0">-1</entry> <entry type="string" name="0">Default</entry>
</entry> </entry>
<entry type="array" name="plugin_options"> <entry type="array" name="plugin_options">
<entry type="boolean" name="begin_with_fieldnames">TRUE</entry>
<entry type="string" name="charset">iso-8859-15</entry>
<entry type="array" name="mapping"> <entry type="array" name="mapping">
<entry type="string" name="n_prefix">Title</entry> <entry type="string" name="n_prefix">Title</entry>
<entry type="string" name="n_given">First Name</entry> <entry type="string" name="n_given">First Name</entry>
@ -52,7 +54,7 @@
<entry type="string" name="note">Notes</entry> <entry type="string" name="note">Notes</entry>
</entry> </entry>
</entry> </entry>
<entry type="string" name="owner">0</entry> <entry type="string" name="owner">admin</entry>
<entry type="string" name="description">Exports selected contacts for english version of MS Outlook</entry> <entry type="string" name="description">Exports selected contacts for english version of MS Outlook</entry>
</entry> </entry>
</entry> </entry>

View File

@ -12,9 +12,11 @@
<entry type="string" name="plugin">export_contacts_csv</entry> <entry type="string" name="plugin">export_contacts_csv</entry>
<entry type="string" name="type">export</entry> <entry type="string" name="type">export</entry>
<entry type="array" name="allowed_users"> <entry type="array" name="allowed_users">
<entry type="string" name="0">-1</entry> <entry type="string" name="0">Default</entry>
</entry> </entry>
<entry type="array" name="plugin_options"> <entry type="array" name="plugin_options">
<entry type="boolean" name="begin_with_fieldnames">TRUE</entry>
<entry type="string" name="charset">iso-8859-15</entry>
<entry type="array" name="mapping"> <entry type="array" name="mapping">
<entry type="string" name="title">Tehtävänimike</entry> <entry type="string" name="title">Tehtävänimike</entry>
<entry type="string" name="n_given">Etunimi</entry> <entry type="string" name="n_given">Etunimi</entry>
@ -51,7 +53,7 @@
<entry type="string" name="Notes">Muistilaput</entry> <entry type="string" name="Notes">Muistilaput</entry>
</entry> </entry>
</entry> </entry>
<entry type="string" name="owner">0</entry> <entry type="string" name="owner">admin</entry>
<entry type="NULL" name="description"/> <entry type="NULL" name="description"/>
</entry> </entry>
</entry> </entry>

View File

@ -12,9 +12,11 @@
<entry type="string" name="plugin">export_contacts_csv</entry> <entry type="string" name="plugin">export_contacts_csv</entry>
<entry type="string" name="type">export</entry> <entry type="string" name="type">export</entry>
<entry type="array" name="allowed_users"> <entry type="array" name="allowed_users">
<entry type="string" name="0">-1</entry> <entry type="string" name="0">Default</entry>
</entry> </entry>
<entry type="array" name="plugin_options"> <entry type="array" name="plugin_options">
<entry type="boolean" name="begin_with_fieldnames">TRUE</entry>
<entry type="string" name="charset">iso-8859-15</entry>
<entry type="array" name="mapping"> <entry type="array" name="mapping">
<entry type="string" name="title">Fonction</entry> <entry type="string" name="title">Fonction</entry>
<entry type="string" name="n_given">Prénom</entry> <entry type="string" name="n_given">Prénom</entry>
@ -51,7 +53,7 @@
<entry type="string" name="note">Notes</entry> <entry type="string" name="note">Notes</entry>
</entry> </entry>
</entry> </entry>
<entry type="string" name="owner">0</entry> <entry type="string" name="owner">admin</entry>
<entry type="NULL" name="description"/> <entry type="NULL" name="description"/>
</entry> </entry>
</entry> </entry>

View File

@ -12,9 +12,11 @@
<entry type="string" name="plugin">export_contacts_csv</entry> <entry type="string" name="plugin">export_contacts_csv</entry>
<entry type="string" name="type">export</entry> <entry type="string" name="type">export</entry>
<entry type="array" name="allowed_users"> <entry type="array" name="allowed_users">
<entry type="string" name="0">-1</entry> <entry type="string" name="0">Default</entry>
</entry> </entry>
<entry type="array" name="plugin_options"> <entry type="array" name="plugin_options">
<entry type="boolean" name="begin_with_fieldnames">TRUE</entry>
<entry type="string" name="charset">iso-8859-15</entry>
<entry type="array" name="mapping"> <entry type="array" name="mapping">
<entry type="string" name="n_prefix">Anrede</entry> <entry type="string" name="n_prefix">Anrede</entry>
<entry type="string" name="n_given">Vorname</entry> <entry type="string" name="n_given">Vorname</entry>
@ -52,7 +54,7 @@
<entry type="string" name="note">Notizen</entry> <entry type="string" name="note">Notizen</entry>
</entry> </entry>
</entry> </entry>
<entry type="string" name="owner">0</entry> <entry type="string" name="owner">admin</entry>
<entry type="string" name="description">Exportiert ausgewählte Kontakte zur Datenübernahme in die deutsche Version von MS Outlook</entry> <entry type="string" name="description">Exportiert ausgewählte Kontakte zur Datenübernahme in die deutsche Version von MS Outlook</entry>
</entry> </entry>
</entry> </entry>

View File

@ -12,9 +12,11 @@
<entry type="string" name="plugin">export_contacts_csv</entry> <entry type="string" name="plugin">export_contacts_csv</entry>
<entry type="string" name="type">export</entry> <entry type="string" name="type">export</entry>
<entry type="array" name="allowed_users"> <entry type="array" name="allowed_users">
<entry type="string" name="0">-1</entry> <entry type="string" name="0">Default</entry>
</entry> </entry>
<entry type="array" name="plugin_options"> <entry type="array" name="plugin_options">
<entry type="boolean" name="begin_with_fieldnames">TRUE</entry>
<entry type="string" name="charset">iso-8859-15</entry>
<entry type="array" name="mapping"> <entry type="array" name="mapping">
<entry type="string" name="title">Posizione</entry> <entry type="string" name="title">Posizione</entry>
<entry type="string" name="n_prefix">Titolo</entry> <entry type="string" name="n_prefix">Titolo</entry>
@ -52,7 +54,7 @@
<entry type="string" name="note">Notes</entry> <entry type="string" name="note">Notes</entry>
</entry> </entry>
</entry> </entry>
<entry type="string" name="owner">0</entry> <entry type="string" name="owner">admin</entry>
<entry type="NULL" name="description"/> <entry type="NULL" name="description"/>
</entry> </entry>
</entry> </entry>