Browse Source

Evolution #42: Pagination des éléments

bastien 13 years ago
parent
commit
f416875eca

+ 0 - 8
src/Muzich/CoreBundle/Resources/views/SearchElement/default.html.twig View File

@@ -37,14 +37,6 @@
37 37
     {% endfor %} 
38 38
   </ul>
39 39
 
40
-   {% if more_count is defined %} 
41
-     <span class="elements_more">
42
-       <a href="{{ path('home_more', {'count': more_count}) }}" >
43
-         {{ 'more'|trans({}, 'userui') }}
44
-       </a>
45
-     </span>
46
-   {% endif %}
47
-
48 40
 {% else %}
49 41
 
50 42
   <p class="no-elements">{{ 'noelements.sentence'|trans({}, 'elements') }}</p>

+ 10 - 6
src/Muzich/HomeBundle/Controller/ShowController.php View File

@@ -16,20 +16,22 @@ class ShowController extends Controller
16 16
    * @Template()
17 17
    * @param string $slug
18 18
    */
19
-  public function showUserAction($slug)
19
+  public function showUserAction($slug, $count = null)
20 20
   {
21 21
     $viewed_user = $this->findUserWithSlug($slug);
22 22
         
23 23
     $search_object = $this->createSearchObject(array(
24 24
       'user_id'  => $viewed_user->getId(),
25
-      'count'    => $this->container->getParameter('search_default_count')
25
+      'count'    => ($count)?$count:$this->container->getParameter('search_default_count')
26 26
     ));
27 27
     
28 28
     return array(
29 29
       'viewed_user' => $viewed_user,
30 30
       'elements'    => $search_object->getElements($this->getDoctrine(), $this->getUserId()),
31 31
       'following'   => $this->getUser()->isFollowingUserByQuery($this->getDoctrine(), $viewed_user->getId()),
32
-      'user'        => $this->getUser()
32
+      'user'        => $this->getUser(),
33
+      'more_count'  => ($count)?$count+$this->container->getParameter('search_default_count'):$this->container->getParameter('search_default_count')*2,
34
+      'more_route'  => 'show_user_more'
33 35
     );
34 36
   }
35 37
   
@@ -39,13 +41,13 @@ class ShowController extends Controller
39 41
    * @Template()
40 42
    * @param string $slug
41 43
    */
42
-  public function showGroupAction($slug)
44
+  public function showGroupAction($slug, $count = null)
43 45
   {
44 46
     $group = $this->findGroupWithSlug($slug);
45 47
         
46 48
     $search_object = $this->createSearchObject(array(
47 49
       'group_id'  => $group->getId(),
48
-      'count'     => $this->container->getParameter('search_default_count')
50
+      'count'     => ($count)?$count:$this->container->getParameter('search_default_count')
49 51
     ));
50 52
     
51 53
     ($group->getOwner()->getId() == $this->getUserId()) ? $his = true : $his = false;
@@ -66,7 +68,9 @@ class ShowController extends Controller
66 68
       'elements'  => $search_object->getElements($this->getDoctrine(), $this->getUserId()),
67 69
       'following' => $this->getUser()->isFollowingGroupByQuery($this->getDoctrine(), $group->getId()),
68 70
       'user'      => $this->getUser(),
69
-      'add_form'  => (isset($add_form)) ? $add_form->createView() : null
71
+      'add_form'  => (isset($add_form)) ? $add_form->createView() : null,
72
+      'more_count'=> ($count)?$count+$this->container->getParameter('search_default_count'):$this->container->getParameter('search_default_count')*2,
73
+      'more_route'=> 'show_group_more'
70 74
     );
71 75
   }
72 76
   

+ 8 - 0
src/Muzich/HomeBundle/Resources/config/routing.yml View File

@@ -12,6 +12,14 @@ show_user:
12 12
   pattern: /user/{slug}
13 13
   defaults: { _controller: MuzichHomeBundle:Show:showUser }
14 14
   
15
+show_user_more:
16
+  pattern: /user/{slug}/more/{count}
17
+  defaults: { _controller: MuzichHomeBundle:Show:showUser, count: null }
18
+  
15 19
 show_group:
16 20
   pattern: /group/{slug}
17 21
   defaults: { _controller: MuzichHomeBundle:Show:showGroup }
22
+  
23
+show_group_more:
24
+  pattern: /group/{slug}/more/{count}
25
+  defaults: { _controller: MuzichHomeBundle:Show:showGroup, count: null }

+ 9 - 0
src/Muzich/HomeBundle/Resources/views/Home/index.html.twig View File

@@ -17,4 +17,13 @@
17 17
 
18 18
   {% include "MuzichCoreBundle:SearchElement:default.html.twig" %}
19 19
     
20
+  
21
+  {% if more_count is defined %} 
22
+   <span class="elements_more">
23
+     <a href="{{ path('home_more', {'count': more_count}) }}" >
24
+       {{ 'more'|trans({}, 'userui') }}
25
+     </a>
26
+   </span>
27
+  {% endif %}
28
+  
20 29
 {% endblock %}

+ 8 - 0
src/Muzich/HomeBundle/Resources/views/Show/showGroup.html.twig View File

@@ -43,4 +43,12 @@
43 43
   
44 44
   {% include "MuzichCoreBundle:SearchElement:default.html.twig" %}
45 45
     
46
+  {% if more_count is defined %} 
47
+   <span class="elements_more">
48
+     <a href="{{ path('show_group_more', {'count': more_count, 'slug': group.slug}) }}" >
49
+       {{ 'more'|trans({}, 'userui') }}
50
+     </a>
51
+   </span>
52
+  {% endif %}
53
+  
46 54
 {% endblock %}

+ 8 - 0
src/Muzich/HomeBundle/Resources/views/Show/showUser.html.twig View File

@@ -25,4 +25,12 @@
25 25
   
26 26
   {% include "MuzichCoreBundle:SearchElement:default.html.twig" %}
27 27
     
28
+  {% if more_count is defined %} 
29
+   <span class="elements_more">
30
+     <a href="{{ path('show_user_more', {'count': more_count, 'slug': viewed_user.slug}) }}" >
31
+       {{ 'more'|trans({}, 'userui') }}
32
+     </a>
33
+   </span>
34
+  {% endif %}
35
+  
28 36
 {% endblock %}