瀏覽代碼

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

Bastien Sevajol 12 年之前
父節點
當前提交
3102feaf46

+ 2 - 0
app/Resources/translations/navigationui.fr.yml 查看文件

@@ -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:

+ 7 - 1
app/Resources/translations/userui.fr.yml 查看文件

@@ -154,4 +154,10 @@ search_tag:
154 154
   title:                 Recherche de tag correspondant à \"%string_search%\" ...
155 155
   
156 156
 global_search:
157
-  no_results:            Il n'y a aucun résultat a votre recherche.
157
+  no_results:            Il n'y a aucun résultat a votre recherche.
158
+  
159
+need_tags:
160
+  text_help:             |
161
+                         Les utilisateurs ayant partagés leurs découvertes ont
162
+                         demandé de l'aide pour tagger correctement leurs partages.
163
+                         Gagnez en réputation en leurs proposants les tags qui conviennent !

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

@@ -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);

+ 4 - 2
src/Muzich/CoreBundle/Resources/config/routing.yml 查看文件

@@ -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 }

+ 8 - 3
src/Muzich/CoreBundle/Resources/views/Menu/containerMenu.html.twig 查看文件

@@ -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') }}

+ 15 - 5
src/Muzich/CoreBundle/Searcher/ElementSearcher.php 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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
 

文件差異過大導致無法顯示
+ 822 - 712
src/Muzich/CoreBundle/Tests/Controller/HomeControllerTest.php


+ 16 - 2
src/Muzich/CoreBundle/lib/FunctionalTest.php 查看文件

@@ -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
 }

+ 17 - 6
src/Muzich/HomeBundle/Controller/HomeController.php 查看文件

@@ -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,18 @@ 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
+    ));
56
+  }
57
+  
47 58
 }

+ 27 - 0
src/Muzich/HomeBundle/Resources/views/Home/need_tags.html.twig 查看文件

@@ -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 %}