Browse Source

Evolution #196: Liste de lecture

Sevajol Bastien 12 years ago
parent
commit
d7f4071f71

+ 26 - 1
src/Muzich/CoreBundle/Controller/ElementController.php View File

11
 use Muzich\CoreBundle\Util\TagLike;
11
 use Muzich\CoreBundle\Util\TagLike;
12
 use Muzich\CoreBundle\Entity\User;
12
 use Muzich\CoreBundle\Entity\User;
13
 use Muzich\CoreBundle\lib\AutoplayManager;
13
 use Muzich\CoreBundle\lib\AutoplayManager;
14
+use Muzich\CoreBundle\Searcher\ElementSearcher;
14
 
15
 
15
 class ElementController extends Controller
16
 class ElementController extends Controller
16
 {
17
 {
993
    * @param "filter"|"show"|"favorites" $type
994
    * @param "filter"|"show"|"favorites" $type
994
    * @param ~ $data
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
     if (($response = $this->mustBeConnected(true)))
999
     if (($response = $this->mustBeConnected(true)))
999
     {
1000
     {
1012
       ));
1013
       ));
1013
       $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId());
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
     if (count($elements))
1041
     if (count($elements))
1017
     {
1042
     {

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

164
   pattern: /ajax/elements/get/datas/autoplay/{type}/{data}
164
   pattern: /ajax/elements/get/datas/autoplay/{type}/{data}
165
   defaults: { _controller: MuzichCoreBundle:Element:getDatasAutoplay, data: null }
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
 element_show_need_tags:
171
 element_show_need_tags:
168
   pattern: /need-tags
172
   pattern: /need-tags
169
   defaults: { _controller: MuzichHomeBundle:Home:needTags }
173
   defaults: { _controller: MuzichHomeBundle:Home:needTags }

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

54
     'object_type' : 'group'
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
   {% if his_group or group.open %}
66
   {% if his_group or group.open %}
58
   
67
   
59
     <div id="element_add_box" style="display: none;">
68
     <div id="element_add_box" style="display: none;">
92
         'object_id'     : group.id, 
101
         'object_id'     : group.id, 
93
         'tags_ids_json' : ''
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
      <a href="{{ path('show_elements_get', {
109
      <a href="{{ path('show_elements_get', {
96
         'type'          : 'group',
110
         'type'          : 'group',
97
         'object_id'     : group.id, 
111
         'object_id'     : group.id, 

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

85
     'object_type' : 'user'
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
   {% include "MuzichCoreBundle:SearchElement:default.html.twig" %}
97
   {% include "MuzichCoreBundle:SearchElement:default.html.twig" %}
89
     
98
     
90
   <div class="elements_loader_div">
99
   <div class="elements_loader_div">
99
         'object_id'     : viewed_user.id, 
108
         'object_id'     : viewed_user.id, 
100
         'tags_ids_json' : ''
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
      <a href="{{ path('show_elements_get', {
116
      <a href="{{ path('show_elements_get', {
103
         'type'          : 'user',
117
         'type'          : 'user',
104
         'object_id'     : viewed_user.id, 
118
         'object_id'     : viewed_user.id, 

+ 3 - 0
web/bundles/muzichcore/js/muzich.js View File

1486
     var a_more = $('a.elements_more');
1486
     var a_more = $('a.elements_more');
1487
     a_more.attr('href', $('input#more_elements_url').val()+'/'+array2json(tags_ids_for_filter));
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
     return check_timelaps_and_find_with_tags(link, new Date().getTime(), false);
1492
     return check_timelaps_and_find_with_tags(link, new Date().getTime(), false);
1490
   }
1493
   }
1491
    
1494