Browse Source

Evolution #686: Click sur Avec filtres: mettres les derniers tags choisis

Bastien Sevajol 12 years ago
parent
commit
cc6a09213c

+ 14 - 7
src/Muzich/CoreBundle/Controller/CoreController.php View File

438
    * 
438
    * 
439
    * @return Response 
439
    * @return Response 
440
    */
440
    */
441
-  public function getFavoriteTagsAction()
441
+  public function getDefaultTagsAction()
442
   {    
442
   {    
443
-    // On construit l'element searcher avec les tags favoris
444
-    $es = $this->getElementSearcher(null, true);
445
-    // Et on retourne les tags
443
+    $last_tags = $this->get("session")->get('user.element_search.last_tags');
444
+    if (!count($last_tags))
445
+    {
446
+      $es = $this->getElementSearcher(null, true);
447
+      return $this->jsonResponse(array(
448
+        'response' => 'success',
449
+        'tags'     => $es->getTags()
450
+      ));
451
+    }
452
+    
446
     return $this->jsonResponse(array(
453
     return $this->jsonResponse(array(
447
-      'response' => 'success',
448
-      'tags'     => $es->getTags()
449
-    ));
454
+        'response' => 'success',
455
+        'tags'     => $last_tags
456
+      ));
450
   }
457
   }
451
   
458
   
452
   /**
459
   /**

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

50
 
50
 
51
 ajax_get_favorites_tags:
51
 ajax_get_favorites_tags:
52
   pattern: /ajax/my-favorites-tags
52
   pattern: /ajax/my-favorites-tags
53
-  defaults: { _controller: MuzichCoreBundle:Core:getFavoriteTags }
53
+  defaults: { _controller: MuzichCoreBundle:Core:getDefaultTags }
54
 
54
 
55
 ajax_add_tag:
55
 ajax_add_tag:
56
   pattern: /ajax/add-tag
56
   pattern: /ajax/add-tag

+ 10 - 1
src/Muzich/CoreBundle/lib/Controller.php View File

47
     {
47
     {
48
       $session_id = '.'.$session_id;
48
       $session_id = '.'.$session_id;
49
     }
49
     }
50
+    
51
+    if (!count($params['tags']))
52
+    {
53
+      if (count($this->getElementSearcher()->getTags()))
54
+      {
55
+        $this->get("session")->set('user.element_search.last_tags', $this->getElementSearcher()->getTags());
56
+      }
57
+    }
58
+    
50
     $this->get("session")->set('user.element_search.params'.$session_id, $params);
59
     $this->get("session")->set('user.element_search.params'.$session_id, $params);
51
   }
60
   }
52
   
61
   
59
     }
68
     }
60
     elseif ($user instanceof User)
69
     elseif ($user instanceof User)
61
     {
70
     {
62
-      return true;
71
+      return false;
63
     }
72
     }
64
     
73
     
65
     throw new \Exception('Unable to determine user type');
74
     throw new \Exception('Unable to determine user type');