Selaa lähdekoodia

Modification sur le lancement de l'autoplay:

Sevajol Bastien 12 vuotta sitten
vanhempi
commit
622f424f74
22 muutettua tiedostoa jossa 212 lisäystä ja 110 poistoa
  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 Näytä tiedosto

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

+ 7 - 4
src/Muzich/CoreBundle/Controller/ElementController.php Näytä tiedosto

1026
    * @param "filter"|"show"|"favorites" $type
1026
    * @param "filter"|"show"|"favorites" $type
1027
    * @param ~ $data
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
     if (($response = $this->mustBeConnected(true)))
1031
     if (($response = $this->mustBeConnected(true)))
1032
     {
1032
     {
1041
       // Pour cette option on utilise le dernier filtre appliqué
1041
       // Pour cette option on utilise le dernier filtre appliqué
1042
       $search_object = $this->getElementSearcher();
1042
       $search_object = $this->getElementSearcher();
1043
       $search_object->update(array(
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
       $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId());
1047
       $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId());
1047
     }
1048
     }
1068
       $search_object->init(array(
1069
       $search_object->init(array(
1069
         'tags'           => $tags,
1070
         'tags'           => $tags,
1070
         $show_type.'_id' => $show_id,
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
       $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId());
1076
       $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId());
1092
         'tags'     => $tags,
1094
         'tags'     => $tags,
1093
         'user_id'  => $show_id,
1095
         'user_id'  => $show_id,
1094
         'favorite' => true,
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
       $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId());
1101
       $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId());

+ 21 - 9
src/Muzich/CoreBundle/Controller/SearchController.php Näytä tiedosto

25
    * @param string $session_id
25
    * @param string $session_id
26
    * @return Response 
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
     $data = array();
31
     $data = array();
34
     if ($count)
34
     if ($count)
35
     {
35
     {
36
       $html = $this->render('MuzichCoreBundle:SearchElement:default.html.twig', array(
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
       ))->getContent();
41
       ))->getContent();
40
       
42
       
41
       $data['more_link_href'] = $this->generateUrl('search_elements_more', array(
43
       $data['more_link_href'] = $this->generateUrl('search_elements_more', array(
44
+        'context'    => $context,
42
         'id_limit'   => $elements[count($elements)-1]->getId(),
45
         'id_limit'   => $elements[count($elements)-1]->getId(),
43
         'session_id' => $session_id
46
         'session_id' => $session_id
44
       ));
47
       ));
59
    * que les paramétres en session). 
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
     if (($response = $this->mustBeConnected()))
67
     if (($response = $this->mustBeConnected()))
65
     {
68
     {
125
       
128
       
126
       $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId());
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
     else
133
     else
131
     {
134
     {
142
    * @param int $id_limit
145
    * @param int $id_limit
143
    * @return Response 
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
     if ($this->getRequest()->isXmlHttpRequest())
151
     if ($this->getRequest()->isXmlHttpRequest())
148
     {
152
     {
149
       $object = null;
153
       $object = null;
150
       $param_id =  '';
154
       $param_id =  '';
151
       if ($type == 'user')
155
       if ($type == 'user')
152
       {
156
       {
157
+        $autoplay_context = 'show_user';
153
         $object = $this->getDoctrine()
158
         $object = $this->getDoctrine()
154
           ->getRepository('MuzichCoreBundle:User')
159
           ->getRepository('MuzichCoreBundle:User')
155
           ->findOneBy(array('id' => $object_id))
160
           ->findOneBy(array('id' => $object_id))
158
       }
163
       }
159
       elseif ($type == 'group')
164
       elseif ($type == 'group')
160
       {
165
       {
166
+        $autoplay_context = 'show_group';
161
         $object = $this->getDoctrine()
167
         $object = $this->getDoctrine()
162
           ->getRepository('MuzichCoreBundle:Group')
168
           ->getRepository('MuzichCoreBundle:Group')
163
           ->findOneById($object_id)
169
           ->findOneById($object_id)
178
 
184
 
179
       $elements = $search->getElements($this->getDoctrine(), $this->getUserId());
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
         $this->trans(
191
         $this->trans(
183
           'elements.ajax.more.noelements', 
192
           'elements.ajax.more.noelements', 
184
           array(), 
193
           array(), 
199
    * @param string $string
208
    * @param string $string
200
    * @return Response 
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
     if (($response = $this->mustBeConnected(true)))
213
     if (($response = $this->mustBeConnected(true)))
205
     {
214
     {
214
     
223
     
215
     $elements = $search->getElements($this->getDoctrine(), $this->getUserId());
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
       $this->trans(
230
       $this->trans(
219
         'elements.ajax.more.noelements', 
231
         'elements.ajax.more.noelements', 
220
         array(), 
232
         array(), 

+ 14 - 2
src/Muzich/CoreBundle/Extension/MyTwigExtension.php Näytä tiedosto

9
 class MyTwigExtension extends \Twig_Extension {
9
 class MyTwigExtension extends \Twig_Extension {
10
 
10
 
11
   private $translator;
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
     $this->translator = $translator;
16
     $this->translator = $translator;
17
+    $this->params = $params;
16
   }
18
   }
17
   
19
   
18
   public function getFilters()
20
   public function getFilters()
22
       'date_or_relative_date'  => new \Twig_Filter_Method($this, 'date_or_relative_date'),
24
       'date_or_relative_date'  => new \Twig_Filter_Method($this, 'date_or_relative_date'),
23
       'date_epurate'           => new \Twig_Filter_Method($this, 'date_epurate'),
25
       'date_epurate'           => new \Twig_Filter_Method($this, 'date_epurate'),
24
       'form_has_errors'        => new \Twig_Filter_Method($this, 'form_has_errors'),
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
     return number_format($score, 0, '.', ' ');
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
   protected function datetime2timestamp($string)
54
   protected function datetime2timestamp($string)
43
   {
55
   {
44
     list($date, $time) = explode(' ', $string);
56
     list($date, $time) = explode(' ', $string);

+ 11 - 11
src/Muzich/CoreBundle/Resources/config/routing.yml Näytä tiedosto

1
 
1
 
2
 
2
 
3
 search_elements:
3
 search_elements:
4
-  pattern:  /search-elements
4
+  pattern:  /search-elements/{context}
5
   defaults: { _controller: MuzichCoreBundle:Search:searchElements }
5
   defaults: { _controller: MuzichCoreBundle:Search:searchElements }
6
   
6
   
7
 search_elements_more:
7
 search_elements_more:
8
-  pattern:  /search-elements/{id_limit}/{session_id}
8
+  pattern:  /search-elements/{context}/{id_limit}/{session_id}
9
   defaults: { _controller: MuzichCoreBundle:Search:searchElements, session_id: null }
9
   defaults: { _controller: MuzichCoreBundle:Search:searchElements, session_id: null }
10
    
10
    
11
 search_elements_show_more_empty:
11
 search_elements_show_more_empty:
12
-  pattern:  /search-elements/show/{type}/{object_id}
12
+  pattern:  /search-elements/show/{context}/{type}/{object_id}
13
   defaults: { _controller: MuzichCoreBundle:Search:searchElementsShow }
13
   defaults: { _controller: MuzichCoreBundle:Search:searchElementsShow }
14
     
14
     
15
 search_elements_show_more:
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
   defaults: { _controller: MuzichCoreBundle:Search:searchElementsShow }
17
   defaults: { _controller: MuzichCoreBundle:Search:searchElementsShow }
18
    
18
    
19
 global_search_elements_empty:
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
 global_search_elements:
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
 follow:
27
 follow:
28
   pattern:  /follow/{type}/{id}/{token}
28
   pattern:  /follow/{type}/{id}/{token}
169
   defaults: { _controller: MuzichCoreBundle:Element:getDatasApi }
169
   defaults: { _controller: MuzichCoreBundle:Element:getDatasApi }
170
     
170
     
171
 elements_get_filter_data_autoplay:
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
   defaults: { _controller: MuzichCoreBundle:Element:getDatasAutoplay, data: null }
173
   defaults: { _controller: MuzichCoreBundle:Element:getDatasAutoplay, data: null }
174
     
174
     
175
 elements_get_filter_data_autoplay_show:
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
   defaults: { _controller: MuzichCoreBundle:Element:getDatasAutoplay, type: 'show', data: null }
177
   defaults: { _controller: MuzichCoreBundle:Element:getDatasAutoplay, type: 'show', data: null }
178
     
178
     
179
 elements_get_filter_data_autoplay_favorite:
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
   defaults: { _controller: MuzichCoreBundle:Element:getDatasAutoplay, type: 'favorite', data: null }
181
   defaults: { _controller: MuzichCoreBundle:Element:getDatasAutoplay, type: 'favorite', data: null }
182
     
182
     
183
 element_show_need_tags:
183
 element_show_need_tags:

+ 7 - 4
src/Muzich/CoreBundle/Resources/public/js/autoplay.js Näytä tiedosto

4
   var _playlist = new Array();
4
   var _playlist = new Array();
5
   var _player = null;
5
   var _player = null;
6
   var _current_index = 0;
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
     open_popin_dialog('autoplay');
12
     open_popin_dialog('autoplay');
11
     initializePlaylist(this.play);
13
     initializePlaylist(this.play);
12
   }
14
   }
13
   
15
   
14
   var initializePlaylist = function(callback)
16
   var initializePlaylist = function(callback)
15
   {
17
   {
16
-    JQueryJson($('a#autoplay_launch').attr('href'), {}, function(response){
18
+    JQueryJson(_link.attr('href'), {}, function(response){
17
       if (response.status == 'success')
19
       if (response.status == 'success')
18
       {
20
       {
19
         if (response.data.length)
21
         if (response.data.length)
131
   
133
   
132
   window.autoplay = new Autoplay();
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
     return false;
139
     return false;
137
   });
140
   });
138
   
141
   

+ 12 - 1
src/Muzich/CoreBundle/Resources/public/js/muzich.js Näytä tiedosto

375
       window.search_tag_prompt_connector.initializeTags([tag]);
375
       window.search_tag_prompt_connector.initializeTags([tag]);
376
       
376
       
377
       form.submit();
377
       form.submit();
378
+      
378
     }
379
     }
380
+    
381
+    $('html, body').animate({ scrollTop: 0 }, 'fast');
382
+    return false;
379
   });
383
   });
380
   
384
   
381
   function element_last_opened(li)
385
   function element_last_opened(li)
1604
     a_more.attr('href', $('input#more_elements_url').val()+'/'+array2json(tags_ids_for_filter));
1608
     a_more.attr('href', $('input#more_elements_url').val()+'/'+array2json(tags_ids_for_filter));
1605
     
1609
     
1606
     // On adapte aussi le lien de l'autoplay
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
     return check_timelaps_and_find_with_tags(link, new Date().getTime(), false);
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 Näytä tiedosto

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

1
 {% if display_new_elements is not defined %}
1
 {% if display_new_elements is not defined %}
2
   {% set display_new_elements = false %}
2
   {% set display_new_elements = false %}
3
 {% endif %}
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
 {% if display_new_elements %}
11
 {% if display_new_elements %}
6
   <div class="display_more_elements" style="display: none;">
12
   <div class="display_more_elements" style="display: none;">
15
 {% endif %}
21
 {% endif %}
16
 
22
 
17
 {% if elements|length %}
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
     {% for element in elements %} 
25
     {% for element in elements %} 
20
       
26
       
21
       {% include "MuzichCoreBundle:SearchElement:li.element.html.twig" %}
27
       {% include "MuzichCoreBundle:SearchElement:li.element.html.twig" %}

+ 56 - 0
src/Muzich/CoreBundle/Resources/views/SearchElement/element.html.twig Näytä tiedosto

10
 {% if his_group is not defined %}
10
 {% if his_group is not defined %}
11
   {% set his_group = false %}
11
   {% set his_group = false %}
12
 {% endif %}
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
 <table>
20
 <table>
15
   <tr>
21
   <tr>
91
           </a>
97
           </a>
92
         </li>
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
         {% if app.user.id != element.owner.id %}
150
         {% if app.user.id != element.owner.id %}
95
       
151
       
96
           {% if display_edit_actions %}
152
           {% if display_edit_actions %}

+ 2 - 1
src/Muzich/CoreBundle/Tests/Controller/HomeControllerTest.php Näytä tiedosto

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

+ 11 - 0
src/Muzich/CoreBundle/lib/Controller.php Näytä tiedosto

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 Näytä tiedosto

244
       return $response;
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
     $tag_ids = json_decode($tags_ids_json);
253
     $tag_ids = json_decode($tags_ids_json);
248
     $search_object = new ElementSearcher();
254
     $search_object = new ElementSearcher();
249
     $tags = null;
255
     $tags = null;
271
       'elements'
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
     $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId());
287
     $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId());
275
     $count = count($elements);
288
     $count = count($elements);
276
     $html = '';
289
     $html = '';
277
     if ($count)
290
     if ($count)
278
     {
291
     {
279
       $html = $this->render('MuzichCoreBundle:SearchElement:default.html.twig', array(
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
       ))->getContent();
299
       ))->getContent();
283
     }
300
     }
284
     
301
     

+ 4 - 15
src/Muzich/FavoriteBundle/Resources/views/Favorite/myList.html.twig Näytä tiedosto

12
     {% include "MuzichCoreBundle:Tag:tagsList.favorite.html.twig" with {
12
     {% include "MuzichCoreBundle:Tag:tagsList.favorite.html.twig" with {
13
       'user_id' : app.user.id
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
   </div>
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
   {% if elements|length %}
23
   {% if elements|length %}
29
     {% include "MuzichCoreBundle:SearchElement:more_button.html.twig" with {
24
     {% include "MuzichCoreBundle:SearchElement:more_button.html.twig" with {
38
     }%}
33
     }%}
39
   {% endif %}
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
 {% endblock %}
36
 {% endblock %}

+ 4 - 15
src/Muzich/FavoriteBundle/Resources/views/Favorite/userList.html.twig Näytä tiedosto

21
       'user_id' : viewed_user.id
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
   </div>
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
   {% if elements|length %}
31
   {% if elements|length %}
37
     {% include "MuzichCoreBundle:SearchElement:more_button.html.twig" with {
32
     {% include "MuzichCoreBundle:SearchElement:more_button.html.twig" with {
46
     }%}
41
     }%}
47
   {% endif %}
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
 {% endblock %}
44
 {% endblock %}

+ 17 - 2
src/Muzich/HomeBundle/Controller/ShowController.php Näytä tiedosto

156
       throw new \Exception("Wrong Type.");
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
     $search_object = new ElementSearcher();
170
     $search_object = new ElementSearcher();
160
     $tags = null;
171
     $tags = null;
161
     $tag_ids = json_decode($tags_ids_json);
172
     $tag_ids = json_decode($tags_ids_json);
189
     if ($count)
200
     if ($count)
190
     {
201
     {
191
       $html = $this->render('MuzichCoreBundle:SearchElement:default.html.twig', array(
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
       ))->getContent();
209
       ))->getContent();
195
     }
210
     }
196
     
211
     

+ 5 - 9
src/Muzich/HomeBundle/Resources/views/Home/index.html.twig Näytä tiedosto

31
   <div class="top_tools" {% if search_tags_id|length == 0 %}style="display: none;"{% endif %}>
31
   <div class="top_tools" {% if search_tags_id|length == 0 %}style="display: none;"{% endif %}>
32
   
32
   
33
     <div class="search_tools">
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
         {% include "MuzichCoreBundle:SearchElement:form.html.twig" with { 
36
         {% include "MuzichCoreBundle:SearchElement:form.html.twig" with { 
37
           'form_name'               : search_form_name,
37
           'form_name'               : search_form_name,
42
         
42
         
43
       </form>
43
       </form>
44
     </div>
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
   </div>
46
   </div>
53
 
47
 
54
   {% include "MuzichCoreBundle:SearchElement:default.html.twig" with {
48
   {% include "MuzichCoreBundle:SearchElement:default.html.twig" with {
55
     'noelements_filter'    : true,
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
   {% if elements|length %}
55
   {% if elements|length %}
60
     {% include "MuzichCoreBundle:SearchElement:more_button.html.twig" with {
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
   {% endif %}
59
   {% endif %}
64
   
60
   

+ 1 - 0
src/Muzich/HomeBundle/Resources/views/Home/need_tags.html.twig Näytä tiedosto

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

+ 4 - 16
src/Muzich/HomeBundle/Resources/views/Show/showGroup.html.twig Näytä tiedosto

64
     </p>
64
     </p>
65
   
65
   
66
     {% include "MuzichCoreBundle:Tag:tagsList.show.html.twig" with {
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
   </div>
73
   </div>
101
     {% endif %}
95
     {% endif %}
102
   {% endif %}
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
 {% endblock %}
98
 {% endblock %}

+ 5 - 16
src/Muzich/HomeBundle/Resources/views/Show/showUser.html.twig Näytä tiedosto

73
       'object_id'   : viewed_user.id,
73
       'object_id'   : viewed_user.id,
74
       'object_type' : 'user'
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
   </div>
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
   {% if more_count is defined %} 
84
   {% if more_count is defined %} 
90
     {% if elements|length %}
85
     {% if elements|length %}
102
       }%}
97
       }%}
103
     {% endif %}
98
     {% endif %}
104
   {% endif %}
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
 {% endblock %}
101
 {% endblock %}

+ 1 - 0
src/Muzich/UserBundle/Resources/views/Event/elements.html.twig Näytä tiedosto

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

BIN
web/img/1361037350_control_play.png Näytä tiedosto