ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Helper.php
Go to the documentation of this file.
1 <?php
2 namespace enshrined\svgSanitize;
3 
4 class Helper
5 {
10  public static function getElementHref(\DOMElement $element)
11  {
12  if ($element->hasAttribute('href')) {
13  return $element->getAttribute('href');
14  }
15  if ($element->hasAttributeNS('http://www.w3.org/1999/xlink', 'href')) {
16  return $element->getAttributeNS('http://www.w3.org/1999/xlink', 'href');
17  }
18  return null;
19  }
20 
25  public static function extractIdReferenceFromHref($href)
26  {
27  if (!is_string($href) || strpos($href, '#') !== 0) {
28  return null;
29  }
30  return substr($href, 1);
31  }
32 
38  public static function isElementContainedIn(\DOMElement $needle, \DOMElement $haystack)
39  {
40  if ($needle === $haystack) {
41  return true;
42  }
43  foreach ($haystack->childNodes as $childNode) {
44  if (!$childNode instanceof \DOMElement) {
45  continue;
46  }
47  if (self::isElementContainedIn($needle, $childNode)) {
48  return true;
49  }
50  }
51  return false;
52  }
53 }
static getElementHref(\DOMElement $element)
Definition: Helper.php:10
static extractIdReferenceFromHref($href)
Definition: Helper.php:25
static isElementContainedIn(\DOMElement $needle, \DOMElement $haystack)
Definition: Helper.php:38