Some documentation updates

This commit is contained in:
Nathan Gray 2012-10-15 21:28:33 +00:00
parent 8c74ba7383
commit d92a2315cb
2 changed files with 29 additions and 12 deletions

View File

@ -10,17 +10,21 @@ applications and its specific definitions.
Attending importeport framework with you application is pretty easy. Attending importeport framework with you application is pretty easy.
You just need to have your plugins in files which start with You just need to have your plugins in files which start with
class.import_<name> or class.<app>_import_<name> or
class.export_<name> class.<app>_export_<name>
in 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_import_plugin.inc.php or
EGW_INCLUDE_ROOT/importexport/inc/class.iface_export_plugin.inc.php EGW_INCLUDE_ROOT/importexport/inc/class.iface_export_plugin.inc.php
Thats all, pretty easy, isn't it? 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 == == definitions ==
The bases of all imports and exports is the '''definition'''. 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. need to parse that definition. This is up to you.
Definitions can be created in admin->importexport->define{im|ex}ports. They are stored 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 <yourapp/importexport/definitions> Definitions (as xml files) residing in the folder <yourapp/setup/*.xml>
will be imported at apps installation time automatically. will be imported at apps installation time automatically.
== import == == import ==
== export == == export ==
Starting an export is as easy as just putting a button in your app with: Starting an export is as easy as using the sidebox button. Once your plugins are detected
onClick="importexport.uiexport.export_dialog&appname=<appname>&have_selection=<{true|false}>" (they are cached and refreshed hourly), Import/Export will add the needed entries to the sidebox.
If parameter "have_selection" if true, export askes (javascript) opener.get_selection();to retreave Alternatively, you can go to Admin -> Define Imports | Exports.
a list of identifiers of selected records.
NOTE: javascript function get_selection() is the only function which is not part of an interface yet. NOTE: javascript function get_selection() is the only function which is not part of an interface yet.
==Discussion of interfaces== ==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/import_...
EGW_INCLUDE_ROOT/importexport/inc/export_... EGW_INCLUDE_ROOT/importexport/inc/export_...

View File

@ -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) 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 * Simple check to see if the file at least matches the definition
* *
* Checks that column headers match * 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) public static function check_file(&$file, &$definition, &$message = array(), $dst_file = false)
{ {