Lines Matching +full:target +full:- +full:uri
63 'http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd',
64 'http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd',
82 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
122 public const DATA_NAME_HTML_ATTRIBUTE = "data-name";
149 $fetcher->setSourcePath($path);
159 $fetchSvg->buildFromUrl($fetchUrl);
164 * @param string $markup - the svg as a string
165 * @param string $name - a name identifier (used in diff)
171 return self::createSvgEmpty()->setMarkup($markup, $name);
184 $fetcher->buildFromTagAttributes($tagAttributes);
194 if ($this->requestedOptimization === null) {
197 return $this->requestedOptimization;
204 return $this->getRequestedOptimization();
217 if ($this->preserveStyle === null) {
220 return $this->preserveStyle;
231 $this->requestedOptimization = $boolean;
247 if ($this->getRequestedOptimizeOrDefault()) {
255 … foreach ($this->getXmlDocument()->getNamespaces() as $namespacePrefix => $namespaceUri) {
262 $this->getXmlDocument()->removeNamespace($namespaceUri);
269 $documentElement = $this->getXmlDocument()->getDomDocument()->documentElement;
270 … foreach ($this->getXmlDocument()->getNamespaces() as $namespacePrefix => $namespaceUri) {
271 $nodes = $this->getXmlDocument()->xpath("//*[namespace-uri()='$namespaceUri']");
272 … $attributes = $this->getXmlDocument()->xpath("//@*[namespace-uri()='$namespaceUri']");
273 if ($nodes->length == 0 && $attributes->length == 0) {
274 $result = $documentElement->removeAttributeNS($namespaceUri, $namespacePrefix);
284 $commentNodes = $this->getXmlDocument()->xpath("//comment()");
286 $this->getXmlDocument()->removeNode($commentNode);
293 foreach ($documentElement->attributes as $attribute) {
295 $name = $attribute->name;
297 if ($defaultValues[$name] == $attribute->value) {
298 $documentElement->removeAttributeNode($attribute);
304 * Suppress the attributes (by default id, style and class, data-name)
306 …g::getConfValue(FetcherSvg::CONF_OPTIMIZATION_ATTRIBUTES_TO_DELETE, "id, style, class, data-name");
310 … if (in_array($value, ["style", "class", "id"]) && $this->getRequestedPreserveStyleOrDefault()) {
315 $nodes = $this->getXmlDocument()->xpath("//@$value");
319 $DOMNode = $node->parentNode;
320 $DOMNode->removeAttributeNode($node);
332 $widthAttributeValue = $documentElement->getAttribute("width");
336 $heightAttributeValue = $documentElement->getAttribute("height");
341 $viewBoxAttribute = $documentElement->getAttribute(FetcherSvg::VIEW_BOX);
356 $documentElement->removeAttribute("width");
357 $documentElement->removeAttribute("height");
370 * Delete of scripts https://developer.mozilla.org/en-US/docs/Web/SVG/Element/script
379 * Example with carbon that use cls-1 on all icons
380 * https://github.com/carbon-design-system/carbon/issues/5568
381 * The facebook icon has a class cls-1 with an opacity of 0
382 * that leaks to the tumblr icon that has also a cls-1 class
385 * For instance, all un-draw: https://undraw.co/illustrations
390 if ($elementToDelete === "style" && $this->getRequestedPreserveStyleOrDefault()) {
393 XmlSystems::deleteAllElementsByName($elementToDelete, $this->getXmlDocument());
397 // * https://developer.mozilla.org/en-US/docs/Web/SVG/Element/defs
398 // * https://developer.mozilla.org/en-US/docs/Web/SVG/Element/metadata
402 … $elementNodeList = $this->getXmlDocument()->xpath("//*[local-name()='$elementToDeleteIfEmpty']");
405 if (!$element->hasChildNodes()) {
406 $element->parentNode->removeChild($element);
416 …$documentElement->removeAttributeNS(FetcherSvg::SVG_NAMESPACE_URI, FetcherSvg::SVG_NAMESPACE_PREFI…
431 $this->buildXmlDocumentIfNeeded();
433 throw new ExceptionBadSyntaxRuntime($e->getMessage(), self::CANONICAL, 1, $e);
435 return $this->intrinsicHeight;
447 $this->buildXmlDocumentIfNeeded();
449 throw new ExceptionBadSyntaxRuntime($e->getMessage(), self::CANONICAL, 1, $e);
451 return $this->intrinsicWidth;
465 return $this->process()->getMarkup();
472 * @throws ExceptionBadState - if no svg was set to be processed
476 return $this->getXmlDocument()->toXml();
486 $this->setOriginalPathTraitAlias($path);
494 * @return Url - the fetch url
505 $this->addLocalPathParametersToFetchUrl($url, MediaMarkup::$MEDIA_QUERY_PARAMETER);
511 $url->addQueryParameter(ColorRgb::COLOR, $this->getRequestedColor()->toCssValue());
516 …$url->addQueryParameter(self::REQUESTED_PRESERVE_ASPECT_RATIO_KEY, $this->getRequestedPreserveAspe…
521 $url->addQueryParameter(self::REQUESTED_NAME_ATTRIBUTE, $this->getRequestedName());
526 $url->addQueryParameter(Dimension::ZOOM_ATTRIBUTE, $this->getRequestedZoom());
531 $url->addQueryParameter(TagAttributes::CLASS_KEY, $this->getRequestedClass());
536 $url->addQueryParameter(TagAttributes::TYPE_KEY, $this->getRequestedType());
550 if ($this->preserveAspectRatio === null) {
553 return $this->preserveAspectRatio;
562 * @throws ExceptionBadSyntax - the file is not a svg file
564 * @throws ExceptionNotFound - the file was not found
573 $files[] = $this->getSourcePath();
577 …y::internalError("Unable to add the FetchImageSvg class as dependency. Error: {$e->getMessage()}");
582 …ity::internalError("Unable to add the XmlDocument class as dependency. Error: {$e->getMessage()}");
586 $fetchCache->addFileDependency($file);
594 $isCacheUsable = $fetchCache->isCacheUsable();
598 $fetchCache->storeCache($content);
600 return $fetchCache->getFile();
617 $buster = FileSystems::getCacheBuster($this->getSourcePath());
620 $buster = "$buster-$configFile";
636 …$dokuPath = FetcherRawLocalPath::createEmpty()->buildFromUrl($url)->processIfNeededAndGetFetchPath…
645 if ($mime->toString() === Mime::SVG) {
660 $this->color = $color;
669 if ($this->color === null) {
672 return $this->color;
676 * @param string $preserveAspectRatio - the aspect ratio of the svg
681 $this->preserveAspectRatio = $preserveAspectRatio;
687 * @var string|null - a name identifier that is added in the SVG
713 $this->requestedName = $name;
721 if (isset($this->name)) {
722 return $this->name;
724 if (isset($this->path)) {
726 return $this->path->getLastNameWithoutExtension();
759 $this->buildXmlDocumentIfNeeded();
760 return $this->xmlDocument;
769 return $this->getXmlDocument()->getDomDocument();
777 if ($this->requestedName === null) {
780 return $this->requestedName;
785 $this->preserveStyle = $bool;
792 return $this->getRequestedPreserveStyle();
803 if ($this->requestedType === null) {
806 return $this->requestedType;
810 * @param string $markup - the svg as a string
811 * @param string $name - a name identifier (used in diff)
816 $this->name = $name;
817 $this->buildXmlDocumentIfNeeded($markup);
824 $this->requestedType = $requestedType;
831 return $this->getDefaultWidhtAndHeightForIconAndTileIfNotSet();
840 return $this->getDefaultWidhtAndHeightForIconAndTileIfNotSet();
855 if ($this->processed) {
860 $this->processed = true;
863 $documentElement = $this->getXmlDocument()->getElement();
866 if ($this->getRequestedOptimizeOrDefault()) {
867 $this->optimize();
872 $name = $this->getRequestedNameOrDefault();
873 $documentElement->setAttribute('data-name', $name);
881 $requestedWidth = $this->getRequestedWidth();
888 $requestedHeight = $this->getRequestedHeight();
895 $requestedType = $this->getRequestedType();
910 $intrinsicWidth = $this->getIntrinsicWidth();
911 $intrinsicHeight = $this->getIntrinsicHeight();
914 $svgStructureType = $this->getInternalStructureType();
947 $zoomFactor = $this->getRequestedZoom();
950 $zoomFactor = -4;
971 $targetWidth = $this->getTargetWidth();
972 $targetHeight = $this->getTargetHeight();
973 if ($this->isCropRequested() || $zoomFactor !== 1) {
980 * Zoom applies on the target/cropped dimension
991 * if you double the viewbox to 0 0 48 48, you have applied of -2
994 $viewBoxWidth = $this->getIntrinsicWidth();
995 $viewBoxHeight = $this->getIntrinsicHeight();
997 $viewBoxWidth = -$zoomFactor * $viewBoxWidth;
998 $viewBoxHeight = -$zoomFactor * $viewBoxHeight;
1010 $x = -($viewBoxWidth - $intrinsicWidth) / 2;
1011 $y = -($viewBoxHeight - $intrinsicHeight) / 2;
1012 … $documentElement->setAttribute(FetcherSvg::VIEW_BOX, "$x $y $viewBoxWidth $viewBoxHeight");
1015 $viewBox = $documentElement->getAttribute(FetcherSvg::VIEW_BOX);
1018 …$documentElement->setAttribute(FetcherSvg::VIEW_BOX, "0 0 {$this->getIntrinsicWidth()} {$this->get…
1024 …* - to not take the dimension of the parent - Setting the width and height is important, otherwise…
1025 * - to show the crop
1026 * - to have internal calculate dimension otherwise, it's tiny
1027 …* - To have an internal width and not shrink on the css property `width: auto !important;` of a ta…
1028 …* - To have an internal height and not shrink on the css property `height: auto !important;` of a …
1029 …* - Using a icon in the navbrand component of bootstrap require the set of width and height otherw…
1030 * - ...
1033 ->setAttribute(Dimension::WIDTH_KEY, $targetWidth)
1034 ->setAttribute(Dimension::HEIGHT_KEY, $targetHeight);
1052 …he same dimension but the svg ($this) has a target width of ($targetWidth) that is different from …
1064 $aspectRatio = $this->getRequestedPreserveAspectRatio();
1070 … * https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/preserveAspectRatio
1075 $documentElement->setAttribute("preserveAspectRatio", $aspectRatio);
1080 * ie the max-width style
1088 $extraAttributes->addStyleDeclarationIfNotSet("width", "100%");
1089 $extraAttributes->addStyleDeclarationIfNotSet("height", "auto");
1095 * If a dimension was set, it's seen by default as a max-width
1100 … $widthInPixel = ConditionalLength::createFromString($requestedWidth)->toPixelNumber();
1102 …edWidth could not be converted to pixel. It returns the following error ({$e->getMessage()}). Proc…
1105 $extraAttributes->addStyleDeclarationIfNotSet("max-width", "{$widthInPixel}px");
1112 * If a dimension was set, it's seen by default as a max-width
1117 … $heightInPixel = ConditionalLength::createFromString($requestedHeight)->toPixelNumber();
1119 …dHeight could not be converted to pixel. It returns the following error ({$e->getMessage()}). Proc…
1122 … $extraAttributes->addStyleDeclarationIfNotSet("max-height", "{$heightInPixel}px");
1147 if ($documentElement->hasAttribute(FetcherSvg::STROKE_ATTRIBUTE)) {
1155 $svgFillsElement = $this->getXmlDocument()->xpath("//*[@fill]");
1157 for ($i = 0; $i < $svgFillsElement->length; $i++) {
1162 $value = $nodeElement->getAttribute("fill");
1183 …* Example: view-source:https://raw.githubusercontent.com/feathericons/feather/master/icons/airplay…
1188 if (!$isDoubleColor && !$documentElement->hasAttribute("fill")) {
1193 $documentElement->setAttribute("fill", FetcherSvg::CURRENT_COLOR);
1201 * * eva:facebook-fill
1202 … * * carbon:logo-tumblr (https://github.com/carbon-design-system/carbon/issues/5568)
1213 $path = $this->getSourcePath();
1214 $pathString = $path->toAbsolutePath()->toAbsoluteId();
1218 XmlSystems::deleteAllElementsByName("rect", $this->getXmlDocument());
1227 $color = $this->getRequestedColor();
1255 $colorValue = $color->toCssValue();
1263 $documentElement->setAttribute("fill", $colorValue);
1267 * Update the fill property on sub-path
1268 * If the fill is set on sub-path, it will not work
1272 … $svgPaths = $this->getXmlDocument()->xpath("//*[local-name()='path' or local-name()='g']");
1273 for ($i = 0; $i < $svgPaths->length; $i++) {
1278 $value = $nodeElement->getAttribute("fill");
1280 if ($nodeElement->parentNode->tagName !== "svg") {
1281 … $nodeElement->setAttribute("fill", FetcherSvg::CURRENT_COLOR);
1283 … $this->getXmlDocument()->removeAttributeValue("fill", $nodeElement);
1291 … $firsFillElement = $this->getXmlDocument()->xpath("//*[@fill][1]")->item(0);
1293 $firsFillElement->setAttribute("fill", $colorValue);
1299 $documentElement->setAttribute("fill", "none");
1300 … $documentElement->setAttribute(FetcherSvg::STROKE_ATTRIBUTE, $colorValue);
1304 * Delete the stroke property on sub-path
1306 // if the fill is set on sub-path, it will not work
1307 … $svgPaths = $this->getXmlDocument()->xpath("//*[local-name()='path']");
1308 for ($i = 0; $i < $svgPaths->length; $i++) {
1313 … $value = $nodeElement->getAttribute(FetcherSvg::STROKE_ATTRIBUTE);
1315 … $this->getXmlDocument()->removeAttributeValue(FetcherSvg::STROKE_ATTRIBUTE, $nodeElement);
1317 $this->getXmlDocument()->removeNode($nodeElement);
1336 $extraAttributeAsArray = $extraAttributes->toHtmlArray();
1338 $documentElement->setAttribute($name, $value);
1345 $class = $this->getRequestedClass();
1346 $documentElement->addClass($class);
1352 ->addClass(StyleAttribute::addComboStrapSuffix(self::TAG))
1353 ->addClass(StyleAttribute::addComboStrapSuffix(self::TAG . "-" . $requestedType));
1356 $name = $this->getRequestedNameOrDefault();
1357 $svgPaths = $documentElement->querySelectorAll('path');
1362 $stylingClass = $name . "-" . $i;
1363 $element->addClass($stylingClass);
1387 foreach (array_keys($tagAttributes->getComponentAttributes()) as $svgAttribute) {
1396 $value = $tagAttributes->getValueAndRemove($svgAttribute);
1398 $lengthInt = ConditionalLength::createFromString($value)->toPixelNumber();
1404 $this->setRequestedWidth($lengthInt);
1406 $this->setRequestedHeight($lengthInt);
1410 $value = $tagAttributes->getValueAndRemove($svgAttribute);
1417 $this->setRequestedZoom($lengthFloat);
1420 $value = $tagAttributes->getValueAndRemove($svgAttribute);
1427 $this->setRequestedColor($color);
1430 $value = $tagAttributes->getValue($svgAttribute);
1431 $this->setRequestedType($value);
1434 $value = $tagAttributes->getValueAndRemove($svgAttribute);
1440 $this->setPreserveStyle($preserve);
1443 $value = $tagAttributes->getValueAndRemove($svgAttribute);
1444 $this->setRequestedName($value);
1447 $value = $tagAttributes->getValueAndRemove($svgAttribute);
1448 $this->setRequestedClass($value);
1451 $value = $tagAttributes->getValueAndRemove($svgAttribute);
1452 $this->setRequestedPreserveAspectRatio($value);
1463 !$tagAttributes->hasAttribute(MediaMarkup::$MEDIA_QUERY_PARAMETER) &&
1464 $this->getRequestedType() === self::ICON_TYPE
1465 && $this->getRequestedName() !== null;
1468 $dokuPath = $this->downloadAndGetIconPath();
1470 …throw new ExceptionBadArgument("We can't get the icon path. Error: {$e->getMessage()}. (ie media o…
1472 $this->setSourcePath($dokuPath);
1482 $this->buildOriginalPathFromTagAttributes($tagAttributes);
1499 $requestedType = $this->getRequestedType();
1500 $requestedName = $this->getRequestedName();
1511 …ionNotFound("The name ($requestedName) is not a valid icon name. Error: ({$e->getMessage()}.", sel…
1513 $originalPath = $iconDownloader->getPath();
1518 $iconDownloader->download();
1520 …ptionCompile("The icon ($requestedName) could not be downloaded. Error: ({$e->getMessage()}.", sel…
1522 $this->setSourcePath($originalPath);
1534 return $this->getRequestedName();
1536 return $this->getSourcePath()->getLastNameWithoutExtension();
1541 * @return bool - true if no width or height was requested
1546 if ($this->requestedWidth !== null) {
1549 if ($this->requestedHeight !== null) {
1561 $zoom = $this->zoomFactor;
1570 $this->zoomFactor = $zoomFactor;
1576 $this->requestedClass = $value;
1586 if ($this->requestedClass === null) {
1589 return $this->requestedClass;
1598 $this->setIntrinsicHeight()
1599 ->setIntrinsicWidth();
1607 …$viewBox = $this->getXmlDocument()->getDomDocument()->documentElement->getAttribute(FetcherSvg::VI…
1609 $attributes = $this->getViewBoxAttributes($viewBox);
1615 $this->intrinsicHeight = DataType::toIntegerCeil($viewBoxHeight);
1623 * https://raw.githubusercontent.com/fefanto/fontaudio/master/svgs/fad-random-1dice.svg
1625 … $height = $this->getXmlDocument()->getDomDocument()->documentElement->getAttribute("height");
1630 $this->intrinsicHeight = DataType::toInteger($height);
1642 $viewBox = $this->getXmlDom()->documentElement->getAttribute(FetcherSvg::VIEW_BOX);
1644 $attributes = $this->getViewBoxAttributes($viewBox);
1650 $this->intrinsicWidth = DataType::toIntegerCeil($viewBoxWidth);
1659 * https://raw.githubusercontent.com/fefanto/fontaudio/master/svgs/fad-random-1dice.svg
1661 $width = $this->getXmlDom()->documentElement->getAttribute("width");
1666 $this->intrinsicWidth = DataType::toInteger($width);
1687 if ($this->xmlDocument !== null) {
1696 $this->xmlDocument = XmlDocument::createXmlDocFromMarkup($markup);
1697 $localName = $this->xmlDocument->getElement()->getLocalName();
1701 $this->setIntrinsicDimensions();
1712 $path = $this->getSourcePath();
1719 $this->buildXmlDocumentIfNeeded($markup);
1721 … throw new ExceptionRuntime("The svg file ($path) is not a valid svg. Error: {$e->getMessage()}");
1730 * @return bool - true if the svg is an icon
1734 return $this->getInternalStructureType() === self::ICON_TYPE;
1738 * @return string - the internal structure of the svg
1744 $mediaWidth = $this->getIntrinsicWidth();
1745 $mediaHeight = $this->getIntrinsicHeight();
1756 // in size than 400. example 1024 for ant-design:table-outlined
1757 …// https://github.com/ant-design/ant-design-icons/blob/master/packages/icons-svg/svg/outlined/tabl…
1761 $isInIconDirectory = IconDownloader::isInIconDirectory($this->getSourcePath());
1767 $requestType = $this->getRequestedType();
1785 * @throws ExceptionNotFound - if not a icon or tile requested
1790 if (!$this->norWidthNorHeightWasRequested()) {
1794 if ($this->isCropRequested()) {
1801 $internalStructure = $this->getInternalStructureType();
1805 $requestedType = $this->getRequestedType();