From 3429324188412c1670799b25e3f3d5e7a17ec0da Mon Sep 17 00:00:00 2001 From: ghost Date: Tue, 13 Feb 2024 01:40:05 +0200 Subject: [PATCH] add namespace title support --- src/Controller/MainController.php | 39 +++++++++++++++++++- templates/default/main/namespace.html.twig | 11 +++--- templates/default/main/transaction.html.twig | 11 +++--- 3 files changed, 49 insertions(+), 12 deletions(-) diff --git a/src/Controller/MainController.php b/src/Controller/MainController.php index baef2a7..8516c7d 100644 --- a/src/Controller/MainController.php +++ b/src/Controller/MainController.php @@ -89,6 +89,9 @@ class MainController extends AbstractController ], $request->get('part') > 1 ? (int) $request->get('part') * $this->getParameter('app.main.index.limit') : 0, $this->getParameter('app.main.index.limit') + ), + 'title' => $this->_title( + $request->get('namespace') ) ] ); @@ -126,14 +129,46 @@ class MainController extends AbstractController throw $this->createNotFoundException(); } + $record = reset( + $records + ); + return $this->render( 'default/main/transaction.html.twig', [ 'request' => $request, - 'record' => reset( - $records + 'record' => $record, + 'title' => $this->_title( + $record['namespace'] + ) + ] + ); + } + + private function _title(string $namespace): ?string + { + $index = new \Kvazar\Index\Manticore(); + + $title = $index->get( + '_KEVA_NS_', + [ + 'crc32namespace' => crc32( + $namespace ) ] ); + + if ($title) + { + $title = reset( + $title + ); + + return trim( + $title['value'] + ); + } + + return null; } } \ No newline at end of file diff --git a/templates/default/main/namespace.html.twig b/templates/default/main/namespace.html.twig index 54c648c..59b768f 100644 --- a/templates/default/main/namespace.html.twig +++ b/templates/default/main/namespace.html.twig @@ -1,4 +1,5 @@ {% extends 'default/layout.html.twig' %} +{% block title %}{% if title %}{{ title }} - {% endif %}{{ app.name }}{% endblock %} {% block body %}
@@ -8,11 +9,11 @@
{{ request.get('namespace') }}
- {# @TODO current namespace value -
- {{ 'Observe Kevacoin Universe' | trans }} -
- #} + {% if title %} +
+ {{ title }} +
+ {% endif %}
diff --git a/templates/default/main/transaction.html.twig b/templates/default/main/transaction.html.twig index aee6346..f0b454d 100644 --- a/templates/default/main/transaction.html.twig +++ b/templates/default/main/transaction.html.twig @@ -1,4 +1,5 @@ {% extends 'default/layout.html.twig' %} +{% block title %}{% if title %}{{ title }} - {% endif %}{{ app.name }}{% endblock %} {% block body %}
@@ -10,11 +11,11 @@ {{ record.namespace }}
- {# @TODO current namespace value -
- {{ 'Observe Kevacoin Universe' | trans }} -
- #} + {% if title %} +
+ {{ title }} +
+ {% endif %}