function export_node_encode in Node export 6
Same name and namespace in other branches
- 5.2 export.pages.inc \export_node_encode()
build node code string recursively
1 call to export_node_encode()
- export_node_export in ./
export.pages.inc - exports a node - prepopulate a node editing form set $return_code to TRUE to not return form but the code instead.
File
- ./
export.pages.inc, line 262
Code
function export_node_encode($var, $iteration = 0) {
$tab = '';
for ($i = 0; $i < $iteration; $i++) {
$tab = $tab . " ";
}
$iteration++;
if (is_object($var)) {
$var = (array) $var;
$var['#_export_node_encode_object'] = '1';
}
if (is_array($var)) {
$empty = empty($var);
$code = "array(" . ($empty ? '' : "\n");
foreach ($var as $key => $value) {
$code .= $tab . " '" . $key . "' => " . export_node_encode($value, $iteration) . ",\n";
}
$code .= ($empty ? '' : $tab) . ")";
return $code;
}
else {
if (is_string($var)) {
return "'" . addslashes($var) . "'";
}
elseif (is_numeric($var)) {
return $var;
}
elseif (is_bool($var)) {
return $var ? 'TRUE' : 'FALSE';
}
else {
return 'NULL';
}
}
}