Преглед на файлове

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

Bastien Sevajol преди 11 години
родител
ревизия
cc6a09213c

+ 14 - 7
src/Muzich/CoreBundle/Controller/CoreController.php Целия файл

@@ -438,15 +438,22 @@ class CoreController extends Controller
438 438
    * 
439 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 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 Целия файл

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

+ 10 - 1
src/Muzich/CoreBundle/lib/Controller.php Целия файл

@@ -47,6 +47,15 @@ class Controller extends BaseController
47 47
     {
48 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 59
     $this->get("session")->set('user.element_search.params'.$session_id, $params);
51 60
   }
52 61
   
@@ -59,7 +68,7 @@ class Controller extends BaseController
59 68
     }
60 69
     elseif ($user instanceof User)
61 70
     {
62
-      return true;
71
+      return false;
63 72
     }
64 73
     
65 74
     throw new \Exception('Unable to determine user type');