From f49a30c36673d981af7396f9be1fe0b369f760c5 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Wed, 9 Mar 2011 15:04:56 +0100 Subject: [PATCH] [WebProfilerBundle] Better handling of queries with an empty result --- .../Controller/ProfilerController.php | 2 +- .../Resources/views/Profiler/layout.html.twig | 18 +++++----- .../views/Profiler/results.html.twig | 35 +++++++++++-------- 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php index 4bc680037cf8..8b399f1017ae 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php @@ -235,7 +235,7 @@ public function searchAction() $tokens = $profiler->find($ip, $url, $limit); - return new RedirectResponse($this->container->get('router')->generate('_profiler_search_results', array('token' => $tokens ? $tokens[0]['token'] : ''))); + return new RedirectResponse($this->container->get('router')->generate('_profiler_search_results', array('token' => $tokens ? $tokens[0]['token'] : 'empty'))); } protected function getTemplateNames($profiler) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig index 1c7814d491cc..aef342daa6c7 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig @@ -7,14 +7,16 @@
{% include 'WebProfilerBundle:Profiler:header.html.twig' only %} -
-

- {{ profiler.url }} - - by {{ profiler.ip }} at {{ profiler.time|date('r') }} - -

-
+ {% if not profiler.isempty %} +
+

+ {{ profiler.url }} + + by {{ profiler.ip }} at {{ profiler.time|date('r') }} + +

+
+ {% endif %}
diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/results.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/results.html.twig index cd0fbc69b347..b71ece615841 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/results.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/results.html.twig @@ -3,20 +3,27 @@ {% block panel %}

Search Results

- - - - - - - - {% for elements in tokens %} + {% if tokens %} +
TokenIPURLTime
- - - - + + + + - {% endfor %} -
{{ elements.token }}{{ elements.ip }}{{ elements.url }}{{ elements.time|date('r') }}TokenIPURLTime
+ {% for elements in tokens %} + + {{ elements.token }} + {{ elements.ip }} + {{ elements.url }} + {{ elements.time|date('r') }} + + {% endfor %} + + {% else %} +

+ The query returned no result. +

+ {% endif %} + {% endblock %}