Browse Source

Modification sur le lancement de l'autoplay:

Sevajol Bastien 12 years ago
parent
commit
622f424f74
22 changed files with 212 additions and 110 deletions
  1. 2 0
      app/Resources/translations/elements.fr.yml
  2. 7 4
      src/Muzich/CoreBundle/Controller/ElementController.php
  3. 21 9
      src/Muzich/CoreBundle/Controller/SearchController.php
  4. 14 2
      src/Muzich/CoreBundle/Extension/MyTwigExtension.php
  5. 11 11
      src/Muzich/CoreBundle/Resources/config/routing.yml
  6. 7 4
      src/Muzich/CoreBundle/Resources/public/js/autoplay.js
  7. 12 1
      src/Muzich/CoreBundle/Resources/public/js/muzich.js
  8. 2 2
      src/Muzich/CoreBundle/Resources/views/Component/element_autoplay_button.html.twig
  9. 7 1
      src/Muzich/CoreBundle/Resources/views/SearchElement/default.html.twig
  10. 56 0
      src/Muzich/CoreBundle/Resources/views/SearchElement/element.html.twig
  11. 2 1
      src/Muzich/CoreBundle/Tests/Controller/HomeControllerTest.php
  12. 11 0
      src/Muzich/CoreBundle/lib/Controller.php
  13. 19 2
      src/Muzich/FavoriteBundle/Controller/FavoriteController.php
  14. 4 15
      src/Muzich/FavoriteBundle/Resources/views/Favorite/myList.html.twig
  15. 4 15
      src/Muzich/FavoriteBundle/Resources/views/Favorite/userList.html.twig
  16. 17 2
      src/Muzich/HomeBundle/Controller/ShowController.php
  17. 5 9
      src/Muzich/HomeBundle/Resources/views/Home/index.html.twig
  18. 1 0
      src/Muzich/HomeBundle/Resources/views/Home/need_tags.html.twig
  19. 4 16
      src/Muzich/HomeBundle/Resources/views/Show/showGroup.html.twig
  20. 5 16
      src/Muzich/HomeBundle/Resources/views/Show/showUser.html.twig
  21. 1 0
      src/Muzich/UserBundle/Resources/views/Event/elements.html.twig
  22. BIN
      web/img/1361037350_control_play.png

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

@@ -26,6 +26,8 @@ element:
26 26
   link:                 Ouvrir la page d'origine
27 27
   edit:
28 28
     link:               Modifier
29
+  autoplay:
30
+    title:              Lancer avec la lecture automatique
29 31
   remove:
30 32
     link:               Supprimer
31 33
     confirm:

+ 7 - 4
src/Muzich/CoreBundle/Controller/ElementController.php View File

@@ -1026,7 +1026,7 @@ class ElementController extends Controller
1026 1026
    * @param "filter"|"show"|"favorites" $type
1027 1027
    * @param ~ $data
1028 1028
    */
1029
-  public function getDatasAutoplayAction(Request $request, $type, $data, $show_type = null, $show_id = null)
1029
+  public function getDatasAutoplayAction(Request $request, $element_id, $type, $data, $show_type = null, $show_id = null)
1030 1030
   {
1031 1031
     if (($response = $this->mustBeConnected(true)))
1032 1032
     {
@@ -1041,7 +1041,8 @@ class ElementController extends Controller
1041 1041
       // Pour cette option on utilise le dernier filtre appliqué
1042 1042
       $search_object = $this->getElementSearcher();
1043 1043
       $search_object->update(array(
1044
-        'count' => $this->container->getParameter('autoplay_max_elements')
1044
+        'count' => $this->container->getParameter('autoplay_max_elements'),
1045
+        'id_limit' => $element_id+1
1045 1046
       ));
1046 1047
       $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId());
1047 1048
     }
@@ -1068,7 +1069,8 @@ class ElementController extends Controller
1068 1069
       $search_object->init(array(
1069 1070
         'tags'           => $tags,
1070 1071
         $show_type.'_id' => $show_id,
1071
-        'count'          => $this->container->getParameter('autoplay_max_elements')
1072
+        'count'          => $this->container->getParameter('autoplay_max_elements'),
1073
+        'id_limit' => $element_id+1
1072 1074
       ));
1073 1075
       
1074 1076
       $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId());
@@ -1092,7 +1094,8 @@ class ElementController extends Controller
1092 1094
         'tags'     => $tags,
1093 1095
         'user_id'  => $show_id,
1094 1096
         'favorite' => true,
1095
-        'count'    => $this->container->getParameter('autoplay_max_elements')
1097
+        'count'    => $this->container->getParameter('autoplay_max_elements'),
1098
+        'id_limit' => $element_id+1
1096 1099
       ));
1097 1100
       
1098 1101
       $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId());

+ 21 - 9
src/Muzich/CoreBundle/Controller/SearchController.php View File

@@ -25,7 +25,7 @@ class SearchController extends Controller
25 25
    * @param string $session_id
26 26
    * @return Response 
27 27
    */
28
-  protected function searchElementsMore($elements, $message, $session_id)
28
+  protected function searchElementsMore($context, $autoplay_context, $elements, $message, $session_id)
29 29
   {
30 30
     
31 31
     $data = array();
@@ -34,11 +34,14 @@ class SearchController extends Controller
34 34
     if ($count)
35 35
     {
36 36
       $html = $this->render('MuzichCoreBundle:SearchElement:default.html.twig', array(
37
-        'user'        => $this->getUser(),
38
-        'elements'    => $elements
37
+        'user'             => $this->getUser(),
38
+        'elements'         => $elements,
39
+        'display_autoplay'  => $this->getDisplayAutoplayBooleanForContext($context),
40
+        'autoplay_context' => ($autoplay_context)?$autoplay_context:$context
39 41
       ))->getContent();
40 42
       
41 43
       $data['more_link_href'] = $this->generateUrl('search_elements_more', array(
44
+        'context'    => $context,
42 45
         'id_limit'   => $elements[count($elements)-1]->getId(),
43 46
         'session_id' => $session_id
44 47
       ));
@@ -59,7 +62,7 @@ class SearchController extends Controller
59 62
    * que les paramétres en session). 
60 63
    * 
61 64
    */
62
-  public function searchElementsAction($id_limit = null, $session_id = null)
65
+  public function searchElementsAction($context, $id_limit = null, $session_id = null)
63 66
   {
64 67
     if (($response = $this->mustBeConnected()))
65 68
     {
@@ -125,7 +128,7 @@ class SearchController extends Controller
125 128
       
126 129
       $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId());
127 130
       
128
-      return $this->searchElementsMore($elements, $message, $session_id);      
131
+      return $this->searchElementsMore($context, null, $elements, $message, $session_id);      
129 132
     }
130 133
     else
131 134
     {
@@ -142,14 +145,16 @@ class SearchController extends Controller
142 145
    * @param int $id_limit
143 146
    * @return Response 
144 147
    */
145
-  public function searchElementsShowAction($type, $object_id, $id_limit)
148
+  public function searchElementsShowAction($context, $type, $object_id, $id_limit)
146 149
   {
150
+    $autoplay_context = null;
147 151
     if ($this->getRequest()->isXmlHttpRequest())
148 152
     {
149 153
       $object = null;
150 154
       $param_id =  '';
151 155
       if ($type == 'user')
152 156
       {
157
+        $autoplay_context = 'show_user';
153 158
         $object = $this->getDoctrine()
154 159
           ->getRepository('MuzichCoreBundle:User')
155 160
           ->findOneBy(array('id' => $object_id))
@@ -158,6 +163,7 @@ class SearchController extends Controller
158 163
       }
159 164
       elseif ($type == 'group')
160 165
       {
166
+        $autoplay_context = 'show_group';
161 167
         $object = $this->getDoctrine()
162 168
           ->getRepository('MuzichCoreBundle:Group')
163 169
           ->findOneById($object_id)
@@ -178,7 +184,10 @@ class SearchController extends Controller
178 184
 
179 185
       $elements = $search->getElements($this->getDoctrine(), $this->getUserId());
180 186
       
181
-      return $this->searchElementsMore($elements,
187
+      return $this->searchElementsMore(
188
+        $context,
189
+        $autoplay_context,
190
+        $elements,
182 191
         $this->trans(
183 192
           'elements.ajax.more.noelements', 
184 193
           array(), 
@@ -199,7 +208,7 @@ class SearchController extends Controller
199 208
    * @param string $string
200 209
    * @return Response 
201 210
    */
202
-  public function globalSearchMoreAction(Request $request, $last_id, $string)
211
+  public function globalSearchMoreAction(Request $request, $context, $last_id, $string)
203 212
   {
204 213
     if (($response = $this->mustBeConnected(true)))
205 214
     {
@@ -214,7 +223,10 @@ class SearchController extends Controller
214 223
     
215 224
     $elements = $search->getElements($this->getDoctrine(), $this->getUserId());
216 225
       
217
-    return $this->searchElementsMore($elements,
226
+    return $this->searchElementsMore(
227
+      $context,
228
+      $autoplay_context = null,
229
+      $elements,
218 230
       $this->trans(
219 231
         'elements.ajax.more.noelements', 
220 232
         array(), 

+ 14 - 2
src/Muzich/CoreBundle/Extension/MyTwigExtension.php View File

@@ -9,10 +9,12 @@ use Symfony\Component\Form\FormView;
9 9
 class MyTwigExtension extends \Twig_Extension {
10 10
 
11 11
   private $translator;
12
+  protected $params = array();
12 13
 
13
-  public function __construct(Translator $translator)
14
+  public function __construct(Translator $translator, $params)
14 15
   {
15 16
     $this->translator = $translator;
17
+    $this->params = $params;
16 18
   }
17 19
   
18 20
   public function getFilters()
@@ -22,7 +24,8 @@ class MyTwigExtension extends \Twig_Extension {
22 24
       'date_or_relative_date'  => new \Twig_Filter_Method($this, 'date_or_relative_date'),
23 25
       'date_epurate'           => new \Twig_Filter_Method($this, 'date_epurate'),
24 26
       'form_has_errors'        => new \Twig_Filter_Method($this, 'form_has_errors'),
25
-      'format_score'           => new \Twig_Filter_Method($this, 'format_score')
27
+      'format_score'           => new \Twig_Filter_Method($this, 'format_score'),
28
+      'can_autoplay'           => new \Twig_Filter_Method($this, 'can_autoplay')
26 29
     );
27 30
   }
28 31
   
@@ -39,6 +42,15 @@ class MyTwigExtension extends \Twig_Extension {
39 42
     return number_format($score, 0, '.', ' ');
40 43
   }
41 44
   
45
+  public function can_autoplay($element)
46
+  {
47
+    if (in_array($element->getType(), $this->params['autoplay_sites_enabled']))
48
+    {
49
+      return true;
50
+    }
51
+    return false;
52
+  }
53
+  
42 54
   protected function datetime2timestamp($string)
43 55
   {
44 56
     list($date, $time) = explode(' ', $string);

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

@@ -1,28 +1,28 @@
1 1
 
2 2
 
3 3
 search_elements:
4
-  pattern:  /search-elements
4
+  pattern:  /search-elements/{context}
5 5
   defaults: { _controller: MuzichCoreBundle:Search:searchElements }
6 6
   
7 7
 search_elements_more:
8
-  pattern:  /search-elements/{id_limit}/{session_id}
8
+  pattern:  /search-elements/{context}/{id_limit}/{session_id}
9 9
   defaults: { _controller: MuzichCoreBundle:Search:searchElements, session_id: null }
10 10
    
11 11
 search_elements_show_more_empty:
12
-  pattern:  /search-elements/show/{type}/{object_id}
12
+  pattern:  /search-elements/show/{context}/{type}/{object_id}
13 13
   defaults: { _controller: MuzichCoreBundle:Search:searchElementsShow }
14 14
     
15 15
 search_elements_show_more:
16
-  pattern:  /search-elements/show/{type}/{object_id}/{id_limit}
16
+  pattern:  /search-elements/show/{context}/{type}/{object_id}/{id_limit}
17 17
   defaults: { _controller: MuzichCoreBundle:Search:searchElementsShow }
18 18
    
19 19
 global_search_elements_empty:
20
-  pattern:  /global-search-elements/
21
-  defaults: { _controller: MuzichCoreBundle:Search:globalSearchMore }
20
+  pattern:  /global-search-elements
21
+  defaults: { _controller: MuzichCoreBundle:Search:globalSearchMore, context: global_search }
22 22
   
23 23
 global_search_elements:
24
-  pattern:  /global-search-elements/{last_id}/{string}
25
-  defaults: { _controller: MuzichCoreBundle:Search:globalSearchMore }
24
+  pattern:  /global-search-elements/{context}/{last_id}/{string}
25
+  defaults: { _controller: MuzichCoreBundle:Search:globalSearchMore, context: global_search }
26 26
    
27 27
 follow:
28 28
   pattern:  /follow/{type}/{id}/{token}
@@ -169,15 +169,15 @@ element_retrieve_api_datas:
169 169
   defaults: { _controller: MuzichCoreBundle:Element:getDatasApi }
170 170
     
171 171
 elements_get_filter_data_autoplay:
172
-  pattern: /ajax/elements/get/datas/autoplay/{type}/{data}
172
+  pattern: /ajax/elements/get/datas/autoplay/{element_id}/{type}/{data}
173 173
   defaults: { _controller: MuzichCoreBundle:Element:getDatasAutoplay, data: null }
174 174
     
175 175
 elements_get_filter_data_autoplay_show:
176
-  pattern: /ajax/show/{show_type}/{show_id}/elements/get/datas/autoplay/{data}
176
+  pattern: /ajax/show/{show_type}/{show_id}/elements/get/datas/autoplay/{element_id}/{data}
177 177
   defaults: { _controller: MuzichCoreBundle:Element:getDatasAutoplay, type: 'show', data: null }
178 178
     
179 179
 elements_get_filter_data_autoplay_favorite:
180
-  pattern: /ajax/favorite/{show_type}/{show_id}/elements/get/datas/autoplay/{data}
180
+  pattern: /ajax/favorite/{show_type}/{show_id}/elements/get/datas/autoplay/{element_id}/{data}
181 181
   defaults: { _controller: MuzichCoreBundle:Element:getDatasAutoplay, type: 'favorite', data: null }
182 182
     
183 183
 element_show_need_tags:

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

@@ -4,16 +4,18 @@ function Autoplay()
4 4
   var _playlist = new Array();
5 5
   var _player = null;
6 6
   var _current_index = 0;
7
+  var _link = null;
7 8
   
8
-  this.start = function()
9
+  this.start = function(link)
9 10
   {
11
+    _link = link;
10 12
     open_popin_dialog('autoplay');
11 13
     initializePlaylist(this.play);
12 14
   }
13 15
   
14 16
   var initializePlaylist = function(callback)
15 17
   {
16
-    JQueryJson($('a#autoplay_launch').attr('href'), {}, function(response){
18
+    JQueryJson(_link.attr('href'), {}, function(response){
17 19
       if (response.status == 'success')
18 20
       {
19 21
         if (response.data.length)
@@ -131,8 +133,9 @@ $(document).ready(function() {
131 133
   
132 134
   window.autoplay = new Autoplay();
133 135
   
134
-  $('a#autoplay_launch').click(function(){
135
-    window.autoplay.start();
136
+  $('a.autoplay_link').live('click', function(){
137
+    window.autoplay.start($(this));
138
+    $('html, body').animate({ scrollTop: 0 }, 'fast');
136 139
     return false;
137 140
   });
138 141
   

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

@@ -375,7 +375,11 @@ $(document).ready(function(){
375 375
       window.search_tag_prompt_connector.initializeTags([tag]);
376 376
       
377 377
       form.submit();
378
+      
378 379
     }
380
+    
381
+    $('html, body').animate({ scrollTop: 0 }, 'fast');
382
+    return false;
379 383
   });
380 384
   
381 385
   function element_last_opened(li)
@@ -1604,7 +1608,14 @@ $(document).ready(function(){
1604 1608
     a_more.attr('href', $('input#more_elements_url').val()+'/'+array2json(tags_ids_for_filter));
1605 1609
     
1606 1610
     // On adapte aussi le lien de l'autoplay
1607
-    $('a#autoplay_launch').attr('href', $('input#autoplay_url').val()+'/'+array2json(tags_ids_for_filter));
1611
+    //$('a.autoplay_link').attr('href', $('input#autoplay_url').val()+'/'+array2json(tags_ids_for_filter));
1612
+    //$('a.autoplay_link').each(function(){
1613
+    //  console.debug($(this));
1614
+    //  console.log(
1615
+    //    str_replace('__ELEMENT_ID__', $(this).data('element_id'), $('input#autoplay_url').val()+'/'+array2json(tags_ids_for_filter))
1616
+    //  );
1617
+    //  $(this).attr('href', str_replace('__ELEMENT_ID__', $(this).data('element_id'), $('input#autoplay_url').val()+'/'+array2json(tags_ids_for_filter)));
1618
+    //});
1608 1619
     
1609 1620
     return check_timelaps_and_find_with_tags(link, new Date().getTime(), false);
1610 1621
   }

+ 2 - 2
src/Muzich/CoreBundle/Resources/views/Component/element_autoplay_button.html.twig View File

@@ -1,4 +1,4 @@
1
-<a href="{{ autoplay_path }}" class="button" id="autoplay_launch" 
1
+<!--<a href="{{ autoplay_path }}" class="button" id="autoplay_launch" 
2 2
    title="{{ 'elements.autoplay.launch'|trans({}, 'elements') }}" >
3 3
   <img src="{{ asset('/bundles/muzichcore/img/1353494305_player_play.png') }}" alt="" />
4
-</a>
4
+</a>-->

+ 7 - 1
src/Muzich/CoreBundle/Resources/views/SearchElement/default.html.twig View File

@@ -1,6 +1,12 @@
1 1
 {% if display_new_elements is not defined %}
2 2
   {% set display_new_elements = false %}
3 3
 {% endif %}
4
+{% if display_autoplay is not defined %}
5
+  {% set display_autoplay = false %}
6
+{% endif %}
7
+{% if autoplay_context is not defined %}
8
+  {% set autoplay_context = '' %}
9
+{% endif %}
4 10
 
5 11
 {% if display_new_elements %}
6 12
   <div class="display_more_elements" style="display: none;">
@@ -15,7 +21,7 @@
15 21
 {% endif %}
16 22
 
17 23
 {% if elements|length %}
18
-  {% if not app.request.isXmlHttpRequest %}<ul class="elements">{% endif %}
24
+  {% if not app.request.isXmlHttpRequest %}<ul class="elements" data-autoplay_context="{{ autoplay_context }}">{% endif %}
19 25
     {% for element in elements %} 
20 26
       
21 27
       {% include "MuzichCoreBundle:SearchElement:li.element.html.twig" %}

+ 56 - 0
src/Muzich/CoreBundle/Resources/views/SearchElement/element.html.twig View File

@@ -10,6 +10,12 @@
10 10
 {% if his_group is not defined %}
11 11
   {% set his_group = false %}
12 12
 {% endif %}
13
+{% if display_autoplay is not defined %}
14
+  {% set display_autoplay = false %}
15
+{% endif %}
16
+{% if tag_ids_json is not defined %}
17
+  {% set tag_ids_json = '[]' %}
18
+{% endif %}
13 19
 
14 20
 <table>
15 21
   <tr>
@@ -91,6 +97,56 @@
91 97
           </a>
92 98
         </li>
93 99
         
100
+        {% if display_autoplay and element|can_autoplay %}
101
+          <li class="element_autoplay">
102
+            <a title="{{ 'element.autoplay.title'|trans({}, 'elements') }}"
103
+               data-element_id="{{ element.id }}"
104
+               class="autoplay_link"
105
+              {% if autoplay_context == 'home' %}
106
+                href="{{ path('elements_get_filter_data_autoplay', {
107
+                  'element_id' : element.id,
108
+                  'type'       : 'filter'
109
+                }) }}"
110
+              {% endif %}
111
+              {% if autoplay_context == 'show_user' %}
112
+                href="{{ path('elements_get_filter_data_autoplay_show', {
113
+                  'element_id' : element.id,
114
+                  'show_type'  : 'user',
115
+                  'show_id'    : viewed_user.id, 
116
+                  'data'       : tag_ids_json
117
+                }) }}"
118
+              {% endif %}
119
+              {% if autoplay_context == 'show_group' %}
120
+                href="{{ path('elements_get_filter_data_autoplay_show', {
121
+                  'element_id' : element.id,
122
+                  'show_type'  : 'group',
123
+                  'show_id'    : group.id, 
124
+                  'data'       : tag_ids_json
125
+                }) }}"
126
+              {% endif %}
127
+              {% if autoplay_context == 'favorite_my' %}
128
+                href="{{ path('elements_get_filter_data_autoplay_favorite', {
129
+                  'element_id' : element.id,
130
+                  'show_type'  : 'user',
131
+                  'show_id'    : app.user.id, 
132
+                  'data'       : tag_ids_json
133
+                }) }}"
134
+              {% endif %}
135
+              {% if autoplay_context == 'favorite_user' %}
136
+                href="{{ path('elements_get_filter_data_autoplay_favorite', {
137
+                  'element_id' : element.id,
138
+                  'show_type'  : 'user',
139
+                  'show_id'    : viewed_user.id, 
140
+                  'data'       : tag_ids_json
141
+                }) }}"
142
+              {% endif %}
143
+               target="_blank"
144
+            >
145
+              <img src="{{ asset('/img/1361037350_control_play.png') }}" alt="open in playlist" />
146
+            </a>
147
+          </li>
148
+        {% endif %}
149
+        
94 150
         {% if app.user.id != element.owner.id %}
95 151
       
96 152
           {% if display_edit_actions %}

+ 2 - 1
src/Muzich/CoreBundle/Tests/Controller/HomeControllerTest.php View File

@@ -24,7 +24,7 @@ class HomeControllerTest extends FunctionalTest
24 24
     $this->exist('form[action="'.$url.'"] input[type="submit"]');
25 25
     
26 26
     // Présence du formulaire de filtrage
27
-    $this->exist('form[action="'.($url = $this->generateUrl('search_elements')).'"]');
27
+    $this->exist('form[action="'.($url = $this->generateUrl('search_elements', array('context'=>'home'))).'"]');
28 28
     $this->exist('form[action="'.$url.'"] select[id="element_search_form_network"]');
29 29
     $this->exist('form[action="'.$url.'"] input[type="submit"]');
30 30
     
@@ -737,6 +737,7 @@ class HomeControllerTest extends FunctionalTest
737 737
     $id_limit = (int)str_replace('element_', '', $extract[9]);
738 738
     
739 739
     $url = $this->generateUrl('search_elements_more', array(
740
+      'context' => 'home',
740 741
       'id_limit'  => $id_limit
741 742
     ));
742 743
     

+ 11 - 0
src/Muzich/CoreBundle/lib/Controller.php View File

@@ -501,4 +501,15 @@ class Controller extends BaseController
501 501
     ;
502 502
   }
503 503
   
504
+  protected function getDisplayAutoplayBooleanForContext($context)
505
+  {
506
+    if (in_array($context, 
507
+      $this->container->getParameter('autoplay_contexts')
508
+    ))
509
+    {
510
+      return true;
511
+    }
512
+    return false;
513
+  }
514
+  
504 515
 }

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

@@ -244,6 +244,12 @@ class FavoriteController extends Controller
244 244
       return $response;
245 245
     }
246 246
     
247
+    $autoplay_context = 'favorite_user';
248
+    if ($user_id == $this->getUserId())
249
+    {
250
+      $autoplay_context = 'favorite_my';
251
+    }
252
+    
247 253
     $tag_ids = json_decode($tags_ids_json);
248 254
     $search_object = new ElementSearcher();
249 255
     $tags = null;
@@ -271,14 +277,25 @@ class FavoriteController extends Controller
271 277
       'elements'
272 278
     );
273 279
     
280
+    $viewed_user = $this->getUser();
281
+    if ($user_id != $this->getUserId())
282
+    {
283
+      $viewed_user = $this->getDoctrine()->getEntityManager()->getRepository('MuzichCoreBundle:User')
284
+        ->findOneById($user_id, array())->getSingleResult();
285
+    }
286
+    
274 287
     $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId());
275 288
     $count = count($elements);
276 289
     $html = '';
277 290
     if ($count)
278 291
     {
279 292
       $html = $this->render('MuzichCoreBundle:SearchElement:default.html.twig', array(
280
-        'user'        => $this->getUser(),
281
-        'elements'    => $elements
293
+        'display_autoplay' => $this->getDisplayAutoplayBooleanForContext($autoplay_context),
294
+        'autoplay_context' => $autoplay_context,
295
+        'user'             => $this->getUser(),
296
+        'elements'         => $elements,
297
+        'tag_ids_json'     => $tags_ids_json,
298
+        'viewed_user'      => $viewed_user
282 299
       ))->getContent();
283 300
     }
284 301
     

+ 4 - 15
src/Muzich/FavoriteBundle/Resources/views/Favorite/myList.html.twig View File

@@ -12,18 +12,13 @@
12 12
     {% include "MuzichCoreBundle:Tag:tagsList.favorite.html.twig" with {
13 13
       'user_id' : app.user.id
14 14
     } %}
15
-    
16
-    {% include 'MuzichCoreBundle:Component:element_autoplay_button.html.twig' with {
17
-      'autoplay_path' : path('elements_get_filter_data_autoplay_favorite', {
18
-        'show_type'  : 'user',
19
-        'show_id'    : app.user.id, 
20
-        'data'       : '[]'
21
-      })
22
-    } %}
23 15
   
24 16
   </div>
25 17
   
26
-  {% include "MuzichCoreBundle:SearchElement:default.html.twig" %}
18
+  {% include "MuzichCoreBundle:SearchElement:default.html.twig" with{
19
+      'display_autoplay'     : true,
20
+      'autoplay_context'     : 'favorite_my'
21
+  } %}
27 22
   
28 23
   {% if elements|length %}
29 24
     {% include "MuzichCoreBundle:SearchElement:more_button.html.twig" with {
@@ -38,10 +33,4 @@
38 33
     }%}
39 34
   {% endif %}
40 35
   
41
-  <input type="hidden" id="autoplay_url" value="{{ path('elements_get_filter_data_autoplay_favorite', {
42
-    'show_type'  : 'user',
43
-    'show_id'    : app.user.id, 
44
-    'data' : ''
45
-  }) }}" />
46
-    
47 36
 {% endblock %}

+ 4 - 15
src/Muzich/FavoriteBundle/Resources/views/Favorite/userList.html.twig View File

@@ -21,17 +21,12 @@
21 21
       'user_id' : viewed_user.id
22 22
     } %}
23 23
     
24
-    {% include 'MuzichCoreBundle:Component:element_autoplay_button.html.twig' with {
25
-      'autoplay_path' : path('elements_get_filter_data_autoplay_favorite', {
26
-        'show_type'  : 'user',
27
-        'show_id'    : viewed_user.id, 
28
-        'data'       : '[]'
29
-      })
30
-    } %}
31
-    
32 24
   </div>
33 25
 
34
-  {% include "MuzichCoreBundle:SearchElement:default.html.twig" %}
26
+  {% include "MuzichCoreBundle:SearchElement:default.html.twig" with{
27
+      'display_autoplay'     : true,
28
+      'autoplay_context'     : 'favorite_user'
29
+  } %}
35 30
     
36 31
   {% if elements|length %}
37 32
     {% include "MuzichCoreBundle:SearchElement:more_button.html.twig" with {
@@ -46,10 +41,4 @@
46 41
     }%}
47 42
   {% endif %}
48 43
   
49
-  <input type="hidden" id="autoplay_url" value="{{ path('elements_get_filter_data_autoplay_favorite', {
50
-    'show_type'  : 'user',
51
-    'show_id'    : viewed_user.id, 
52
-    'data' : ''
53
-  }) }}" />
54
-    
55 44
 {% endblock %}

+ 17 - 2
src/Muzich/HomeBundle/Controller/ShowController.php View File

@@ -156,6 +156,17 @@ class ShowController extends Controller
156 156
       throw new \Exception("Wrong Type.");
157 157
     }
158 158
     
159
+    $viewed_user = null;
160
+    if ($type == 'user' && $object_id == $this->getUserId())
161
+    {
162
+      $viewed_user = $this->getUser();
163
+    }
164
+    else if ($type == 'user')
165
+    {
166
+      $viewed_user = $this->getDoctrine()->getEntityManager()->getRepository('MuzichCoreBundle:User')
167
+        ->findOneById($object_id, array())->getSingleResult();
168
+    }
169
+    
159 170
     $search_object = new ElementSearcher();
160 171
     $tags = null;
161 172
     $tag_ids = json_decode($tags_ids_json);
@@ -189,8 +200,12 @@ class ShowController extends Controller
189 200
     if ($count)
190 201
     {
191 202
       $html = $this->render('MuzichCoreBundle:SearchElement:default.html.twig', array(
192
-        'user'        => $this->getUser(),
193
-        'elements'    => $elements
203
+        'display_autoplay' => $this->getDisplayAutoplayBooleanForContext('show_'.$type),
204
+        'autoplay_context' => 'show_'.$type,
205
+        'user'             => $this->getUser(),
206
+        'viewed_user'      => $viewed_user,
207
+        'elements'         => $elements,
208
+        'tag_ids_json'     => $tags_ids_json
194 209
       ))->getContent();
195 210
     }
196 211
     

+ 5 - 9
src/Muzich/HomeBundle/Resources/views/Home/index.html.twig View File

@@ -31,7 +31,7 @@
31 31
   <div class="top_tools" {% if search_tags_id|length == 0 %}style="display: none;"{% endif %}>
32 32
   
33 33
     <div class="search_tools">
34
-      <form name="{{ search_form_name }}" action="{{ path('search_elements') }}" method="post" {{ form_enctype(search_form) }}>
34
+      <form name="{{ search_form_name }}" action="{{ path('search_elements', {'context':'home'}) }}" method="post" {{ form_enctype(search_form) }}>
35 35
         
36 36
         {% include "MuzichCoreBundle:SearchElement:form.html.twig" with { 
37 37
           'form_name'               : search_form_name,
@@ -42,23 +42,19 @@
42 42
         
43 43
       </form>
44 44
     </div>
45
-
46
-    {% include 'MuzichCoreBundle:Component:element_autoplay_button.html.twig' with {
47
-      'autoplay_path' : path('elements_get_filter_data_autoplay', {
48
-        'type' : 'filter'
49
-      })
50
-    } %}
51 45
   
52 46
   </div>
53 47
 
54 48
   {% include "MuzichCoreBundle:SearchElement:default.html.twig" with {
55 49
     'noelements_filter'    : true,
56
-    'display_new_elements' : true
50
+    'display_new_elements' : true,
51
+    'display_autoplay'     : true,
52
+    'autoplay_context'     : 'home'
57 53
   }%}
58 54
   
59 55
   {% if elements|length %}
60 56
     {% include "MuzichCoreBundle:SearchElement:more_button.html.twig" with {
61
-      'more_path'           : path('search_elements')
57
+      'more_path'           : path('search_elements', {'context':'home'})
62 58
     }%}
63 59
   {% endif %}
64 60
   

+ 1 - 0
src/Muzich/HomeBundle/Resources/views/Home/need_tags.html.twig View File

@@ -17,6 +17,7 @@
17 17
   {% if elements|length %}
18 18
     {% include "MuzichCoreBundle:SearchElement:more_button.html.twig" with {
19 19
       'more_path'     : path('search_elements_more', {
20
+        'context'    : 'need_tags',
20 21
         'session_id' : app.user.getPersonalHash('needstagpage'),
21 22
         'id_limit'   : last_element_id
22 23
       }),

+ 4 - 16
src/Muzich/HomeBundle/Resources/views/Show/showGroup.html.twig View File

@@ -64,16 +64,10 @@
64 64
     </p>
65 65
   
66 66
     {% include "MuzichCoreBundle:Tag:tagsList.show.html.twig" with {
67
-      'object_id'   : group.id,
68
-      'object_type' : 'group'
69
-    } %}
70
-    
71
-    {% include 'MuzichCoreBundle:Component:element_autoplay_button.html.twig' with {
72
-      'autoplay_path' : path('elements_get_filter_data_autoplay_show', {
73
-        'show_type'  : 'group',
74
-        'show_id'    : group.id, 
75
-        'data'       : '[]'
76
-      })
67
+      'object_id'            : group.id,
68
+      'object_type'          : 'group',
69
+      'display_autoplay'     : true,
70
+      'autoplay_context'     : 'show_group'
77 71
     } %}
78 72
     
79 73
   </div>
@@ -101,10 +95,4 @@
101 95
     {% endif %}
102 96
   {% endif %}
103 97
   
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
-  }) }}" />
109
-            
110 98
 {% endblock %}

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

@@ -73,18 +73,13 @@
73 73
       'object_id'   : viewed_user.id,
74 74
       'object_type' : 'user'
75 75
     } %}
76
-    
77
-    {% include 'MuzichCoreBundle:Component:element_autoplay_button.html.twig' with {
78
-      'autoplay_path' : path('elements_get_filter_data_autoplay_show', {
79
-        'show_type'  : 'user',
80
-        'show_id'    : viewed_user.id, 
81
-        'data'       : '[]'
82
-      }) 
83
-    } %}
84 76
   
85 77
   </div>
86 78
   
87
-  {% include "MuzichCoreBundle:SearchElement:default.html.twig" %}
79
+  {% include "MuzichCoreBundle:SearchElement:default.html.twig" with {
80
+    'display_autoplay'     : true,
81
+    'autoplay_context'     : 'show_user'
82
+  } %}
88 83
   
89 84
   {% if more_count is defined %} 
90 85
     {% if elements|length %}
@@ -102,11 +97,5 @@
102 97
       }%}
103 98
     {% endif %}
104 99
   {% endif %}
105
-    
106
-  <input type="hidden" id="autoplay_url" value="{{ path('elements_get_filter_data_autoplay_show', {
107
-    'show_type'          : 'user',
108
-    'show_id'     : viewed_user.id, 
109
-    'data' : ''
110
-  }) }}" />
111
-  
100
+
112 101
 {% endblock %}

+ 1 - 0
src/Muzich/UserBundle/Resources/views/Event/elements.html.twig View File

@@ -58,6 +58,7 @@
58 58
   {% if elements|length %}
59 59
     {% include "MuzichCoreBundle:SearchElement:more_button.html.twig" with {
60 60
       'more_path'     : path('search_elements_more', {
61
+        'context'    : 'event',
61 62
         'session_id' : app.user.getPersonalHash(app.request.get('event_id')),
62 63
         'id_limit'   : last_element_id
63 64
       }),

BIN
web/img/1361037350_control_play.png View File