Browse Source

Update to latest pagerfanta

Jordi Boggiano 12 years ago
parent
commit
82278555ad

+ 1 - 1
composer.json

@@ -51,7 +51,7 @@
         "zendframework/zend-version": "2.0.*",
 
         "kriswallsmith/assetic": "@dev",
-        "pagerfanta/pagerfanta": "1.0.x-dev#ae0ff215b3be2c3bd0b131a8b8daa9b15568c6db"
+        "pagerfanta/pagerfanta": "@dev"
     },
     "scripts": {
         "post-install-cmd": [

+ 4 - 4
composer.lock

@@ -1,5 +1,5 @@
 {
-    "hash": "457b02677ddbb625736c1fed46eeec24",
+    "hash": "af3068657b3b1e2673fb640a6ef8aad2",
     "packages": [
         {
             "name": "composer/composer",
@@ -1087,12 +1087,12 @@
             "source": {
                 "type": "git",
                 "url": "https://github.com/whiteoctober/Pagerfanta.git",
-                "reference": "ae0ff215b3be2c3bd0b131a8b8daa9b15568c6db"
+                "reference": "92921b9bb155cecc68695fb273729a08586ceaf4"
             },
             "dist": {
                 "type": "zip",
                 "url": "https://api.github.com/repos/whiteoctober/Pagerfanta/zipball/92921b9bb155cecc68695fb273729a08586ceaf4",
-                "reference": "ae0ff215b3be2c3bd0b131a8b8daa9b15568c6db",
+                "reference": "92921b9bb155cecc68695fb273729a08586ceaf4",
                 "shasum": ""
             },
             "require": {
@@ -1139,7 +1139,7 @@
                 "page",
                 "paging"
             ],
-            "time": "2013-03-12 22:52:44"
+            "time": "2013-04-02 11:00:09"
         },
         {
             "name": "predis/predis",

+ 2 - 2
src/Packagist/WebBundle/Controller/WebController.php

@@ -26,7 +26,7 @@ use Packagist\WebBundle\Form\Model\SearchQuery;
 use Packagist\WebBundle\Package\Updater;
 use Packagist\WebBundle\Entity\Package;
 use Packagist\WebBundle\Entity\Version;
-use Packagist\WebBundle\Model\FixedAdapter;
+use Pagerfanta\Adapter\FixedAdapter;
 use Packagist\WebBundle\Form\Type\PackageType;
 use Symfony\Component\HttpFoundation\RedirectResponse;
 use Symfony\Component\HttpFoundation\Response;
@@ -137,7 +137,7 @@ class WebController extends Controller
             return array_search($a->getId(), $popularIds) > array_search($b->getId(), $popularIds) ? 1 : -1;
         });
 
-        $packages = new Pagerfanta(new FixedAdapter($popular, $redis->zcard('downloads:trending')));
+        $packages = new Pagerfanta(new FixedAdapter($redis->zcard('downloads:trending'), $popular));
         $packages->setMaxPerPage(15);
         $packages->setCurrentPage($req->get('page', 1), false, true);
 

+ 0 - 46
src/Packagist/WebBundle/Model/FixedAdapter.php

@@ -1,46 +0,0 @@
-<?php
-
-/*
- * This file is part of Packagist.
- *
- * (c) Jordi Boggiano <j.boggiano@seld.be>
- *     Nils Adermann <naderman@naderman.de>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Packagist\WebBundle\Model;
-
-use Pagerfanta\Adapter\AdapterInterface;
-
-/**
- * @author Jordi Boggiano <j.boggiano@seld.be>
- */
-class FixedAdapter implements AdapterInterface
-{
-    protected $data;
-    protected $count;
-
-    public function __construct($data, $count)
-    {
-        $this->data = $data;
-        $this->count = $count;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public function getNbResults()
-    {
-        return $this->count;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public function getSlice($offset, $length)
-    {
-        return $this->data;
-    }
-}

+ 1 - 1
src/Packagist/WebBundle/Resources/views/macros.html.twig

@@ -20,7 +20,7 @@
             </li>
         {% endfor %}
 
-        {% if paginate is defined and paginate and packages.nbPages > 1 %}
+        {% if paginate is defined and paginate and packages.haveToPaginate() %}
             {{ pagerfanta(packages, 'default', {'proximity': 2}) }}
         {% endif %}
     </ul>