$newobj = own_clone_node($obj, $node->owner_document());
$node->append_child($newobj);
- XML_Template_process($newobj, NULL, $clean);
- } else if (isset($obj) && !is_array($obj)) { # overwrite
+ XML_Template_process($newobj, array(), $clean);
+ } else if (!is_array($obj)) { # overwrite
foreach ($node->child_nodes() as $child) {
$node->remove_child($child);
}
$doc = $node->owner_document();
$node->add_child($doc->create_text_node($obj));
- } else if (!isset($obj) || is_associative_array($obj)) { # substitute
+ } else if (is_associative_array($obj)) { # substitute
foreach ($node->child_nodes() as $child) {
$processed = false;
# check all substitutions to see if we found anything
# appropriate
- if (isset($obj)) {
- foreach (array_keys($obj) as $key) {
- # FIXME: we would want something like \Q and \E here...
- if (preg_match('/^' . $tag . '\/(.*)$/', $key, $matches) ||
- (isset($id) && preg_match('/^#' . $id . '\/(.*)$/', $key, $matches))) {
- $child->set_attribute($matches[1], $obj[$key]);
- }
+ foreach (array_keys($obj) as $key) {
+ # FIXME: we would want something like \Q and \E here...
+ if (preg_match('/^' . $tag . '\/(.*)$/', $key, $matches) ||
+ (isset($id) && preg_match('/^#' . $id . '\/(.*)$/', $key, $matches))) {
+ $child->set_attribute($matches[1], $obj[$key]);
+ }
- if ($processed) {
- continue;
- }
- if ($key == $tag || (isset($id) && $key == ('#'.$id))) {
- XML_Template_process($child, $obj[$key], $clean);
- $processed = true;
- }
+ if ($processed) {
+ continue;
+ }
+ if ($key == $tag || (isset($id) && $key == ('#'.$id))) {
+ XML_Template_process($child, $obj[$key], $clean);
+ $processed = true;
}
}
}
if (!is_array($arr)) {
return false;
}
-
- if (count($arr) == 0) {
- return false; // special case
- }
-
$diff = array_diff(range(0, count($arr) - 1), array_keys($arr));
return (count($diff) > 0);
}