1
0

Merge pull request #11 from rangerer/cleanup_adv

Advanced cleanup features, thanks to @rangerer
This commit is contained in:
2013-06-21 05:04:15 -07:00

View File

@ -118,13 +118,21 @@ class Af_Feedmod extends Plugin implements IHandler
if ($basenode) { if ($basenode) {
// remove nodes from cleanup configuration // remove nodes from cleanup configuration
if (isset($config['cleanup'])) { if (isset($config['cleanup'])) {
if (!is_array($config['cleanup']) {
$config['cleanup'] = array($config['cleanup']);
}
foreach ($config['cleanup'] as $cleanup) { foreach ($config['cleanup'] as $cleanup) {
$nodelist = $xpath->query('//'.$cleanup, $basenode); $nodelist = $xpath->query('//'.$cleanup, $basenode);
foreach ($nodelist as $node) { foreach ($nodelist as $node) {
if ($node instanceof DOMAttr) {
$node->ownerElement->removeAttributeNode($node);
}
else {
$node->parentNode->removeChild($node); $node->parentNode->removeChild($node);
} }
} }
} }
}
$article['content'] = $doc->saveXML($basenode); $article['content'] = $doc->saveXML($basenode);
$article['plugin_data'] = "feedmod,$owner_uid:" . $article['plugin_data']; $article['plugin_data'] = "feedmod,$owner_uid:" . $article['plugin_data'];
} }