add app url (tel:, mailto:, fax:)
This commit is contained in:
parent
37a7a3b625
commit
e42860ac5b
|
@ -334,6 +334,19 @@ class Node implements EntityInterface
|
||||||
return $string->startsWith('http://') || $string->startsWith('https://');
|
return $string->startsWith('http://') || $string->startsWith('https://');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hasAppUrl(): bool
|
||||||
|
{
|
||||||
|
$string = u($this->getUrl());
|
||||||
|
|
||||||
|
foreach (['tel:', 'fax:', 'mailto:'] as $prefix) {
|
||||||
|
if ($string->startsWith($prefix)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public function getIsVisible(): ?bool
|
public function getIsVisible(): ?bool
|
||||||
{
|
{
|
||||||
return $this->isVisible;
|
return $this->isVisible;
|
||||||
|
|
|
@ -133,7 +133,13 @@ class NodeEventSubscriber extends EntityManagerEventSubscriber
|
||||||
$generatedUrl = $generatedUrl.'-'.$number;
|
$generatedUrl = $generatedUrl.'-'.$number;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!u($generatedUrl)->startsWith('https://') && !u($generatedUrl)->startsWith('http://')) {
|
if (
|
||||||
|
!u($generatedUrl)->startsWith('https://')
|
||||||
|
&& !u($generatedUrl)->startsWith('http://')
|
||||||
|
&& !u($generatedUrl)->startsWith('tel:')
|
||||||
|
&& !u($generatedUrl)->startsWith('mailto:')
|
||||||
|
&& !u($generatedUrl)->startsWith('fax:')
|
||||||
|
) {
|
||||||
$generatedUrl = '/'.$generatedUrl;
|
$generatedUrl = '/'.$generatedUrl;
|
||||||
$generatedUrl = preg_replace('#/{2,}#', '/', $generatedUrl);
|
$generatedUrl = preg_replace('#/{2,}#', '/', $generatedUrl);
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,6 +87,10 @@
|
||||||
<a href="{{ safe_node_url(node) }}" class="btn btn-sm border border-secondary btn-light">
|
<a href="{{ safe_node_url(node) }}" class="btn btn-sm border border-secondary btn-light">
|
||||||
<span class="fa fa-sign-out-alt text-muted"></span>
|
<span class="fa fa-sign-out-alt text-muted"></span>
|
||||||
</a>
|
</a>
|
||||||
|
{% elseif node.hasAppUrl %}
|
||||||
|
<a href="{{ node.url }}" class="btn btn-sm border border-secondary btn-light">
|
||||||
|
<span class="fa fa-sign-out-alt text-muted"></span>
|
||||||
|
</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if not node.disableUrl %}
|
{% if not node.disableUrl %}
|
||||||
{% if node.parameters|length %}
|
{% if node.parameters|length %}
|
||||||
|
|
|
@ -57,6 +57,10 @@ class SiteRouteLoader extends Loader
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($node->hasAppUrl()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (null !== $node->getAliasNode()) {
|
if (null !== $node->getAliasNode()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue