49 for($iter->rewind(); $iter->valid(); $iter->next()) {
51 $currentNode = $iter->currentNode();
52 $valueName = $iter->key();
53 $value = $currentNode->getValue($valueName);
60 $urls[$value] = 'direct';
64 foreach ($urls as $url => $type) {
66 if (!InternalLink::isLink($url) && !preg_match('/^#|^{|^$|^[a-zA-Z]+:\/\/|^javascript:|^mailto:/', $url) &&
67 @file_exists($url) === false) {
71 $url = $urlConv['absolute'];
82 elseif (preg_match('/^#/', $url)) {
86 if ($urlConv !== null) {
92 $logger->error("Invalid URL found: ".$url);
93 $oidStr = $currentNode->getOID()->__toString();
94 if (!isset($invalidURLs[$oidStr])) {
97 $invalidURLs[$oidStr][] = $url;
101 if ($oldValue != $value) {
102 $currentNode->setValue($valueName, $value, true);
116 protected static function replaceUrl($value, $url, $urlConv, $type) {
117 if ($type == 'embedded') {
118 $value = str_replace('"'.$url.'"', '"'.$urlConv.'"', $value);
121 $value = str_replace($url, $urlConv, $value);
133 if (preg_match('/^#|^{|^$|^mailto:/', $url) || (strpos($url, 'javascript:') === 0 && !InternalLink::isLink($url)) ||
134 @file_exists($url) !== false) {
143 $object = $persistenceFacade->load($oid);
145 $logger->error("Linked object ".$oid." does not exist");
153 $logger->error("Type of linked object ".$oid." is unknown");
177 $object = $persistenceFacade->load($oid);
184 if ($anchorOID != null) {
185 if (strrpos($urlConv) !== 0) {
188 $urlConv .= $anchorOID;
192 if ($anchorName != null) {
193 if (strrpos($urlConv) !== 0) {
196 $urlConv .= $anchorName;
static checkUrl($url, LinkProcessorStrategy $strategy)
Check if an url is reachable (e.g.
static getReferencedOID($link)
Get the oid of the referenced object.
NodeValueIterator is used to iterate over all persistent values of a Node (not including relations).
StringUtil provides support for string manipulation.
static convertInternalLink($url, LinkProcessorStrategy $strategy)
Convert an internal link.
InternalLink contains static methods for handling internal application links.
static translate($pathFromA, $pathFromScriptToA)
Translate a relative URI from one location to the script location.
static isLink($link)
Test if a link is an internal link.
URIUtil provides support for uri manipulation.
static replaceUrl($value, $url, $urlConv, $type)
Replace the url in the given value.
static getLogger($name)
Get the logger with the given name.
static getInstance($name, $dynamicConfiguration=[])
isValidTarget(PersistentObject $object)
Check if the given object is a valid link target.
LinkProcessor is used to process links in Node instances.
LogManager is used to retrieve Logger instances.
ObjectFactory implements the service locator pattern by wrapping a Factory instance and providing sta...
wCMF - wemove Content Management Framework Copyright (C) 2005-2020 wemove digital solutions GmbH
getObjectUrl(PersistentObject $object, $params=null)
Get the url under which the object should be published.
static processLinks($node, $base, LinkProcessorStrategy $strategy, $recursive=true)
Check and convert links in the given node.
LinkProcessorStrategy defines the interface for strategies used by LinkProcessor.
static getAnchorOID($link)
Get the oid of the referenced subobject if any.
static getUrls($string)
Extraxt urls from a string.
static getAnchorName($link)
Get the name of the anchor inside the referenced subobject if any.