Przeglądaj źródła

Merge branch 'stable/v0.8' into feature/v0.8/addelement

Sevajol Bastien 12 lat temu
rodzic
commit
308892d7b1
27 zmienionych plików z 1479 dodań i 759 usunięć
  1. 2 0
      app/Resources/translations/elements.fr.yml
  2. 2 0
      app/Resources/translations/navigationui.fr.yml
  3. 11 1
      app/Resources/translations/userui.fr.yml
  4. 1 0
      src/Muzich/CoreBundle/Controller/ElementController.php
  5. 76 0
      src/Muzich/CoreBundle/Entity/User.php
  6. 19 1
      src/Muzich/CoreBundle/Entity/UsersTagsFavorites.php
  7. 1 1
      src/Muzich/CoreBundle/Factory/Elements/Youtube.php
  8. 4 2
      src/Muzich/CoreBundle/Resources/config/routing.yml
  9. 1 1
      src/Muzich/CoreBundle/Resources/views/Info/development.html.twig
  10. 8 3
      src/Muzich/CoreBundle/Resources/views/Menu/containerMenu.html.twig
  11. 21 10
      src/Muzich/CoreBundle/Resources/views/SearchElement/element.html.twig
  12. 12 1
      src/Muzich/CoreBundle/Resources/views/Tag/tagsList.favorite.html.twig
  13. 11 1
      src/Muzich/CoreBundle/Resources/views/Tag/tagsList.show.html.twig
  14. 15 5
      src/Muzich/CoreBundle/Searcher/ElementSearcher.php
  15. 11 0
      src/Muzich/CoreBundle/Searcher/ElementSearcherQueryBuilder.php
  16. 7 8
      src/Muzich/CoreBundle/Searcher/Searcher.php
  17. 822 712
      src/Muzich/CoreBundle/Tests/Controller/HomeControllerTest.php
  18. 215 0
      src/Muzich/CoreBundle/Tests/ElementFactory/ElementFactoryTest.php
  19. 83 0
      src/Muzich/CoreBundle/Tests/User/UserTest.php
  20. 16 2
      src/Muzich/CoreBundle/lib/FunctionalTest.php
  21. 31 3
      src/Muzich/CoreBundle/lib/UnitTest.php
  22. 18 6
      src/Muzich/HomeBundle/Controller/HomeController.php
  23. 3 1
      src/Muzich/HomeBundle/Controller/ShowController.php
  24. 27 0
      src/Muzich/HomeBundle/Resources/views/Home/need_tags.html.twig
  25. 22 0
      src/Muzich/HomeBundle/Resources/views/Show/showUser.html.twig
  26. 11 1
      web/bundles/muzichcore/css/main.css
  27. 29 0
      web/bundles/muzichcore/js/muzich.js

+ 2 - 0
app/Resources/translations/elements.fr.yml Wyświetl plik

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

+ 2 - 0
app/Resources/translations/navigationui.fr.yml Wyświetl plik

@@ -5,6 +5,7 @@ container_menu:
5 5
   my_favorites:         Mes favoris
6 6
   my_feeds:             Mes diffusions
7 7
   return:               Retour
8
+  need_tags:            Demandes
8 9
   
9 10
 top_bar:
10 11
   my_account:           Mon compte (%name%)
@@ -40,6 +41,7 @@ title:
40 41
   hello:                Découvrez et partagez la musique !
41 42
   element:
42 43
     edit:               Modification d'un élément
44
+  need_tags:            Partages en demande de tags
43 45
   
44 46
   
45 47
 bottom_menu:

+ 11 - 1
app/Resources/translations/userui.fr.yml Wyświetl plik

@@ -64,6 +64,10 @@ tags:
64 64
     has_news_link:  cliquez ici pour les afficher
65 65
     has_news_link_one:  cliquez ici pour l'afficher
66 66
     has_news_link_more_x:  cliquez ici pour en afficher %x%
67
+  cloud:
68
+    display_more:           Des tags ont été cachés, cliquez ici pour les afficher tous
69
+    filter:
70
+      text:                 Chercher un tag parmis la liste
67 71
            
68 72
 filter:
69 73
   network: "Résultats de "
@@ -154,4 +158,10 @@ search_tag:
154 158
   title:                 Recherche de tag correspondant à \"%string_search%\" ...
155 159
   
156 160
 global_search:
157
-  no_results:            Il n'y a aucun résultat a votre recherche.
161
+  no_results:            Il n'y a aucun résultat a votre recherche.
162
+  
163
+need_tags:
164
+  text_help:             |
165
+                         Les utilisateurs ayant partagés leurs découvertes ont
166
+                         demandé de l'aide pour tagger correctement leurs partages.
167
+                         Gagnez en réputation en leurs proposants les tags qui conviennent !

+ 1 - 0
src/Muzich/CoreBundle/Controller/ElementController.php Wyświetl plik

@@ -743,6 +743,7 @@ class ElementController extends Controller
743 743
       $element->addTag($tag);
744 744
     }
745 745
     $element->setHasTagProposition(false);
746
+    $element->setNeedTags(false);
746 747
     $this->getDoctrine()->getEntityManager()->persist($element);
747 748
     
748 749
     $event = new EventElement($this->container);

+ 76 - 0
src/Muzich/CoreBundle/Entity/User.php Wyświetl plik

@@ -11,6 +11,7 @@ use Muzich\CoreBundle\Entity\UsersTagsFavorites;
11 11
 use Symfony\Component\Validator\Constraints as Assert;
12 12
 use Muzich\CoreBundle\Validator as MuzichAssert;
13 13
 use Muzich\CoreBundle\Entity\ElementTagsProposition;
14
+use Muzich\CoreBundle\Entity\Tag;
14 15
 
15 16
 /**
16 17
  * Cet entité est l'utilisateur ayant effectué la requête.
@@ -173,6 +174,16 @@ class User extends BaseUser
173 174
   protected $live_datas = array();
174 175
   
175 176
   /**
177
+   * Tableau contenant les id => name des tags favoris
178
+   * de l'user. Ces donnée sont faites pour optimiser les calculs.
179
+   * Ce chamsp est mis ajour a chaque fois qu'un UsersTagsFavorite est manipulé.
180
+   * 
181
+   * @ORM\Column(type="text", unique=false, nullable=true)
182
+   * @var array 
183
+   */
184
+  private $tags_favorites_quick;
185
+  
186
+  /**
176 187
    * 
177 188
    */
178 189
   public function __construct()
@@ -757,4 +768,69 @@ class User extends BaseUser
757 768
     return false;
758 769
   }
759 770
   
771
+  public function getTagsFavoritesQuick()
772
+  {
773
+    if ($this->tags_favorites_quick == null)
774
+    {
775
+      return array();
776
+    }
777
+    
778
+    return json_decode($this->tags_favorites_quick, true);
779
+  }
780
+  
781
+  /**
782
+   * 
783
+   * @param array $tags_favorites_quick (id => name)
784
+   */
785
+  public function setTagsFavoritesQuick($tags_favorites_quick)
786
+  {
787
+    $this->tags_favorites_quick = json_encode($tags_favorites_quick);
788
+  }
789
+  
790
+  /**
791
+   * 
792
+   * @param \Muzich\CoreBundle\Entity\Tag $tag
793
+   */
794
+  public function addTagFavoriteQuick(Tag $tag)
795
+  {
796
+    $tags_favorites_quick = $this->getTagsFavoritesQuick();
797
+    if (!array_key_exists($tag->getId(), $tags_favorites_quick))
798
+    {
799
+      $tags_favorites_quick[$tag->getId()] = $tag->getName();
800
+    }
801
+    $this->setTagsFavoritesQuick($tags_favorites_quick);
802
+  }
803
+  
804
+  /**
805
+   * 
806
+   * @param \Muzich\CoreBundle\Entity\Tag $tag
807
+   */
808
+  public function removeTagFavoriteQuick(Tag $tag)
809
+  {
810
+    $tags_favorites_quick = $this->getTagsFavoritesQuick();
811
+    if (array_key_exists($tag->getId(), $tags_favorites_quick))
812
+    {
813
+      unset($tags_favorites_quick[$tag->getId()]);
814
+    }
815
+    $this->setTagsFavoritesQuick($tags_favorites_quick);
816
+  }
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
+  
760 836
 }

+ 19 - 1
src/Muzich/CoreBundle/Entity/UsersTagsFavorites.php Wyświetl plik

@@ -10,6 +10,7 @@ use Doctrine\ORM\Mapping as ORM;
10 10
  * 
11 11
  * @ORM\Entity
12 12
  * @ORM\Table(name="users_tags_favorites")
13
+ * @ORM\HasLifecycleCallbacks
13 14
  */
14 15
 class UsersTagsFavorites
15 16
 {
@@ -42,7 +43,7 @@ class UsersTagsFavorites
42 43
    * L'attribut position permet de connaitre l'ordre de préfèrence de 
43 44
    * l'utilisateur.
44 45
    * 
45
-   * @ORM\Column(type="integer")
46
+   * @ORM\Column(type="integer", nullable=true)
46 47
    * @var type int
47 48
    */
48 49
   protected $position;
@@ -118,4 +119,21 @@ class UsersTagsFavorites
118 119
   {
119 120
     return $this->tag;
120 121
   }
122
+  
123
+  /**
124
+   * @ORM\prePersist
125
+   */
126
+  public function prePersist()
127
+  {
128
+    $this->getUser()->addTagFavoriteQuick($this->getTag());
129
+  }
130
+  
131
+  /**
132
+   * @ORM\preRemove
133
+   */
134
+  public function preRemove()
135
+  {
136
+    $this->getUser()->removeTagFavoriteQuick($this->getTag());
137
+  }
138
+  
121 139
 }

+ 1 - 1
src/Muzich/CoreBundle/Factory/Elements/Youtube.php Wyświetl plik

@@ -28,7 +28,7 @@ class Youtube extends Youtubecom
28 28
     // Données API
29 29
     if ($ref_id)
30 30
     {
31
-      
31
+      $this->proceedAPIDatas($ref_id);
32 32
     }
33 33
   }
34 34
   

+ 4 - 2
src/Muzich/CoreBundle/Resources/config/routing.yml Wyświetl plik

@@ -154,11 +154,13 @@ global_search:
154 154
 teapot:
155 155
   pattern: /what/are/you
156 156
   defaults: { _controller: MuzichCoreBundle:Info:teapot }
157
-  
158 157
 #
159 158
 
160 159
 element_retrieve_api_datas:
161 160
   pattern: /ajax/element/get/datas/api
162 161
   defaults: { _controller: MuzichCoreBundle:Element:getDatasApi }
163 162
   requirements:
164
-    method:  POST
163
+    
164
+element_show_need_tags:
165
+  pattern: /need-tags
166
+  defaults: { _controller: MuzichHomeBundle:Home:needTags }

+ 1 - 1
src/Muzich/CoreBundle/Resources/views/Info/development.html.twig Wyświetl plik

@@ -9,7 +9,7 @@
9 9
   <h1>Muzich est en cours de construction</h1>
10 10
 
11 11
   <p>
12
-    Actuellement vous utilisez la version <strong>0.7</strong> de Muzich. De nombreuses 
12
+    Actuellement vous utilisez la version <strong>0.8</strong> de Muzich. De nombreuses 
13 13
     fonctionnalités doivent voir le jours au fur et a mesure du développement.
14 14
   </p>
15 15
 

+ 8 - 3
src/Muzich/CoreBundle/Resources/views/Menu/containerMenu.html.twig Wyświetl plik

@@ -12,14 +12,19 @@
12 12
         {{ 'container_menu.my_network'|trans({}, 'navigationui') }}
13 13
       </a>
14 14
     </li>
15
-    <li {% if active == 'myfeeds' %} class="active" {% endif %}>
16
-      <a href="{{ path('show_user', {'slug': app.user.slug}) }}">
17
-        {{ 'container_menu.my_feeds'|trans({}, 'navigationui') }}
15
+    <li {% if active == 'needs-tags' %} class="active" {% endif %}>
16
+      <a href="{{ path('element_show_need_tags') }}">
17
+        {{ 'container_menu.need_tags'|trans({}, 'navigationui') }}
18 18
       </a>
19 19
     </li>
20 20
   </ul>
21 21
 
22 22
   <ul class="top-tabs-right">
23
+    <li {% if active == 'myfeeds' %} class="active" {% endif %}>
24
+      <a href="{{ path('show_user', {'slug': app.user.slug}) }}">
25
+        {{ 'container_menu.my_feeds'|trans({}, 'navigationui') }}
26
+      </a>
27
+    </li>
23 28
     <li class="{% if active == 'mygroups' %}active{% endif %}">
24 29
       <a href="{{ path('groups_own_list') }}" >
25 30
         {{ 'network.mygroups'|trans({}, 'navigationui') }}

+ 21 - 10
src/Muzich/CoreBundle/Resources/views/SearchElement/element.html.twig Wyświetl plik

@@ -130,18 +130,29 @@
130 130
       <ul class="element_tags">
131 131
         {% for tag in element.tags %} 
132 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 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 156
           </li>
146 157
         {% endfor %} 
147 158
       </ul>

+ 12 - 1
src/Muzich/CoreBundle/Resources/views/Tag/tagsList.favorite.html.twig Wyświetl plik

@@ -1,11 +1,15 @@
1 1
 {% if tags|length %}
2
+
3
+  <label for="cloud_tags_filter" >{{ 'tags.cloud.filter.text'|trans({}, 'userui') }}</label>
4
+  <input type="text" id="cloud_tags_filter" />
5
+
2 6
   <input type="hidden" id="get_elements_url" value="{{ path('favorite_get', {
3 7
     'user_id': user_id, 
4 8
     'tags_ids_json' : ''
5 9
   }) }}" />
6 10
   <ul id="favorite_tags">
7 11
     {% for tag in tags %}
8
-      <li>
12
+      <li {% if loop.index0 > cloud_tags_limit_to_display %}style="display: none;"{% endif %}>
9 13
         <a id="filtering_tag_{{ tag.id }}" href="#" class="button tag">
10 14
           {{ tag.name }}
11 15
         </a>
@@ -13,4 +17,11 @@
13 17
     {% endfor %}
14 18
   </ul>
15 19
   <div class="clearboth" ></div>
20
+  
21
+  {% if tags|length > cloud_tags_limit_to_display+1 %}
22
+    <a href="#" id="display_all_cloud_tag" >
23
+      {{ 'tags.cloud.display_more'|trans({}, 'userui') }}
24
+    </a>
25
+  {% endif %}
26
+  
16 27
 {% endif %}

+ 11 - 1
src/Muzich/CoreBundle/Resources/views/Tag/tagsList.show.html.twig Wyświetl plik

@@ -1,4 +1,8 @@
1 1
 {% if tags|length %}
2
+
3
+  <label for="cloud_tags_filter" >{{ 'tags.cloud.filter.text'|trans({}, 'userui') }}</label>
4
+  <input type="text" id="cloud_tags_filter" />
5
+
2 6
   <input type="hidden" id="get_elements_url" value="{{ path('show_elements_get', {
3 7
     'type'          : object_type,
4 8
     'object_id'     : object_id, 
@@ -6,7 +10,7 @@
6 10
   }) }}" />
7 11
   <ul id="favorite_tags">
8 12
     {% for tag in tags %}
9
-      <li>
13
+      <li {% if loop.index0 > cloud_tags_limit_to_display %}style="display: none;"{% endif %}>
10 14
         <a id="filtering_tag_{{ tag.id }}" href="#" class="button tag">
11 15
           {{ tag.name }}
12 16
         </a>
@@ -14,4 +18,10 @@
14 18
     {% endfor %}
15 19
   </ul>
16 20
   <div class="clearboth" ></div>
21
+  
22
+  {% if tags|length > cloud_tags_limit_to_display+1 %}
23
+    <a href="#" id="display_all_cloud_tag" >
24
+      {{ 'tags.cloud.display_more'|trans({}, 'userui') }}
25
+    </a>
26
+  {% endif %}
17 27
 {% endif %}

+ 15 - 5
src/Muzich/CoreBundle/Searcher/ElementSearcher.php Wyświetl plik

@@ -107,11 +107,12 @@ class ElementSearcher extends Searcher implements SearcherInterface
107 107
    */
108 108
   protected $string = null;
109 109
   
110
-  private $attributes = array(
111
-    'network', 'tags', 'count', 'user_id', 'group_id', 
112
-    'favorite', 'id_limit', 'searchnew', 'ids', 'ids_display',
113
-    'tag_strict', 'string'
114
-  );
110
+  /**
111
+   * Pour la recherche de partage qui demande des tags.
112
+   * 
113
+   * @var boolean 
114
+   */
115
+  protected $need_tags = false;
115 116
   
116 117
   /**
117 118
    * @see SearcherInterface
@@ -339,4 +340,13 @@ class ElementSearcher extends Searcher implements SearcherInterface
339 340
     return $this->searchnew;
340 341
   }
341 342
   
343
+  public function isNeedTags()
344
+  {
345
+    if ($this->need_tags)
346
+    {
347
+      return true;
348
+    }
349
+    return false;
350
+  }
351
+  
342 352
 }

+ 11 - 0
src/Muzich/CoreBundle/Searcher/ElementSearcherQueryBuilder.php Wyświetl plik

@@ -264,6 +264,15 @@ class ElementSearcherQueryBuilder
264 264
       }
265 265
     }
266 266
   }
267
+  
268
+  private function buildNeedTags()
269
+  {
270
+    // Si id_limit est précisé c'est que l'on demande "la suite" ou "les nouveaux"
271
+    if ($this->es->isNeedTags())
272
+    {
273
+      $this->query_ids->andWhere("e.need_tags  = '1'");
274
+    }
275
+  }
267 276
 
268 277
   /**
269 278
    *
@@ -299,6 +308,8 @@ class ElementSearcherQueryBuilder
299 308
     $this->buildLimits();
300 309
     // Si on recherche les tags de manière stricte
301 310
     $this->buildStrict();
311
+    // Si on recherche des partages en demande de tags
312
+    $this->buildNeedTags();
302 313
     
303 314
     $this->query_ids->setParameters($this->parameters_ids);
304 315
   }

+ 7 - 8
src/Muzich/CoreBundle/Searcher/Searcher.php Wyświetl plik

@@ -23,15 +23,14 @@ abstract class Searcher
23 23
     foreach ($params as $param_id => $param_value)
24 24
     {
25 25
       // TODO: check existance attribut
26
-//      if (isset($this->$param_id))
27
-//      {
26
+      if (property_exists($this, $param_id))
27
+      {
28 28
         $this->$param_id = $param_value;
29
-//      }
30
-//      else
31
-//      {
32
-//        die(var_dump($this->$param_id));
33
-//        throw new \Exception("You're trying access unknow attribute '$param_id'");
34
-//      }
29
+      }
30
+      else
31
+      {
32
+        throw new \Exception("You're trying access unknow attribute '$param_id'");
33
+      }
35 34
     }
36 35
   }
37 36
 

Plik diff jest za duży
+ 822 - 712
src/Muzich/CoreBundle/Tests/Controller/HomeControllerTest.php


+ 215 - 0
src/Muzich/CoreBundle/Tests/ElementFactory/ElementFactoryTest.php Wyświetl plik

@@ -285,4 +285,219 @@ class ElementFactoryTest extends UnitTest
285 285
     
286 286
   }
287 287
   
288
+  public function testDataApiengine()
289
+  {
290
+    $r = $this->getDoctrine();
291
+    $bux = $r->getRepository('MuzichCoreBundle:User')
292
+      ->findOneByUsername('bux')
293
+    ;
294
+    
295
+    /*
296
+     *   - youtube.com && youtu.be
297
+     */
298
+    
299
+    $this->assertEquals(array(
300
+      'data_ref_id' => 'Itfg7UpkcSs',
301
+      'data_title'  => 'DIDIER SUPER SUR FRANCE O : UN PETIT MALENTENDU ?'
302
+    ),$this->proceed_element_datas_api(
303
+      $bux, 
304
+      'http://www.youtube.com/watch?v=Itfg7UpkcSs&feature=g-vrec&context=G2e61726RVAAAAAAAAAg'
305
+    ));
306
+    
307
+    $this->assertEquals(array(
308
+      'data_ref_id' => 'Itfg7UpkcSs',
309
+      'data_title'  => 'DIDIER SUPER SUR FRANCE O : UN PETIT MALENTENDU ?'
310
+    ),$this->proceed_element_datas_api(
311
+      $bux, 
312
+      'http://www.youtube.com/watch?feature=player_detailpage&v=Itfg7UpkcSs#t=3s'
313
+    ));
314
+    
315
+    $this->assertEquals(array(
316
+      'data_ref_id' => 'Itfg7UpkcSs',
317
+      'data_title'  => 'DIDIER SUPER SUR FRANCE O : UN PETIT MALENTENDU ?'
318
+    ),$this->proceed_element_datas_api(
319
+      $bux, 
320
+      'http://youtu.be/Itfg7UpkcSs'
321
+    ));
322
+    
323
+    $this->assertEquals(array(
324
+      'data_ref_id' => 'Itfg7UpkcSs',
325
+      'data_title'  => 'DIDIER SUPER SUR FRANCE O : UN PETIT MALENTENDU ?'
326
+    ),$this->proceed_element_datas_api(
327
+      $bux, 
328
+      'http://www.youtube.com/watch?v=Itfg7UpkcSs'
329
+    ));
330
+    
331
+    
332
+    /*
333
+     *   - dailymotion.com
334
+     */
335
+    
336
+      // 'http://www.dailymotion.com/video/xafj1q_black-bomb-a-tales-from-the-old-sch_music', 
337
+    
338
+      // TODO: l'url est pas toujours la même pour le thumb :/
339
+//    $this->assertEquals(array(
340
+//      'data_ref_id' => 'xafj1q',
341
+//      'data_thumb_url'  => 'http://static2.dmcdn.net/static/video/686/025/17520686:jpeg_preview_medium.jpg?20110820212502'
342
+//    ),$this->proceed_element_datas_api(
343
+//      $bux, 
344
+//      'http://www.dailymotion.com/video/xafj1q_black-bomb-a-tales-from-the-old-sch_music'
345
+//    ));
346
+    
347
+    /*
348
+     * - soundcloud.com
349
+     */
350
+    
351
+    // 'http://soundcloud.com/matas/sets/library-project'
352
+    
353
+    $this->assertEquals(array(
354
+      'data_ref_id' => 3770,
355
+      'data_title' => 'Library Project',
356
+      'data_thumb_url' => 'http://i1.sndcdn.com/artworks-000000514203-fsvbcj-large.jpg?04ad178',
357
+      'data_type' => 'playlist',
358
+      'data_download' => null,
359
+      'data_download_url' => 'http://soundcloud.com/matas/sets/library-project/download',
360
+      'data_artist' => 'matas',
361
+    ),$this->proceed_element_datas_api(
362
+      $bux, 
363
+      'http://soundcloud.com/matas/sets/library-project'
364
+    ));
365
+    
366
+    // 'http://soundcloud.com/matas/above-hyperion-redux'
367
+    
368
+    $this->assertEquals(array(
369
+      'data_ref_id' => 3154252,
370
+      'data_title' => 'Above Hyperion (redux)',
371
+      'data_thumb_url' => 'http://i1.sndcdn.com/artworks-000001536693-gb1n5v-large.jpg?04ad178',
372
+      'data_type' => 'track',
373
+      'data_download' => false,
374
+      'data_download_url' => 'http://soundcloud.com/matas/above-hyperion-redux/download',
375
+      'data_artist' => 'matas',
376
+      'data_tags' => array(
377
+        0 => 'Spacestep'
378
+      )
379
+    ),$this->proceed_element_datas_api(
380
+      $bux, 
381
+      'http://soundcloud.com/matas/above-hyperion-redux'
382
+    ));
383
+    
384
+    // 'http://soundcloud.com/tracks/search?q%5Bfulltext%5D=EEK+A+MOUSSE&q%5Btype%5D=&q%5Bduration%5D='
385
+    
386
+    $this->assertEquals(array(
387
+      
388
+    ),$this->proceed_element_datas_api(
389
+      $bux, 
390
+      'http://soundcloud.com/tracks/search?q%5Bfulltext%5D=EEK+A+MOUSSE&q%5Btype%5D=&q%5Bduration%5D='
391
+    ));
392
+    
393
+    //'http://soundcloud.com/people/search?q%5Bfulltext%5D=EEK+A+MOUSSE&q%5Btype%5D=&q%5Bduration%5D='
394
+    
395
+    $this->assertEquals(array(
396
+      
397
+    ),$this->proceed_element_datas_api(
398
+      $bux, 
399
+      'http://soundcloud.com/people/search?q%5Bfulltext%5D=EEK+A+MOUSSE&q%5Btype%5D=&q%5Bduration%5D='
400
+    ));
401
+    
402
+    // 'http://soundcloud.com/groups/search?q%5Bfulltext%5D=EEK+A+MOUSSE&q%5Btype%5D=&q%5Bduration%5D='
403
+    
404
+    $this->assertEquals(array(
405
+      
406
+    ),$this->proceed_element_datas_api(
407
+      $bux, 
408
+      'http://soundcloud.com/groups/search?q%5Bfulltext%5D=EEK+A+MOUSSE&q%5Btype%5D=&q%5Bduration%5D='
409
+    ));
410
+     
411
+    /*
412
+     *   - jamendo.com
413
+     */
414
+    
415
+    // 'http://www.jamendo.com/fr/album/30661'
416
+    
417
+    $this->assertEquals(array(
418
+      'data_ref_id' => '30661',
419
+      'data_title' => 'ZwaNe 01',
420
+      'data_type' => 'album',
421
+      'data_thumb_url' => 'http://imgjam.com/albums/s30/30661/covers/1.100.jpg',
422
+      'data_artist' => 'Ptit lutin',
423
+      'data_tags' => array(
424
+        0 => 'Basse',
425
+        1 => 'Batterie',
426
+        2 => 'Hardtek',
427
+        3 => 'Tek',
428
+        4 => 'Hardtechno',
429
+      ),
430
+      'data_download' => true,
431
+    ),$this->proceed_element_datas_api(
432
+      $bux, 
433
+      'http://www.jamendo.com/fr/album/30661'
434
+    ));
435
+    
436
+    // 'http://www.jamendo.com/fr/track/207079'
437
+    
438
+    $this->assertEquals(array(
439
+      'data_ref_id' => '207079',
440
+      'data_title' => 'Insanity',
441
+      'data_type' => 'track',
442
+      'data_thumb_url' => 'http://imgjam.com/albums/s30/30661/covers/1.100.jpg',
443
+      'data_artist' => 'Ptit lutin',
444
+      'data_tags' => array(
445
+        0 => 'Techno',
446
+        1 => 'Hardtek'
447
+      ),
448
+      'data_download' => true,
449
+    ),$this->proceed_element_datas_api(
450
+      $bux, 
451
+      'http://www.jamendo.com/fr/track/207079'
452
+    ));
453
+    
454
+    // 'http://www.jamendo.com/fr/search/all/psytrance'
455
+    
456
+    $this->assertEquals(array(
457
+      'data_ref_id' => null,
458
+      'data_type' => null,
459
+      'data_download' => true,
460
+    ),$this->proceed_element_datas_api(
461
+      $bux, 
462
+      'http://www.jamendo.com/fr/search/all/psytrance'
463
+    ));
464
+    
465
+    // 'http://www.jamendo.com/fr/artist/DJ_BETO'
466
+    
467
+    $this->assertEquals(array(
468
+      'data_ref_id' => null,
469
+      'data_type' => null,
470
+      'data_download' => true,
471
+    ),$this->proceed_element_datas_api(
472
+      $bux, 
473
+      'http://www.jamendo.com/fr/artist/DJ_BETO'
474
+    ));
475
+    
476
+    /*/*
477
+     *   - deezer.com
478
+     */
479
+    
480
+    // 'http://www.deezer.com/fr/music/pantera/far-beyond-driven-80398'
481
+    
482
+    $this->assertEquals(array(
483
+      'data_ref_id' => '80398',
484
+      'data_type' => 'album',
485
+      'data_thumb_url' => 'http://api.deezer.com/2.0/album/80398/image'
486
+    ),$this->proceed_element_datas_api(
487
+      $bux, 
488
+      'http://www.deezer.com/fr/music/pantera/far-beyond-driven-80398'
489
+    ));
490
+    
491
+    // 'http://www.deezer.com/fr/music/playlist/18701350'
492
+    
493
+    $this->assertEquals(array(
494
+      'data_ref_id' => '18701350',
495
+      'data_type' => 'playlist',
496
+    ),$this->proceed_element_datas_api(
497
+      $bux, 
498
+      'http://www.deezer.com/fr/music/playlist/18701350'
499
+    ));
500
+    
501
+  }
502
+  
288 503
 }

+ 83 - 0
src/Muzich/CoreBundle/Tests/User/UserTest.php Wyświetl plik

@@ -0,0 +1,83 @@
1
+<?php
2
+
3
+namespace Muzich\CoreBundle\Tests\User;
4
+
5
+use Muzich\CoreBundle\lib\UnitTest;
6
+use Muzich\CoreBundle\Entity\UsersTagsFavorites;
7
+
8
+class UserTest extends UnitTest
9
+{  
10
+  
11
+  public function testTagsFavoritesQuick()
12
+  {
13
+    // On vérifie en premier lieu que les donnée en base corresponde bien a 
14
+    // ce que l'on veut avoir en fonction des fixtures (c'est une donnée calculé
15
+    // lors de la manipulation de UsersTagsFavorite
16
+    
17
+    $tribe   = $this->getTag('Tribe');
18
+    $hardtek   = $this->getTag('Hardtek');
19
+    $electro = $this->getTag('Electro');
20
+    $metal   = $this->getTag('Metal');
21
+    $metalco = $this->getTag('Metalcore');
22
+    $minimal = $this->getTag('Minimal');
23
+    $jungle  = $this->getTag('Jungle');
24
+    $melanco = $this->getTag('Melancolique');
25
+    $mellow  = $this->getTag('Mellow');
26
+    $melodiq = $this->getTag('Melodique');
27
+    
28
+    $bux = $this->getUser('bux');
29
+    $this->assertEquals(array(
30
+      $tribe->getId() => 'Tribe',
31
+      $electro->getId() => 'Electro',
32
+      $metal->getId() => 'Metal',
33
+      $minimal->getId() => 'Minimal',
34
+      $jungle->getId() => 'Jungle',
35
+      $hardtek->getId()  => 'Hardtek'
36
+    ), $bux->getTagsFavoritesQuick());
37
+    
38
+    $jean = $this->getUser('jean');
39
+    $this->assertEquals(array(
40
+      $melanco->getId() => 'Melancolique',
41
+      $mellow->getId() => 'Mellow',
42
+      $melodiq->getId() => 'Melodique',
43
+      $metal->getId() => 'Metal',
44
+      $metalco->getId() => 'Metalcore',
45
+      $minimal->getId() => 'Minimal'
46
+    ), $jean->getTagsFavoritesQuick());
47
+    
48
+    /*
49
+     * Si on effectue des modifs dans les tags favoris
50
+     */
51
+    
52
+    $bux_melodique = new UsersTagsFavorites();
53
+    $bux_melodique->setUser($bux);
54
+    $bux_melodique->setTag($melodiq);
55
+    $this->persist($bux_melodique);
56
+    $this->flush();
57
+    
58
+    $bux = $this->getUser('bux');
59
+    $this->assertEquals(array(
60
+      $tribe->getId() => 'Tribe',
61
+      $electro->getId() => 'Electro',
62
+      $metal->getId() => 'Metal',
63
+      $minimal->getId() => 'Minimal',
64
+      $jungle->getId() => 'Jungle',
65
+      $hardtek->getId()  => 'Hardtek',
66
+      $melodiq->getId()  => 'Melodique'
67
+    ), $bux->getTagsFavoritesQuick());
68
+    
69
+    $this->getDoctrine()->getEntityManager()->remove($bux_melodique);
70
+    $this->flush();
71
+    
72
+    $bux = $this->getUser('bux');
73
+    $this->assertEquals(array(
74
+      $tribe->getId() => 'Tribe',
75
+      $electro->getId() => 'Electro',
76
+      $metal->getId() => 'Metal',
77
+      $minimal->getId() => 'Minimal',
78
+      $jungle->getId() => 'Jungle',
79
+      $hardtek->getId()  => 'Hardtek'
80
+    ), $bux->getTagsFavoritesQuick());
81
+  }
82
+  
83
+}

+ 16 - 2
src/Muzich/CoreBundle/lib/FunctionalTest.php Wyświetl plik

@@ -213,8 +213,9 @@ class FunctionalTest extends WebTestCase
213 213
    * @param string $url
214 214
    * @param array $tags
215 215
    * @param string $group_slug 
216
+   * @param boolean $need_tags 
216 217
    */
217
-  protected function procedure_add_element($name, $url, $tags, $group_slug = null)
218
+  protected function procedure_add_element($name, $url, $tags, $group_slug = null, $need_tags = false)
218 219
   {
219 220
     if (!$group_slug)
220 221
     {
@@ -231,7 +232,16 @@ class FunctionalTest extends WebTestCase
231 232
     $form = $this->selectForm('form[action="'.$form_url.'"] input[type="submit"]');
232 233
     $form['element_add[name]'] = $name;
233 234
     $form['element_add[url]'] = $url;
234
-    $form['element_add[tags]'] = json_encode($tags);
235
+    
236
+    if (count($tags))
237
+    {
238
+      $form['element_add[tags]'] = json_encode($tags);
239
+    }
240
+    
241
+    if ($need_tags)
242
+    {
243
+      $form['element_add[need_tags]'] = true;
244
+    }
235 245
     
236 246
     $this->submit($form);
237 247
   }
@@ -519,5 +529,9 @@ class FunctionalTest extends WebTestCase
519 529
       ->findOneBy($params);
520 530
   }
521 531
   
532
+  protected function goToPage($url)
533
+  {
534
+    $this->crawler = $this->client->request('GET', $url);
535
+  }
522 536
   
523 537
 }

+ 31 - 3
src/Muzich/CoreBundle/lib/UnitTest.php Wyświetl plik

@@ -39,9 +39,6 @@ class UnitTest extends \PHPUnit_Framework_TestCase
39 39
   
40 40
   protected function proceed_elementAndFill($user, $name, $url, $tag_ids, $final_embed)
41 41
   {
42
-    $youtube_width = '590';
43
-    $youtube_height = '300';
44
-        
45 42
     $element = new Element();
46 43
     $element->setName($name);
47 44
     $element->setTags(json_encode($tag_ids));
@@ -68,11 +65,42 @@ class UnitTest extends \PHPUnit_Framework_TestCase
68 65
     $this->assertEquals($element->getEmbed(), $final_embed);
69 66
   }
70 67
   
68
+  protected function proceed_element_datas_api($user, $url)
69
+  {
70
+    $element = new Element();
71
+    $element->setUrl($url);
72
+    
73
+    $factory = new ElementManager($element, 
74
+      $this->getDoctrine()->getEntityManager(), $this->_container);
75
+    $factory->proceedFill($user);
76
+    
77
+    return $element->getDatas();
78
+  }
79
+
80
+
71 81
   protected function getUser($username)
72 82
   {
73 83
     return $this->getDoctrine()->getRepository('MuzichCoreBundle:User')
74 84
       ->findOneByUsername($username)
75 85
     ;
76 86
   }
87
+
88
+
89
+  protected function getTag($name)
90
+  {
91
+    return $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')
92
+      ->findOneByName($name)
93
+    ;
94
+  }
95
+  
96
+  protected function persist($entity)
97
+  {
98
+    $this->getDoctrine()->getEntityManager()->persist($entity);
99
+  }
100
+  
101
+  protected function flush()
102
+  {
103
+    $this->getDoctrine()->getEntityManager()->flush();
104
+  }
77 105
   
78 106
 }

+ 18 - 6
src/Muzich/HomeBundle/Controller/HomeController.php Wyświetl plik

@@ -4,10 +4,7 @@ namespace Muzich\HomeBundle\Controller;
4 4
 
5 5
 use Muzich\CoreBundle\lib\Controller;
6 6
 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
7
-
8
-use Doctrine\ORM\Query;
9
-use Muzich\CoreBundle\Form\Search\ElementSearchForm;
10
-use Muzich\CoreBundle\Form\Element\ElementAddForm;
7
+use Muzich\CoreBundle\Searcher\ElementSearcher;
11 8
 
12 9
 class HomeController extends Controller
13 10
 {
@@ -29,12 +26,12 @@ class HomeController extends Controller
29 26
     $add_form = $this->getAddForm();
30 27
     
31 28
     $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId());
32
-    $count_elements = count($elements);
29
+    //$count_elements = count($elements);
33 30
     
34 31
     return array(
35 32
       'search_tags_id'   => $search_object->getTags(),
36 33
       'ids_display'      => $search_object->getIdsDisplay(),
37
-      'user'             => $this->getUser(),
34
+      'user'             => $user,
38 35
       'add_form'         => $add_form->createView(),
39 36
       'add_form_name'    => 'add',
40 37
       'search_form'      => $search_form->createView(),
@@ -44,4 +41,19 @@ class HomeController extends Controller
44 41
       //'display_more_button' => ($count_elements >= $this->container->getParameter('search_default_count'))?true:false
45 42
     );
46 43
   }
44
+  
45
+  public function needTagsAction()
46
+  {
47
+    $es = new ElementSearcher();
48
+    $es->init(array(
49
+      'count'     => $this->container->getParameter('search_default_count'),
50
+      'need_tags' => true
51
+    ));
52
+    
53
+    return $this->render('MuzichHomeBundle:Home:need_tags.html.twig', array(
54
+      'elements' => $es->getElements($this->getDoctrine(), $this->getUserId()),
55
+      'topmenu_active' => 'needs-tags'
56
+    ));
57
+  }
58
+  
47 59
 }

+ 3 - 1
src/Muzich/HomeBundle/Controller/ShowController.php Wyświetl plik

@@ -65,7 +65,9 @@ class ShowController extends Controller
65 65
       'count_owned'     => count($element_ids_owned),
66 66
       'count_favorited' => $count_favorited,
67 67
       'count_favorited_users' => $count_favorited_users,
68
-      'count_followers' => $count_followers
68
+      'count_followers' => $count_followers,
69
+      'add_form'        => ($this->getUserId() == $viewed_user->getId())?$this->getAddForm()->createView():null,
70
+      'add_form_name'   => 'add'
69 71
     );
70 72
   }
71 73
   

+ 27 - 0
src/Muzich/HomeBundle/Resources/views/Home/need_tags.html.twig Wyświetl plik

@@ -0,0 +1,27 @@
1
+{% extends "MuzichHomeBundle::layout.html.twig" %}
2
+
3
+{% block title %}{{ 'title.need_tags'|trans({}, 'navigationui') }}{% endblock %}
4
+
5
+{% block content %}
6
+
7
+  <h1>{{ 'title.need_tags'|trans({}, 'navigationui') }}</h1>
8
+
9
+  <p>{{ 'need_tags.text_help'|trans({}, 'userui') }}</p>
10
+  
11
+  <div class="display_more_elements" style="display: none;">
12
+    <span></span>
13
+  </div>
14
+
15
+  <div class="elements_loader_div">
16
+    <img class="elements_new_loader" style="display: none;" src="{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}" alt="loading" />
17
+  </div>
18
+
19
+  {% include "MuzichCoreBundle:SearchElement:default.html.twig" %}
20
+    
21
+  {% include "MuzichCoreBundle:SearchElement:more_button.html.twig" with {
22
+    'display_more_button' : true,
23
+    'elements_length'     : elements|length,
24
+    'more_path'           : 'search_elements'
25
+  }%}
26
+  
27
+{% endblock %}

+ 22 - 0
src/Muzich/HomeBundle/Resources/views/Show/showUser.html.twig Wyświetl plik

@@ -25,6 +25,28 @@
25 25
   
26 26
 
27 27
   <h2>{{ 'user.show.title'|trans({'%name%' : viewed_user.name}, 'users') }}</h2>
28
+
29
+  {% if app.user.id == viewed_user.id %}
30
+    <div id="element_add_box" style="display: none;">    
31
+    
32
+      <a href="#" id="element_add_close_link" class="button">
33
+        &lt;&lt; {{ 'home.add_element_box.close'|trans({}, 'navigationui') }}
34
+      </a>
35
+
36
+      <form novalidate name="{{ add_form_name }}" action="{{ path('element_add') }}" method="post" {{ form_enctype(add_form) }}>
37
+
38
+        {% include "MuzichCoreBundle:Element:form.add.html.twig" with { 
39
+          'form'          : add_form, 
40
+          'form_name'     : add_form_name
41
+        } %}
42
+
43
+      </form>
44
+    </div>
45
+
46
+    <a href="#" id="element_add_link" class="button">
47
+      {{ 'home.add_element'|trans({}, 'navigationui') }} &gt;&gt;
48
+    </a>
49
+  {% endif %}
28 50
   
29 51
   <div class="reputation">
30 52
     {{ 'user.reputation.name'|trans({}, 'users') }}: 

+ 11 - 1
web/bundles/muzichcore/css/main.css Wyświetl plik

@@ -1068,7 +1068,7 @@ div.comments_loader
1068 1068
 
1069 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 1073
   margin-left: -15px;
1074 1074
   margin-right: 4px;
@@ -1079,6 +1079,11 @@ li.element a.element_tag_large_for_fav
1079 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 1087
 /* END Ajouter tag d'élément a ses tags favoris */
1083 1088
 
1084 1089
 div#added_element_to_group
@@ -1277,4 +1282,9 @@ li.element.shadows
1277 1282
    -moz-box-shadow: 3px 3px 3px #4F4F4F;
1278 1283
    -webkit-box-shadow: 3px 3px 3px #4F4F4F;
1279 1284
    box-shadow: 3px 3px 3px #4F4F4F;
1285
+}
1286
+
1287
+ul#favorite_tags a.button.highlight
1288
+{
1289
+  color: blue;
1280 1290
 }

+ 29 - 0
web/bundles/muzichcore/js/muzich.js Wyświetl plik

@@ -2313,4 +2313,33 @@ $(document).ready(function(){
2313 2313
     }
2314 2314
   });
2315 2315
 
2316
+  /*
2317
+   * Cloud tags
2318
+   */
2319
+  
2320
+  $('a#display_all_cloud_tag').click(function(){
2321
+    $('ul#favorite_tags li').show();
2322
+    $(this).hide();
2323
+  });
2324
+  
2325
+  $('input#cloud_tags_filter').keyup(function(){
2326
+    var search_string = $(this).val();
2327
+    
2328
+    $('ul#favorite_tags li a').removeClass('highlight');
2329
+    
2330
+    if (search_string.length > 1)
2331
+    {
2332
+      $('ul#favorite_tags li a').each(function(){
2333
+
2334
+        if ($(this).text().toUpperCase().search(search_string.toUpperCase()) != -1)
2335
+        {
2336
+          $(this).addClass('highlight')
2337
+        }
2338
+
2339
+      });
2340
+    }
2341
+    
2342
+  });
2343
+
2344
+
2316 2345
 });