You are here

function hook_node_export_format_handlers in Node export 7.3

Same name and namespace in other branches
  1. 6.3 node_export.api.php \hook_node_export_format_handlers()
  2. 6.2 node_export.api.php \hook_node_export_format_handlers()

Register a format handler.

Return value

An array keyed by format names containing an array with keys: #title - the translated display name of the format #module - the module that implements it. #description - the translated description, please include links to docs that give more info about the format. #file - if a file is to be included for callbacks to work, give full path here. This is optional. #mime - to override the default text/plain mime type for the downloaded file set this to the desired mime type string. This is optional. #settings_callback - the function name of the settings callback, this is a function that takes two params $form and $form_state, and returns an array of form elements to append to the $form['basic'] area. The form uses system_settings_form() so values will be automatically saved into variables, but be sure your module deletes these variables upon uninstall. This is optional. #export_callback - the function name of the export callback, this is a function that takes two params $nodes and $format, where $nodes is an array of nodes and $format is the name of the format (in case same function used for multiple formats). #import_callback - the function name of the import callback, this is a function that takes one parameter $code_string, and will be called of all formats when an import is being performed, and should return: The array of nodes, or nothing if code_string not handled by this function. If there is a problem with the supplied code return an array like so: array( 'success' => FALSE, 'output' => array("error msg 1", "error msg 2", etc...), ) Note: Do not use the t() function on error msgs, and don't mix the error message with dynamic variables/content, at least not in the first message so it can be translated properly and used as the main message. See the XML implementation for malformed XML imports for an example that combines information for the user followed by generated errors from PHP.

1 function implements hook_node_export_format_handlers()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

node_export_node_export_format_handlers in ./node_export.formats.inc
Implements hook_node_export_format_handlers().
1 invocation of hook_node_export_format_handlers()
node_export_format_handlers in ./node_export.module
Get a list of possible format handlers (other than the default).

File

./node_export.api.php, line 201
Documents Node export's hooks for api reference.

Code

function hook_node_export_format_handlers() {
  return array(
    // Note: format_short_name should NOT contain the string 'node_export'.
    // Example from DSV format.
    'dsv' => array(
      '#title' => t('DSV'),
      '#module' => 'node_export',
      '#file' => drupal_get_path('module', 'node_export') . '/formats/dsv.inc',
      '#description' => t('Configurable <a href="!dsv">Delimiter-separated values</a> code. Export and import sites must be configured the same.', array(
        '!dsv' => 'http://en.wikipedia.org/wiki/Delimiter-separated_values',
      )),
      '#settings_callback' => 'node_export_dsv_settings',
      '#export_callback' => 'node_export_dsv_export',
      '#import_callback' => 'node_export_dsv_import',
    ),
  );
}