Import more OPML formats.
Fixed bug capturing rss feed. git-svn-id: http://svn.automattic.com/wordpress/trunk@1107 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
af562386ed
commit
e27e90a7b6
|
@ -123,7 +123,7 @@ switch ($step) {
|
|||
if ('http' == substr($titles[$i], 0, 4))
|
||||
$titles[$i] = '';
|
||||
$query = "INSERT INTO $tablelinks (link_url, link_name, link_target, link_category, link_description, link_owner, link_rss)
|
||||
VALUES('{$urls[$i]}', '".addslashes($names[$i])."', '', $cat_id, '".addslashes($descriptions[$i])."', $user_ID, {$feeds[$i]})\n";
|
||||
VALUES('{$urls[$i]}', '".addslashes($names[$i])."', '', $cat_id, '".addslashes($descriptions[$i])."', $user_ID, '{$feeds[$i]}')\n";
|
||||
$result = $wpdb->query($query);
|
||||
echo "<p>Inserted <strong>{$names[$i]}</strong></p>";
|
||||
}
|
||||
|
|
|
@ -4,15 +4,13 @@ require_once(ABSPATH.WPINC.'/functions.php');
|
|||
|
||||
// columns we wish to find are: link_url, link_name, link_target, link_description
|
||||
// we need to map XML attribute names to our columns
|
||||
// if we are doing OPML use this map
|
||||
$opml_map = array(
|
||||
'link_url' => 'URL',
|
||||
'link_url' => 'HTMLURL',
|
||||
'link_name' => 'TEXT',
|
||||
'link_name' => 'TITLE',
|
||||
'link_target' => 'TARGET',
|
||||
'link_description' => 'DESCRIPTION',
|
||||
'link_rss' => 'XMLURL'
|
||||
$opml_map = array('URL' => 'link_url',
|
||||
'HTMLURL' => 'link_url',
|
||||
'TEXT' => 'link_name',
|
||||
'TITLE' => 'link_name',
|
||||
'TARGET' => 'link_target',
|
||||
'DESCRIPTION' => 'link_description',
|
||||
'XMLURL' => 'link_rss'
|
||||
);
|
||||
|
||||
$map = $opml_map;
|
||||
|
@ -26,24 +24,21 @@ function startElement($parser, $tagName, $attrs) {
|
|||
global $names, $urls, $targets, $descriptions, $feeds;
|
||||
|
||||
if ($tagName == 'OUTLINE') {
|
||||
if ($map['link_url'] != '')
|
||||
$link_url = $attrs[$map['link_url']];
|
||||
if ($map['link_name'] != '')
|
||||
$link_name = $attrs[$map['link_name']];
|
||||
if ($map['link_target'] != '')
|
||||
$link_target = $attrs[$map['link_target']];
|
||||
if ($map['link_description'] != '')
|
||||
$link_description = $attrs[$map['link_description']];
|
||||
if ($map['link_rss'] != '')
|
||||
$link_rss = $attrs[$map['link_rss']];
|
||||
foreach (array_keys($map) as $key) {
|
||||
if (isset($attrs[$key])) {
|
||||
$$map[$key] = $attrs[$key];
|
||||
}
|
||||
}
|
||||
|
||||
//echo("got data: link_url = [$link_url], link_name = [$link_name], link_target = [$link_target], link_description = [$link_description]<br />\n");
|
||||
|
||||
// save the data away.
|
||||
$names[] = $link_name;
|
||||
$urls[] = $link_url;
|
||||
$targets[] = $link_target;
|
||||
$feeds[] = $link_rss;
|
||||
$descriptions[] = $link_description;
|
||||
}
|
||||
} // end if outline
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue