/
xmlexport.module
executable file
·93 lines (80 loc) · 2.11 KB
/
xmlexport.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
function xmlexport_menu(){
$items['node/%node/xml'] = array(
'title' => 'Xml',
'page callback' => 'xmlexport_show_xml',
'access callback' => 'user_access',
'access arguments' => array('administer content'),
'type' => MENU_LOCAL_TASK,
'weight' => 2,
'file' => 'xmlexport.pages.inc',
);
$items['admin/xmlexport/%'] = array(
'title' => 'Xml',
'page callback' => 'xmlexport_show_admin',
'access callback' => 'user_access',
'access arguments' => array('administer content'),
'file' => 'xmlexport.pages.inc',
);
return $items;
}
function xmlexport_node2xml($node){
$output = "<node>\n";
foreach ($node as $key => $value){
$output .= xmlexport_value2xml($key, $value);
}
$output .= "</node>\n\n";
return $output;
}
function xmlexport_value2xml($key, $value){
if(function_exists("xtag_".$key)){
$output .= call_user_func_array("xtag_".$key, array($key, $value));
}elseif(is_array($value) or is_object($value)){
foreach ($value as $key2 => $value2){
$output .= xmlexport_value2xml($key2, $value2);
}
}elseif(is_numeric($key)){
$output .= "<t$key>$value</t$key>\n";
}else{
$output .= "<$key>$value</$key>\n";
}
return $output;
}
function xtag_taxonomy($key, $value){
$output .= "<taxonomy>\n";
foreach ($value as $key2 => $value2){
$output .= "<term>$value2->name</term>\n";
}
$output .= "</taxonomy>\n";
return $output;
}
function xtag_comments($key, $value){
$output .= "<comments>\n";
foreach ($value as $key2 => $value2){
$output .= "<comment>\n";
foreach ($value2 as $key3 => $value3){
$output .= xmlexport_value2xml($key3, $value3);
}
$output .= "</comment>\n";
}
$output .= "</comments>\n";
return $output;
}
function xtag_hostname($key, $value){
return;
}
function xtag_body($key, $value){
$output .= "<$key>"._filter_autop($value)."</$key>\n";
return $output;
}
function xtag_teaser($key, $value){
$output .= "<$key>"._filter_autop(strip_tags($value, "<a><i><b><em><strong><img>"))."</$key>\n";
return $output;
}
function xtag_comment($key, $value){
$output .= "<$key>"._filter_autop($value)."</$key>\n";
return $output;
}
function xtag_mail($key, $value){
return "";
}