From d92a2315cb748825a6f92178adf706356fe03a99 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 15 Oct 2012 21:28:33 +0000 Subject: [PATCH] Some documentation updates --- importexport/doc/README_developers.txt | 25 +++++++++++-------- .../inc/class.importexport_import_ui.inc.php | 16 +++++++++++- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/importexport/doc/README_developers.txt b/importexport/doc/README_developers.txt index f5cb7e14a6..9f19250559 100644 --- a/importexport/doc/README_developers.txt +++ b/importexport/doc/README_developers.txt @@ -10,17 +10,21 @@ applications and its specific definitions. Attending importeport framework with you application is pretty easy. You just need to have your plugins in files which start with -class.import_ or -class.export_ +class._import_ or +class._export_ in -EGW_INCLUDE_ROOT/YourApp/importexport/ +EGW_INCLUDE_ROOT/YourApp/inc/ -These pulugins only need to implement the corresponding interface +These plugins only need to implement the corresponding interface EGW_INCLUDE_ROOT/importexport/inc/class.iface_import_plugin.inc.php or EGW_INCLUDE_ROOT/importexport/inc/class.iface_export_plugin.inc.php Thats all, pretty easy, isn't it? +For CSV, just extend importexport/inc/class.importexport_basic_import_csv.inc.php +and override the init(), import_record() and action() methods. You'll get common +functionallity for very little extra effort. + == definitions == The bases of all imports and exports is the '''definition'''. @@ -34,24 +38,23 @@ That means, that your plugin can not work w.o. a definition. However, your plugi need to parse that definition. This is up to you. Definitions can be created in admin->importexport->define{im|ex}ports. They are stored -in the databasae but could be {im|ex}ported itselve. +in the database but can also be {im|ex}ported to / from other systems. -Definitions (as xml files) residing in the folder +Definitions (as xml files) residing in the folder will be imported at apps installation time automatically. == import == == export == -Starting an export is as easy as just putting a button in your app with: -onClick="importexport.uiexport.export_dialog&appname=&have_selection=<{true|false}>" -If parameter "have_selection" if true, export askes (javascript) opener.get_selection();to retreave -a list of identifiers of selected records. +Starting an export is as easy as using the sidebox button. Once your plugins are detected +(they are cached and refreshed hourly), Import/Export will add the needed entries to the sidebox. +Alternatively, you can go to Admin -> Define Imports | Exports. NOTE: javascript function get_selection() is the only function which is not part of an interface yet. ==Discussion of interfaces== -To make live easy there are several general plugins which can be found +To make life easy there are several general plugins which can be found EGW_INCLUDE_ROOT/importexport/inc/import_... EGW_INCLUDE_ROOT/importexport/inc/export_... diff --git a/importexport/inc/class.importexport_import_ui.inc.php b/importexport/inc/class.importexport_import_ui.inc.php index b76477efd4..748c4cdbe0 100644 --- a/importexport/inc/class.importexport_import_ui.inc.php +++ b/importexport/inc/class.importexport_import_ui.inc.php @@ -248,8 +248,14 @@ } /** - * Display the interpretation of the file for dry runs + * Return an interpretation of the file for dry runs * + * If the plugin has a preview, use that. Otherwise, try a simple CSV => HTML table + * + * @param importexport_iface_import_plugin $plugin Instance of plugin to be used + * @param resource $stream + * @param importexport_definition $definition + * @return String HTML fragment illustrating how the data will be understood by egw */ protected function preview(importexport_iface_import_plugin &$plugin, &$stream, importexport_definition &$definition_obj) { @@ -284,6 +290,14 @@ * Simple check to see if the file at least matches the definition * * Checks that column headers match + * @note Currently only works for CSV + * + * @param resource $file + * @param importexport_definition $definition + * @param Array message Will be filled with any warnings or errors detected + * @param String Temporary file location, so user doesn't have to keep uploading + * + * @return boolean Ok to import */ public static function check_file(&$file, &$definition, &$message = array(), $dst_file = false) {