summaryrefslogtreecommitdiffstats
path: root/wp-admin/link-parse-opml.php
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-06-22 18:31:50 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-06-22 18:31:50 +0000
commitd48e85e0ac5e675ca33fac173f30c75403d1033f (patch)
tree1164430fa3b83a4d9283961b09c1576f2885e6b2 /wp-admin/link-parse-opml.php
parent086dcde66603301531efc6d8087bd06d0546f148 (diff)
downloadwordpress-mu-d48e85e0ac5e675ca33fac173f30c75403d1033f.tar.gz
wordpress-mu-d48e85e0ac5e675ca33fac173f30c75403d1033f.tar.xz
wordpress-mu-d48e85e0ac5e675ca33fac173f30c75403d1033f.zip
Moved everything in wp-inst down a directory.
Uses's Ryan Boren's htaccess rules and mods If you're upgrading, try this on a test server first! git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@591 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-admin/link-parse-opml.php')
-rw-r--r--wp-admin/link-parse-opml.php65
1 files changed, 65 insertions, 0 deletions
diff --git a/wp-admin/link-parse-opml.php b/wp-admin/link-parse-opml.php
new file mode 100644
index 0000000..196f3cb
--- /dev/null
+++ b/wp-admin/link-parse-opml.php
@@ -0,0 +1,65 @@
+<?php
+require_once('../wp-config.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
+$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;
+
+/**
+ ** startElement()
+ ** Callback function. Called at the start of a new xml tag.
+ **/
+function startElement($parser, $tagName, $attrs) {
+ global $updated_timestamp, $all_links, $map;
+ global $names, $urls, $targets, $descriptions, $feeds;
+
+ if ($tagName == 'OUTLINE') {
+ 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
+}
+
+/**
+ ** endElement()
+ ** Callback function. Called at the end of an xml tag.
+ **/
+function endElement($parser, $tagName) {
+ // nothing to do.
+}
+
+// Create an XML parser
+$xml_parser = xml_parser_create();
+
+// Set the functions to handle opening and closing tags
+xml_set_element_handler($xml_parser, "startElement", "endElement");
+
+if (!xml_parse($xml_parser, $opml, true)) {
+ echo(sprintf(__('XML error: %1$s at line %2$s'),
+ xml_error_string(xml_get_error_code($xml_parser)),
+ xml_get_current_line_number($xml_parser)));
+}
+
+// Free up memory used by the XML parser
+xml_parser_free($xml_parser);
+?>