You are here

node_export_serialize.module in Node export 6.3

The Node export serialize module.

Adds serialize format to Node export.

File

modules/node_export_serialize/node_export_serialize.module
View source
<?php

/**
 * @file
 * The Node export serialize module.
 *
 * Adds serialize format to Node export.
 */

/**
 * Implementation of hook_node_export_format_handlers().
 *
 * @see hook_node_export_format_handlers()
 */
function node_export_serialize_node_export_format_handlers() {
  return array(
    'serialize' => array(
      '#title' => t('Serialize'),
      '#module' => 'node_export_serialize',
    ),
  );
}

/**
 * Implementation of hook_node_export().
 *
 * @see hook_node_export()
 */
function node_export_serialize_node_export($nodes, $format) {
  return "node_export_serialize::" . htmlspecialchars(serialize($nodes));
}

/**
 * Implementation of hook_node_export_import().
 *
 * @see hook_node_export_import()
 */
function node_export_serialize_node_export_import($code_string) {

  // Check for "node_export_serialize::" at the start.
  if (substr(ltrim($code_string), 0, 23) == "node_export_serialize::") {
    return unserialize(htmlspecialchars_decode(str_replace("node_export_serialize::", "", $code_string)));
  }
}