replacements as $key => $path) {
// Query and process the nodes slated for replacement.
$nodes = $xpath->query($path);
foreach ($nodes as $node) {
// Process this replacement if the key exists as a parameter.
if (isset($_GET[$key]) && $_GET[$key]) {
// Clear out all children of the container.
$this->clearNode($node);
// Create a new child text node with parameter value.
$new_txt = $doc->createTextNode($_GET[$key]);
$node->appendChild($new_txt);
} elseif (isset($_GET["prefix_$key"]) && $_GET["prefix_$key"]) {
$txt_node = $doc->createTextNode($_GET["prefix_$key"]);
$node->insertBefore($txt_node, $node->firstChild);
} elseif (isset($_GET["suffix_$key"]) && $_GET["suffix_$key"]) {
$txt_node = $doc->createTextNode($_GET["suffix_$key"]);
$node->appendChild($txt_node);
}
}
}
return $doc;
}
/**
* Clear out all the children for a given DOM node.
*/
function clearNode(&$node) {
while ($node->firstChild) {
$node->removeChild($node->firstChild);
}
}
}
// Instantiate and run the filter only when not being used as an include.
if (strpos(basename(__FILE__), basename($_SERVER['SCRIPT_FILENAME'])) !== false) {
processFilter(new FeedHeaderFilter());
}
?>