| @@ 682-702 (lines=21) @@ | ||
| 679 | } |
|
| 680 | ||
| 681 | // filter by child node |
|
| 682 | if ($options['child']) { |
|
| 683 | $childNodes = self::findNodes($dom, $options['child'], $isHtml); |
|
| 684 | $childNodes = !empty($childNodes) ? $childNodes : array(); |
|
| 685 | ||
| 686 | foreach ($nodes as $node) { |
|
| 687 | foreach ($node->childNodes as $child) { |
|
| 688 | foreach ($childNodes as $childNode) { |
|
| 689 | if ($childNode === $child) { |
|
| 690 | $filtered[] = $node; |
|
| 691 | } |
|
| 692 | } |
|
| 693 | } |
|
| 694 | } |
|
| 695 | ||
| 696 | $nodes = $filtered; |
|
| 697 | $filtered = array(); |
|
| 698 | ||
| 699 | if (empty($nodes)) { |
|
| 700 | return false; |
|
| 701 | } |
|
| 702 | } |
|
| 703 | ||
| 704 | // filter by adjacent-sibling |
|
| 705 | if ($options['adjacent-sibling']) { |
|
| @@ 762-782 (lines=21) @@ | ||
| 759 | } |
|
| 760 | ||
| 761 | // filter by descendant |
|
| 762 | if ($options['descendant']) { |
|
| 763 | $descendantNodes = self::findNodes($dom, $options['descendant'], $isHtml); |
|
| 764 | $descendantNodes = !empty($descendantNodes) ? $descendantNodes : array(); |
|
| 765 | ||
| 766 | foreach ($nodes as $node) { |
|
| 767 | foreach (self::getDescendants($node) as $descendant) { |
|
| 768 | foreach ($descendantNodes as $descendantNode) { |
|
| 769 | if ($descendantNode === $descendant) { |
|
| 770 | $filtered[] = $node; |
|
| 771 | } |
|
| 772 | } |
|
| 773 | } |
|
| 774 | } |
|
| 775 | ||
| 776 | $nodes = $filtered; |
|
| 777 | $filtered = array(); |
|
| 778 | ||
| 779 | if (empty($nodes)) { |
|
| 780 | return false; |
|
| 781 | } |
|
| 782 | } |
|
| 783 | ||
| 784 | // filter by children |
|
| 785 | if ($options['children']) { |
|