Pārlūkot izejas kodu

Lecture aléatoire sur le profil et sur les favoris

Bastien Sevajol 9 gadus atpakaļ
vecāks
revīzija
1b9d969945

+ 18 - 2
src/Muzich/CoreBundle/Controller/ElementController.php Parādīt failu

@@ -1015,6 +1015,11 @@ class ElementController extends Controller
1015 1015
       $tag_ids = json_decode($data);
1016 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 1023
       if (count($tag_ids))
1019 1024
       {
1020 1025
         $tags = array();
@@ -1028,7 +1033,7 @@ class ElementController extends Controller
1028 1033
         'tags'           => $tags,
1029 1034
         $show_type.'_id' => $show_id,
1030 1035
         'count'          => $this->container->getParameter('autoplay_max_elements'),
1031
-        'id_limit' => $element_id+1
1036
+        'id_limit' => $id_limit
1032 1037
       ));
1033 1038
       
1034 1039
       $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId(true));
@@ -1047,13 +1052,18 @@ class ElementController extends Controller
1047 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 1061
       $search_object->init(array(
1052 1062
         'tags'     => $tags,
1053 1063
         'user_id'  => $show_id,
1054 1064
         'favorite' => true,
1055 1065
         'count'    => $this->container->getParameter('autoplay_max_elements'),
1056
-        'id_limit' => $element_id+1
1066
+        'id_limit' => $id_limit
1057 1067
       ));
1058 1068
       
1059 1069
       $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId(true));
@@ -1063,6 +1073,12 @@ class ElementController extends Controller
1063 1073
     {
1064 1074
       // On récupère les élements
1065 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 1082
       $elements_json = $autoplaym->getList();
1067 1083
     }
1068 1084
     

+ 12 - 1
src/Muzich/CoreBundle/Resources/public/css/main.css Parādīt failu

@@ -2709,4 +2709,15 @@ div.private_links textarea
2709 2709
   animation-name: clignote;
2710 2710
   animation-duration: 1s;
2711 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 Parādīt failu

@@ -148,7 +148,7 @@ $(document).ready(function() {
148 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 152
     window.autoplay.start($(this));
153 153
     $('html, body').animate({ scrollTop: 0 }, 'fast');
154 154
     return false;

+ 34 - 0
src/Muzich/CoreBundle/Resources/views/SearchElement/default.html.twig Parādīt failu

@@ -10,6 +10,12 @@
10 10
 {% if elements_context is not defined %}
11 11
   {% set elements_context = '' %}
12 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 20
 {% if display_new_elements %}
15 21
   <div class="display_more_elements" style="display: none;">
@@ -25,6 +31,34 @@
25 31
 
26 32
 {% if elements|length %}
27 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 62
     {% for element in elements %} 
29 63
       
30 64
       {% include "MuzichCoreBundle:SearchElement:li.element.html.twig" %}

+ 2 - 1
src/Muzich/FavoriteBundle/Controller/FavoriteController.php Parādīt failu

@@ -292,7 +292,8 @@ class FavoriteController extends Controller
292 292
         'user'             => $this->getUser(),
293 293
         'elements'         => $elements,
294 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 297
       ))->getContent();
297 298
     }
298 299
     

+ 1 - 0
src/Muzich/FavoriteBundle/Resources/views/Favorite/userList.html.twig Parādīt failu

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

+ 3 - 1
src/Muzich/HomeBundle/Controller/ShowController.php Parādīt failu

@@ -73,7 +73,9 @@ class ShowController extends Controller
73 73
       'count_favorited_users' => $count_favorited_users,
74 74
       'count_followers' => $count_followers,
75 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 Parādīt failu

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