Permalink
Browse files

Added paginator to software

  • Loading branch information...
1 parent 4d6e563 commit 26fd67d568e97ad81ce95663560b35873d7b4f58 @jaytaph committed Jul 9, 2012
View
@@ -38,5 +38,5 @@ BoxConfig
* [ ] Implement user profile (/profile)
* [ ] fancybox always uses 75% now, make it so it autoscales to small window
* [ ] On password forget implementation, make sure we have a nice noticebar and the window closes automatically
-* [ ] Paginate software
+* [i] Paginate software
* [ ] easy search software
View
@@ -22,6 +22,7 @@ public function registerBundles()
new Mopa\Bundle\BootstrapBundle\MopaBootstrapBundle(),
new Ornicar\GravatarBundle\OrnicarGravatarBundle(),
new Knp\Bundle\MenuBundle\KnpMenuBundle(),
+ new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),
new BoxConfig\DefaultBundle\BoxConfigDefaultBundle(),
new BoxConfig\AccountBundle\BoxConfigAccountBundle(),
@@ -0,0 +1,30 @@
+{% if pageCount > 1 %}
+<div class="pagination" style='text-align:center;'>
+ <ul>
+
+ {% if first is defined and current != first %}
+ <li><a href="{{ path(route, query|merge({(pageParameterName): first})) }}">&lt;&lt;</a></li>
+ {% endif %}
+
+ {% if previous is defined %}
+ <li><a href="{{ path(route, query|merge({(pageParameterName): previous})) }}">&lt;</a></li>
+ {% endif %}
+
+ {% for page in pagesInRange %}
+ {% if page != current %}
+ <li><a href="{{ path(route, query|merge({(pageParameterName): page})) }}">{{ page }}</a></li>
+ {% else %}
+ <li class="active"><a href="#">{{ page }}</a></li>
+ {% endif %}
+ {% endfor %}
+
+ {% if next is defined %}
+ <li><a href="{{ path(route, query|merge({(pageParameterName): next})) }}">&gt;</a></li>
+ {% endif %}
+
+ {% if last is defined and current != last %}
+ <li><a href="{{ path(route, query|merge({(pageParameterName): last})) }}">&gt;&gt;</a></li>
+ {% endif %}
+ </ul>
+</div>
+{% endif %}
View
@@ -21,6 +21,8 @@
'Ornicar' => __DIR__.'/../vendor/bundles',
'Knp\Bundle' => __DIR__.'/../vendor/bundles',
'Knp\Menu' => __DIR__.'/../vendor/KnpMenu/src',
+ 'Knp\\Component' => __DIR__.'/../vendor/knp-components/src',
+ 'Knp\\Bundle' => __DIR__.'/../vendor/bundles',
));
$loader->registerPrefixes(array(
'Twig_Extensions_' => __DIR__.'/../vendor/twig-extensions/lib',
View
@@ -93,3 +93,14 @@ knp_menu:
templating: false
default_renderer: twig
+knp_paginator:
+ page_range: 5 # default page range used in pagination control
+ default_options:
+ page_name: page # page query parameter name
+ sort_field_name: sort # sort field query parameter name
+ sort_direction_name: direction # sort direction query parameter name
+ distinct: true # ensure distinct results, useful when ORM queries are using GROUP BY statements
+ template:
+ pagination: KnpPaginatorBundle:Pagination:sliding.html.twig # sliding pagination controls template
+ sortable: KnpPaginatorBundle:Pagination:sortable_link.html.twig # sort link template
+
View
9 deps
@@ -91,4 +91,11 @@
[KnpMenuBundle]
git=https://github.com/KnpLabs/KnpMenuBundle.git
target=bundles/Knp/Bundle/MenuBundle
- version=v1.1.0
+ version=v1.1.0
+
+[knp-components]
+ git=http://github.com/KnpLabs/knp-components.git
+
+[KnpPaginatorBundle]
+ git=http://github.com/KnpLabs/KnpPaginatorBundle.git
+ target=bundles/Knp/Bundle/PaginatorBundle
@@ -64,13 +64,17 @@ function($item) use($environment) {
}
);
+ $paginator = $this->get('knp_paginator');
+ $software = $paginator->paginate($software, $this->get('request')->query->get('page', 1), 25);
+ $available_software = $paginator->paginate($available_software, $this->get('request')->query->get('page', 1), 25);
+ $installed_software = $paginator->paginate($installed_software, $this->get('request')->query->get('page', 1), 25);
+
return $this->render('BoxConfigBoxBundle:Software:index.html.twig', array(
'machine' => $machine,
'environment' => $environment,
'software' => $software,
'installed' => $installed_software,
'available' => $available_software,
-
));
}
@@ -1,3 +1,5 @@
+{{ software.render()|raw }}
+
<table class="table records_list">
<thead>
<tr>
@@ -44,4 +46,4 @@
</tbody>
</table>
-
+{{ software.render()|raw }}
@@ -15,7 +15,7 @@ public function topAction($slug)
case "hardware" :
$title = "Hardware";
$items = $em->getRepository('BoxConfigComponentBundle:Hardware')->getTop(5);
- $path = "hardware_show";
+ $path = "component_hardware_show";
break;
case "ide" :
$title = "PHP IDE's";
@@ -26,12 +26,12 @@ public function topAction($slug)
case "os" :
$title = "Operating Systems";
$items = $em->getRepository('BoxConfigComponentBundle:OperatingSystem')->getTop(5);
- $path = "operatingsystem_show";
+ $path = "component_operatingsystem_show";
break;
case "os" :
$title = "Software";
$items = $em->getRepository('BoxConfigComponentBundle:Software')->getTop(5);
- $path = "software_show";
+ $path = "component_software_show";
break;
default :
throw new \Symfony\Component\HttpKernel\Exception\NotFoundHttpException();
@@ -6,5 +6,5 @@
<p>You have currently <b>{{ app.user.machines | length }}</b> machines registered.</p>
- <p><a class="btn btn-primary btn-large" href="{{ path("machine") }}">View machines &raquo;</a></p>
+ <p><a class="btn btn-primary btn-large" href="{{ path("box_machine") }}">View machines &raquo;</a></p>
{% endblock %}

0 comments on commit 26fd67d

Please sign in to comment.