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:
mikelittle 2004-04-20 22:01:15 +00:00
parent af562386ed
commit e27e90a7b6
2 changed files with 16 additions and 21 deletions

View File

@ -123,7 +123,7 @@ switch ($step) {
if ('http' == substr($titles[$i], 0, 4)) if ('http' == substr($titles[$i], 0, 4))
$titles[$i] = ''; $titles[$i] = '';
$query = "INSERT INTO $tablelinks (link_url, link_name, link_target, link_category, link_description, link_owner, link_rss) $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); $result = $wpdb->query($query);
echo "<p>Inserted <strong>{$names[$i]}</strong></p>"; 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 // columns we wish to find are: link_url, link_name, link_target, link_description
// we need to map XML attribute names to our columns // we need to map XML attribute names to our columns
// if we are doing OPML use this map $opml_map = array('URL' => 'link_url',
$opml_map = array( 'HTMLURL' => 'link_url',
'link_url' => 'URL', 'TEXT' => 'link_name',
'link_url' => 'HTMLURL', 'TITLE' => 'link_name',
'link_name' => 'TEXT', 'TARGET' => 'link_target',
'link_name' => 'TITLE', 'DESCRIPTION' => 'link_description',
'link_target' => 'TARGET', 'XMLURL' => 'link_rss'
'link_description' => 'DESCRIPTION',
'link_rss' => 'XMLURL'
); );
$map = $opml_map; $map = $opml_map;
@ -26,24 +24,21 @@ function startElement($parser, $tagName, $attrs) {
global $names, $urls, $targets, $descriptions, $feeds; global $names, $urls, $targets, $descriptions, $feeds;
if ($tagName == 'OUTLINE') { if ($tagName == 'OUTLINE') {
if ($map['link_url'] != '') foreach (array_keys($map) as $key) {
$link_url = $attrs[$map['link_url']]; if (isset($attrs[$key])) {
if ($map['link_name'] != '') $$map[$key] = $attrs[$key];
$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']];
//echo("got data: link_url = [$link_url], link_name = [$link_name], link_target = [$link_target], link_description = [$link_description]<br />\n"); //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. // save the data away.
$names[] = $link_name; $names[] = $link_name;
$urls[] = $link_url; $urls[] = $link_url;
$targets[] = $link_target; $targets[] = $link_target;
$feeds[] = $link_rss; $feeds[] = $link_rss;
$descriptions[] = $link_description; $descriptions[] = $link_description;
} } // end if outline
} }
/** /**