Procházet zdrojové kódy

Evolution #196: Liste de lecture

Sevajol Bastien před 11 roky
rodič
revize
d7f4071f71

+ 26 - 1
src/Muzich/CoreBundle/Controller/ElementController.php Zobrazit soubor

@@ -11,6 +11,7 @@ use Muzich\CoreBundle\Entity\Element;
11 11
 use Muzich\CoreBundle\Util\TagLike;
12 12
 use Muzich\CoreBundle\Entity\User;
13 13
 use Muzich\CoreBundle\lib\AutoplayManager;
14
+use Muzich\CoreBundle\Searcher\ElementSearcher;
14 15
 
15 16
 class ElementController extends Controller
16 17
 {
@@ -993,7 +994,7 @@ class ElementController extends Controller
993 994
    * @param "filter"|"show"|"favorites" $type
994 995
    * @param ~ $data
995 996
    */
996
-  public function getDatasAutoplayAction(Request $request, $type, $data)
997
+  public function getDatasAutoplayAction(Request $request, $type, $data, $show_type = null, $show_id = null)
997 998
   {
998 999
     if (($response = $this->mustBeConnected(true)))
999 1000
     {
@@ -1012,6 +1013,30 @@ class ElementController extends Controller
1012 1013
       ));
1013 1014
       $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId());
1014 1015
     }
1016
+    elseif ($type == 'show')
1017
+    {
1018
+      if ($show_type != 'user' && $show_type != 'group')
1019
+      {
1020
+        throw $this->createNotFoundException('Not found');
1021
+      }
1022
+      
1023
+      $tag_ids = json_decode($data);
1024
+      $search_object = new ElementSearcher();
1025
+
1026
+      $tags = array();
1027
+      foreach ($tag_ids as $id)
1028
+      {
1029
+        $tags[$id] = $id;
1030
+      }
1031
+
1032
+      $search_object->init(array(
1033
+        'tags'           => $tags,
1034
+        $show_type.'_id' => $show_id,
1035
+        'count'          => $this->container->getParameter('autoplay_max_elements')
1036
+      ));
1037
+      
1038
+      $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId());
1039
+    }
1015 1040
     
1016 1041
     if (count($elements))
1017 1042
     {

+ 4 - 0
src/Muzich/CoreBundle/Resources/config/routing.yml Zobrazit soubor

@@ -164,6 +164,10 @@ elements_get_filter_data_autoplay:
164 164
   pattern: /ajax/elements/get/datas/autoplay/{type}/{data}
165 165
   defaults: { _controller: MuzichCoreBundle:Element:getDatasAutoplay, data: null }
166 166
     
167
+elements_get_filter_data_autoplay_show:
168
+  pattern: /ajax/show/{show_type}/{show_id}/elements/get/datas/autoplay/{data}
169
+  defaults: { _controller: MuzichCoreBundle:Element:getDatasAutoplay, type: 'show', data: null }
170
+    
167 171
 element_show_need_tags:
168 172
   pattern: /need-tags
169 173
   defaults: { _controller: MuzichHomeBundle:Home:needTags }

+ 14 - 0
src/Muzich/HomeBundle/Resources/views/Show/showGroup.html.twig Zobrazit soubor

@@ -54,6 +54,15 @@
54 54
     'object_type' : 'group'
55 55
   } %}
56 56
   
57
+  <a href="{{ path('elements_get_filter_data_autoplay_show', {
58
+        'show_type'  : 'group',
59
+        'show_id'    : group.id, 
60
+        'data'       : tags_id_json
61
+      }) }}" class="button" id="autoplay_launch" 
62
+     title="{{ 'elements.autoplay.launch'|trans({}, 'elements') }}" >
63
+    <img src="{{ asset('/bundles/muzichcore/img/1353494305_player_play.png') }}" alt="" />
64
+  </a>
65
+  
57 66
   {% if his_group or group.open %}
58 67
   
59 68
     <div id="element_add_box" style="display: none;">
@@ -92,6 +101,11 @@
92 101
         'object_id'     : group.id, 
93 102
         'tags_ids_json' : ''
94 103
       }) }}" />
104
+     <input type="hidden" id="autoplay_url" value="{{ path('elements_get_filter_data_autoplay_show', {
105
+        'show_type'          : 'group',
106
+        'show_id'            : group.id, 
107
+        'data' : ''
108
+      }) }}" />
95 109
      <a href="{{ path('show_elements_get', {
96 110
         'type'          : 'group',
97 111
         'object_id'     : group.id, 

+ 14 - 0
src/Muzich/HomeBundle/Resources/views/Show/showUser.html.twig Zobrazit soubor

@@ -85,6 +85,15 @@
85 85
     'object_type' : 'user'
86 86
   } %}
87 87
   
88
+  <a href="{{ path('elements_get_filter_data_autoplay_show', {
89
+        'show_type'  : 'user',
90
+        'show_id'    : viewed_user.id, 
91
+        'data'       : tags_id_json
92
+      }) }}" class="button" id="autoplay_launch" 
93
+     title="{{ 'elements.autoplay.launch'|trans({}, 'elements') }}" >
94
+    <img src="{{ asset('/bundles/muzichcore/img/1353494305_player_play.png') }}" alt="" />
95
+  </a>
96
+  
88 97
   {% include "MuzichCoreBundle:SearchElement:default.html.twig" %}
89 98
     
90 99
   <div class="elements_loader_div">
@@ -99,6 +108,11 @@
99 108
         'object_id'     : viewed_user.id, 
100 109
         'tags_ids_json' : ''
101 110
       }) }}" />
111
+     <input type="hidden" id="autoplay_url" value="{{ path('elements_get_filter_data_autoplay_show', {
112
+        'show_type'          : 'user',
113
+        'show_id'     : viewed_user.id, 
114
+        'data' : ''
115
+      }) }}" />
102 116
      <a href="{{ path('show_elements_get', {
103 117
         'type'          : 'user',
104 118
         'object_id'     : viewed_user.id, 

+ 3 - 0
web/bundles/muzichcore/js/muzich.js Zobrazit soubor

@@ -1486,6 +1486,9 @@ $(document).ready(function(){
1486 1486
     var a_more = $('a.elements_more');
1487 1487
     a_more.attr('href', $('input#more_elements_url').val()+'/'+array2json(tags_ids_for_filter));
1488 1488
     
1489
+    // On adapte aussi le lien de l'autoplay
1490
+    $('a#autoplay_launch').attr('href', $('input#autoplay_url').val()+'/'+array2json(tags_ids_for_filter));
1491
+    
1489 1492
     return check_timelaps_and_find_with_tags(link, new Date().getTime(), false);
1490 1493
   }
1491 1494