Import more OPML formats.

Fixed bug capturing rss feed.


git-svn-id: https://develop.svn.wordpress.org/trunk@1107 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Mike Little 2004-04-20 22:01:15 +00:00
parent fd96a38fd7
commit c9239346a5
2 changed files with 16 additions and 21 deletions

View File

@ -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>";
}

View File

@ -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
}
/**