Browse Source

Lecture aléatoire sur le profil et sur les favoris

Bastien Sevajol 9 years ago
parent
commit
1b9d969945

+ 18 - 2
src/Muzich/CoreBundle/Controller/ElementController.php View File

1015
       $tag_ids = json_decode($data);
1015
       $tag_ids = json_decode($data);
1016
       $search_object = new ElementSearcher();
1016
       $search_object = new ElementSearcher();
1017
       
1017
       
1018
+      $id_limit = $element_id+1;
1019
+      if ($element_id < 1) {
1020
+          $id_limit = Null;
1021
+      }
1022
+      
1018
       if (count($tag_ids))
1023
       if (count($tag_ids))
1019
       {
1024
       {
1020
         $tags = array();
1025
         $tags = array();
1028
         'tags'           => $tags,
1033
         'tags'           => $tags,
1029
         $show_type.'_id' => $show_id,
1034
         $show_type.'_id' => $show_id,
1030
         'count'          => $this->container->getParameter('autoplay_max_elements'),
1035
         'count'          => $this->container->getParameter('autoplay_max_elements'),
1031
-        'id_limit' => $element_id+1
1036
+        'id_limit' => $id_limit
1032
       ));
1037
       ));
1033
       
1038
       
1034
       $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId(true));
1039
       $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId(true));
1047
           $tags[$id] = $id;
1052
           $tags[$id] = $id;
1048
         }
1053
         }
1049
       }
1054
       }
1055
+      
1056
+      $id_limit = $element_id+1;
1057
+      if ($element_id < 1) {
1058
+          $id_limit = Null;
1059
+      }
1050
 
1060
 
1051
       $search_object->init(array(
1061
       $search_object->init(array(
1052
         'tags'     => $tags,
1062
         'tags'     => $tags,
1053
         'user_id'  => $show_id,
1063
         'user_id'  => $show_id,
1054
         'favorite' => true,
1064
         'favorite' => true,
1055
         'count'    => $this->container->getParameter('autoplay_max_elements'),
1065
         'count'    => $this->container->getParameter('autoplay_max_elements'),
1056
-        'id_limit' => $element_id+1
1066
+        'id_limit' => $id_limit
1057
       ));
1067
       ));
1058
       
1068
       
1059
       $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId(true));
1069
       $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId(true));
1063
     {
1073
     {
1064
       // On récupère les élements
1074
       // On récupère les élements
1065
       $autoplaym = new AutoplayManager($elements, $this->container);
1075
       $autoplaym = new AutoplayManager($elements, $this->container);
1076
+      
1077
+      // Petit hack pour savoir qu'on est en suffle
1078
+      if ($element_id == -1) {
1079
+          $autoplaym->shuffle();
1080
+      }
1081
+      
1066
       $elements_json = $autoplaym->getList();
1082
       $elements_json = $autoplaym->getList();
1067
     }
1083
     }
1068
     
1084
     

+ 12 - 1
src/Muzich/CoreBundle/Resources/public/css/main.css View File

2709
   animation-name: clignote;
2709
   animation-name: clignote;
2710
   animation-duration: 1s;
2710
   animation-duration: 1s;
2711
   animation-iteration-count:infinite;
2711
   animation-iteration-count:infinite;
2712
-}
2712
+}
2713
+
2714
+ul.elements li.inline_actions {
2715
+    float: right;
2716
+    text-align: right;
2717
+}
2718
+
2719
+ul.elements li.inline_actions a.button {
2720
+    margin-left: -30px;
2721
+    margin-top: -15px;
2722
+    position: absolute;
2723
+}

+ 1 - 1
src/Muzich/CoreBundle/Resources/public/js/autoplay.js View File

148
     return false;
148
     return false;
149
   });
149
   });
150
   
150
   
151
-  $('a.autoplay_playlist').live('click', function(){
151
+  $('a.autoplay_playlist, a.autoplay_favshow').live('click', function(){
152
     window.autoplay.start($(this));
152
     window.autoplay.start($(this));
153
     $('html, body').animate({ scrollTop: 0 }, 'fast');
153
     $('html, body').animate({ scrollTop: 0 }, 'fast');
154
     return false;
154
     return false;

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

10
 {% if elements_context is not defined %}
10
 {% if elements_context is not defined %}
11
   {% set elements_context = '' %}
11
   {% set elements_context = '' %}
12
 {% endif %}
12
 {% endif %}
13
+{% if autoplay_shuffle is not defined %}
14
+  {% set autoplay_shuffle = '' %}
15
+{% endif %}
16
+{% if tag_ids_json is not defined %}
17
+  {% set tag_ids_json = '[]' %}
18
+{% endif %}
13
 
19
 
14
 {% if display_new_elements %}
20
 {% if display_new_elements %}
15
   <div class="display_more_elements" style="display: none;">
21
   <div class="display_more_elements" style="display: none;">
25
 
31
 
26
 {% if elements|length %}
32
 {% if elements|length %}
27
   {% if not app.request.isXmlHttpRequest %}<ul class="elements" data-autoplay_context="{{ autoplay_context }}" data-context="{{ elements_context }}">{% endif %}
33
   {% if not app.request.isXmlHttpRequest %}<ul class="elements" data-autoplay_context="{{ autoplay_context }}" data-context="{{ elements_context }}">{% endif %}
34
+    
35
+    {% if autoplay_shuffle %}
36
+        <li class="inline_actions">
37
+            <a class="autoplay_favshow button simpleimg darkbutton" 
38
+                {% if autoplay_shuffle == 'elements_get_filter_data_autoplay_show' %}
39
+                    href="{{ path(autoplay_shuffle, {
40
+                             'element_id' : -1,
41
+                             'type'       : 'show',
42
+                             'show_type'  : autoplay_shuffle_show_type,
43
+                             'show_id'    : viewed_user.id, 
44
+                             'data'       : tag_ids_json
45
+                           }) }}"
46
+                {% endif %}
47
+                {% if autoplay_shuffle == 'elements_get_filter_data_autoplay_favorite' %}
48
+                    href="{{ path(autoplay_shuffle, {
49
+                             'element_id' : -1,
50
+                             'type'       : 'favorite',
51
+                             'show_type'  : 'user',
52
+                             'show_id'    : viewed_user.id, 
53
+                             'data'       : tag_ids_json
54
+                           }) }}"
55
+                {% endif %}
56
+            >
57
+              <img src="{{ asset('/img/1372889556_random_shuffle.png') }}" alt="shuffle" />
58
+            </a>
59
+        </li>
60
+    {% endif %}
61
+      
28
     {% for element in elements %} 
62
     {% for element in elements %} 
29
       
63
       
30
       {% include "MuzichCoreBundle:SearchElement:li.element.html.twig" %}
64
       {% include "MuzichCoreBundle:SearchElement:li.element.html.twig" %}

+ 2 - 1
src/Muzich/FavoriteBundle/Controller/FavoriteController.php View File

292
         'user'             => $this->getUser(),
292
         'user'             => $this->getUser(),
293
         'elements'         => $elements,
293
         'elements'         => $elements,
294
         'tag_ids_json'     => $tags_ids_json,
294
         'tag_ids_json'     => $tags_ids_json,
295
-        'viewed_user'      => $viewed_user
295
+        'viewed_user'      => $viewed_user,
296
+        'autoplay_shuffle' => 'elements_get_filter_data_autoplay_favorite'
296
       ))->getContent();
297
       ))->getContent();
297
     }
298
     }
298
     
299
     

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

31
     
31
     
32
     {% include "MuzichCoreBundle:SearchElement:default.html.twig" with{
32
     {% include "MuzichCoreBundle:SearchElement:default.html.twig" with{
33
         'display_autoplay'     : true,
33
         'display_autoplay'     : true,
34
+        'autoplay_shuffle'     : 'elements_get_filter_data_autoplay_favorite',
34
         'autoplay_context'     : 'favorite_user'
35
         'autoplay_context'     : 'favorite_user'
35
     } %}
36
     } %}
36
     
37
     

+ 3 - 1
src/Muzich/HomeBundle/Controller/ShowController.php View File

73
       'count_favorited_users' => $count_favorited_users,
73
       'count_favorited_users' => $count_favorited_users,
74
       'count_followers' => $count_followers,
74
       'count_followers' => $count_followers,
75
       'add_form'        => ($this->getUserId(true) == $viewed_user->getId())?$this->getAddForm()->createView():null,
75
       'add_form'        => ($this->getUserId(true) == $viewed_user->getId())?$this->getAddForm()->createView():null,
76
-      'add_form_name'   => 'add'
76
+      'add_form_name'   => 'add',
77
+      'autoplay_shuffle' => 'elements_get_filter_data_autoplay_show',
78
+      'autoplay_shuffle_show_type' => 'user'
77
     );
79
     );
78
   }
80
   }
79
   
81
   

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

82
   
82
   
83
   {% include "MuzichCoreBundle:SearchElement:default.html.twig" with {
83
   {% include "MuzichCoreBundle:SearchElement:default.html.twig" with {
84
     'display_autoplay'     : true,
84
     'display_autoplay'     : true,
85
+    'autoplay_shuffle'     : 'elements_get_filter_data_autoplay_show',
86
+    'autoplay_shuffle_show_type': 'user',
85
     'autoplay_context'     : 'show_user'
87
     'autoplay_context'     : 'show_user'
86
   } %}
88
   } %}
87
   
89