Browse Source

add app url (tel:, mailto:, fax:)

develop
Simon Vieille 1 month ago
parent
commit
e42860ac5b
  1. 13
      core/Entity/Site/Node.php
  2. 8
      core/EventSuscriber/Site/NodeEventSubscriber.php
  3. 4
      core/Resources/views/site/tree_admin/navigation.html.twig
  4. 4
      core/Router/SiteRouteLoader.php

13
core/Entity/Site/Node.php

@ -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;

8
core/EventSuscriber/Site/NodeEventSubscriber.php

@ -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);
}

4
core/Resources/views/site/tree_admin/navigation.html.twig

@ -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 %}

4
core/Router/SiteRouteLoader.php

@ -57,6 +57,10 @@ class SiteRouteLoader extends Loader
continue;
}
if ($node->hasAppUrl()) {
continue;
}
if (null !== $node->getAliasNode()) {
continue;
}

Loading…
Cancel
Save