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://');
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
return $this->isVisible;
|
||||
|
|
|
@ -133,7 +133,13 @@ class NodeEventSubscriber extends EntityManagerEventSubscriber
|
|||
$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 = preg_replace('#/{2,}#', '/', $generatedUrl);
|
||||
}
|
||||
|
|
|
@ -87,6 +87,10 @@
|
|||
<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>
|
||||
</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 %}
|
||||
{% if not node.disableUrl %}
|
||||
{% if node.parameters|length %}
|
||||
|
|
|
@ -57,6 +57,10 @@ class SiteRouteLoader extends Loader
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($node->hasAppUrl()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (null !== $node->getAliasNode()) {
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue