Browse Source

Evolution #196: Liste de lecture

Sevajol Bastien 12 years ago
parent
commit
ac91c08a7b

+ 46 - 0
src/Muzich/CoreBundle/Controller/ElementController.php View File

1026
     ));
1026
     ));
1027
   }
1027
   }
1028
   
1028
   
1029
+  public function getOneDomAction(Request $request, $element_id, $type)
1030
+  {
1031
+    if (($response = $this->mustBeConnected()))
1032
+    {
1033
+      return $response;
1034
+    }
1035
+    
1036
+    if (!in_array($type, array('autoplay')))
1037
+    {
1038
+      return $this->jsonResponse(array(
1039
+        'status' => 'error',
1040
+        'errors' => array('NotAllowed')
1041
+      ));
1042
+    }
1043
+    
1044
+    // variables pour le template
1045
+    $display_edit_actions  = true;
1046
+    $display_player        = true;
1047
+    $display_comments      = true;
1048
+    
1049
+    if ($type == 'autoplay')
1050
+    {
1051
+      $display_edit_actions  = false;
1052
+      $display_player        = false;
1053
+      $display_comments      = false;
1054
+    }
1055
+    
1056
+    if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
1057
+      ->findOneById($element_id)))
1058
+    {
1059
+      throw $this->createNotFoundException('Not found');
1060
+    }
1061
+    
1062
+    $html = $this->render('MuzichCoreBundle:SearchElement:element.html.twig', array(
1063
+      'element'               => $element,
1064
+      'display_edit_actions'  => $display_edit_actions,
1065
+      'display_player'        => $display_player,
1066
+      'display_comments'      => $display_comments
1067
+    ))->getContent();
1068
+    
1069
+    return $this->jsonResponse(array(
1070
+      'status'  => 'success',
1071
+      'data'    => $html
1072
+    ));
1073
+  }
1074
+  
1029
 }
1075
 }

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

167
 element_show_need_tags:
167
 element_show_need_tags:
168
   pattern: /need-tags
168
   pattern: /need-tags
169
   defaults: { _controller: MuzichHomeBundle:Home:needTags }
169
   defaults: { _controller: MuzichHomeBundle:Home:needTags }
170
+
171
+element_dom_get_one:
172
+  pattern: /ajax/element/dom/get/{type}/{element_id}
173
+  defaults: { _controller: MuzichCoreBundle:Element:getOneDom, element_id: null }

+ 79 - 54
src/Muzich/CoreBundle/Resources/views/SearchElement/element.html.twig View File

1
+{% if display_edit_actions is not defined %}
2
+  {% set display_edit_actions = true %}
3
+{% endif %}
4
+{% if display_player is not defined %}
5
+  {% set display_player = true %}
6
+{% endif %}
7
+{% if display_comments is not defined %}
8
+  {% set display_comments = true %}
9
+{% endif %}
10
+
1
 <table>
11
 <table>
2
   <tr>
12
   <tr>
3
     <td class="element_thumbnail">
13
     <td class="element_thumbnail">
4
       
14
       
5
       {% if element.embed %}
15
       {% if element.embed %}
6
-        <a href="#" class="a_thumbnail element_open element_embed_open_link {% if element.embed %}embed{% else %}noembed{% endif %}">
16
+        <a href="#" class="a_thumbnail {% if display_player %}element_open element_embed_open_link{% endif %} {% if element.embed and display_player %}embed{% else %}noembed{% endif %}">
7
           <img class="play" style="display: none;" src="{{ asset('bundles/muzichcore/img/1328283150_media-playback-start.png') }}" alt="" />
17
           <img class="play" style="display: none;" src="{{ asset('bundles/muzichcore/img/1328283150_media-playback-start.png') }}" alt="" />
8
           <img 
18
           <img 
9
             class="element_thumbnail"
19
             class="element_thumbnail"
53
       
63
       
54
       {% if app.user.id != element.owner.id %}
64
       {% if app.user.id != element.owner.id %}
55
       
65
       
56
-        <a title="{{ 'element.proposition_tags.link_title'|trans({}, 'userui') }}" 
57
-          class="element_propose_tags" 
58
-          href="{{ path('ajax_element_propose_tags_open', {'element_id' : element.id}) }}">
59
-          <img src="{{ asset('bundles/muzichcore/img/1333484018_rss-tag.png') }}" alt="tags_proposition" />
60
-        </a>
61
-        
62
-        <a title="{{ 'element.reshare.link_title'|trans({}, 'userui') }}" 
63
-          class="element_reshare" 
64
-          href="{{ path('ajax_reshare_element', {'element_id':element.id, 'token':app.user.getPersonalHash('reshare_'~element.id)}) }}">
65
-          <img src="{{ asset('bundles/muzichcore/img/1349338086_adept_update.png') }}" alt="re" />
66
-        </a>
66
+      {% if display_edit_actions %}
67
       
67
       
68
-        <a title="{{ 'element.report.link_title'|trans({}, 'userui') }}" 
69
-          class="element_report" 
70
-          href="{{ path('ajax_report_element', {'element_id':element.id, 'token':app.user.getPersonalHash}) }}">
71
-          <img src="{{ asset('bundles/muzichcore/img/1331832708_comment_alert.png') }}" alt="report" />
72
-        </a>
68
+          <a title="{{ 'element.proposition_tags.link_title'|trans({}, 'userui') }}" 
69
+            class="element_propose_tags" 
70
+            href="{{ path('ajax_element_propose_tags_open', {'element_id' : element.id}) }}">
71
+            <img src="{{ asset('bundles/muzichcore/img/1333484018_rss-tag.png') }}" alt="tags_proposition" />
72
+          </a>
73
+
74
+          <a title="{{ 'element.reshare.link_title'|trans({}, 'userui') }}" 
75
+            class="element_reshare" 
76
+            href="{{ path('ajax_reshare_element', {'element_id':element.id, 'token':app.user.getPersonalHash('reshare_'~element.id)}) }}">
77
+            <img src="{{ asset('bundles/muzichcore/img/1349338086_adept_update.png') }}" alt="re" />
78
+          </a>
79
+
80
+          <a title="{{ 'element.report.link_title'|trans({}, 'userui') }}" 
81
+            class="element_report" 
82
+            href="{{ path('ajax_report_element', {'element_id':element.id, 'token':app.user.getPersonalHash}) }}">
83
+            <img src="{{ asset('bundles/muzichcore/img/1331832708_comment_alert.png') }}" alt="report" />
84
+          </a>
85
+      
86
+      {% endif %}
73
       
87
       
74
       {% endif %}
88
       {% endif %}
75
       
89
       
76
       {% if app.user.id == element.owner.id %}
90
       {% if app.user.id == element.owner.id %}
77
       
91
       
78
-        {% if element.hasTagProposition %}
79
-          <a title="{{ 'element.view_propositions.link'|trans({}, 'elements') }}" class="element_view_propositions_link" 
80
-             href="{{ path('ajax_element_proposed_tags_view', {'element_id' : element.id})  }}"
92
+        {% if display_edit_actions %}
93
+      
94
+          {% if element.hasTagProposition %}
95
+            <a title="{{ 'element.view_propositions.link'|trans({}, 'elements') }}" class="element_view_propositions_link" 
96
+              href="{{ path('ajax_element_proposed_tags_view', {'element_id' : element.id})  }}"
97
+            >
98
+              <img src="{{ asset('bundles/muzichcore/img/1333493527_tag_add.png') }}" alt="tags proposition" />
99
+            </a>
100
+          {% endif %}
101
+
102
+          <a title="{{ 'element.edit.link'|trans({}, 'elements') }}" class="element_edit_link" 
103
+            href="{{ path('element_edit', {'element_id' : element.id})  }}" style="display: none;"
81
           >
104
           >
82
-            <img src="{{ asset('bundles/muzichcore/img/1333493527_tag_add.png') }}" alt="tags proposition" />
105
+            <img src="{{ asset('bundles/muzichcore/img/1327151338_desktop.png') }}" alt="edit" />
106
+          </a>
107
+
108
+          <a title="{{ 'element.remove.link'|trans({}, 'elements') }}" class="element_remove_link" 
109
+            href="{{ path('element_remove', {'element_id' : element.id})  }}" style="display: none;"
110
+          >
111
+            <img src="{{ asset('bundles/muzichcore/img/1327168960_fileclose.png') }}" alt="delete" />
83
           </a>
112
           </a>
84
         {% endif %}
113
         {% endif %}
85
       
114
       
86
-        <a title="{{ 'element.edit.link'|trans({}, 'elements') }}" class="element_edit_link" 
87
-           href="{{ path('element_edit', {'element_id' : element.id})  }}" style="display: none;"
88
-        >
89
-          <img src="{{ asset('bundles/muzichcore/img/1327151338_desktop.png') }}" alt="edit" />
90
-        </a>
91
-
92
-        <a title="{{ 'element.remove.link'|trans({}, 'elements') }}" class="element_remove_link" 
93
-           href="{{ path('element_remove', {'element_id' : element.id})  }}" style="display: none;"
94
-        >
95
-          <img src="{{ asset('bundles/muzichcore/img/1327168960_fileclose.png') }}" alt="delete" />
96
-        </a>
97
       {% endif %}
115
       {% endif %}
98
       
116
       
99
       <br />
117
       <br />
162
         {{ 'element.show.close_embed'|trans({}, 'elements') }}
180
         {{ 'element.show.close_embed'|trans({}, 'elements') }}
163
       </a>
181
       </a>
164
       
182
       
183
+      {% if display_comments %}
165
       
184
       
166
-      {% autoescape false %}
167
-        {% if element.comments|length > 1 %}
168
-          <a href="#hide_comments_{{ element.id }}" class="hide_comments" style="display: none;">
169
-            {{ 'element.comments.hideare'|trans({}, 'elements') }}
170
-          </a>  
171
-          <a href="#comments_{{ element.id }}" class="display_comments">
172
-            {{ 'element.comments.thereare'|trans({'%count%':element.comments|length}, 'elements') }}
173
-          </a>
174
-        {% elseif element.comments|length == 1 %}
175
-          <a href="#hide_comments_{{ element.id }}" class="hide_comments" style="display: none;">
176
-            {{ 'element.comments.hideis'|trans({}, 'elements') }}
177
-          </a> 
178
-          <a href="#comments_{{ element.id }}" class="display_comments">
179
-            {{ 'element.comments.thereis'|trans({}, 'elements') }}
180
-          </a>
181
-        {%endif %}
182
-      {% endautoescape %}
183
-                
184
-      <a href="#add_comment_{{ element.id }}" class="add_comment">
185
-        {{ 'element.comments.add'|trans({}, 'elements') }}
186
-      </a>
185
+        {% autoescape false %}
186
+          {% if element.comments|length > 1 %}
187
+            <a href="#hide_comments_{{ element.id }}" class="hide_comments" style="display: none;">
188
+              {{ 'element.comments.hideare'|trans({}, 'elements') }}
189
+            </a>  
190
+            <a href="#comments_{{ element.id }}" class="display_comments">
191
+              {{ 'element.comments.thereare'|trans({'%count%':element.comments|length}, 'elements') }}
192
+            </a>
193
+          {% elseif element.comments|length == 1 %}
194
+            <a href="#hide_comments_{{ element.id }}" class="hide_comments" style="display: none;">
195
+              {{ 'element.comments.hideis'|trans({}, 'elements') }}
196
+            </a> 
197
+            <a href="#comments_{{ element.id }}" class="display_comments">
198
+              {{ 'element.comments.thereis'|trans({}, 'elements') }}
199
+            </a>
200
+          {%endif %}
201
+        {% endautoescape %}
202
+
203
+        <a href="#add_comment_{{ element.id }}" class="add_comment">
204
+          {{ 'element.comments.add'|trans({}, 'elements') }}
205
+        </a>
206
+      
207
+      {% endif %}
187
       
208
       
188
       
209
       
189
     </td>
210
     </td>
245
 {% endif %}
266
 {% endif %}
246
 {% endif %}
267
 {% endif %}
247
 
268
 
248
-{% if element.embed %}
269
+{% if element.embed and display_player %}
249
   {% autoescape false %}
270
   {% autoescape false %}
250
     <div id="embed_{{ element.id }}" class="element_embed" style="display: none;">
271
     <div id="embed_{{ element.id }}" class="element_embed" style="display: none;">
251
       {{ element.embed }}
272
       {{ element.embed }}
253
   {% endautoescape %}
274
   {% endautoescape %}
254
 {% endif %}
275
 {% endif %}
255
 
276
 
277
+{% if display_comments %}
278
+
256
   <div class="comments" style="display: none;">
279
   <div class="comments" style="display: none;">
257
     <ul class="comments">
280
     <ul class="comments">
258
     {% if element.comments|length %}
281
     {% if element.comments|length %}
286
     </a>
309
     </a>
287
       
310
       
288
   </div>
311
   </div>
312
+
313
+{% endif %}

+ 4 - 6
src/Muzich/CoreBundle/Resources/views/layout.html.twig View File

72
     url_global_search = "{{ path('global_search') }}";
72
     url_global_search = "{{ path('global_search') }}";
73
     url_datas_api = "{{ path('element_retrieve_api_datas') }}";
73
     url_datas_api = "{{ path('element_retrieve_api_datas') }}";
74
     url_element_add = "{{ path('element_add') }}";
74
     url_element_add = "{{ path('element_add') }}";
75
+    url_element_dom_get_one_autoplay = "{{ path('element_dom_get_one', {'type':'autoplay'}) }}";
75
     
76
     
76
     url_img_ajax_loader = "{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}";
77
     url_img_ajax_loader = "{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}";
77
   </script>
78
   </script>
84
     <a href="javascript:void(0);" id="autoplay_close" >
85
     <a href="javascript:void(0);" id="autoplay_close" >
85
       <img src="{{ asset('/bundles/muzichcore/img/1353498913_window-close.png') }}" alt="close" />
86
       <img src="{{ asset('/bundles/muzichcore/img/1353498913_window-close.png') }}" alt="close" />
86
     </a>
87
     </a>
87
-    <div id="autoplay_controls">
88
       
88
       
89
       <a href="javascript:void(0);" id="autoplay_previous">
89
       <a href="javascript:void(0);" id="autoplay_previous">
90
-        <img src="{{ asset('/bundles/muzichcore/img/player_start.png') }}" alt="previous" />
90
+        <img src="{{ asset('/bundles/muzichcore/img/1353505865_button_previous.png') }}" alt="previous" />
91
       </a>
91
       </a>
92
       <a href="javascript:void(0);" id="autoplay_next">
92
       <a href="javascript:void(0);" id="autoplay_next">
93
-        <img src="{{ asset('/bundles/muzichcore/img/player_end.png') }}" alt="next" />
93
+        <img src="{{ asset('/bundles/muzichcore/img/1353505874_button_next.png') }}" alt="next" />
94
       </a>
94
       </a>
95
-        
96
-      <div id="autoplay_title"></div>
97
       
95
       
98
-    </div>
96
+    <ul id="autoplay_element"><li class="element" id="autoplay_element_container"></li></ul>
99
     <div id="autoplay_player_container">
97
     <div id="autoplay_player_container">
100
       <div id="autoplay_player"></div>
98
       <div id="autoplay_player"></div>
101
     </div>
99
     </div>

+ 24 - 11
web/bundles/muzichcore/css/main.css View File

84
   background-color: #39C9CC;
84
   background-color: #39C9CC;
85
 }
85
 }
86
 
86
 
87
-#container a
87
+#container a, #autoplay a
88
 {
88
 {
89
   text-decoration: none;
89
   text-decoration: none;
90
   color: #00d0de;
90
   color: #00d0de;
91
 }
91
 }
92
 
92
 
93
-#container a.button
93
+#container a.button, #autoplay a.button
94
 {
94
 {
95
   color: white;
95
   color: white;
96
 }
96
 }
542
   left: 483px;
542
   left: 483px;
543
 }*/
543
 }*/
544
 
544
 
545
-#container li.element a.favorite_link:hover
545
+#container li.element a.favorite_link:hover, #autoplay li.element a.favorite_link:hover
546
 {
546
 {
547
   text-decoration: none;
547
   text-decoration: none;
548
 }
548
 }
585
   height: 90px;
585
   height: 90px;
586
 }
586
 }
587
 
587
 
588
-#container li.element span.element_name a
588
+#container li.element span.element_name a, #autoplay li.element span.element_name a
589
 {
589
 {
590
   color: black;
590
   color: black;
591
 }
591
 }
596
   
596
   
597
 }
597
 }
598
 
598
 
599
-ul.elements
599
+ul.elements, ul#autoplay_element
600
 {
600
 {
601
   margin-left: 0px;
601
   margin-left: 0px;
602
 }
602
 }
612
   margin-left: 0px;
612
   margin-left: 0px;
613
 }
613
 }
614
   
614
   
615
-.elements ul.element_tags li
615
+.elements ul.element_tags li, ul#autoplay_element ul.element_tags li
616
 {
616
 {
617
   display: inline;
617
   display: inline;
618
   font-size: 90%;
618
   font-size: 90%;
1308
   font-size: 15px;
1308
   font-size: 15px;
1309
 }
1309
 }
1310
 
1310
 
1311
+div#autoplay
1312
+{
1313
+  text-align: left;
1314
+  padding-top: 0px;
1315
+}
1316
+
1311
 a#autoplay_launch
1317
 a#autoplay_launch
1312
 {
1318
 {
1313
   float: right;
1319
   float: right;
1319
   width: 500px;
1325
   width: 500px;
1320
 }
1326
 }
1321
 
1327
 
1322
-div#autoplay.popin_block div#autoplay_controls
1323
-{
1324
- text-align: left;
1325
-}
1326
-
1327
 a#autoplay_previous
1328
 a#autoplay_previous
1328
 {
1329
 {
1329
   float: left;
1330
   float: left;
1330
   text-decoration: none;
1331
   text-decoration: none;
1332
+  margin-left: -50px;
1331
 }
1333
 }
1332
 
1334
 
1333
 a#autoplay_next
1335
 a#autoplay_next
1334
 {
1336
 {
1335
   float: right;
1337
   float: right;
1336
   text-decoration: none;
1338
   text-decoration: none;
1339
+  margin-right: -50px;
1337
 }
1340
 }
1338
 
1341
 
1339
 div#autoplay_title
1342
 div#autoplay_title
1349
   text-decoration: none;
1352
   text-decoration: none;
1350
   margin-top: -32px;
1353
   margin-top: -32px;
1351
   margin-right: -32px;
1354
   margin-right: -32px;
1355
+}
1356
+
1357
+div#autoplay_player_container
1358
+{
1359
+  text-align: center;
1360
+}
1361
+
1362
+div#autoplay ul.elements, div#autoplay
1363
+{
1364
+  margin-top: 0px;
1352
 }
1365
 }

BIN
web/bundles/muzichcore/img/1353503730_button-previous.png View File


BIN
web/bundles/muzichcore/img/1353503762_button-next.png View File


BIN
web/bundles/muzichcore/img/1353505865_button_previous.png View File


BIN
web/bundles/muzichcore/img/1353505874_button_next.png View File


+ 39 - 11
web/bundles/muzichcore/js/autoplay.js View File

47
     // pu être créé par la lecture précedente.
47
     // pu être créé par la lecture précedente.
48
     $('div#'+autoplay_player_div_id+'_container').html('<div id="'+autoplay_player_div_id+'"></div>');
48
     $('div#'+autoplay_player_div_id+'_container').html('<div id="'+autoplay_player_div_id+'"></div>');
49
     $('#autoplay_noelements_text').hide();
49
     $('#autoplay_noelements_text').hide();
50
+    $('li#autoplay_element_container').html('');
51
+    $('img#autoplay_loader').show();
50
     
52
     
51
     if (autoplay_list.length)
53
     if (autoplay_list.length)
52
     {
54
     {
53
     
55
     
54
       if (array_key_exists(step, autoplay_list))
56
       if (array_key_exists(step, autoplay_list))
55
       {
57
       {
56
-        // Youtube case
57
-        if (autoplay_list[step].element_type == 'youtube.com' || autoplay_list[step].element_type == 'youtu.be')
58
-        {
59
-          $('img#autoplay_loader').show();
60
-          $('div#autoplay_title').text(autoplay_list[step].element_name);
61
-          youtube_create_player(autoplay_list[step].element_ref_id);
62
-        }
58
+        
59
+        // Récupération du dom d'un élement
60
+        $.getJSON(url_element_dom_get_one_autoplay+'/'+autoplay_list[step].element_id, function(response) {
61
+          if (response.status == 'mustbeconnected')
62
+          {
63
+            $(location).attr('href', url_index);
64
+          }
65
+
66
+          if (response.status == 'success')
67
+          {
68
+            // On récupère la liste d'élèments
69
+            $('li#autoplay_element_container').html(response.data);
70
+            
71
+            // Youtube case
72
+            if (autoplay_list[step].element_type == 'youtube.com' || autoplay_list[step].element_type == 'youtu.be')
73
+            {
74
+              youtube_create_player(autoplay_list[step].element_ref_id);
75
+            }
76
+            
77
+          }
78
+
79
+        });
80
+        
81
+        
63
       }
82
       }
64
     
83
     
65
     }
84
     }
66
     else
85
     else
67
     {
86
     {
68
-      $('#autoplay_noelements_text').show();
69
-      $('img#autoplay_loader').hide();
87
+      autoplay_display_nomore();
70
     }
88
     }
71
   }
89
   }
72
   
90
   
91
+  function autoplay_display_nomore()
92
+  {
93
+    $('div#'+autoplay_player_div_id+'_container').html('<div id="'+autoplay_player_div_id+'"></div>');
94
+    $('li#autoplay_element_container').html('');
95
+    $('#autoplay_noelements_text').show();
96
+    $('img#autoplay_loader').hide();
97
+  }
98
+  
73
   // Avancer d'un élelement dans la liste
99
   // Avancer d'un élelement dans la liste
74
   function autoplay_next()
100
   function autoplay_next()
75
   {
101
   {
80
     }
106
     }
81
     else
107
     else
82
     {
108
     {
83
-      autoplay_step--;
109
+      autoplay_display_nomore();
110
+      autoplay_step = autoplay_list.length;
84
     }
111
     }
85
   }
112
   }
86
   
113
   
94
     }
121
     }
95
     else
122
     else
96
     {
123
     {
97
-      autoplay_step++;
124
+      autoplay_display_nomore();
125
+      autoplay_step = -1;
98
     }
126
     }
99
   }
127
   }
100
   
128