-
+ 6B8A1C261AB5551CF175C3CB3923E7DB9B526770F009998650E66F7161DD5A1D69284CF198ADA18030D47D216CE20543C7764D2692642BCA519A51901B95FAD7mp-wp/wp-admin/link-parse-opml.php(0 . 0)(1 . 97)
52363 <?php
52364 /**
52365 * Parse OPML XML files and store in globals.
52366 *
52367 * @package WordPress
52368 * @subpackage Administration
52369 */
52370
52371 /** Load WordPress Bootstrap */
52372 require_once('../wp-load.php');
52373
52374 global $opml, $map;
52375
52376 // columns we wish to find are: link_url, link_name, link_target, link_description
52377 // we need to map XML attribute names to our columns
52378 $opml_map = array('URL' => 'link_url',
52379 'HTMLURL' => 'link_url',
52380 'TEXT' => 'link_name',
52381 'TITLE' => 'link_name',
52382 'TARGET' => 'link_target',
52383 'DESCRIPTION' => 'link_description',
52384 'XMLURL' => 'link_rss'
52385 );
52386
52387 $map = $opml_map;
52388
52389 /**
52390 * XML callback function for the start of a new XML tag.
52391 *
52392 * @since unknown
52393 * @access private
52394 *
52395 * @uses $updated_timestamp Not used inside function.
52396 * @uses $all_links Not used inside function.
52397 * @uses $map Stores names of attributes to use.
52398 * @global array $names
52399 * @global array $urls
52400 * @global array $targets
52401 * @global array $descriptions
52402 * @global array $feeds
52403 *
52404 * @param mixed $parser XML Parser resource.
52405 * @param string $tagName XML element name.
52406 * @param array $attrs XML element attributes.
52407 */
52408 function startElement($parser, $tagName, $attrs) {
52409 global $updated_timestamp, $all_links, $map;
52410 global $names, $urls, $targets, $descriptions, $feeds;
52411
52412 if ($tagName == 'OUTLINE') {
52413 foreach (array_keys($map) as $key) {
52414 if (isset($attrs[$key])) {
52415 $$map[$key] = $attrs[$key];
52416 }
52417 }
52418
52419 //echo("got data: link_url = [$link_url], link_name = [$link_name], link_target = [$link_target], link_description = [$link_description]<br />\n");
52420
52421 // save the data away.
52422 $names[] = $link_name;
52423 $urls[] = $link_url;
52424 $targets[] = $link_target;
52425 $feeds[] = $link_rss;
52426 $descriptions[] = $link_description;
52427 } // end if outline
52428 }
52429
52430 /**
52431 * XML callback function that is called at the end of a XML tag.
52432 *
52433 * @since unknown
52434 * @access private
52435 * @package WordPress
52436 * @subpackage Dummy
52437 *
52438 * @param mixed $parser XML Parser resource.
52439 * @param string $tagName XML tag name.
52440 */
52441 function endElement($parser, $tagName) {
52442 // nothing to do.
52443 }
52444
52445 // Create an XML parser
52446 $xml_parser = xml_parser_create();
52447
52448 // Set the functions to handle opening and closing tags
52449 xml_set_element_handler($xml_parser, "startElement", "endElement");
52450
52451 if (!xml_parse($xml_parser, $opml, true)) {
52452 echo(sprintf(__('XML error: %1$s at line %2$s'),
52453 xml_error_string(xml_get_error_code($xml_parser)),
52454 xml_get_current_line_number($xml_parser)));
52455 }
52456
52457 // Free up memory used by the XML parser
52458 xml_parser_free($xml_parser);
52459 ?>