Browse Source

Consultation des favoris d'un utilisateur.

bastien 13 years ago
parent
commit
153cdfb25e

+ 1 - 1
app/Resources/translations/elements.fr.yml View File

@@ -4,4 +4,4 @@ noelements:
4 4
   
5 5
 element:
6 6
   favorite:
7
-    add:                Ajouter aux favoris
7
+    add:                Ajouter a mes favoris

+ 2 - 1
app/Resources/translations/network.fr.yml View File

@@ -13,4 +13,5 @@ groups:               Groupes
13 13
 followed_by:          Vous êtes suivis par
14 14
 
15 15
 favorites:
16
-  your_favorites:     Vos favoris
16
+  your_favorites:     Vos favoris
17
+  user_favorites:     Favoris de %name%

+ 2 - 1
app/Resources/translations/users.fr.yml View File

@@ -1,4 +1,5 @@
1 1
 
2 2
 user:
3 3
   follow:                       Suivre
4
-  notfollow:                    Ne plus suivre
4
+  notfollow:                    Ne plus suivre
5
+  view_favorites:               Voir les favoris

+ 34 - 0
src/Muzich/FavoriteBundle/Controller/FavoriteController.php View File

@@ -56,6 +56,8 @@ class FavoriteController extends Controller
56 56
   }
57 57
   
58 58
   /**
59
+   * Page affichant les elements favoris de l'utilisateur
60
+   * 
59 61
    * @Template()
60 62
    */
61 63
   public function myListAction()
@@ -71,4 +73,36 @@ class FavoriteController extends Controller
71 73
     );
72 74
   }
73 75
   
76
+  /**
77
+   * Affichage des elements favoris d'un utilisateur particulier.
78
+   * 
79
+   * @param type $slug 
80
+   * @Template()
81
+   */
82
+  public function userListAction($slug)
83
+  {
84
+    try {
85
+      
86
+      $viewed_user = $this->getDoctrine()
87
+        ->getRepository('MuzichCoreBundle:User')
88
+        ->findOneBySlug($slug)
89
+        ->getSingleResult()
90
+      ;
91
+      
92
+    } catch (\Doctrine\ORM\NoResultException $e) {
93
+        throw $this->createNotFoundException('Utilisateur introuvable.');
94
+    }
95
+    
96
+    $search_object = new ElementSearcher();
97
+    $search_object->init(array(
98
+      'user_id'  => $viewed_user->getId(),
99
+      'favorite' => true
100
+    ));
101
+    
102
+    return array(
103
+      'viewed_user' => $viewed_user,
104
+      'search_object' => $search_object
105
+    );
106
+  }
107
+  
74 108
 }

+ 4 - 0
src/Muzich/FavoriteBundle/Resources/config/routing.yml View File

@@ -6,3 +6,7 @@ favorite_add:
6 6
 favorites_my_list:
7 7
   pattern:   /favorites
8 8
   defaults: { _controller: MuzichFavoriteBundle:Favorite:myList }
9
+
10
+favorite_user_list:
11
+  pattern:   /user/{slug}/favorites
12
+  defaults: { _controller: MuzichFavoriteBundle:Favorite:userList }

+ 11 - 0
src/Muzich/FavoriteBundle/Resources/views/Favorite/userList.html.twig View File

@@ -0,0 +1,11 @@
1
+{% extends "MuzichFavoriteBundle::layout.html.twig" %}
2
+
3
+{% block title %}Favoris de {{ viewed_user.name }}{% endblock %}
4
+
5
+{% block content %}
6
+
7
+  <h2>{{ 'favorites.user_favorites'|trans({'%name%' : viewed_user.name}, 'network') }}</h2>
8
+
9
+  {% render "MuzichCoreBundle:Search:doSearchElements" with { 'search': search_object } %}
10
+    
11
+{% endblock %}

+ 5 - 1
src/Muzich/HomeBundle/Resources/views/Show/showUser.html.twig View File

@@ -1,11 +1,15 @@
1 1
 {% extends "MuzichHomeBundle::layout.html.twig" %}
2 2
 
3
-{% block title %}{% endblock %}
3
+{% block title %}{{ viewed_user.name }}{% endblock %}
4 4
 
5 5
 {% block content %}
6 6
 
7 7
   <span class="follow_link following">
8 8
     
9
+    <a href="{{ path('favorite_user_list', {'slug' : viewed_user.slug}) }}" >
10
+      {{ 'user.view_favorites'|trans({}, 'users') }}
11
+    </a>
12
+    | 
9 13
     <a href="{{ path('follow', { 'type': 'user', 'id': viewed_user.id, 'token': user.personalHash }) }}" class="follow_link following" >
10 14
       {% if following %}
11 15
         {{ 'user.notfollow'|trans({}, 'users') }}