diff --git a/src/Controller/MainController.php b/src/Controller/MainController.php index 0d96851..39804da 100644 --- a/src/Controller/MainController.php +++ b/src/Controller/MainController.php @@ -104,9 +104,6 @@ class MainController extends AbstractController ], $request->get('part') > 1 ? ((int) $request->get('part') - 1) * (int) $this->getParameter('app.main.index.limit') : 0, $this->getParameter('app.main.index.limit') - ), - 'title' => $this->_title( - $request->get('namespace') ) ], $response @@ -153,40 +150,8 @@ class MainController extends AbstractController 'default/main/transaction.html.twig', [ 'request' => $request, - 'record' => $record, - 'title' => $this->_title( - $record['namespace'] - ) - ] - ); - } - - private function _title(string $namespace): ?string - { - $index = new \Kvazar\Index\Manticore(); - - $results = $index->get( - '_KEVA_NS_', - [ - 'crc32_namespace' => crc32( - $namespace - ) + 'record' => $record ] ); - - if ($results) - { - foreach ($results as $result) - { - if ($result['key'] == '_KEVA_NS_') - { - return trim( - $result['value'] - ); - } - } - } - - return null; } } \ No newline at end of file diff --git a/src/Twig/AppExtension.php b/src/Twig/AppExtension.php index dc1d6bc..9682fdf 100644 --- a/src/Twig/AppExtension.php +++ b/src/Twig/AppExtension.php @@ -24,6 +24,13 @@ class AppExtension extends AbstractExtension $this, 'formatType' ] + ), + new TwigFilter( + 'namespace_title', + [ + $this, + 'namespaceTitle' + ] ) ]; } @@ -122,4 +129,35 @@ class AppExtension extends AbstractExtension return '[undefined]'; } } + + public function namespaceTitle( + string $namespace + ): string + { + $index = new \Kvazar\Index\Manticore(); + + $results = $index->get( + '_KEVA_NS_', + [ + 'crc32_namespace' => crc32( + $namespace + ) + ] + ); + + if ($results) + { + foreach ($results as $result) + { + if ($result['key'] == '_KEVA_NS_') + { + return trim( + $result['value'] + ); + } + } + } + + return $namespace; + } } \ No newline at end of file diff --git a/templates/default/main/namespace.html.twig b/templates/default/main/namespace.html.twig index 07e3a61..14e5163 100644 --- a/templates/default/main/namespace.html.twig +++ b/templates/default/main/namespace.html.twig @@ -1,5 +1,5 @@ {% extends 'default/layout.html.twig' %} -{% block title %}{% if title %}{{ title }} - {% endif %}{% if request.get('part') > 1 %}{{ 'Part' | trans | upper }} {{ request.get('part') }} - {% endif %}{{ app.name }}{% endblock %} +{% block title %}{{ request.get('namespace') | namespace_title }} - {% if request.get('part') > 1 %}{{ 'Part' | trans | upper }} {{ request.get('part') }} - {% endif %}{{ app.name }}{% endblock %} {% block favicon %}{% endblock %} {% block body %}
@@ -10,11 +10,9 @@
{{ request.get('namespace') }}
- {% if title %} -
- {{ title }} -
- {% endif %} +
+ {{ request.get('namespace') | namespace_title }} +
diff --git a/templates/default/main/namespace.rss.twig b/templates/default/main/namespace.rss.twig index 8e82221..84e83c5 100644 --- a/templates/default/main/namespace.rss.twig +++ b/templates/default/main/namespace.rss.twig @@ -2,7 +2,7 @@ - {{ app.name }} + {{ request.get('namespace') | namespace_title }} - {{ app.name }} {{ url('main_namespace',{'namespace':request.get('namespace')}) }} {% for record in records %} diff --git a/templates/default/main/transaction.html.twig b/templates/default/main/transaction.html.twig index 402d117..9a0f91d 100644 --- a/templates/default/main/transaction.html.twig +++ b/templates/default/main/transaction.html.twig @@ -1,5 +1,5 @@ {% extends 'default/layout.html.twig' %} -{% block title %}{% if title %}{{ title }} - {% endif %}{{ app.name }}{% endblock %} +{% block title %}{{ record.key | format_type(record.type.key) }} - {{ record.namespace | namespace_title }} - {{ app.name }}{% endblock %} {% block favicon %}{% endblock %} {% block body %}
@@ -12,11 +12,9 @@ {{ record.namespace }}
- {% if title %} -
- {{ title }} -
- {% endif %} +
+ {{ record.namespace | namespace_title }} +