1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* The Node export Drupal format handler.
|
6
|
*
|
7
|
* Adds Drupal var export format to Node export.
|
8
|
*/
|
9
|
|
10
|
/**
|
11
|
* Export callback.
|
12
|
*/
|
13
|
function node_export_drupal_export($nodes, $format) {
|
14
|
require_once DRUPAL_ROOT . '/includes/utility.inc';
|
15
|
return drupal_var_export($nodes);
|
16
|
}
|
17
|
|
18
|
/**
|
19
|
* Import callback.
|
20
|
*/
|
21
|
function node_export_drupal_import($code_string) {
|
22
|
if (substr(ltrim($code_string), 0, 6) == "array(") {
|
23
|
$nodes = eval('return ' . $code_string . ';');
|
24
|
if (is_array($nodes)) {
|
25
|
return node_export_drupal_decode_objects($nodes);
|
26
|
}
|
27
|
}
|
28
|
}
|
29
|
|
30
|
/**
|
31
|
* Recursively convert arrays back to objects.
|
32
|
*
|
33
|
* This is only for backwards compatibility with the deprecated node_code format.
|
34
|
*/
|
35
|
function node_export_drupal_decode_objects($array) {
|
36
|
foreach ($array as $k => $v) {
|
37
|
if (is_array($v)) {
|
38
|
$array[$k] = node_export_drupal_decode_objects($v);
|
39
|
}
|
40
|
}
|
41
|
if (isset($array['#_export_node_encode_object'])) {
|
42
|
unset($array['#_export_node_encode_object']);
|
43
|
$array = (object)$array;
|
44
|
}
|
45
|
return $array;
|
46
|
}
|
47
|
|
48
|
/**
|
49
|
* Callback for actions.
|
50
|
*/
|
51
|
function node_export_drupal_action_form($context, &$form_state) {
|
52
|
return node_export_action_form($context, $form_state, 'drupal');
|
53
|
}
|