Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Table of Contents
There are currently two different types of plugins supported:
- Row based
- XML based
All plugins must be located under the import/ subdirectory of the OpenDb distribution.
- There is one common function each plugin class provides:
get_plugin_type()This should return 'xml', 'row'
- Return an english display name. Currently no language support in these plugins, although plugin writers can lookup the $OPENDB_LANGUAGE variable and return a value appropriate to the current language, if they want to.
- For 'row' plugins, the following function should be provided:
- For 'xml' plugins, the DOCTYPE will be parsed to work out what plugin to use, so 'xml' plugins must provide:
- For 'xml' plugins, the namespace will be parsed to determin what plugin to use, 'xml' plugins should provide:
is_namespace_supported($nameSpace). However this function is not compulsory.
- The class name should match the name of the php file name (this match is case-sensitive), minus the .php extension of course.
In the following a description of each plugin type:
/** * @return display name of plugin for UI */ function get_display_name() /** * @return TRUE if specified $extension is valid for this * plugin. */ function is_extension_supported($extension) /* * Indicates that read_header(&$fileHandler) will actually * return the first row of data, that would normally be read * from read_row(...) if read_header(...) were not called first. */ function is_header_row() /* * @return a array of strings representing the header * columns. */ function read_header(&$fileHandler, &$error) /* * @return a array of columns values for the current row. Once * this function has finished the &$fileHandler will have moved * to the start of the next row. Returns FALSE if no data can * be read from &$fileHandler. * * Allows the plugin to filter on $s_item_type, $owner_id if * required. */ function read_row(&$fileHandler, &$error)
The valid extension needs to be 'xml' for all XML imports, and the doctype will be parsed to ascertain which plugin to use.
Will parse a complete OpenDb item, including item, instance(s), attribute(s) and linked item(s) (including any linked item attributes) via a series of callback functions:
It is up to the plugin to map the structure of the file being parsed to match what is required in the callbacks. The plugin script, can record state details in global variables, as they will only be accessed from the read_item function. The read_item function will be called, and the calling process will wait for it to finish, and then call it again, until it returns FALSE.
/* Check doctype to ensure we support it in this plugin. */ function is_doctype_supported($doctype) /* Check namespace to ensure we support it in this plugin. */ function is_namespace_supported($nameSpace) /** @param $itemImportHandler @param $name The name of the tag. @param $attribs An array of all attributes, whether they have a value or not. @param $pcdata Any PCDATA for the attribute. This avoid having to implement a characters function as well. */ function start_element($name, $attribs, $pcdata) /** @param $itemImportHandler @param $name The name of the tag. */ function end_element($name)
On Windows with IIS 5 (I have not tried with Apache on windows), if file_upload = Off, and you attempt to do a file upload, scripts that perform file uploads will misbehave badly. This is because no HTTP parameters will actually get through to the script. Linux with Apache on the other hand, will send all but the FILE $_FILES array information, which will result in slightly better behaviour and better error information.
So if you want to do file uploads, ensure that the php.ini 'file_upload' variable is set to true.