瀏覽代碼

Messages d'erreurs françisé, amélioration dom ...

bastien 13 年之前
父節點
當前提交
04ee0f2ed9

+ 5 - 0
app/Resources/translations/validators.en.yml 查看文件

@@ -0,0 +1,5 @@
1
+
2
+error:
3
+  element:
4
+    name:
5
+      notblank:          Choose a name please

+ 9 - 0
app/Resources/translations/validators.fr.yml 查看文件

@@ -24,6 +24,15 @@ error:
24 24
   changeemail:
25 25
     email:
26 26
       invalid:           L'email saisie n'est pas valide.
27
+  element:
28
+    url:
29
+      notblank:          Vous devez saisir une url (adresse http://)
30
+      tolong:            L'url (adresse http://) est trop longue
31
+      invalid:           L'url (adresse http://) n'est pas correcte
32
+    name:
33
+      notblank:          Vous devez saisir un nom
34
+      toshort:           Le nom est trop court
35
+      tolong:            Le nom est trop long
27 36
       
28 37
 registration:
29 38
   token:

+ 1 - 1
src/Muzich/CoreBundle/Controller/CoreController.php 查看文件

@@ -248,7 +248,7 @@ class CoreController extends Controller
248 248
 
249 249
         foreach ($errorList as $error)
250 250
         {
251
-          $errors[] = $error->getMessage();
251
+          $errors[] = $this->trans($error->getMessage(), array(), 'validators');
252 252
         }
253 253
         
254 254
         return $this->jsonResponse(array(

+ 1 - 1
src/Muzich/CoreBundle/Controller/ElementController.php 查看文件

@@ -139,7 +139,7 @@ class ElementController extends Controller
139 139
       
140 140
       foreach ($errorList as $error)
141 141
       {
142
-        $errors[] = $error->getMessage();
142
+        $errors[] = $this->trans($error->getMessage(), array(), 'validators');
143 143
       }
144 144
     }
145 145
     

+ 7 - 7
src/Muzich/CoreBundle/Entity/Element.php 查看文件

@@ -77,9 +77,9 @@ class Element
77 77
    * L'url est l'url du media. 
78 78
    * 
79 79
    * @ORM\Column(type="string", length=1024)
80
-   * @Assert\NotBlank()
81
-   * @Assert\MaxLength(1024)
82
-   * @Assert\Url()
80
+   * @Assert\NotBlank(message = "error.element.url.notblank")
81
+   * @Assert\MaxLength(limit = 1024, message = "error.element.url.tolong")
82
+   * @Assert\Url(message = "error.element.url.invalid")
83 83
    * @var type string
84 84
    */
85 85
   protected $url;
@@ -87,10 +87,10 @@ class Element
87 87
   /**
88 88
    * Libellé du media
89 89
    * 
90
-   * @ORM\Column(type="string", length=128)
91
-   * @Assert\NotBlank()
92
-   * @Assert\MinLength(limit=3)
93
-   * @Assert\MaxLength(64)
90
+   * @ORM\Column(type = "string", length = 128)
91
+   * @Assert\NotBlank(message = "error.element.name.notblank")
92
+   * @Assert\MinLength(limit = 3, message = "error.element.name.toshort")
93
+   * @Assert\MaxLength(limit = 64, message = "error.element.name.tolong")
94 94
    * @var type string
95 95
    */
96 96
   protected $name;

+ 2 - 0
src/Muzich/CoreBundle/Managers/GroupManager.php 查看文件

@@ -51,8 +51,10 @@ class GroupManager
51 51
     {
52 52
       $this->em->remove($group_tag);
53 53
     }
54
+    $this->em->flush();
54 55
     // Pour etablir les nouveaux liens
55 56
     $this->group->setTagsWithIds($this->em, $tags_ids);
57
+    $this->em->flush();
56 58
   }
57 59
   
58 60
 }

+ 1 - 1
src/Muzich/CoreBundle/Resources/views/Element/ajax.element.edit.html.twig 查看文件

@@ -1,5 +1,5 @@
1 1
 
2
-<form class="edit_element" name="{{ form_name }}" action="{{ path('element_update', {'element_id': element_id}) }}" method="post" {{ form_enctype(form) }}>
2
+<form novalidate class="edit_element" name="{{ form_name }}" action="{{ path('element_update', {'element_id': element_id}) }}" method="post" {{ form_enctype(form) }}>
3 3
 
4 4
   {% include "MuzichCoreBundle:Element:form.edit.html.twig" with { 
5 5
     'form'          : form, 

+ 1 - 1
src/Muzich/CoreBundle/Resources/views/Element/element.edit.html.twig 查看文件

@@ -6,7 +6,7 @@
6 6
 
7 7
   <span class="sinfo">{{ 'system.infos.normally_js'|trans({}, 'userui') }}</span>
8 8
 
9
-  <form name="{{ form_name }}" action="{{ path('element_update', {'element_id': element_id}) }}" method="post" {{ form_enctype(form) }}>
9
+  <form novalidate name="{{ form_name }}" action="{{ path('element_update', {'element_id': element_id}) }}" method="post" {{ form_enctype(form) }}>
10 10
 
11 11
     {% include "MuzichCoreBundle:Element:form.edit.html.twig" with { 
12 12
       'form'          : form, 

+ 7 - 0
src/Muzich/CoreBundle/lib/Controller.php 查看文件

@@ -295,6 +295,13 @@ class Controller extends BaseController
295 295
     return $this->container->get('templating.helper.assets')->getUrl($path, $packageName);
296 296
   }
297 297
   
298
+  /**
299
+   *
300
+   * @param strin $string
301
+   * @param array $params
302
+   * @param string $package
303
+   * @return string 
304
+   */
298 305
   protected function trans($string, $params = array(), $package = null)
299 306
   {
300 307
     return $this->get('translator')->trans($string, $params, $package);

+ 23 - 16
src/Muzich/GroupBundle/Controller/DefaultController.php 查看文件

@@ -36,9 +36,10 @@ class DefaultController extends Controller
36 36
     $form_new = $this->getGroupForm($new_group);
37 37
     
38 38
     return array(
39
-      'groups'        => $user->getGroupsOwned(),
40
-      'form_new'      => $form_new->createView(),
41
-      'form_new_name' => $form_new->getName()
39
+      'groups'         => $user->getGroupsOwned(),
40
+      'form_new'       => $form_new->createView(),
41
+      'form_new_name'  => $form_new->getName(),
42
+      'open_add_group' => false
42 43
     );
43 44
   }
44 45
   
@@ -94,9 +95,10 @@ class DefaultController extends Controller
94 95
       return $this->render(
95 96
         'MuzichGroupBundle:Default:myList.html.twig', 
96 97
          array(
97
-           'groups'        => $user->getGroupsOwned(),
98
-           'form_new'      => $form_new->createView(),
99
-           'form_new_name' => $form_new->getName()
98
+           'groups'         => $user->getGroupsOwned(),
99
+           'form_new'       => $form_new->createView(),
100
+           'form_new_name'  => $form_new->getName(),
101
+           'open_add_group' => true
100 102
          )
101 103
       );
102 104
     }
@@ -138,7 +140,7 @@ class DefaultController extends Controller
138 140
       $prompt_tags[$tag->getTag()->getId()] = $tag->getTag()->getName();
139 141
     }
140 142
     
141
-    $group->setTagsToIds();
143
+    $group->setTags($group->getTagsIdsJson());
142 144
     $form = $this->getGroupForm($group);
143 145
     
144 146
     return array(
@@ -159,9 +161,14 @@ class DefaultController extends Controller
159 161
       throw $this->createNotFoundException('Vous n\'ête pas le créateur de ce groupe.');
160 162
     }
161 163
 
162
-    // Pour être compatible avec le formulaire, la collection de tags dois être
163
-    // une collection d'id
164
-    $group->setTagsToIds();
164
+    $prompt_tags = array();
165
+    foreach ($group->getTags() as $tag)
166
+    {
167
+      $prompt_tags[$tag->getTag()->getId()] = $tag->getTag()->getName();
168
+    }
169
+    
170
+    // Pour être compatible avec le formulaire
171
+    $group->setTags($group->getTagsIdsJson());
165 172
     $form = $this->getGroupForm($group);
166 173
     
167 174
     $form->bindRequest($request);
@@ -178,14 +185,14 @@ class DefaultController extends Controller
178 185
       return $this->redirect($this->generateUrl('show_group', array('slug' => $group->getSlug())));
179 186
     }
180 187
     else
181
-    {
182
-      $this->setFlash('error', 'group.update.failure');
183
-      
188
+    {      
184 189
       return $this->render(
185
-        'GroupBundle:Default:edit.html.twig', 
190
+        'MuzichGroupBundle:Default:edit.html.twig', 
186 191
          array(
187
-           'form_new'      => $form->createView(),
188
-           'form_new_name' => $form_new->getName()
192
+          'group'       => $group,
193
+          'form'        => $form->createView(),
194
+          'form_name'   => 'group',
195
+          'search_tags' => $prompt_tags
189 196
          )
190 197
       );
191 198
     }

+ 1 - 1
src/Muzich/GroupBundle/Resources/views/Default/myList.html.twig 查看文件

@@ -34,7 +34,7 @@
34 34
 
35 35
   {% endif %}
36 36
 
37
-  <div id="group_add_box" style="display: none;">
37
+  <div id="group_add_box" style="{% if not open_add_group %}display: none;{% endif %}">
38 38
 
39 39
     <a href="#" id="group_add_close_link" class="button">
40 40
       &lt;&lt; {{ 'group.add_group_box.close'|trans({}, 'navigationui') }}