- Bugfix: ignore "textinput" and "image" tags, for now. Reported by Al Maw.

4.2.x
Dries Buytaert 2003-03-23 11:48:53 +00:00
parent e2ab17fbae
commit 016b8336f8
3 changed files with 108 additions and 27 deletions

View File

@ -167,10 +167,16 @@ function import_remove($feed) {
// Call-back function used by XML parser: // Call-back function used by XML parser:
function import_element_start($parser, $name, $attributes) { function import_element_start($parser, $name, $attributes) {
global $item, $tag; global $item, $element, $tag;
if ($name == "ITEM") { switch ($name) {
$item += 1; case "IMAGE":
case "TEXTINPUT":
$element = $name;
break;
case "ITEM":
$element = $name;
$item += 1;
} }
$tag = $name; $tag = $name;
@ -178,17 +184,34 @@ function import_element_start($parser, $name, $attributes) {
// Call-back function used by XML parser: // Call-back function used by XML parser:
function import_element_end($parser, $name) { function import_element_end($parser, $name) {
global $element;
switch ($name) {
case "IMAGE":
case "TEXTINPUT":
case "ITEM":
$element = "";
}
} }
// Call-back function used by XML parser: // Call-back function used by XML parser:
function import_element_data($parser, $data) { function import_element_data($parser, $data) {
global $channel, $items, $item, $tag; global $channel, $element, $items, $item, $tag;
if ($item) { switch ($element) {
$items[$item][$tag] .= $data; case "ITEM":
} $items[$item][$tag] .= $data;
else { break;
$channel[$tag] .= $data; case "IMAGE":
case "TEXTINPUT":
/*
** The sub-elements "image" and "textinput" are not supported
** but we have recognize them or their content will end up in
** the items-array.
*/
break;
default:
$channel[$tag] .= $data;
} }
} }
@ -216,6 +239,10 @@ function import_refresh($feed) {
} }
fclose($fp); fclose($fp);
// unset the global variables:
unset($GLOBALS["channel"], $GLOBAL["element"], $GLOBALS["item"], $GLOBAL["items"]);
// parse the data:
$xml_parser = xml_parser_create(); $xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "import_element_start", "import_element_end"); xml_set_element_handler($xml_parser, "import_element_start", "import_element_end");
xml_set_character_data_handler($xml_parser, "import_element_data"); xml_set_character_data_handler($xml_parser, "import_element_data");

View File

@ -167,10 +167,16 @@ function import_remove($feed) {
// Call-back function used by XML parser: // Call-back function used by XML parser:
function import_element_start($parser, $name, $attributes) { function import_element_start($parser, $name, $attributes) {
global $item, $tag; global $item, $element, $tag;
if ($name == "ITEM") { switch ($name) {
$item += 1; case "IMAGE":
case "TEXTINPUT":
$element = $name;
break;
case "ITEM":
$element = $name;
$item += 1;
} }
$tag = $name; $tag = $name;
@ -178,17 +184,34 @@ function import_element_start($parser, $name, $attributes) {
// Call-back function used by XML parser: // Call-back function used by XML parser:
function import_element_end($parser, $name) { function import_element_end($parser, $name) {
global $element;
switch ($name) {
case "IMAGE":
case "TEXTINPUT":
case "ITEM":
$element = "";
}
} }
// Call-back function used by XML parser: // Call-back function used by XML parser:
function import_element_data($parser, $data) { function import_element_data($parser, $data) {
global $channel, $items, $item, $tag; global $channel, $element, $items, $item, $tag;
if ($item) { switch ($element) {
$items[$item][$tag] .= $data; case "ITEM":
} $items[$item][$tag] .= $data;
else { break;
$channel[$tag] .= $data; case "IMAGE":
case "TEXTINPUT":
/*
** The sub-elements "image" and "textinput" are not supported
** but we have recognize them or their content will end up in
** the items-array.
*/
break;
default:
$channel[$tag] .= $data;
} }
} }
@ -216,6 +239,10 @@ function import_refresh($feed) {
} }
fclose($fp); fclose($fp);
// unset the global variables:
unset($GLOBALS["channel"], $GLOBAL["element"], $GLOBALS["item"], $GLOBAL["items"]);
// parse the data:
$xml_parser = xml_parser_create(); $xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "import_element_start", "import_element_end"); xml_set_element_handler($xml_parser, "import_element_start", "import_element_end");
xml_set_character_data_handler($xml_parser, "import_element_data"); xml_set_character_data_handler($xml_parser, "import_element_data");

View File

@ -167,10 +167,16 @@ function import_remove($feed) {
// Call-back function used by XML parser: // Call-back function used by XML parser:
function import_element_start($parser, $name, $attributes) { function import_element_start($parser, $name, $attributes) {
global $item, $tag; global $item, $element, $tag;
if ($name == "ITEM") { switch ($name) {
$item += 1; case "IMAGE":
case "TEXTINPUT":
$element = $name;
break;
case "ITEM":
$element = $name;
$item += 1;
} }
$tag = $name; $tag = $name;
@ -178,17 +184,34 @@ function import_element_start($parser, $name, $attributes) {
// Call-back function used by XML parser: // Call-back function used by XML parser:
function import_element_end($parser, $name) { function import_element_end($parser, $name) {
global $element;
switch ($name) {
case "IMAGE":
case "TEXTINPUT":
case "ITEM":
$element = "";
}
} }
// Call-back function used by XML parser: // Call-back function used by XML parser:
function import_element_data($parser, $data) { function import_element_data($parser, $data) {
global $channel, $items, $item, $tag; global $channel, $element, $items, $item, $tag;
if ($item) { switch ($element) {
$items[$item][$tag] .= $data; case "ITEM":
} $items[$item][$tag] .= $data;
else { break;
$channel[$tag] .= $data; case "IMAGE":
case "TEXTINPUT":
/*
** The sub-elements "image" and "textinput" are not supported
** but we have recognize them or their content will end up in
** the items-array.
*/
break;
default:
$channel[$tag] .= $data;
} }
} }
@ -216,6 +239,10 @@ function import_refresh($feed) {
} }
fclose($fp); fclose($fp);
// unset the global variables:
unset($GLOBALS["channel"], $GLOBAL["element"], $GLOBALS["item"], $GLOBAL["items"]);
// parse the data:
$xml_parser = xml_parser_create(); $xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "import_element_start", "import_element_end"); xml_set_element_handler($xml_parser, "import_element_start", "import_element_end");
xml_set_character_data_handler($xml_parser, "import_element_data"); xml_set_character_data_handler($xml_parser, "import_element_data");