Browse Source

Evolution #298: Petits coeurs

Bastien Sevajol 12 years ago
parent
commit
7416c8ffcc

+ 2 - 0
app/Resources/translations/elements.fr.yml View File

38
         sentence:       Ajouter aux favoris ?
38
         sentence:       Ajouter aux favoris ?
39
         yes:            Oui
39
         yes:            Oui
40
         no:             Non
40
         no:             Non
41
+    isfav:
42
+      title:            Le tag "%tagname%" fait partis de vos tags favoris
41
   comments: 
43
   comments: 
42
     add:                Ajouter un commentaire
44
     add:                Ajouter un commentaire
43
     thereis:            Afficher le commentaire
45
     thereis:            Afficher le commentaire

+ 18 - 0
src/Muzich/CoreBundle/Entity/User.php View File

815
     $this->setTagsFavoritesQuick($tags_favorites_quick);
815
     $this->setTagsFavoritesQuick($tags_favorites_quick);
816
   }
816
   }
817
   
817
   
818
+  /**
819
+   * Retourne vrai si le tag_id transmis fait partis des tags favoris de 
820
+   * l'utilisateur
821
+   * 
822
+   * @param int $tag_id
823
+   * @return boolean
824
+   */
825
+  public function haveTagsFavorite($tag_id)
826
+  {
827
+    $tags_favorites_quick = $this->getTagsFavoritesQuick();
828
+    if (array_key_exists($tag_id, $tags_favorites_quick))
829
+    {
830
+      return true;
831
+    }
832
+    
833
+    return false;
834
+  }
835
+  
818
 }
836
 }

+ 21 - 10
src/Muzich/CoreBundle/Resources/views/SearchElement/element.html.twig View File

130
       <ul class="element_tags">
130
       <ul class="element_tags">
131
         {% for tag in element.tags %} 
131
         {% for tag in element.tags %} 
132
           <li class="element_tag">
132
           <li class="element_tag">
133
-            <a id="element_tag_{{ tag.id }}" href="#" class="element_tag button">{{ tag.name }}</a>
134
-            <a 
135
-              href="{{ path('ajax_tag_add_to_favorites', {
136
-                'tag_id' : tag.id,
137
-                'token'  : app.user.getPersonalHash
138
-              }) }}" 
139
-              class="tag_to_favorites" 
140
-              style="display: none;"
141
-              title="{{ 'element.tag.addtofav.title'|trans({}, 'elements') }}"   
133
+            <a id="element_tag_{{ tag.id }}" href="#" 
134
+              class="element_tag button {% if app.user.haveTagsFavorite(tag.id) %}element_tag_large_for_fav_still{% endif %}"
142
             >
135
             >
143
-              <img src="{{ asset('/bundles/muzichcore/img/1331734087_emblem-favorite.png') }}" alt="add-to-favorites"/>
136
+              {{ tag.name }}
144
             </a>
137
             </a>
138
+            {% if app.user.haveTagsFavorite(tag.id) %}
139
+              <img class="tag_to_favorites" src="{{ asset('/bundles/muzichcore/img/1331734087_emblem-favorite.png') }}" 
140
+                alt="add-to-favorites"
141
+                title="{{ 'element.tag.isfav.title'|trans({'%tagname%':tag.name}, 'elements') }}"
142
+              />
143
+            {% else %}
144
+              <a 
145
+                href="{{ path('ajax_tag_add_to_favorites', {
146
+                  'tag_id' : tag.id,
147
+                  'token'  : app.user.getPersonalHash
148
+                }) }}" 
149
+                class="tag_to_favorites" 
150
+                style="display: none;"
151
+                title="{{ 'element.tag.addtofav.title'|trans({}, 'elements') }}"   
152
+              >
153
+                <img src="{{ asset('/bundles/muzichcore/img/1331734087_emblem-favorite.png') }}" alt="add-to-favorites"/>
154
+              </a>
155
+            {% endif %}
145
           </li>
156
           </li>
146
         {% endfor %} 
157
         {% endfor %} 
147
       </ul>
158
       </ul>

+ 6 - 1
web/bundles/muzichcore/css/main.css View File

1068
 
1068
 
1069
 /* Ajouter tag d'élément a ses tags favoris */
1069
 /* Ajouter tag d'élément a ses tags favoris */
1070
 
1070
 
1071
-li.element a.tag_to_favorites
1071
+li.element a.tag_to_favorites, li.element img.tag_to_favorites
1072
 {
1072
 {
1073
   margin-left: -15px;
1073
   margin-left: -15px;
1074
   margin-right: 4px;
1074
   margin-right: 4px;
1079
   padding-right: 15px;
1079
   padding-right: 15px;
1080
 }
1080
 }
1081
 
1081
 
1082
+li.element a.element_tag_large_for_fav_still
1083
+{
1084
+  padding-right: 15px;
1085
+}
1086
+
1082
 /* END Ajouter tag d'élément a ses tags favoris */
1087
 /* END Ajouter tag d'élément a ses tags favoris */
1083
 
1088
 
1084
 div#added_element_to_group
1089
 div#added_element_to_group