update the text for searching in...
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 26 Jun 2014 20:25:56 +0000 (16:25 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 26 Jun 2014 20:25:56 +0000 (16:25 -0400)
if the filters are given then output it as
filtered by; then comma separated all filters

Toolkit/Members/SearchDisplay.php
Toolkit/Members/templates/userSearchForm.html

index c843865..6880f43 100644 (file)
 class Toolkit_Members_SearchDisplay
 {
     private $_searchTerms;
+    private $_filters;
 
     public function __construct(PDO $dbh)
     {
         $this->_searchTerms = new ArrayObject();
+        $this->_filters     = new ArrayObject();
         $posted = filter_var_array(
             $_REQUEST,
             array(
-                'member_name'   => FILTER_SANITIZE_STRING,
-                'activityId'    => FILTER_VALIDATE_INT,
-                'destinationId' => FILTER_VALIDATE_INT,
-                'parkId'        => FILTER_VALIDATE_INT,
-                'regionId'      => FILTER_VALIDATE_INT,
-                'countyId'      => FILTER_VALIDATE_INT,
-                'cityId'        => FILTER_VALIDATE_INT,
-                'amenity'       => array(
+                'member_name'    => FILTER_SANITIZE_STRING,
+                'activityId'     => FILTER_VALIDATE_INT,
+                'destinationId'  => FILTER_VALIDATE_INT,
+                'parkId'         => FILTER_VALIDATE_INT,
+                'regionId'       => FILTER_VALIDATE_INT,
+                'countyId'       => FILTER_VALIDATE_INT,
+                'cityId'         => FILTER_VALIDATE_INT,
+                'amenity'        => array(
+                    'filter' => FILTER_VALIDATE_INT,
+                    'flags'  => FILTER_FORCE_ARRAY
+                ),
+                'filterActivity' => array(
+                    'filter' => FILTER_VALIDATE_INT,
+                    'flags'  => FILTER_FORCE_ARRAY
+                ),
+                'filterParks'    => array(
                     'filter' => FILTER_VALIDATE_INT,
                     'flags'  => FILTER_FORCE_ARRAY
                 )
@@ -83,7 +93,21 @@ class Toolkit_Members_SearchDisplay
             foreach ($amenity as $amm) {
                 $amenities[] = $this->getAmenityName($dbh, $amm);
             }
-            $this->_searchTerms->offsetSet('amenity', $amenities);
+            $this->_filters->offsetSet('amenity', $amenities);
+        }
+        if (!empty($filterActivity) && $filterActivity[0]) {
+            $activityFilter = array();
+            foreach ($filterActivity as $catId) {
+                $activityFilter[] = $this->getCategoryName($dbh, $catId);
+            }
+            $this->_filters->offsetSet('activities', $activityFilter);
+        }
+        if (!empty($filterParks) && $filterParks[0]) {
+            $parkFilter = array();
+            foreach ($filterParks as $catId) {
+                $parkFilter[] = $this->getCategoryName($dbh, $catId);
+            }
+            $this->_filters->offsetSet('parks', $parkFilter);
         }
     }
 
@@ -137,6 +161,17 @@ class Toolkit_Members_SearchDisplay
             }
 
         }
+        if (count($this->_filters) > 0) {
+            $html .= '<br>Filtered by ';
+            $fCount = 0;
+            foreach ($this->_filters as $filters) {
+                if ($fCount > 0) {
+                    $html .= ', ';
+                }
+                $html .= implode(', ', $filters);
+                $fCount++;
+            }
+        }
         return $html;
     }
 
index 762603c..a295720 100644 (file)
         <input type="hidden" name="search" value="1">
         <input type="hidden" name="catid" value="<?php echo $_REQUEST['catid'];?>">
         <?php
+        if ($dest = filter_var($_REQUEST['destinationId'], FILTER_VALIDATE_INT)) {
+            echo '<input type="hidden" name="destinationId" value="'.$dest.'">';
+        }
         if ($activity = filter_var($_REQUEST['activityId'], FILTER_VALIDATE_INT)) {
             echo '<input type="hidden" name="activityId" value="'.$activity.'">';
         }