Skip to content

Commit

Permalink
[WebProfilerBundle] Better handling of queries with an empty result
Browse files Browse the repository at this point in the history
  • Loading branch information
vicb committed Mar 9, 2011
1 parent ed09566 commit f49a30c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 23 deletions.
Expand Up @@ -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)
Expand Down
Expand Up @@ -7,14 +7,16 @@
<div id="content">
{% include 'WebProfilerBundle:Profiler:header.html.twig' only %}

<div class="resume">
<p>
<strong><a href="{{ profiler.url }}">{{ profiler.url }}</a></strong>
<span class="date">
<strong>by {{ profiler.ip }}</strong> at <strong>{{ profiler.time|date('r') }}</strong>
</span>
</p>
</div>
{% if not profiler.isempty %}
<div class="resume">
<p>
<strong><a href="{{ profiler.url }}">{{ profiler.url }}</a></strong>
<span class="date">
<strong>by {{ profiler.ip }}</strong> at <strong>{{ profiler.time|date('r') }}</strong>
</span>
</p>
</div>
{% endif %}

<div class="main">

Expand Down
Expand Up @@ -3,20 +3,27 @@
{% block panel %}
<h2>Search Results</h2>

<table>
<tr>
<th>Token</th>
<th>IP</th>
<th>URL</th>
<th>Time</th>
</tr>
{% for elements in tokens %}
{% if tokens %}
<table>
<tr>
<td><a href="{{ path('_profiler', { 'token': elements.token }) }}">{{ elements.token }}</a></td>
<td>{{ elements.ip }}</td>
<td>{{ elements.url }}</td>
<td>{{ elements.time|date('r') }}</td>
<th>Token</th>
<th>IP</th>
<th>URL</th>
<th>Time</th>
</tr>
{% endfor %}
</table>
{% for elements in tokens %}
<tr>
<td><a href="{{ path('_profiler', { 'token': elements.token }) }}">{{ elements.token }}</a></td>
<td>{{ elements.ip }}</td>
<td>{{ elements.url }}</td>
<td>{{ elements.time|date('r') }}</td>
</tr>
{% endfor %}
</table>
{% else %}
<p>
<em>The query returned no result.</em>
</p>
{% endif %}

{% endblock %}

0 comments on commit f49a30c

Please sign in to comment.