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
     {% endfor %} 
37
     {% endfor %} 
38
   </ul>
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
 {% else %}
40
 {% else %}
49
 
41
 
50
   <p class="no-elements">{{ 'noelements.sentence'|trans({}, 'elements') }}</p>
42
   <p class="no-elements">{{ 'noelements.sentence'|trans({}, 'elements') }}</p>

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

16
    * @Template()
16
    * @Template()
17
    * @param string $slug
17
    * @param string $slug
18
    */
18
    */
19
-  public function showUserAction($slug)
19
+  public function showUserAction($slug, $count = null)
20
   {
20
   {
21
     $viewed_user = $this->findUserWithSlug($slug);
21
     $viewed_user = $this->findUserWithSlug($slug);
22
         
22
         
23
     $search_object = $this->createSearchObject(array(
23
     $search_object = $this->createSearchObject(array(
24
       'user_id'  => $viewed_user->getId(),
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
     return array(
28
     return array(
29
       'viewed_user' => $viewed_user,
29
       'viewed_user' => $viewed_user,
30
       'elements'    => $search_object->getElements($this->getDoctrine(), $this->getUserId()),
30
       'elements'    => $search_object->getElements($this->getDoctrine(), $this->getUserId()),
31
       'following'   => $this->getUser()->isFollowingUserByQuery($this->getDoctrine(), $viewed_user->getId()),
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
    * @Template()
41
    * @Template()
40
    * @param string $slug
42
    * @param string $slug
41
    */
43
    */
42
-  public function showGroupAction($slug)
44
+  public function showGroupAction($slug, $count = null)
43
   {
45
   {
44
     $group = $this->findGroupWithSlug($slug);
46
     $group = $this->findGroupWithSlug($slug);
45
         
47
         
46
     $search_object = $this->createSearchObject(array(
48
     $search_object = $this->createSearchObject(array(
47
       'group_id'  => $group->getId(),
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
     ($group->getOwner()->getId() == $this->getUserId()) ? $his = true : $his = false;
53
     ($group->getOwner()->getId() == $this->getUserId()) ? $his = true : $his = false;
66
       'elements'  => $search_object->getElements($this->getDoctrine(), $this->getUserId()),
68
       'elements'  => $search_object->getElements($this->getDoctrine(), $this->getUserId()),
67
       'following' => $this->getUser()->isFollowingGroupByQuery($this->getDoctrine(), $group->getId()),
69
       'following' => $this->getUser()->isFollowingGroupByQuery($this->getDoctrine(), $group->getId()),
68
       'user'      => $this->getUser(),
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
   pattern: /user/{slug}
12
   pattern: /user/{slug}
13
   defaults: { _controller: MuzichHomeBundle:Show:showUser }
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
 show_group:
19
 show_group:
16
   pattern: /group/{slug}
20
   pattern: /group/{slug}
17
   defaults: { _controller: MuzichHomeBundle:Show:showGroup }
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
 
17
 
18
   {% include "MuzichCoreBundle:SearchElement:default.html.twig" %}
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
 {% endblock %}
29
 {% endblock %}

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

43
   
43
   
44
   {% include "MuzichCoreBundle:SearchElement:default.html.twig" %}
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
 {% endblock %}
54
 {% endblock %}

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

25
   
25
   
26
   {% include "MuzichCoreBundle:SearchElement:default.html.twig" %}
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
 {% endblock %}
36
 {% endblock %}