Browse Source

Evolution #409: Xpi: url pas bonne

Sevajol Bastien 12 years ago
parent
commit
1e9e95821d

+ 6 - 19
app/config/routing.yml View File

14
   
14
   
15
 MuzichAdminBundle:
15
 MuzichAdminBundle:
16
   resource: "@MuzichAdminBundle/Resources/config/routing.yml"
16
   resource: "@MuzichAdminBundle/Resources/config/routing.yml"
17
-#  prefix: /{_locale}/
18
-#  defaults: { _locale: fr }
19
   
17
   
20
 MuzichIndexBundle:
18
 MuzichIndexBundle:
21
   resource: "@MuzichIndexBundle/Resources/config/routing.yml"
19
   resource: "@MuzichIndexBundle/Resources/config/routing.yml"
29
   pattern:  /auto-language
27
   pattern:  /auto-language
30
   defaults: { _controller: MuzichCoreBundle:Core:automaticLanguage }
28
   defaults: { _controller: MuzichCoreBundle:Core:automaticLanguage }
31
   
29
   
30
+share_form:
31
+  pattern:  /share-from/
32
+  defaults: { _controller: MuzichCoreBundle:Core:shareFrom }
33
+  
32
 MuzichCoreBundle:
34
 MuzichCoreBundle:
33
   resource: "@MuzichCoreBundle/Resources/config/routing.yml"
35
   resource: "@MuzichCoreBundle/Resources/config/routing.yml"
34
   prefix: /{_locale}/
36
   prefix: /{_locale}/
35
-  defaults: { _locale: fr }
36
 
37
 
38
+  
37
 MuzichHomeBundle:
39
 MuzichHomeBundle:
38
   resource: "@MuzichHomeBundle/Resources/config/routing.yml"
40
   resource: "@MuzichHomeBundle/Resources/config/routing.yml"
39
   prefix: /{_locale}/
41
   prefix: /{_locale}/
40
-#  defaults:
41
-#    _locale: fr
42
     
42
     
43
 # On doit rajouter une route au cas ou la langue n'est pas précisé.
43
 # On doit rajouter une route au cas ou la langue n'est pas précisé.
44
 home_bis:
44
 home_bis:
45
   pattern:  /
45
   pattern:  /
46
   defaults: { _controller: MuzichHomeBundle:Home:index }
46
   defaults: { _controller: MuzichHomeBundle:Home:index }
47
   
47
   
48
-#share_form:
49
-#  pattern:  /share-from/{url}
50
-#  defaults: { _controller: MuzichCoreBundle:Core:shareFrom }
51
-
52
 MuzichUserBundle:
48
 MuzichUserBundle:
53
   resource: "@MuzichUserBundle/Resources/config/routing.yml"
49
   resource: "@MuzichUserBundle/Resources/config/routing.yml"
54
   prefix: /{_locale}/
50
   prefix: /{_locale}/
55
-  defaults:
56
-    _locale: en|fr
57
 
51
 
58
 MuzichMynetworkBundle:
52
 MuzichMynetworkBundle:
59
   resource: "@MuzichMynetworkBundle/Resources/config/routing.yml"
53
   resource: "@MuzichMynetworkBundle/Resources/config/routing.yml"
60
   prefix:   /{_locale}/
54
   prefix:   /{_locale}/
61
-  defaults:
62
-    _locale: en|fr
63
   
55
   
64
 MuzichGroupBundle:
56
 MuzichGroupBundle:
65
   resource: "@MuzichGroupBundle/Resources/config/routing.yml"
57
   resource: "@MuzichGroupBundle/Resources/config/routing.yml"
66
   prefix:   /{_locale}/
58
   prefix:   /{_locale}/
67
-  defaults:
68
-    _locale: en|fr
69
   
59
   
70
 MuzichFavoriteBundle:
60
 MuzichFavoriteBundle:
71
   resource: "@MuzichFavoriteBundle/Resources/config/routing.yml"
61
   resource: "@MuzichFavoriteBundle/Resources/config/routing.yml"
72
   prefix:   /{_locale}/
62
   prefix:   /{_locale}/
73
-  defaults:
74
-    _locale: en|fr
75
   
63
   
76
 MuzichCommentBundle:
64
 MuzichCommentBundle:
77
   resource: "@MuzichCommentBundle/Resources/config/routing.yml"
65
   resource: "@MuzichCommentBundle/Resources/config/routing.yml"
78
   prefix:   /{_locale}/
66
   prefix:   /{_locale}/
79
-  defaults:
80
-    _locale: en|fr
67
+  

+ 31 - 6
src/Muzich/CoreBundle/Controller/CoreController.php View File

19
 use Muzich\CoreBundle\Managers\ElementReportManager;
19
 use Muzich\CoreBundle\Managers\ElementReportManager;
20
 use Muzich\CoreBundle\Propagator\EventUser;
20
 use Muzich\CoreBundle\Propagator\EventUser;
21
 use Muzich\CoreBundle\Entity\User;
21
 use Muzich\CoreBundle\Entity\User;
22
+use Symfony\Component\HttpFoundation\Request;
22
 
23
 
23
 class CoreController extends Controller
24
 class CoreController extends Controller
24
 {
25
 {
59
   }
60
   }
60
   
61
   
61
   /**
62
   /**
62
-   * 
63
-   * Cette action est écrite pour les utilisateur redirigé du a l'absence de 
64
-   * lague dans leur route.
65
-   * Cette redirection n'est pas interne au code, elle est actuellement effectué
66
-   * par le .htaccess lorsque il n'y as pas d'url (en plus de muzi.ch/
63
+   *  Determiner la locale automatiquement
64
+   * @return string 
67
    */
65
    */
68
-  public function automaticLanguageAction()
66
+  protected function determineLocale()
69
   {
67
   {
70
     $lang = $this->container->get('request')
68
     $lang = $this->container->get('request')
71
       ->getPreferredLanguage($this->container->getParameter('supported_langs')); 
69
       ->getPreferredLanguage($this->container->getParameter('supported_langs')); 
73
     // Si on a une lang en sortie, 
71
     // Si on a une lang en sortie, 
74
     if (is_null($lang))
72
     if (is_null($lang))
75
     {
73
     {
74
+      // TODO: Récupérer ce paramètre dans la config
76
       $lang = 'fr';
75
       $lang = 'fr';
77
     }
76
     }
78
     
77
     
78
+    return $lang;
79
+  }
80
+  
81
+  /**
82
+   * 
83
+   * Cette action est écrite pour les utilisateur redirigé du a l'absence de 
84
+   * lague dans leur route.
85
+   * Cette redirection n'est pas interne au code, elle est actuellement effectué
86
+   * par le .htaccess lorsque il n'y as pas d'url (en plus de muzi.ch/
87
+   */
88
+  public function automaticLanguageAction()
89
+  {
90
+    $lang = $this->determineLocale();
79
     if ($this->getUser() != 'anon.')
91
     if ($this->getUser() != 'anon.')
80
     {
92
     {
81
       return $this->redirect($this->generateUrl('home', array('_locale' => $lang)));
93
       return $this->redirect($this->generateUrl('home', array('_locale' => $lang)));
678
     ));
690
     ));
679
   }
691
   }
680
   
692
   
693
+  /**
694
+   * Url de récupération des plugins/application qui vienne partager une url
695
+   * @param Request $request 
696
+   */
697
+  public function shareFromAction(Request $request)
698
+  {
699
+    return $this->redirect($this->generateUrl('home', array(
700
+      'from_url' => $request->get('from_url'),
701
+      // On ne se préoccupe pas de la locale coté plugins/applications
702
+      '_locale'  => $this->determineLocale()
703
+    )));
704
+  }
705
+  
681
 }
706
 }

+ 1 - 0
src/Muzich/CoreBundle/Resources/config/security.yml View File

80
         - { path: ^/(?:fr|en)/favoritesajax, role: IS_AUTHENTICATED_ANONYMOUSLY }
80
         - { path: ^/(?:fr|en)/favoritesajax, role: IS_AUTHENTICATED_ANONYMOUSLY }
81
         - { path: ^/(?:fr|en)/ajax, role: IS_AUTHENTICATED_ANONYMOUSLY }
81
         - { path: ^/(?:fr|en)/ajax, role: IS_AUTHENTICATED_ANONYMOUSLY }
82
         - { path: ^/(?:fr|en)/event/view/elements, role: IS_AUTHENTICATED_ANONYMOUSLY }
82
         - { path: ^/(?:fr|en)/event/view/elements, role: IS_AUTHENTICATED_ANONYMOUSLY }
83
+        - { path: ^/share-from, role: IS_AUTHENTICATED_ANONYMOUSLY }
83
                                         
84
                                         
84
         - { path: ^/, roles: ROLE_USER }
85
         - { path: ^/, roles: ROLE_USER }
85
         
86
         

+ 2 - 5
src/Muzich/IndexBundle/Resources/config/routing.yml View File

6
     
6
     
7
 index:
7
 index:
8
     pattern:  /hello/{_locale}
8
     pattern:  /hello/{_locale}
9
-    defaults: { _controller: MuzichIndexBundle:Index:index }
9
+    defaults:
10
+      _controller: MuzichIndexBundle:Index:index
10
 
11
 
11
 fos_user_security:
12
 fos_user_security:
12
     resource: "@FOSUserBundle/Resources/config/routing/security.xml"
13
     resource: "@FOSUserBundle/Resources/config/routing/security.xml"
15
 fos_user_profile:
16
 fos_user_profile:
16
     resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
17
     resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
17
     prefix: /{_locale}/profile/
18
     prefix: /{_locale}/profile/
18
-    defaults: { _locale: fr }
19
 
19
 
20
 fos_user_register:
20
 fos_user_register:
21
     resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
21
     resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
22
     prefix: /{_locale}/register/
22
     prefix: /{_locale}/register/
23
-    defaults: { _locale: fr }
24
 
23
 
25
 fos_user_resetting:
24
 fos_user_resetting:
26
     resource: "@FOSUserBundle/Resources/config/routing/resetting.xml"
25
     resource: "@FOSUserBundle/Resources/config/routing/resetting.xml"
27
     prefix: /{_locale}/resetting
26
     prefix: /{_locale}/resetting
28
-    defaults: { _locale: fr }
29
 
27
 
30
 fos_user_change_password:
28
 fos_user_change_password:
31
     resource: "@FOSUserBundle/Resources/config/routing/change_password.xml"
29
     resource: "@FOSUserBundle/Resources/config/routing/change_password.xml"
32
     prefix: /{_locale}/change-password/
30
     prefix: /{_locale}/change-password/
33
-    defaults: { _locale: fr }