Pārlūkot izejas kodu

Adaptation au plugin

Bastien Sevajol 11 gadus atpakaļ
vecāks
revīzija
af41460b68

+ 1 - 0
app/Resources/translations/elements.en.yml Parādīt failu

@@ -19,6 +19,7 @@ element:
19 19
     group:
20 20
       will_be_in:       This element will be add to the group.
21 21
     url_title_step2:    Ressource
22
+    shared_from_finish: Music shared, you can close the box (top-left cross)
22 23
   show:
23 24
     close_embed:        Close the player
24 25
     open_embed:         Display the player

+ 1 - 0
app/Resources/translations/elements.fr.yml Parādīt failu

@@ -18,6 +18,7 @@ element:
18 18
     group:
19 19
       will_be_in:       L'élément sera ajouté dans le groupe
20 20
     url_title_step2:    Ressource
21
+    shared_from_finish: Le partage a été effectué, vous pouvez fermer la boite (croix en haut à gauche)
21 22
   show:
22 23
     close_embed:        Fermer le lecteur
23 24
     open_embed:         Afficher le lecteur

+ 11 - 1
src/Muzich/CoreBundle/Controller/CoreController.php Parādīt failu

@@ -284,7 +284,8 @@ class CoreController extends Controller
284 284
         return $this->jsonResponse(array(
285 285
           'status' => 'success',
286 286
           'html'   => $html,
287
-          'groups' => (!$group)?$this->isAddedElementCanBeInGroup($element):array()
287
+          'groups' => (!$group)?$this->isAddedElementCanBeInGroup($element):array(),
288
+          'message' => ($this->getRequest()->get('shared_from'))?$this->trans('element.add.shared_from_finish', array(), 'elements'):''
288 289
         ));
289 290
       }
290 291
       else
@@ -691,4 +692,13 @@ class CoreController extends Controller
691 692
     throw new \Exception('test error');
692 693
   }
693 694
   
695
+  public function getCsrfTokenAction()
696
+  {
697
+    if (($response = $this->mustBeConnected(true)))
698
+      return $response;
699
+    
700
+    $csrfToken = $this->container->get('form.csrf_provider')->generateCsrfToken('unknown');
701
+    return $this->jsonSuccessResponse($csrfToken);
702
+  }
703
+  
694 704
 }

+ 6 - 1
src/Muzich/CoreBundle/Resources/config/routing.yml Parādīt failu

@@ -212,4 +212,9 @@ url_get_embed_for_element:
212 212
 
213 213
 share_from:
214 214
   pattern: /element/share/from
215
-  defaults: { _controller: MuzichCoreBundle:Element:shareFrom }
215
+  defaults: { _controller: MuzichCoreBundle:Element:shareFrom }
216
+  
217
+get_csrf_token:
218
+  pattern: /ajax/getcsrf
219
+  defaults: { _controller: MuzichCoreBundle:Core:getCsrfToken }
220
+  

+ 7 - 0
src/Muzich/CoreBundle/Resources/public/css/main.css Parādīt failu

@@ -2509,6 +2509,13 @@ div#tags_prompt_search p.help_notags span
2509 2509
   width: 100%;
2510 2510
 }
2511 2511
 
2512
+div#share_from_message
2513
+{
2514
+  font-weight: bold;
2515
+  padding: 15px;
2516
+  font-size: 115%;
2517
+}
2518
+
2512 2519
 /*
2513 2520
 *
2514 2521
 *

+ 57 - 11
src/Muzich/CoreBundle/Resources/public/js/muzich.js Parādīt failu

@@ -23,7 +23,7 @@ function hideAllMessages()
23 23
 
24 24
 function ResponseController()
25 25
 {
26
-  var propagate = function(response)
26
+  var propagate = function(response, after_login_success_callback)
27 27
   {
28 28
     if (response.status === 'error')
29 29
     {
@@ -35,18 +35,19 @@ function ResponseController()
35 35
       }
36 36
       else if (response.error === 'UserNotConnected')
37 37
       {
38
-        open_connection_or_subscription_window();
38
+        open_connection_or_subscription_window(false, {}, after_login_success_callback);
39 39
       }
40 40
     }
41 41
     else if (response.status === 'mustbeconnected')
42 42
     {
43
-      open_connection_or_subscription_window(true);
43
+      open_connection_or_subscription_window(true, {}, after_login_success_callback);
44 44
     }
45
-  }
45
+  };
46 46
   
47
-  this.execute = function(response, success_callback, failure_callback)
47
+  this.execute = function(response, success_callback, failure_callback, after_login_success_callback)
48 48
   {
49
-    propagate(response);
49
+    propagate(response, after_login_success_callback);
50
+    
50 51
     if (response.status === 'success')
51 52
     {
52 53
       success_callback(response);
@@ -55,7 +56,7 @@ function ResponseController()
55 56
     {
56 57
       failure_callback(response);
57 58
     }
58
-  }
59
+  };
59 60
 }
60 61
 
61 62
 window.ResponseController = new ResponseController();
@@ -1320,6 +1321,16 @@ $(document).ready(function(){
1320 1321
       
1321 1322
       form_add_hide_errors();
1322 1323
       
1324
+      // Dans le cas d'un ajout depuis l'extérieur (iframe)
1325
+      if ($('form[name="add"] input[name="shared_from"]').val() === "1")
1326
+      {
1327
+        var elements = $('<ul class="elements"></ul>')
1328
+        elements.prepend(response.html);
1329
+        $('div#share_from_content').append(elements);
1330
+        $('div#share_from_message').text(response.message);
1331
+        //$('form[name="add"]').append($('<input type="hidden" name="shared_from_finished" id="shared_from_finished" value="1" />'));
1332
+      }
1333
+      
1323 1334
       return true;
1324 1335
     }
1325 1336
     else if (response.status == 'error')
@@ -1540,11 +1551,30 @@ $(document).ready(function(){
1540 1551
   });
1541 1552
   $('form[name="add"]').ajaxForm(function(response) {
1542 1553
     
1554
+    var callback_login = null;
1555
+    // Dans le cas d'un ajout depuis l'extérieur (iframe)
1556
+    if ($('form[name="add"] input[name="shared_from"]').val() === "1")
1557
+    {
1558
+      callback_login = function(){ 
1559
+        $('#form_add_loader').show();
1560
+        JQueryJson(url_csrf, {}, function(response){
1561
+          if (response.status == 'success')
1562
+          {
1563
+            $('form[name="add"] input[name="element_add[_token]"]').val(response.data);
1564
+            $('form[name="add"]').submit();
1565
+            $('#form_add_loader').hide();
1566
+          }
1567
+        });
1568
+         
1569
+      };
1570
+    }
1571
+    
1543 1572
     $('form[name="add"] img.tag_loader').hide();
1544 1573
     window.ResponseController.execute(
1545 1574
       response,
1546 1575
       function(){},
1547
-      function(){}
1576
+      function(){},
1577
+      callback_login
1548 1578
     );
1549 1579
     
1550 1580
       // Si on en est a la première étape la réponse sera des données récupérés auprès
@@ -3361,7 +3391,7 @@ function open_ajax_popin(url, callback, data)
3361 3391
   }
3362 3392
 }
3363 3393
 
3364
-function open_connection_or_subscription_window(open_login_part, data)
3394
+function open_connection_or_subscription_window(open_login_part, data, login_success_callback)
3365 3395
 {
3366 3396
   if (window_login_or_subscription_opened == false)
3367 3397
   {
@@ -3390,7 +3420,15 @@ function open_connection_or_subscription_window(open_login_part, data)
3390 3420
         $('div.login form').find('img.loader').hide();
3391 3421
         if (response.status == 'success')
3392 3422
         {
3393
-          $(location).attr('href', response.data.redirect_url);
3423
+          if (login_success_callback)
3424
+          {
3425
+            $('a#helpbox_close').click();
3426
+            login_success_callback();
3427
+          }
3428
+          else
3429
+          {
3430
+            $(location).attr('href', response.data.redirect_url);
3431
+          }
3394 3432
         }
3395 3433
         else if (response.status == 'error')
3396 3434
         {
@@ -3407,7 +3445,15 @@ function open_connection_or_subscription_window(open_login_part, data)
3407 3445
         $('div.register form.fos_user_registration_register').find('img.loader').hide();
3408 3446
         if (response.status == 'success')
3409 3447
         {
3410
-          $(location).attr('href', url_home);
3448
+          if (login_success_callback)
3449
+          {
3450
+            $('a#helpbox_close').click();
3451
+            login_success_callback();
3452
+          }
3453
+          else
3454
+          {
3455
+            $(location).attr('href', url_home);
3456
+          }
3411 3457
         }
3412 3458
         else if (response.status == 'error')
3413 3459
         {

+ 5 - 0
src/Muzich/CoreBundle/Resources/views/Component/element_add_box.html.twig Parādīt failu

@@ -7,6 +7,9 @@
7 7
 {% if show_add_to_group is not defined %}
8 8
   {% set show_add_to_group = true %}
9 9
 {% endif %}
10
+{% if shared_from is not defined %}
11
+  {% set shared_from = 0 %}
12
+{% endif %}
10 13
 
11 14
 {% if not group_slug %}
12 15
   {% set form_action = path('element_add') %}
@@ -37,6 +40,8 @@
37 40
       'form_name'     : add_form_name
38 41
     } %}
39 42
   
43
+     <input type="hidden" name="shared_from" value="{{ shared_from }}" />
44
+          
40 45
   </form>
41 46
 </div>
42 47
 

+ 4 - 0
src/Muzich/CoreBundle/Resources/views/Element/share_from.html.twig Parādīt failu

@@ -7,6 +7,7 @@
7 7
   {% include 'MuzichCoreBundle:Component:element_add_box.html.twig' with {
8 8
     'box_title'     : 'home.add_element_box.title_external'|trans({}, 'navigationui'),
9 9
     'add_form_name' : 'add',
10
+    'shared_from'   : 1
10 11
   } %}
11 12
 
12 13
   <script type="text/javascript">
@@ -19,5 +20,8 @@
19 20
       $('form[name="add"]').submit();
20 21
     });
21 22
   </script>
23
+  
24
+  <div id="share_from_content"></div>
25
+  <div id="share_from_message"></div>
22 26
 
23 27
 {% endblock %}

+ 1 - 1
src/Muzich/CoreBundle/Resources/views/Layout/head_js.html.twig Parādīt failu

@@ -129,7 +129,7 @@
129 129
   url_img_ajax_loader = "{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}";
130 130
   url_get_embed_for_element = "{{ path('url_get_embed_for_element') }}";
131 131
   url_helpbox_tags_favorites = "{{ path('helpbox_tags_favorites') }}";
132
-  
132
+  url_csrf = "{{ path('get_csrf_token') }}";
133 133
   url_subscription_or_login = "{{ path('subscribe_or_login') }}";
134 134
   url_email_not_confirmed = "{{ path('email_not_confirmed') }}";
135 135
   url_send_email_confirmation = "{{ path('send_email_confirmation') }}";

+ 1 - 2
src/Muzich/CoreBundle/lib/Controller.php Parādīt failu

@@ -499,14 +499,13 @@ class Controller extends BaseController
499 499
     
500 500
     if ($this->getUser() == 'anon.')
501 501
     {
502
-      $this->setFlash('error', 'user.session_expired');
503
-      
504 502
       if ($this->getRequest()->isXmlHttpRequest())
505 503
       {
506 504
         return $this->mustBeConnectedResponse();
507 505
       }
508 506
       else
509 507
       {
508
+        $this->setFlash('error', 'user.session_expired');
510 509
         return $this->redirect($this->generateUrl('home'));
511 510
       }
512 511
     }