Permalink
Browse files

battle reports paginated, removed unesseary page-dummy-parameter

  • Loading branch information...
1 parent f0f026d commit 761e76d07a36d6808478a86944256a3ba217ae13 @ppetermann ppetermann committed Dec 31, 2012
Showing with 62 additions and 18 deletions.
  1. +4 −5 conf/routes.php
  2. +24 −2 src/Kingboard/Views/Battle.php
  3. +23 −0 templates/battle/index.html
  4. +8 −8 templates/components/kill_list.html
  5. +3 −3 templates/newindex.html
View
@@ -24,11 +24,10 @@
$router->addRoute('/alliance/name/', 'Kingboard\Views\Search', "nameAlliance", array("alliancename"));
// corp/alliance/faction/pilot statistics
-$router->addRoute("/details/", 'Kingboard\Views\Homepage', "killlist", array("ownerType", "ownerID", "dummy", "page"));
+$router->addRoute("/details/", 'Kingboard\Views\Homepage', "killlist", array("ownerType", "ownerID","page"));
-
-$router->addRoute("/kills", 'Kingboard\Views\Kill', 'index');
-$router->addRoute("/kills/page/", 'Kingboard\Views\Kill', "index", array('page'));
+// kills index
+$router->addRoute("/kills/", 'Kingboard\Views\Kill', 'index', array('page'));
// kill details
$router->addRoute("/kill/", 'Kingboard\Views\Kill', 'details', array('killID'));
@@ -60,7 +59,7 @@
$router->addRoute("/autocomplete/search/?/", 'Kingboard\Views\AutoCompleter', "search", array("text"));
// battles
-$router->addRoute("/battles", 'Kingboard\Views\Battle', "index");
+$router->addRoute("/battles/", 'Kingboard\Views\Battle', "index", array("page"));
$router->addRoute("/battle/editor", 'Kingboard\Views\BattleEditor', "index");
$router->addRoute("/battle/new", 'Kingboard\Views\BattleEditor', "create");
@@ -7,10 +7,32 @@ class Battle extends \Kingboard\Views\Base
* @param array $parameters
* @return void
*/
- public function index(array $parameters)
+ public function index(array $request)
{
+ $templateVars = array();
+ $currentPage = 1;
+ if (!empty($request['page']))
+ {
+ $currentPage = ((int) $request['page'] <1) ? 1 : (int) $request['page'];
+ }
+
+ $count = \Kingboard\Model\BattleSettings::find()->count();
+
+ $paginator = new \Kingboard\Lib\Paginator($currentPage, $count);
+
+ // merge in pagination data
+ $templateVars= array_merge($templateVars, $paginator->getNavArray());
+
+
// battles
- $templateVars['reports'] = \Kingboard\Model\BattleSettings::find()->limit(5)->sort(array('enddate' => -1));
+ $templateVars['reports'] = \Kingboard\Model\BattleSettings::find()
+ ->skip($paginator->getSkip())
+ ->limit($paginator->getKillsPerPage())
+ ->sort(array('enddate' => -1));
+
+ $templateVars['action'] = "/battles";
+
+
return $this->render("battle/index.html", $templateVars);
}
@@ -6,6 +6,18 @@
{% block content %}
<div class="row-fluid">
<div class="span12">
+ {% if currentPage %}
+ <div class="pagination">
+ <ul>
+ {% if currentPage != 1 %}<li><a href="{{ action }}/1">1</a></li>{% endif %}
+ <li class="prev {% if prev %}{% else %}disabled{% endif %}"><a href="{% if prev %}{{ action }}/{{ prev }}{% else %}#{% endif %}">&larr; Previous</a></li>
+ <li class="active"><a href="#">{{ currentPage }}</a></li>
+ <li class="next {% if next %}{% else %}disabled{% endif %}"><a href="{% if next %}{{ action }}/{{ next }}{% else %}#{% endif %}">Next &rarr;</a></li>
+ {% if currentPage != lastPage %}<li><a href="{{ action }}/{{ lastPage }}">{{ lastPage }}</a></li>{% endif %}
+ </ul>
+ </div>
+ {% endif %}
+
<div id="battlereports">
<h2>Latest Battlereports</h2>
<div class="row">
@@ -29,6 +41,17 @@
</table>
</div>
</div>
+ {% if currentPage %}
+ <div class="pagination">
+ <ul>
+ {% if currentPage != 1 %}<li><a href="{{ action }}/1">1</a></li>{% endif %}
+ <li class="prev {% if prev %}{% else %}disabled{% endif %}"><a href="{% if prev %}{{ action }}/{{ prev }}{% else %}#{% endif %}">&larr; Previous</a></li>
+ <li class="active"><a href="#">{{ currentPage }}</a></li>
+ <li class="next {% if next %}{% else %}disabled{% endif %}"><a href="{% if next %}{{ action }}/{{ next }}{% else %}#{% endif %}">Next &rarr;</a></li>
+ {% if currentPage != lastPage %}<li><a href="{{ action }}/{{ lastPage }}">{{ lastPage }}</a></li>{% endif %}
+ </ul>
+ </div>
+ {% endif %}
</div>
</div>
{% endblock %}
@@ -1,11 +1,11 @@
{% if currentPage %}
<div class="pagination">
<ul>
- {% if currentPage != 1 %}<li><a href="{{ action }}/page/1">1</a></li>{% endif %}
- <li class="prev {% if prev %}{% else %}disabled{% endif %}"><a href="{% if prev %}{{ action }}/page/{{ prev }}{% else %}#{% endif %}">&larr; Previous</a></li>
+ {% if currentPage != 1 %}<li><a href="{{ action }}/1">1</a></li>{% endif %}
+ <li class="prev {% if prev %}{% else %}disabled{% endif %}"><a href="{% if prev %}{{ action }}/{{ prev }}{% else %}#{% endif %}">&larr; Previous</a></li>
<li class="active"><a href="#">{{ currentPage }}</a></li>
- <li class="next {% if next %}{% else %}disabled{% endif %}"><a href="{% if next %}{{ action }}/page/{{ next }}{% else %}#{% endif %}">Next &rarr;</a></li>
- {% if currentPage != lastPage %}<li><a href="{{ action }}/page/{{ lastPage }}">{{ lastPage }}</a></li>{% endif %}
+ <li class="next {% if next %}{% else %}disabled{% endif %}"><a href="{% if next %}{{ action }}/{{ next }}{% else %}#{% endif %}">Next &rarr;</a></li>
+ {% if currentPage != lastPage %}<li><a href="{{ action }}/{{ lastPage }}">{{ lastPage }}</a></li>{% endif %}
</ul>
</div>
{% endif %}
@@ -73,11 +73,11 @@
{% if currentPage %}
<div class="pagination">
<ul>
- {% if currentPage != 1 %}<li><a href="{{ action }}/page/1">1</a></li>{% endif %}
- <li class="prev {% if prev %}{% else %}disabled{% endif %}"><a href="{% if prev %}{{ action }}/page/{{ prev }}{% else %}#{% endif %}">&larr; Previous</a></li>
+ {% if currentPage != 1 %}<li><a href="{{ action }}/1">1</a></li>{% endif %}
+ <li class="prev {% if prev %}{% else %}disabled{% endif %}"><a href="{% if prev %}{{ action }}/{{ prev }}{% else %}#{% endif %}">&larr; Previous</a></li>
<li class="active"><a href="#">{{ currentPage }}</a></li>
- <li class="next {% if next %}{% else %}disabled{% endif %}"><a href="{% if next %}{{ action }}/page/{{ next }}{% else %}#{% endif %}">Next &rarr;</a></li>
- {% if currentPage != lastPage %}<li><a href="{{ action }}/page/{{ lastPage }}">{{ lastPage }}</a></li>{% endif %}
+ <li class="next {% if next %}{% else %}disabled{% endif %}"><a href="{% if next %}{{ action }}/{{ next }}{% else %}#{% endif %}">Next &rarr;</a></li>
+ {% if currentPage != lastPage %}<li><a href="{{ action }}/{{ lastPage }}">{{ lastPage }}</a></li>{% endif %}
</ul>
</div>
{% endif %}
View
@@ -12,7 +12,7 @@
{% block content %}
<ul class="thumbnails">
<li class="span4">
- <a class="thumbnail" href="/kills"><img src="/images/home/kills_360x270.png" /></a>
+ <a class="thumbnail" href="/kills/"><img src="/images/home/kills_360x270.png" /></a>
</li>
<li class="span3">
<a class="thumbnail" href="/top/value"><img src="/images/home/top12isk_260x120.png" /></a>
@@ -21,10 +21,10 @@
<a class="thumbnail" href="/charts"><img src="/images/home/charts_260x120.png" /></a>
</li>
<li class="span2">
- <a class="thumbnail" href="/kills"><img src="/images/home/placeholder_160x120.png" /></a>
+ <a class="thumbnail" href="/kills/"><img src="/images/home/placeholder_160x120.png" /></a>
</li>
<li class="span3">
- <a class="thumbnail" href="/battles"><img src="/images/home/battlereports_260x120.png" /></a>
+ <a class="thumbnail" href="/battles/"><img src="/images/home/battlereports_260x120.png" /></a>
</li>
<li class="span3">
<a class="thumbnail" href="/top/kills"><img src="/images/home/top12kills_260x120.png" /></a>

0 comments on commit 761e76d

Please sign in to comment.