Esempio n. 1
0
 private function _BuildProductFeed($feedTitle, $feedDescription, $feedId, $sortField, $sortOrder, $searchTerms = array())
 {
     $this->_SetFeedDetails();
     $feed = new ISC_FEED_GENERATOR($feedId, $this->_type, (int) GetConfig('RSSCacheTime') * 60);
     $channel = array("title" => $feedTitle, "description" => $feedDescription, "link" => $GLOBALS['ShopPath']);
     $feed->SetChannel($channel);
     // The magical Interspire Shopping Cart RSS feeds are actually just custom searches so pipe it off to our search function
     $searchterms = BuildProductSearchTerms($searchTerms);
     $searchQueries = BuildProductSearchQuery($searchterms, '', $sortField, $sortOrder);
     // Run the query
     $searchQueries['query'] .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, (int) GetConfig('RSSItemsLimit'));
     $result = $GLOBALS['ISC_CLASS_DB']->Query($searchQueries['query']);
     while ($product = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         if (isc_strlen($product['proddesc']) > 300) {
             $product['proddesc'] = isc_substr($product['proddesc'], 0, 298) . "..";
         }
         if ($product['imagefile']) {
             $product['proddesc'] = sprintf("<div style='float: right; padding: 10px;'>%s</div>%s", ImageThumb($product['imagefile'], ProdLink($product['prodname'])), $product['proddesc']);
         }
         // Determine the price of this product
         $price = CalculateProductPrice($product);
         $price = GetLang('Price') . ": " . $price;
         if (GetConfig('ShowProductRating')) {
             $ratingImage = $GLOBALS['TPL_PATH'] . '/images/IcoRating' . (int) $product['prodavgrating'] . '.gif';
             $ratingImage = '<img src="' . $ratingImage . '" alt="" />';
         } else {
             $ratingImage = '';
         }
         $product['proddesc'] .= '<p><strong>' . $price . '</strong> ' . $ratingImage . '</p>';
         // Add the item to the feed
         $item = array("title" => $product['prodname'], "description" => $product['proddesc'], "link" => ProdLink($product['prodname']), "date" => $product['proddateadded']);
         $feed->AddItem($item);
     }
     // Send the feed to the browser
     $feed->OutputFeed();
 }
    function SetPanelSettings()
    {
        $output = "";
        $all_makes = array('CHEVROLET', 'GMC', 'FORD', 'DODGE', 'TOYOTA', 'NISSAN', 'HONDA', 'JEEP', 'HYUNDAI', 'CHRYSLER', 'INFINITI', 'LEXUS');
        $colours = array('Red', 'Navy', 'Green', 'Brown', 'Black', 'Silver', 'Dark Gray', 'Tan', 'White');
        $prod_make = array();
        $prod_model = array();
        $prod_submodel = array();
        $prod_year = array();
        $prod_price = array();
        $prod_categoryid = array();
        $count_categoryid = array();
        $brand_id = array();
        $make_link = "";
        $model_link = "";
        $model_flag_link = 0;
        $submodel_link = "";
        $year_link = "";
        $sub_modelrow = array();
        $GLOBALS['SITEPATH'] = GetConfig('ShopPath');
        // Get the link to the "all brands" page
        $GLOBALS['AllBrandsLink'] = BrandLink();
        $params = $this->searchterms;
        if (empty($params)) {
            $params['dynfilters'] = array();
        }
        /*--- Here when brand series is searched directly , brand series is set in seesion to be accessed in other pages --- */
        if (isset($params['series']) && !empty($params['series'])) {
            $_SESSION['absearchterms']['series'] = $params['series'];
        }
        // Build the search query using our terms & the fields we want
        $column_concat = " p.productid , p.prodcode , group_concat(DISTINCT c.categoryid separator '~') as categoryid, group_concat(DISTINCT prodbrandid separator '~') as prodbrandid ";
        $column_concat .= " , group_concat(DISTINCT v.prodmake separator '~') as prodmake , group_concat(DISTINCT v.prodmodel separator '~') as prodmodel , group_concat(DISTINCT v.prodsubmodel separator '~') as prodsubmodel , group_concat(v.prodstartyear separator '~') as prodstartyear , group_concat(v.prodendyear separator '~') as prodendyear ";
        if (isset($params['catuniversal']) && $params['catuniversal'] == 1) {
            // this condition has been added as universal category shd be shown only PQ's
            $column_names = $GLOBALS['p_cols'];
            for ($j = 0; $j < count($column_names); $j++) {
                if (isset($GLOBALS['visible_pqvq'][$column_names[$j]]) && $GLOBALS['visible_pqvq'][$column_names[$j]] == 1) {
                    $column_concat .= " , group_concat(DISTINCT " . $column_names[$j] . " separator '~') as  " . $column_names[$j];
                }
            }
        } else {
            if (isset($params['make']) && !empty($params['make']) && (isset($params['model']) && !empty($params['model']) && (!isset($params['model_flag']) || $params['model_flag'] == 1)) && isset($params['year']) && !empty($params['year']) && isset($GLOBALS['ISC_SRCH_CATG_ID'])) {
                $column_names = array_merge($GLOBALS['v_cols'], $GLOBALS['p_cols']);
                for ($j = 0; $j < count($column_names); $j++) {
                    if (stristr($column_names[$j], 'VQbedsize')) {
                        $column_names[$j] = 'VQbedsize';
                    }
                    if (stristr($column_names[$j], 'VQcabsize')) {
                        $column_names[$j] = 'VQcabsize';
                    }
                    if (isset($GLOBALS['visible_pqvq'][$column_names[$j]]) && $GLOBALS['visible_pqvq'][$column_names[$j]] == 1) {
                        if (eregi('^(vq)', $column_names[$j])) {
                            // the below 2 cases are added for checking only in bedsize and cabsize
                            if ($column_names[$j] == 'VQbedsize' or $column_names[$j] == 'VQcabsize') {
                                if (strcasecmp($column_names[$j], 'VQbedsize') == 0) {
                                    $column_concat .= " , group_concat( DISTINCT if( v.bedsize_generalname != '', v.bedsize_generalname, v.VQbedsize ) separator '~' ) as  " . $column_names[$j];
                                } else {
                                    $column_concat .= " , group_concat( DISTINCT if( v.cabsize_generalname != '', v.cabsize_generalname, v.VQcabsize ) separator '~' ) as  " . $column_names[$j];
                                }
                            } else {
                                $column_concat .= " , group_concat(DISTINCT v." . $column_names[$j] . " separator '~') as  " . $column_names[$j];
                            }
                        } else {
                            if (eregi('^(pq)', $column_names[$j])) {
                                $column_concat .= " , group_concat(DISTINCT " . $column_names[$j] . " separator '~') as  " . $column_names[$j];
                            }
                        }
                    }
                }
            }
        }
        $searchQueries = BuildProductSearchQuery($this->searchterms);
        $searchQueries['query'] = str_replace('USE INDEX (categoryid)', 'USE INDEX (PRIMARY)', $searchQueries['query']);
        //$searchQueries['query'] = str_replace('temp.*',$column_concat,$searchQueries['query']);
        $searchQueries['query'] = str_replace($GLOBALS['srch_where'], $column_concat, $searchQueries['query']);
        // lguan_20100513: If in product detail page, and search terms is empty, should use product id to limit the queries for brand, the original
        //              query was killing the performance
        $showOtherBrandForDetail = false;
        if ($this->searchterms == '') {
            $searchQueries['query'] .= isset($GLOBALS['ISC_CLASS_PRODUCT']) && $GLOBALS['ISC_CLASS_PRODUCT']->_product['prodcatids'] ? ' AND c.categoryid IN (' . $GLOBALS['ISC_CLASS_PRODUCT']->_product['prodcatids'] . ')' : '';
            $showOtherBrandForDetail = true;
        }
        $searchQueries['query'] .= " group by p.productid ";
        $searchQueries['query'] .= $GLOBALS['having_query'];
        $Search_Result1 = $GLOBALS['ISC_CLASS_DB']->Query($searchQueries['query']);
        $numrows = @(int) $GLOBALS['ISC_CLASS_DB']->CountResult($Search_Result1);
        $flag = 0;
        // this flag is used to avoid executing query again and again for submodels
        $filterdata = array();
        $countfilterdata = array();
        $sku = array();
        $count_model = array();
        $count_submodel['all']['count'] = 0;
        $sub_model_flag = 0;
        $sub_catg = "";
        if (!isset($params['model_flag']) || isset($params['model_flag']) && $params['model_flag'] == 1) {
            $model_flag_link = 1;
        }
        $strtocheck = '^(vq|pq)';
        if (isset($params['subcategory'])) {
            $sub_catg = "&subcategory=" . MakeURLSafe(strtolower($params['subcategory']));
        }
        if (isset($params['series'])) {
            $sub_catg .= "&series=" . MakeURLSafe(strtolower($params['series']));
        }
        if (isset($params['category'])) {
            $sub_catg .= "&category=" . MakeURLSafe(strtolower($params['category']));
        }
        while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($Search_Result1)) {
            $temp_prod_year = array();
            $grp_make = explode("~", $row['prodmake']);
            $grp_model = explode("~", $row['prodmodel']);
            if ($row['prodsubmodel'] != '~') {
                $grp_submodel = explode("~", $row['prodsubmodel']);
            } else {
                $grp_submodel = array();
            }
            $grp_startyear = explode("~", $row['prodstartyear']);
            $grp_endyear = explode("~", $row['prodendyear']);
            $grp_brandid = explode("~", $row['prodbrandid']);
            $grp_categoryid = explode("~", $row['categoryid']);
            $columns = array_keys($row);
            foreach ($row as $key => $qval) {
                if (eregi($strtocheck, $key)) {
                    $qval = trim($qval, '~');
                    $qval = strtolower($qval);
                    $grp_dyn = preg_split('/[~;]+/', $qval);
                    $grp_dyn = array_unique($grp_dyn);
                    $grp_dyn = array_values($grp_dyn);
                    for ($g = 0; $g < count($grp_dyn); $g++) {
                        $val = settype($val, "string");
                        $val = strtolower($grp_dyn[$g]);
                        if ($val == '') {
                            //Added by Simha
                            $val = "Others";
                        }
                        if (!empty($val)) {
                            /*$filter_value = explode(";",$val);
                              for($k=0;$k<count($filter_value);$k++)
                              {*/
                            //$val = $filter_value[$k];
                            if ($val != "") {
                                if (!isset($filterdata[$key])) {
                                    $filterdata[$key][] = $val;
                                    $countfilterdata[$key][$val]['count'] = 1;
                                } else {
                                    if (!in_array($val, $filterdata[$key], true)) {
                                        $filterdata[$key][] = $val;
                                        $countfilterdata[$key][$val]['count'] = 1;
                                    } else {
                                        $countfilterdata[$key][$val]['count']++;
                                    }
                                }
                            }
                            //}
                        }
                    }
                }
            }
            $prod_id[] = $row['productid'];
            for ($g = 0; $g < count($grp_brandid); $g++) {
                if ($grp_brandid[$g] != 0) {
                    $brand_id[] = $grp_brandid[$g];
                }
            }
            for ($g = 0; $g < count($grp_categoryid); $g++) {
                if ($grp_categoryid[$g] != "") {
                    if (!in_array($grp_categoryid[$g], $prod_categoryid)) {
                        $prod_categoryid[] = $grp_categoryid[$g];
                        $count_categoryid[$grp_categoryid[$g]]['count'] = 1;
                    } else {
                        $count_categoryid[$grp_categoryid[$g]]['count']++;
                    }
                }
            }
            for ($g = 0; $g < count($grp_make); $g++) {
                if ($grp_make[$g] != '') {
                    $product_make = strtoupper($grp_make[$g]);
                    if ($product_make != "NON-SPEC VEHICLE") {
                        // this condition is addded not to show "NON-SPEC VEHICLE" in list
                        if (!in_array($product_make, $prod_make)) {
                            $prod_make[] = $product_make;
                            $count_make[$product_make]['count'] = 1;
                        } else {
                            $count_make[$product_make]['count']++;
                        }
                    }
                }
            }
            for ($g = 0; $g < count($grp_model); $g++) {
                if (strtolower($grp_model[$g]) != 'all') {
                    // this condition is added not to show "All" in list
                    $sub_model_flag = 1;
                    $grp_model[$g] = strtoupper($grp_model[$g]);
                    if (!in_array($grp_model[$g], $prod_model)) {
                        $prod_model[] = $grp_model[$g];
                        $count_model[$grp_model[$g]]['count'] = 1;
                    } else {
                        $count_model[$grp_model[$g]]['count']++;
                    }
                }
            }
            if (count($grp_submodel) > 0) {
                for ($g = 0; $g < count($grp_submodel); $g++) {
                    if (!empty($grp_submodel[$g])) {
                        $sub_model_flag = 1;
                        $grp_submodel[$g] = ucwords(strtolower($grp_submodel[$g]));
                        if (!in_array($grp_submodel[$g], $prod_submodel)) {
                            $prod_submodel[] = $grp_submodel[$g];
                            $count_submodel[$grp_submodel[$g]]['count'] = 1;
                        } else {
                            $count_submodel[$grp_submodel[$g]]['count']++;
                        }
                    }
                }
            } else {
                if (!in_array('all', $prod_submodel)) {
                    $count_submodel['all']['count'] = 1;
                } else {
                    $count_submodel['all']['count']++;
                }
            }
            for ($g = 0; $g < count($grp_startyear); $g++) {
                $prod_start_year = $grp_startyear[$g];
                $prod_end_year = $grp_endyear[$g];
                if (empty($prod_end_year)) {
                    $prod_end_year = $prod_start_year;
                }
                if (strtolower($prod_start_year) != "all") {
                    // this condition is addded not to show "All" in list
                    if (is_numeric($prod_start_year) && is_numeric($prod_end_year)) {
                        $prod_year_diff = $prod_end_year - $prod_start_year;
                    }
                    if (!is_numeric($prod_start_year) && !is_numeric($prod_end_year)) {
                        if (!in_array($prod_start_year, $temp_prod_year)) {
                            $temp_prod_year[] = $prod_start_year;
                        }
                    } else {
                        if (isset($params['year']) && !empty($params['year'])) {
                            if (in_array($params['year'], $prod_year)) {
                                $count_year[$params['year']]['count']++;
                            } else {
                                $prod_year[] = $params['year'];
                                $count_year[$params['year']]['count'] = 1;
                            }
                        } else {
                            for ($i = 0; $i <= $prod_year_diff; $i++) {
                                $actual_year = $prod_start_year + $i;
                                if (!in_array($actual_year, $temp_prod_year)) {
                                    $temp_prod_year[] = $actual_year;
                                }
                            }
                        }
                    }
                }
            }
            for ($k = 0; $k < count($temp_prod_year); $k++) {
                if (!in_array($temp_prod_year[$k], $prod_year)) {
                    $prod_year[] = $temp_prod_year[$k];
                    $count_year[$temp_prod_year[$k]]['count'] = 1;
                } else {
                    $count_year[$temp_prod_year[$k]]['count']++;
                }
            }
        }
        //Added by Simha // for removing if it has only others in qualifier values
        foreach ($countfilterdata as $key => $value) {
            if (isset($value['Others']) && count($value) == 1 && !isset($params['dynfilters'][$key])) {
                unset($countfilterdata[$key]);
                unset($filterdata[$key]);
            }
        }
        foreach ($filterdata as $key => $num) {
            $keys = array_keys($num, 'Others');
            if (isset($keys) && count($keys) == 1) {
                unset($num[$keys[0]]);
                $num[] = 'Others';
            }
            $num = array_values($num);
            $filterdata[$key] = $num;
        }
        //Added by Simha Ends
        $prod_make_new = array_unique($prod_make);
        asort($prod_make_new);
        $prod_model_new = array_unique($prod_model);
        asort($prod_model_new);
        $prod_submodel_new = array_unique($prod_submodel);
        sort($prod_submodel_new);
        $prod_year_new = array_unique($prod_year);
        arsort($prod_year_new);
        $srch_qry = isset($params['search_query']) ? $params['search_query'] : (isset($params['search_query_adv']) ? $params['search_query_adv'] : '');
        $srch_qry = MakeURLSafe($srch_qry);
        $brand_id = array_unique($brand_id);
        $brand_id = array_values($brand_id);
        $GLOBALS['SearchBrands'] = $brand_id;
        // This variable is used in searchpage.php for displaying brands.
        $GLOBALS['SearchCategories'] = $prod_categoryid;
        // This variable is used in searchpage.php for displaying categories.
        if (isset($params['make']) && !empty($params['make'])) {
            $make_link = "&make=" . MakeURLSafe($params['make']);
        }
        if (isset($params['year']) && !empty($params['year'])) {
            $year_link = "&year=" . $params['year'];
        }
        if (isset($params['model']) && !empty($params['model'])) {
            $model_link = "&model=" . MakeURLSafe($params['model']);
        }
        if (isset($params['model_flag']) && $params['model_flag'] == 0) {
            $model_link .= "&model_flag=0";
        }
        if (isset($params['submodel']) && !empty($params['submodel'])) {
            $submodel_link = "&submodel=" . MakeURLSafe($params['submodel']);
        }
        if (isset($params['partnumber'])) {
            $_GET['partnumber'] = $params['partnumber'];
        }
        $query_string_array = $_GET;
        if (isset($params['make'])) {
            $query_string_array['make'] = $params['make'];
        }
        if (isset($params['model'])) {
            $query_string_array['model'] = $params['model'];
        }
        if (isset($params['model_flag']) && $params['model_flag'] == 0) {
            $query_string_array['model_flag'] = $params['model_flag'];
        }
        if (isset($params['submodel'])) {
            $query_string_array['submodel'] = $params['submodel'];
        }
        if (isset($params['year'])) {
            $query_string_array['year'] = $params['year'];
        }
        if (isset($params['brand'])) {
            $query_string_array['brand'] = $params['brand'];
        }
        if (isset($params['series'])) {
            $query_string_array['series'] = $params['series'];
        }
        if (isset($params['subcategory'])) {
            $query_string_array['subcategory'] = $params['subcategory'];
        }
        if (isset($params['category'])) {
            $query_string_array['category'] = $params['category'];
        }
        if (isset($params['search'])) {
            $query_string_array['searchtext'] = $params['search'];
        }
        if (isset($params['searchtext'])) {
            $query_string_array['searchtext'] = $params['searchtext'];
        }
        if (isset($params['vqsbedsize'])) {
            $query_string_array['vqsbedsize'] = $params['vqsbedsize'];
        }
        if (isset($params['vqscabsize'])) {
            $query_string_array['vqscabsize'] = $params['vqscabsize'];
        }
        foreach ($params['dynfilters'] as $key => $value) {
            $key = strtolower($key);
            $query_string_array[$key] = $value;
        }
        $query_string_array['search_query'] = $srch_qry;
        unset($query_string_array['page'], $query_string_array['search_key'], $query_string_array['x'], $query_string_array['y'], $query_string_array['sortby'], $query_string_array['orderby'], $query_string_array['change'], $query_string_array['product'], $query_string_array['refer']);
        $mmy_string_array = $query_string_array;
        unset($mmy_string_array['make'], $mmy_string_array['model'], $mmy_string_array['submodel'], $mmy_string_array['year'], $mmy_string_array['search_query']);
        $mmy_string_new1 = "";
        foreach ($mmy_string_array as $mmy_key => $mmy_val) {
            $mmy_string_new1 .= "&" . $mmy_key . "=" . $mmy_val;
        }
        $dyn_filter = "";
        // this is the main variable which is used for assigning to the global variable
        $dyn_top = "";
        // this is the variable which will remain on top of the filters
        $dyn_bottom = "";
        // this is the variable which will remain at bottom of the filters
        $dyn_flag = 0;
        // this is the variable which will check which are at top or bottom in the filters, 0 for top and 1 for bottom
        /* The below code will be added to redefine search as we need to pass 'a-b-testing' in all URL's for redefine search */
        $add_url_redefine = "&abtesting=" . MakeURLSafe(strtolower($GLOBALS['PathInfo'][1]));
        if (isset($params['make']) || isset($params['make']) && isset($params['model']) && $model_flag_link == 1 || isset($params['year'])) {
            $mmy_clear_links = $this->path . "/search.php?search_query=" . urlencode($params['search_query']) . $sub_catg;
            if (isset($params['brand'])) {
                $mmy_clear_links .= "&brand=" . $params['brand'];
            }
            $clear_mmy_filter_link = $this->GetClearFilterlink($query_string_array, 0);
            $GLOBALS['DynMsg'] = "<a href='#' onclick=\"deleteMMYcookies('" . $this->path . $clear_mmy_filter_link . "');\">Clear my Vehicle</a>";
            $GLOBALS['RemoveBackgroundImage'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("RemoveBgImage");
        }
        if (isset($params['make']) && (isset($params['model']) && $model_flag_link == 1) && isset($params['year']) && !isset($_REQUEST['change'])) {
            // if MMY is selected
            $GLOBALS['MyVehicleAreaHeader'] = $params['year'] . " " . $params['make'] . " " . $params['model'];
            $GLOBALS['DynmenuFilter'] = "";
        } else {
            $GLOBALS['MyVehicleAreaHeader'] = "Choose My Vehicle";
            $GLOBALS['DynmenuFilter'] = "";
        }
        /*-------- Year -----------------------------------------*/
        $GLOBALS['MouseoverFn'] = "this.style.cursor='pointer'";
        $extra_year = "";
        //if( !empty($make_link) || !empty($year_link) || !empty($model_link) ) {
        if (empty($year_link) || !empty($year_link)) {
            $GLOBALS['dynid'] = "prod_year";
            $GLOBALS['Dynmainmenu'] = "Year";
            $output2 = "";
            $year_counter = 1;
            if (count($prod_year_new) > 0) {
                foreach ($prod_year_new as $key => $value) {
                    if (!isset($_REQUEST['change'])) {
                        // when clicked on "clear my vehicle", need to pass the value in the search query to get all Make and year
                        $GLOBALS['BrandLink'] = "{$this->path}/search.php?search_query=" . $srch_qry;
                    } else {
                        $GLOBALS['BrandLink'] = "{$this->path}/search.php?search_query={$value}";
                    }
                    if (!empty($make_link)) {
                        $GLOBALS['BrandLink'] .= $make_link;
                    }
                    if (!empty($model_link)) {
                        $GLOBALS['BrandLink'] .= $model_link;
                    }
                    if (!empty($submodel_link) && isset($_REQUEST['submodel'])) {
                        $GLOBALS['BrandLink'] .= $submodel_link;
                    }
                    if (!empty($year_link)) {
                        $GLOBALS['BrandLink'] .= $year_link;
                    } else {
                        $GLOBALS['BrandLink'] .= "&year=" . $value;
                    }
                    $GLOBALS['BrandLink'] .= $mmy_string_new1;
                    $GLOBALS['BrandLink'] .= $sub_catg;
                    $GLOBALS['BrandName'] = isc_html_escape($value);
                    $GLOBALS['BrandCount'] = $count_year[$value]['count'];
                    if (!empty($year_link)) {
                        if ($GLOBALS['BrandName'] == 'ALL' && $GLOBALS['BrandName'] != $params['year']) {
                            $GLOBALS['BrandName'] = $params['year'];
                            //$output2 .= "<li>".$params['year']."</li>";
                            $output2 .= "<li></li>";
                        } else {
                            $GLOBALS['BrandName'] = $params['year'];
                            //$output2 .= "<li>$value</li>";
                            $output2 .= "<li></li>";
                        }
                        $dyn_flag = 1;
                        break;
                        // break has been added to display only single listing.
                    } else {
                        $dyn_flag = 0;
                        if ($year_counter < 11) {
                            $output2 .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilter3");
                            $year_counter++;
                        } else {
                            $extra_year .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilter3");
                        }
                    }
                }
            } else {
                if (isset($params['year'])) {
                    $dyn_flag = 1;
                    $GLOBALS['BrandName'] = $params['year'];
                    $output2 .= "<li>" . $params['year'] . "</li>";
                }
            }
            $output2 = "<ul>" . $output2 . "</ul>";
            /* the below code is used to apply more link if records exceed 10 */
            if ($year_counter > 11) {
                $GLOBALS['FilterID'] = "year";
                $GLOBALS['ExtraValues'] = $extra_year;
                $output2 .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideFilterMoreLink");
            }
            $output2 = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseSnippets($output2, $GLOBALS['SNIPPETS']);
            //if( !empty($_REQUEST['year']) && !empty($year_link) ) {
            $links_year = $srch_qry;
            if (!empty($year_link)) {
                $links_year .= $year_link;
            }
            if (!empty($make_link)) {
                $links_year .= $make_link;
            }
            if (!empty($model_link) && isset($_REQUEST['model'])) {
                $links_year .= $model_link;
            }
            /*if( !empty($submodel_link) && isset($_REQUEST['submodel']))   {
                              $links_year .= $submodel_link;                    
            		}*/
            if (isset($params['brand'])) {
                $links_year .= "&brand=" . MakeURLSafe($params['brand']);
            }
            if (isset($params['search'])) {
                $links_year .= "&searchtext=" . MakeURLSafe(strtolower($params['search']));
            }
            if (isset($params['searchtext'])) {
                $links_year .= "&searchtext=" . MakeURLSafe(strtolower($params['searchtext']));
            }
            if (isset($params['vqsbedsize'])) {
                $links_year .= "&vqsbedsize=" . MakeURLSafe($params['vqsbedsize']);
            }
            if (isset($params['vqscabsize'])) {
                $links_year .= "&vqscabsize=" . MakeURLSafe($params['vqscabsize']);
            }
            $links_year .= $this->GetOtherLinksForRedefine($params);
            $links_year .= $add_url_redefine;
            /* this below lines are not to display the year when clear is clicked */
            if (isset($_REQUEST['change'])) {
                $GLOBALS['BrandName'] = "";
            }
            if ($dyn_flag == 1 || isset($_REQUEST['change'])) {
                $str = "search_query=" . $links_year . $sub_catg . "&column=year";
                $GLOBALS['Dyndisplay1'] = "block";
                $GLOBALS['Dyndisplay'] = "none";
                $GLOBALS['Dynimage'] = "imgHdrDropDownIconright.gif";
                $GLOBALS['DynFilterArrow'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilterImage");
                //$GLOBALS['DynFilterArrow'] .= "&nbsp;&nbsp;&nbsp;".$GLOBALS['BrandName'];
                $GLOBALS['DynmenuFilter1'] = $output2;
                $GLOBALS['DynmenuFilter'] = "";
                $GLOBALS['JSfunction'] = "getvalueswithajax('" . $GLOBALS['dynid'] . "','{$str}&getymms=1');checkanimate('" . $GLOBALS['dynid'] . "')";
            } else {
                $GLOBALS['BrandName'] = "";
                $GLOBALS['Dyndisplay1'] = "none";
                $GLOBALS['Dyndisplay'] = "block";
                $GLOBALS['Dynimage'] = "imgHdrDropDownIconright.gif";
                $GLOBALS['DynFilterArrow'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilterImage");
                $GLOBALS['DynmenuFilter'] = $output2;
                $GLOBALS['DynmenuFilter1'] = "";
                $GLOBALS['JSfunction'] = "checkanimate('" . $GLOBALS['dynid'] . "')";
                if (empty($year_link)) {
                    $GLOBALS['DynmenuFilter'] = "";
                    $str = "search_query=" . $links_year . $sub_catg . "&column=year";
                    $GLOBALS['JSfunction'] .= ";getvalueswithajax('" . $GLOBALS['dynid'] . "','{$str}&getymms=1')";
                }
            }
            $GLOBALS['mmyid'] = "mmy_year";
            $dyn_output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("MyVehicleAreaSearch");
            $dyn_filter = $dyn_output;
            //$GLOBALS['SNIPPETS']['SideProductFilter3'] = $output2;
        } else {
            $GLOBALS['HideSideProductFiltersPanelYear'] = "none";
        }
        if ($dyn_flag == 1 && !isset($_REQUEST['change'])) {
            $dyn_top .= $dyn_filter;
        } else {
            $dyn_top .= $dyn_filter;
        }
        $dyn_filter = "";
        /*-------- Make -----------------------------------------*/
        $GLOBALS['dynid'] = "prod_make";
        $GLOBALS['Dynmainmenu'] = "Make";
        if (isset($make_link) && !empty($make_link)) {
            if (count($prod_make_new) > 0) {
                foreach ($prod_make_new as $key => $value) {
                    if (!isset($_REQUEST['change'])) {
                        // when clicked on "clear my vehicle", need to pass the value in the search query to get all Make and year
                        $GLOBALS['BrandLink'] = "{$this->path}/search.php?search_query=" . $srch_qry . "&make=" . $value;
                    } else {
                        $GLOBALS['BrandLink'] = "{$this->path}/search.php?search_query={$value}&make=" . $value;
                    }
                    if (isset($_REQUEST['model']) && empty($_REQUEST['model'])) {
                        $GLOBALS['BrandLink'] .= "&model=";
                    }
                    if (isset($_REQUEST['year'])) {
                        $GLOBALS['BrandLink'] .= "&year=" . $_REQUEST['year'];
                    }
                    $GLOBALS['BrandLink'] .= $sub_catg;
                    $GLOBALS['BrandName'] = strtoupper($value);
                    /* this below patch is temporary used when categories with make 'NON-SPEC VEHICLE' are used when searched by redefine category */
                    if (isset($params['catuniversal']) && $params['catuniversal'] == 1 || $GLOBALS['BrandName'] == 'NON-SPEC VEHICLE' && $GLOBALS['BrandName'] != $params['make']) {
                        $GLOBALS['BrandName'] = $params['make'];
                    }
                    if (isset($count_make[$value]['count'])) {
                        $GLOBALS['BrandCount'] = $count_make[$value]['count'];
                    } else {
                        $GLOBALS['BrandCount'] = 0;
                    }
                    $output .= "<li></li>";
                    break;
                    // break has been added to display only single listing.
                }
            } else {
                if (isset($params['make'])) {
                    $GLOBALS['BrandName'] = strtoupper($params['make']);
                    $output .= "<li></li>";
                    //                     $output .= "<li>".$_REQUEST['make']."</li>";
                }
            }
            $dyn_flag = 1;
            $output = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseSnippets($output, $GLOBALS['SNIPPETS']);
        } else {
            $dyn_flag = 0;
            $temp_arr = array_diff($prod_make_new, $all_makes);
            $temp_count_make = "";
            $temp_no_count_make = "";
            $display_count = 1;
            foreach ($all_makes as $key => $value) {
                if (!isset($_REQUEST['change'])) {
                    // when clicked on "clear my vehicle", need to pass the value in the search query to get all Make and year
                    $GLOBALS['BrandLink'] = "{$this->path}/search.php?search_query=" . $srch_qry . "&make=" . $value;
                } else {
                    $GLOBALS['BrandLink'] = "{$this->path}/search.php?search_query={$value}&make=" . $value;
                }
                if (isset($_REQUEST['model']) && empty($_REQUEST['model'])) {
                    $GLOBALS['BrandLink'] .= "&model=";
                }
                if (isset($params['year'])) {
                    $GLOBALS['BrandLink'] .= "&year=" . $params['year'];
                }
                $GLOBALS['BrandLink'] .= $mmy_string_new1;
                $GLOBALS['BrandLink'] .= $sub_catg;
                $GLOBALS['BrandName'] = isc_html_escape($value);
                if (isset($count_make[$value]['count'])) {
                    $GLOBALS['BrandCount'] = $count_make[$value]['count'];
                } else {
                    $GLOBALS['BrandCount'] = 0;
                }
                /*if($GLOBALS['BrandCount'] == 0)
                  $temp_no_count_make .= "<li>$GLOBALS[BrandName] ($GLOBALS[BrandCount])</li>";*/
                if ($GLOBALS['BrandCount'] != 0) {
                    if ($display_count < 13) {
                        // this condiditon is applied to avoid long listing of make lsit
                        $temp_count_make .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilter1");
                    } else {
                        $temp_no_count_make .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilter1");
                    }
                    $display_count++;
                    //$output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilter1");
                }
            }
            if (count($temp_arr) > 0) {
                foreach ($temp_arr as $key => $value) {
                    if (!isset($_REQUEST['change'])) {
                        // when clicked on "clear my vehicle", need to pass the value in the search query to get all Make and year
                        $GLOBALS['BrandLink'] = "{$this->path}/search.php?search_query=" . $srch_qry . "&make=" . $value;
                    } else {
                        $GLOBALS['BrandLink'] = "{$this->path}/search.php?search_query={$value}&make=" . $value;
                    }
                    if (isset($_REQUEST['model']) && empty($_REQUEST['model'])) {
                        $GLOBALS['BrandLink'] .= "&model=";
                    }
                    if (isset($params['year'])) {
                        $GLOBALS['BrandLink'] .= "&year=" . $params['year'];
                    }
                    $GLOBALS['BrandName'] = isc_html_escape($value);
                    if (isset($count_make[$value]['count'])) {
                        $GLOBALS['BrandCount'] = $count_make[$value]['count'];
                    } else {
                        $GLOBALS['BrandCount'] = 0;
                    }
                    $GLOBALS['BrandLink'] .= $mmy_string_new1;
                    $GLOBALS['BrandLink'] .= $sub_catg;
                    /*if($GLOBALS['BrandCount'] == 0)
                      $temp_no_count_make .= "<li>$GLOBALS[BrandName] ($GLOBALS[BrandCount])</li>";*/
                    if ($GLOBALS['BrandCount'] != 0) {
                        if ($display_count < 13) {
                            // this condiditon is applied to avoid long listing of make list
                            $temp_count_make .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilter1");
                        } else {
                            $temp_no_count_make .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilter1");
                        }
                        $display_count++;
                    }
                }
            }
            $output = "<ul>{$temp_count_make}</ul>";
            if ($display_count > 13) {
                $GLOBALS['FilterID'] = "make";
                $GLOBALS['ExtraValues'] = $temp_no_count_make;
                $output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideFilterMoreLink");
                //$output .= "<ul class='more'><li><a href=\"javascript:onclick=show_hide('make')\" id='make_more'>More...</a></li></ul>";
            }
            $output = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseSnippets($output, $GLOBALS['SNIPPETS']);
        }
        /* this below lines are not to display the make when clear is clicked */
        if (isset($_REQUEST['change'])) {
            $GLOBALS['BrandName'] = "";
        }
        if ($dyn_flag == 1 || isset($_REQUEST['change'])) {
            //$str = "search_query=".$srch_qry.$make_link."&model=".$year_link.$sub_catg."&column=make";
            $GLOBALS['Dyndisplay1'] = "block";
            $GLOBALS['Dyndisplay'] = "none";
            $GLOBALS['Dynimage'] = "imgHdrDropDownIconright.gif";
            $GLOBALS['DynFilterArrow'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilterImage");
            //$GLOBALS['DynFilterArrow'] .= "&nbsp;&nbsp;&nbsp;".$GLOBALS['BrandName'];
            $GLOBALS['DynmenuFilter1'] = "<ul>" . $output . "</ul>";
            $GLOBALS['DynmenuFilter'] = "";
            //$GLOBALS['JSfunction'] = "getvalueswithajax('".$GLOBALS['dynid']."','$str');checkanimate('".$GLOBALS['dynid']."')";
            //$GLOBALS['Dynimage'] = "imgHdrDropDownIconright.gif";
        } else {
            $GLOBALS['BrandName'] = "";
            $GLOBALS['Dyndisplay1'] = "none";
            $GLOBALS['Dyndisplay'] = "block";
            $GLOBALS['Dynimage'] = "imgHdrDropDownIconright.gif";
            $GLOBALS['DynFilterArrow'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilterImage");
            $GLOBALS['DynmenuFilter'] = $output;
            $GLOBALS['DynmenuFilter1'] = "";
            //$GLOBALS['JSfunction'] = "checkanimate('".$GLOBALS['dynid']."')";
            if (empty($make_link)) {
                $GLOBALS['DynmenuFilter'] = "";
            }
        }
        $str = "search_query=" . $srch_qry . $make_link . "&model=" . $year_link . $sub_catg . "&column=make";
        if (isset($params['brand'])) {
            $str .= "&brand=" . $params['brand'];
        }
        if (isset($params['search'])) {
            $str .= "&searchtext=" . MakeURLSafe(strtolower($params['search']));
        }
        if (isset($params['searchtext'])) {
            $str .= "&searchtext=" . MakeURLSafe(strtolower($params['searchtext']));
        }
        if (isset($params['vqsbedsize'])) {
            $str .= "&vqsbedsize=" . MakeURLSafe($params['vqsbedsize']);
        }
        if (isset($params['vqscabsize'])) {
            $str .= "&vqscabsize=" . MakeURLSafe($params['vqscabsize']);
        }
        $str .= $this->GetOtherLinksForRedefine($params);
        $str .= $add_url_redefine;
        $GLOBALS['JSfunction'] = "getvalueswithajax('" . $GLOBALS['dynid'] . "','{$str}&getymms=1');checkanimate('" . $GLOBALS['dynid'] . "')";
        $GLOBALS['mmyid'] = "mmy_make";
        $dyn_output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("MyVehicleAreaSearch");
        $dyn_filter = $dyn_output;
        if ($dyn_flag == 1 && !isset($_REQUEST['change'])) {
            $dyn_top .= $dyn_filter;
        } else {
            $dyn_top .= $dyn_filter;
        }
        $dyn_filter = "";
        //$GLOBALS['SNIPPETS']['SideProductFilter1'] = $output;
        /*-------- Model - Starts -----------------------------------------*/
        $GLOBALS['dynid'] = "prod_model";
        $GLOBALS['Dynmainmenu'] = 'Model';
        $output1 = "";
        $display_count = 1;
        $extra = "";
        if (isset($params['make'])) {
            // if make is selected then need to enter the loop
            if (isset($params['model']) && $model_flag_link == 1) {
                // if make is selected need to show only that make
                $GLOBALS['BrandName'] = strtoupper($params['model']);
                $dyn_flag = 1;
            } else {
                $dyn_flag = 0;
                $model_string_array = $query_string_array;
                unset($model_string_array['model_flag'], $model_string_array['model']);
                $ymm_links = $this->GetYMMLinks($model_string_array);
                $ymm_links .= $this->GetOtherLinks($params);
                foreach ($prod_model_new as $key => $value) {
                    if ($GLOBALS['EnableSEOUrls'] == 0) {
                        $GLOBALS['BrandLink'] = $this->path . "/search.php?search_query=" . $srch_qry;
                        $GLOBALS['BrandLink'] .= $ymm_links;
                        $GLOBALS['BrandLink'] .= "&model=" . $value;
                    } else {
                        $GLOBALS['BrandLink'] = $this->path;
                        if ($srch_qry != "") {
                            $GLOBALS['BrandLink'] .= "/" . $srch_qry;
                        }
                        $GLOBALS['BrandLink'] .= $ymm_links;
                        $GLOBALS['BrandLink'] .= "/model/" . MakeURLSafe(strtolower($value));
                    }
                    $GLOBALS['BrandName'] = isc_html_escape($value);
                    $GLOBALS['BrandCount'] = $count_model[$value]['count'];
                    if ($display_count < 11) {
                        $output1 .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilter2");
                    } else {
                        $extra .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilter2");
                    }
                    $display_count++;
                }
                $output1 = "<ul>" . $output1 . "</ul>";
                if ($display_count > 11) {
                    $GLOBALS['FilterID'] = "model";
                    $GLOBALS['ExtraValues'] = $extra;
                    $output1 .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideFilterMoreLink");
                }
            }
            /* the below links are passes for redefine search - starts*/
            $links = $srch_qry;
            $links .= $make_link;
            $links .= $year_link;
            if (isset($params['model']) && $model_flag_link == 1) {
                $links .= $model_link;
            }
            $links .= $sub_catg;
            if (isset($params['brand'])) {
                $links .= "&brand=" . MakeURLSafe($params['brand']);
            }
            if (isset($params['search'])) {
                $links .= "&searchtext=" . MakeURLSafe(strtolower($params['search']));
            }
            if (isset($params['searchtext'])) {
                $links .= "&searchtext=" . MakeURLSafe(strtolower($params['searchtext']));
            }
            if (isset($params['vqsbedsize'])) {
                $links .= "&vqsbedsize=" . MakeURLSafe(strtolower($params['vqsbedsize']));
            }
            if (isset($params['vqscabsize'])) {
                $links .= "&vqscabsize=" . MakeURLSafe(strtolower($params['vqscabsize']));
            }
            $links .= $this->GetOtherLinksForRedefine($params);
            $links .= "&column=model";
            $links .= $add_url_redefine;
            /* the below links are passes for redefine search - ends*/
            /* this below lines are not to display the make when clear is clicked */
            if (isset($_REQUEST['change'])) {
                $GLOBALS['BrandName'] = "";
            }
            if ($dyn_flag == 1 || isset($_REQUEST['change'])) {
                $GLOBALS['Dyndisplay1'] = "block";
                $GLOBALS['Dyndisplay'] = "none";
                $GLOBALS['Dynimage'] = "imgHdrDropDownIconright.gif";
                $GLOBALS['DynFilterArrow'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilterImage");
                $GLOBALS['DynmenuFilter1'] = $output1;
                $GLOBALS['DynmenuFilter'] = "";
                $str = "search_query=" . $links;
                if (!isset($_REQUEST['change'])) {
                    $GLOBALS['JSfunction'] = "getvalueswithajax('" . $GLOBALS['dynid'] . "','{$str}&getymms=1');checkanimate('" . $GLOBALS['dynid'] . "')";
                } else {
                    $GLOBALS['mousedefaultpointer'] = "mousedefaultpointer";
                    $GLOBALS['JSfunction'] = "";
                }
            } else {
                $GLOBALS['BrandName'] = "";
                $GLOBALS['Dyndisplay1'] = "none";
                $GLOBALS['Dyndisplay'] = "block";
                $GLOBALS['Dynimage'] = "imgHdrDropDownIconright.gif";
                $GLOBALS['DynmenuFilter'] = "";
                if (isset($params['model_flag']) && $params['model_flag'] == 0 && (!isset($params['catuniversal']) || $params['catuniversal'] == 0)) {
                    $GLOBALS['DynmenuFilter'] = $output1;
                    $GLOBALS['dynidStyle'] = "style='display:block'";
                    $GLOBALS['Dynimage'] = "imgHdrDropDownIcon.gif";
                }
                $GLOBALS['DynFilterArrow'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilterImage");
                $GLOBALS['DynmenuFilter1'] = "";
                $str = "search_query=" . $links;
                $GLOBALS['JSfunction'] = "getvalueswithajax('" . $GLOBALS['dynid'] . "','{$str}&getymms=1');checkanimate('" . $GLOBALS['dynid'] . "')";
            }
        } else {
            $GLOBALS['BrandName'] = "";
            $GLOBALS['mousedefaultpointer'] = "mousedefaultpointer";
            $GLOBALS['DynmenuFilter'] = "";
            $GLOBALS['JSfunction'] = "";
        }
        $GLOBALS['mmyid'] = "mmy_model";
        $dyn_output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("MyVehicleAreaSearch");
        $dyn_filter = $dyn_output;
        $dyn_top .= $dyn_filter;
        $dyn_filter = "";
        /*-------- Model - Ends -----------------------------------------*/
        $filter1 = <<<P1
    <div class="Block BrandList Moveable" id="SideProductFilters" style="">
P1;
        $filter2 = <<<P1
       <div class="BlockContent">
        <ul>
P1;
        $filter3 = <<<P3
        </ul>
        </div>                
        </div>
P3;
        $GLOBALS['MyVehicleArea'] = $dyn_top;
        $GLOBALS['MyVehicleArea'] .= "<p id='fit'>Guaranteed to Fit Your Vehicle!</p>";
        if (isset($GLOBALS['DynMsg'])) {
            $GLOBALS['MyVehicleArea'] .= "<ul id='modifyvehicle'><li>" . $GLOBALS['DynMsg'] . "</li></ul>";
        }
        if (isset($params['srch_category']) || isset($params['brand']) || isset($params['submodel'])) {
            $clear_filter_below_link = $this->GetClearFilterlink($query_string_array, 1);
            if ($clear_filter_below_link != "/") {
                $clear_filter_below_link = "/" . MakeURLSafe(strtolower($GLOBALS['PathInfo'][1])) . $clear_filter_below_link;
            }
            $GLOBALS['MyVehicleArea'] .= "<ul id='modifyvehicle'><li><a href='" . $this->path . "{$clear_filter_below_link}' ";
            if ($clear_filter_below_link == '/') {
                $GLOBALS['MyVehicleArea'] .= "onclick='return clearOtherFilters();'";
            }
            $GLOBALS['MyVehicleArea'] .= " >Clear All Filters Below</a></li></ul>";
        }
        if (isset($params['search'])) {
            $GLOBALS['QualiferValue'] = "";
            if (isset($params['vqsbedsize'])) {
                $GLOBALS['QualiferValue'] .= "/vqsbedsize/" . MakeURLSafe(strtolower($params['vqsbedsize'])) . "/";
            }
            if (isset($params['vqscabsize'])) {
                $GLOBALS['QualiferValue'] .= "/vqscabsize/" . MakeURLSafe(strtolower($params['vqscabsize'])) . "/";
            }
            $GLOBALS['QualiferValue'] .= $this->GetOtherLinks($params);
            $GLOBALS['QualiferValue'] = trim($GLOBALS['QualiferValue'], "/");
            if (trim($GLOBALS['QualiferValue']) != "") {
                $GLOBALS['QualiferValue'] = " var SearchQualVal = '" . $GLOBALS['QualiferValue'] . "/'; ";
            }
            $GLOBALS['QualiferValue'] .= " var SearchStringVal = '" . MakeURLSafe(strtolower($params['search'])) . "/'; ";
        }
        $dyn_top = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("MyVehicleArea");
        /************** Category Listing ********************/
        $str = "search_query=" . $srch_qry . $make_link . $model_link . $year_link . "&column=categories";
        //$str .= isset($params['brand']) ? "&brand=".MakeURLSafe($params['brand']) : '';
        $str .= isset($GLOBALS['ISC_SRCH_CATG_NAME']) ? "&catg_name=" . MakeURLSafe($GLOBALS['ISC_SRCH_CATG_NAME']) : '';
        $str .= isset($params['search']) ? "&searchtext=" . MakeURLSafe($params['search']) : '';
        $str .= isset($params['searchtext']) ? "&searchtext=" . MakeURLSafe($params['searchtext']) : '';
        $str .= isset($params['vqsbedsize']) ? "&vqsbedsize=" . MakeURLSafe($params['vqsbedsize']) : '';
        $str .= isset($params['vqscabsize']) ? "&vqscabsize=" . MakeURLSafe($params['vqscabsize']) : '';
        $str .= $this->GetOtherLinksForRedefine($params);
        $str .= $add_url_redefine;
        $dyn_top .= $this->GetCategoryListing($prod_categoryid, $count_categoryid, $str, (int) $numrows);
        /*------------ Brand Filter --------------------*/
        if (count($brand_id) > 0 || isset($params['brand'])) {
            $title = "<h2>Brand</h2>";
            //$dyn_filter .=  $filter1.$title.$filter2;
            $brand_link = "";
            $GLOBALS['dynid'] = "dyn_brand";
            $GLOBALS['Dynmainmenu'] = "Brand";
            $count_brand = 1;
            $extra = "";
            $str = "";
            $brand_string_array = $query_string_array;
            unset($brand_string_array['brand'], $brand_string_array['series'], $brand_string_array['search_query']);
            $get_mmy_links = "";
            $brand_string_new1 = "";
            if (isset($GLOBALS['ISC_SRCH_CATG_NAME'])) {
                $get_mmy_links .= MakeURLSafe(strtolower($GLOBALS['PathInfo'][1]));
                $brand_string_new1 .= MakeURLSafe(strtolower($GLOBALS['ISC_SRCH_CATG_NAME']));
            }
            /*else if(isset($GLOBALS['ISC_SRCH_BRAND_NAME']))
            		$get_mmy_links .= MakeURLSafe(strtolower($GLOBALS['ISC_SRCH_BRAND_NAME']));*/
            if ($get_mmy_links != "") {
                if ($GLOBALS['EnableSEOUrls'] == 1) {
                    $get_mmy_links = "/" . $get_mmy_links;
                }
            }
            /* this condition was added when brand & catg is selected and for clear functionality, no need to pass the $params['category'] */
            if (isset($params['brand']) && isset($params['category']) && strtolower($params['category']) == strtolower($GLOBALS['ISC_SRCH_CATG_NAME'])) {
                unset($brand_string_array['category']);
            }
            $get_mmy_links .= $this->GetYMMLinks($brand_string_array);
            $get_mmy_links .= $this->GetOtherLinks($params);
            foreach ($brand_string_array as $br_key => $br_val) {
                $brand_string_new1 .= "&" . $br_key . "=" . MakeURLSafe($br_val);
            }
            //$brand_string_new1 .= $sub_catg;
            if (isset($params['brand']) && !empty($params['brand'])) {
                $dyn_flag = 1;
                $params['brand'] = ucwords(strtolower($params['brand']));
                $dyn_filter .= <<<P2
        <li><img src='{$this->path}/templates/default/images/check.gif'>&nbsp;&nbsp;{$params['brand']}</li>
P2;
                if (strtolower($params['brand']) == strtolower(urldecode($srch_qry))) {
                    // if searched only by brand
                    $brandclearurl = "{$this->path}/search.php?search_query=brands";
                    $str = "search_query=";
                } else {
                    // if searched with other combinations
                    $search_query = trim(str_ireplace($params['brand'], '', MakeURLNormal($srch_qry)));
                    $brandclearurl = "{$this->path}/search.php?search_query=" . MakeURLSafe($search_query);
                    $str = "search_query=";
                    /* the below condition is added not to add the category name again as it is being added in $brand_string_new1 at the top */
                    if (strtolower($search_query) != strtolower(isset($GLOBALS['ISC_SRCH_CATG_NAME']) ? $GLOBALS['ISC_SRCH_CATG_NAME'] : '')) {
                        $str .= MakeURLSafe($search_query);
                    }
                }
                $str .= $brand_string_new1 . "&brand=" . MakeURLSafe($params['brand']) . "&column=prodbrandid";
                $str .= $this->GetOtherLinksForRedefine($params);
                $str .= $add_url_redefine;
                if (!empty($brand_string_new1)) {
                    $brandclearurl .= $brand_string_new1;
                }
                $GLOBALS['ClearURL'] = "<a href='" . $this->LeftClearLink($get_mmy_links) . "'>Clear</a>";
            } else {
                $other_brands = "";
                // this variables is used to show brand list in "other brands"
                $dyn_flag = 0;
                $brand_query = "select distinct brandid , brandname from [|PREFIX|]brands b inner join [|PREFIX|]products p on b.brandid = p.prodbrandid order by brandname asc ";
                $brand_result = $GLOBALS['ISC_CLASS_DB']->Query($brand_query);
                while ($brand_row = $GLOBALS['ISC_CLASS_DB']->Fetch($brand_result)) {
                    if (in_array($brand_row['brandid'], $brand_id)) {
                        $GLOBALS['BrandName'] = $brand_row['brandname'];
                        $search_query = $srch_qry;
                        if (urldecode($srch_qry) == 'brands' || urldecode($srch_qry) == 'categories') {
                            $search_query = MakeURLSafe($GLOBALS['BrandName']);
                        }
                        //$GLOBALS['BrandLink'] = "$this->path/search.php?search_query=$search_query$brand_string_new1&brand=".$brand_row['brandid'];
                        if (!isset($GLOBALS['ISC_SRCH_CATG_NAME'])) {
                            if ($GLOBALS['EnableSEOUrls'] == 1) {
                                $GLOBALS['BrandLink'] = $this->path . "/" . MakeURLSafe(strtolower($brand_row['brandname'])) . $get_mmy_links;
                            } else {
                                $GLOBALS['BrandLink'] = $this->path . "/search.php?search_query=" . MakeURLSafe($brand_row['brandname']) . $get_mmy_links;
                            }
                        } else {
                            $GLOBALS['BrandLink'] = $this->LeftLink($get_mmy_links, 'brand', strtolower($brand_row['brandname']));
                        }
                        if ($count_brand < 11) {
                            $dyn_filter .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilter1");
                        } else {
                            $extra .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilter1");
                        }
                        $count_brand++;
                    } else {
                        $ymm_links_for_brands = $this->GetClearFilterlink($params, 1);
                        $ymm_links_for_brands = rtrim($ymm_links_for_brands, "/");
                        $GLOBALS['BrandName'] = $brand_row['brandname'];
                        if ($GLOBALS['EnableSEOUrls'] == 1) {
                            $GLOBALS['BrandLink'] = $this->LeftLink($get_mmy_links, 'brand', strtolower($brand_row['brandname']));
                            //$GLOBALS['BrandLink'] = $this->path."/".MakeURLSafe(strtolower($brand_row['brandname'])).$ymm_links_for_brands;
                        } else {
                            $ymm_links_for_brands = str_replace('categories', MakeURLSafe(strtolower($brand_row['brandname'])), $ymm_links_for_brands);
                            $GLOBALS['BrandLink'] = $this->path . $ymm_links_for_brands;
                        }
                        $other_brands .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilter1");
                    }
                }
                $dyn_filter = "<ul>" . $dyn_filter . "</ul>";
                if ($count_brand > 11) {
                    $GLOBALS['FilterID'] = "brand";
                    $GLOBALS['ExtraValues'] = $extra;
                    $dyn_filter .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideFilterMoreLink");
                }
                // lguan_20100513: Added a condition to show other brand when user enter the product detail page without any search teams in session,
                //          So that the other brands will be available for user
                if ($other_brands != "" && (isset($params['srch_category']) || $showOtherBrandForDetail)) {
                    $GLOBALS['OtherBrands'] = $other_brands;
                    $dyn_filter .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("OtherBrands");
                }
                //$GLOBALS['ClearURL'] = "$this->path/search.php?search_query=$srch_qry$brand_string_new1";
                $GLOBALS['ClearURL'] = "";
            }
            if ($dyn_flag == 1) {
                //$str = "search_query=".$links.$model_link."&column=model";
                $GLOBALS['Dyndisplay1'] = "showlist";
                $GLOBALS['Dyndisplay'] = "hidelist";
                $GLOBALS['Dynimage'] = "imgHdrDropDownIconright.gif";
                $GLOBALS['DynFilterArrow'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilterImage");
                $GLOBALS['DynmenuFilter1'] = $dyn_filter;
                $GLOBALS['DynmenuFilter'] = "";
                $GLOBALS['JSfunction'] = "getvalueswithajax('" . $GLOBALS['dynid'] . "','{$str}');checkanimate('" . $GLOBALS['dynid'] . "')";
                //$GLOBALS['Dynimage'] = "imgHdrDropDownIconright.gif";
            } else {
                $GLOBALS['Dyndisplay1'] = "hidelist";
                $GLOBALS['Dyndisplay'] = "showlist";
                $GLOBALS['Dynimage'] = "imgHdrDropDownIcon.gif";
                $GLOBALS['DynFilterArrow'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilterImage");
                $GLOBALS['DynmenuFilter'] = $dyn_filter;
                $GLOBALS['DynmenuFilter1'] = "";
                $GLOBALS['JSfunction'] = "checkanimate('" . $GLOBALS['dynid'] . "')";
            }
            $dyn_output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductDynFilter");
            $dyn_filter = $dyn_output;
            if ($dyn_flag == 1) {
                $dyn_bottom .= $dyn_filter;
            } else {
                $dyn_top .= $dyn_filter;
            }
            $dyn_filter = "";
        }
        /*------------ Brand Filter ends --------------------*/
        /*------------ Submodel Filter - starts --------------------*/
        if (isset($params['model']) && $model_flag_link == 1 && (count($prod_submodel_new) > 0 || isset($params['submodel']))) {
            $GLOBALS['dynid'] = "dyn_submodel";
            $GLOBALS['Dynmainmenu'] = "Submodel";
            $count_sub_model = 1;
            $extra = "";
            $submodel_string = $query_string_array;
            unset($submodel_string['submodel'], $submodel_string['search_query']);
            $get_mmy_links = "";
            /*if(isset($GLOBALS['ISC_SRCH_CATG_NAME']))
            			$get_mmy_links .= MakeURLSafe(strtolower($GLOBALS['ISC_SRCH_CATG_NAME']));
            	else if(isset($GLOBALS['ISC_SRCH_BRAND_NAME']))
            			$get_mmy_links .= MakeURLSafe(strtolower($GLOBALS['ISC_SRCH_BRAND_NAME']));*/
            if (isset($params['search_query'])) {
                $get_mmy_links .= MakeURLSafe(strtolower($GLOBALS['PathInfo'][1]));
            }
            if ($get_mmy_links != "") {
                if ($GLOBALS['EnableSEOUrls'] == 1) {
                    $get_mmy_links = "/" . $get_mmy_links;
                }
            }
            $get_mmy_links .= $this->GetYMMLinks($submodel_string);
            $submodel_string_new1 = "";
            foreach ($submodel_string as $br_key => $br_val) {
                if (is_array($br_val)) {
                    $br_val = implode("&" . $br_key . "[]=", $br_val);
                    $br_key = $br_key . "[]";
                } else {
                    $br_val = MakeURLSafe($br_val);
                }
                $submodel_string_new1 .= "&" . $br_key . "=" . $br_val;
            }
            //$submodel_string_new1 .= $sub_catg;
            if (isset($params['submodel']) && !empty($params['submodel'])) {
                $params['submodel'] = ucwords(strtolower($params['submodel']));
                $dyn_flag = 1;
                $dyn_filter .= <<<P2
        <ul><li><img src='{$this->path}/templates/default/images/check.gif'>&nbsp;&nbsp;{$params['submodel']}</li></ul>
P2;
                $str = "search_query=" . $srch_qry;
                $submodelclearurl = $this->path . "/search.php?" . $str;
                $str .= $submodel_string_new1 . "&submodel=" . $params['submodel'] . "&column=submodel";
                $str .= $add_url_redefine;
                $submodelclearurl .= $submodel_string_new1;
                $GLOBALS['ClearURL'] = "<a href='" . $this->LeftClearLink($get_mmy_links) . $this->GetOtherLinks($params) . "'>Clear</a>";
            } else {
                $dyn_flag = 0;
                for ($s = 0; $s < count($prod_submodel_new); $s++) {
                    $GLOBALS['BrandName'] = $prod_submodel_new[$s];
                    $search_query = $srch_qry;
                    $GLOBALS['BrandLink'] = $this->LeftLink($get_mmy_links, 'submodel', $prod_submodel_new[$s]);
                    $GLOBALS['BrandLink'] .= $this->GetOtherLinks($params);
                    if ($count_sub_model < 11) {
                        $dyn_filter .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilter1");
                    } else {
                        $extra .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilter1");
                    }
                    $count_sub_model++;
                }
                $dyn_filter = "<ul>" . $dyn_filter . "</ul>";
                if ($count_sub_model > 11) {
                    $GLOBALS['FilterID'] = "submodel";
                    $GLOBALS['ExtraValues'] = $extra;
                    $dyn_filter .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideFilterMoreLink");
                }
                $GLOBALS['ClearURL'] = "";
            }
            if ($dyn_flag == 1) {
                //$str = "search_query=".$links.$model_link."&column=model";
                $GLOBALS['Dyndisplay1'] = "showlist";
                $GLOBALS['Dyndisplay'] = "hidelist";
                $GLOBALS['Dynimage'] = "imgHdrDropDownIconright.gif";
                $GLOBALS['DynFilterArrow'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilterImage");
                $GLOBALS['DynmenuFilter1'] = $dyn_filter;
                $GLOBALS['DynmenuFilter'] = "";
                $GLOBALS['JSfunction'] = "getvalueswithajax('" . $GLOBALS['dynid'] . "','{$str}');checkanimate('" . $GLOBALS['dynid'] . "')";
                //$GLOBALS['Dynimage'] = "imgHdrDropDownIconright.gif";
            } else {
                $GLOBALS['Dyndisplay1'] = "hidelist";
                $GLOBALS['Dyndisplay'] = "showlist";
                $GLOBALS['Dynimage'] = "imgHdrDropDownIcon.gif";
                $GLOBALS['DynFilterArrow'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilterImage");
                $GLOBALS['DynmenuFilter'] = $dyn_filter;
                $GLOBALS['DynmenuFilter1'] = "";
                $GLOBALS['JSfunction'] = "checkanimate('" . $GLOBALS['dynid'] . "')";
            }
            $dyn_output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductDynFilter");
            $dyn_filter = $dyn_output;
            if ($dyn_flag == 1) {
                $dyn_bottom .= $dyn_filter;
            } else {
                $dyn_top .= $dyn_filter;
            }
            $dyn_filter = "";
        }
        /*------------ Submodel Filter - ends --------------------*/
        /*-------- Other Filters -----------------------------------------*/
        if ((isset($params['catuniversal']) && $params['catuniversal'] == 1 || !empty($make_link) && (!empty($model_link) && (!isset($params['model_flag']) || $params['model_flag'] == 1)) && !empty($year_link)) && ($numrows > 0 || isset($_REQUEST['GO']) && $numrows > 0) && isset($GLOBALS['ISC_SRCH_CATG_ID'])) {
            //    include('includes/display/ProdDynamicFilters.php');
            $map_names = array();
            $filter_names = "select * from [|PREFIX|]qualifier_names";
            $filter_result = $GLOBALS['ISC_CLASS_DB']->Query($filter_names);
            while ($filter_row = $GLOBALS['ISC_CLASS_DB']->Fetch($filter_result)) {
                if ($filter_row['display_names'] != '') {
                    $map_names[$filter_row['column_name']]['name'] = $filter_row['display_names'];
                }
                $map_names[$filter_row['column_name']]['qid'] = $filter_row['qid'];
            }
            $query_string_new = $this->path . "/search.php?";
            $get_mmy_links = "";
            /*if(isset($GLOBALS['ISC_SRCH_CATG_NAME']) && !isset($params['category']))
            			$get_mmy_links .= MakeURLSafe(strtolower($GLOBALS['ISC_SRCH_CATG_NAME']));
            		else if(isset($GLOBALS['ISC_SRCH_BRAND_NAME']))
            			$get_mmy_links .= MakeURLSafe(strtolower($GLOBALS['ISC_SRCH_BRAND_NAME']));*/
            if (isset($params['search_query'])) {
                $get_mmy_links .= MakeURLSafe(strtolower($GLOBALS['PathInfo'][1]));
            }
            if ($get_mmy_links != "") {
                if ($GLOBALS['EnableSEOUrls'] == 1) {
                    $get_mmy_links = "/" . $get_mmy_links;
                }
            }
            $get_mmy_links .= $this->GetYMMLinks($params);
            $get_all_param_links = $this->GetOtherLinks($params);
            //$dyn_filter = "";
            for ($u = 0; $u < count($columns); $u++) {
                // loop for the filters . Here columns are the filters.
                if (eregi('^(vq|pq)', $columns[$u])) {
                    // checking whether the name of the column starts with vq or pq
                    if (isset($filterdata[$columns[$u]]) && count($filterdata[$columns[$u]]) > 0) {
                        $filter_var = array('vq', 'pq');
                        //$title = ucfirst(str_ireplace($filter_var,"",$columns[$u]));
                        if (!isset($map_names[$columns[$u]]['name']) || empty($map_names[$columns[$u]]['name'])) {
                            $title = ucfirst(str_ireplace($filter_var, "", $columns[$u]));
                        } else {
                            $title = $map_names[$columns[$u]]['name'];
                        }
                        $Qualifier_id = $map_names[$columns[$u]]['qid'];
                        $GLOBALS['CategoryId'] = isset($params['subcategory']) ? $this->subcatgid : $GLOBALS['ISC_SRCH_CATG_ID'];
                        $this->GetAssocDetails($GLOBALS['CategoryId'], $Qualifier_id, $OwnAssoc, $ParentAssoc, $OwnValue, $ParentValue);
                        $qvalue_mapping_array = $OwnAssoc;
                        /* The below code is added to have the values sorted in alphabetical order and "Others" added at the end - starts */
                        if ($columns[$u] == "PQbodylength" || $columns[$u] == "PQbodywidth") {
                            asort($filterdata[$columns[$u]], SORT_NUMERIC);
                        } else {
                            $temp_filterdata = array();
                            foreach ($filterdata[$columns[$u]] as $k => $kval) {
                                $CurrentValueItem = array();
                                $CurrentValueItem['vimage'] = '';
                                $CurrentValueItem['vname'] = '';
                                $CurrentValueItem['vcomments'] = '';
                                if (($m = array_search($kval, $OwnValue)) !== false) {
                                    $CurrentValueItem = $qvalue_mapping_array[$m];
                                    if ($CurrentValueItem['vname'] != '') {
                                        $kval = $CurrentValueItem['vname'];
                                    }
                                }
                                if ($CurrentValueItem['vimage'] == "" && $CurrentValueItem['vcomments'] == "" && $CurrentValueItem['vname'] == "") {
                                    if (($n = array_search($kval, $ParentValue)) !== false) {
                                        $CurrentValueItem = $ParentAssoc[$n];
                                        if ($CurrentValueItem['vname'] != '') {
                                            $kval = $CurrentValueItem['vname'];
                                        }
                                    }
                                }
                                $temp_filterdata[$k] = strtolower($kval);
                            }
                            asort($filterdata[$columns[$u]]);
                            asort($temp_filterdata);
                            $temp_arr1 = array_keys($temp_filterdata);
                            $temp_arr2 = array();
                            foreach ($temp_arr1 as $key) {
                                $temp_arr2[] = $filterdata[$columns[$u]][$key];
                            }
                            $filterdata[$columns[$u]] = array_combine($temp_arr1, $temp_arr2);
                        }
                        if (($others_key = array_search('Others', $filterdata[$columns[$u]])) !== FALSE) {
                            unset($filterdata[$columns[$u]][$others_key]);
                            $filterdata[$columns[$u]][$others_key] = 'Others';
                        }
                        /* - ends - */
                        $GLOBALS['dynid'] = "dyn" . ($u + 1);
                        //$GLOBALS['Dynmainmenu'] = $title;
                        $dyn_filter = "";
                        $extra = "";
                        // this is used to hide the values if exceed 10
                        $count_pqvq = 1;
                        //$dyn_filter .=  $filter1.$title.$filter2;
                        //for($k=0;$k<count($filterdata[$columns[$u]]);$k++)       // this loop is for showing the list in the filters column
                        foreach ($filterdata[$columns[$u]] as $k => $kval) {
                            //$countfilterdata[$key][$val]['count']
                            $value = $filterdata[$columns[$u]][$k];
                            $original_value = $filterdata[$columns[$u]][$k];
                            $GLOBALS['HoverImage'] = "";
                            $GLOBALS['Comments'] = "";
                            /*-------------- Below code is used to cehck comments in subcategory and main category ------------ */
                            $CurrentValueItem = array();
                            $CurrentValueItem['vimage'] = '';
                            $CurrentValueItem['vname'] = '';
                            $CurrentValueItem['vcomments'] = '';
                            if (($m = array_search($value, $OwnValue)) !== false) {
                                $CurrentValueItem = $qvalue_mapping_array[$m];
                            }
                            if ($CurrentValueItem['vimage'] == "" && $CurrentValueItem['vcomments'] == "" && $CurrentValueItem['vname'] == "") {
                                if (($n = array_search($value, $ParentValue)) !== false) {
                                    $CurrentValueItem = $ParentAssoc[$n];
                                }
                            }
                            if ($CurrentValueItem['vname'] != "" || $CurrentValueItem['vimage'] != "" || $CurrentValueItem['vcomments'] != "") {
                                if (!empty($CurrentValueItem['vname'])) {
                                    $value = $CurrentValueItem['vname'];
                                }
                                if (!empty($CurrentValueItem['vimage'])) {
                                    $file = realpath(ISC_BASE_PATH . '/' . GetConfig('ImageDirectory') . '/' . $CurrentValueItem['vimage']);
                                    if (file_exists($file)) {
                                        $GLOBALS['HoverImage'] = $this->path . "/" . GetConfig('ImageDirectory') . "/" . $CurrentValueItem['vimage'];
                                    }
                                }
                                $GLOBALS['Comments'] = $CurrentValueItem['vcomments'];
                            }
                            /*-------------- Below code is used to cehck comments in subcategory and main category Ends ------------ */
                            if (isset($params['dynfilters'][$columns[$u]]) && !empty($params['dynfilters'][$columns[$u]])) {
                                $dyn_flag = 1;
                                $query_string_mod_array = $query_string_array;
                                //*$query_string_mod_array[$columns[$u]]= "";
                                //$query_string_new1 = $query_string_new;
                                //*$query_string_new1 = "redefine_filters.php?";
                                $query_string_new1 = "";
                                $qualifierclearurl = "search.php?";
                                foreach ($query_string_mod_array as $qs_key => $qs_val) {
                                    //*if($query_string_new1 != $query_string_new)
                                    if (!empty($query_string_new1)) {
                                        $query_string_new1 .= "&";
                                    }
                                    if ($qs_key != "search_query") {
                                        $qs_val = MakeURLSafe($qs_val);
                                    }
                                    $query_string_new1 .= $qs_key . "=" . $qs_val;
                                    if ($qs_key != $columns[$u]) {
                                        if ($qualifierclearurl != "search.php?") {
                                            $qualifierclearurl .= "&";
                                        }
                                        $qualifierclearurl .= $qs_key . "=" . $qs_val;
                                    }
                                }
                                $get_qualifier_links = $this->GetOtherLinks($params, $columns[$u]);
                                if ($GLOBALS['EnableSEOUrls'] == 1) {
                                    $qualifierclearurl = $this->path . $get_mmy_links . $get_qualifier_links;
                                } else {
                                    $qualifierclearurl = $this->path . "/search.php?search_query=" . $get_mmy_links . $get_qualifier_links;
                                }
                                if (strtolower($original_value) == strtolower($params['dynfilters'][$columns[$u]])) {
                                    $GLOBALS['ClearURL'] = "<a href='{$qualifierclearurl}'>Clear</a>";
                                    $dyn_filter .= "<li><img src='{$this->path}/templates/default/images/check.gif'>&nbsp;&nbsp;" . ucwords($value) . "</li>";
                                    //*$dyn_filter .= "<li><a class='thickbox' href='$query_string_new1&column=$columns[$u]'><b>Redefine search...</b></a></li>";
                                    $str = "{$query_string_new1}&column=" . strtolower($columns[$u]);
                                    $str .= $add_url_redefine;
                                    break;
                                }
                            } else {
                                $dyn_flag = 0;
                                $query_string_mod_array = $query_string_array;
                                $query_string_new1 = $query_string_new . "search_query=" . $query_string_mod_array['search_query'];
                                unset($query_string_mod_array['search_query']);
                                //if(array_key_exists($columns[$u],$query_string_mod_array)) {
                                //$query_string_mod_array[$columns[$u]] = $original_value;
                                //}
                                foreach ($query_string_mod_array as $qs_key => $qs_val) {
                                    if ($query_string_new1 != $query_string_new) {
                                        $query_string_new1 .= "&";
                                    }
                                    if ($qs_key != "search_query") {
                                        $qs_val = MakeURLSafe($qs_val);
                                    }
                                    $query_string_new1 .= $qs_key . "=" . $qs_val;
                                }
                                //$GLOBALS['ClearURL'] = $query_string_new1;
                                $GLOBALS['ClearURL'] = "";
                                if ($GLOBALS['EnableSEOUrls'] == 1) {
                                    $query_string_new1 = "/" . strtolower($columns[$u]) . "/" . MakeURLSafe(strtolower($original_value));
                                    // this is added to pass the listing value
                                    $GLOBALS['QualifierLink'] = $this->path . $get_mmy_links . $get_all_param_links . $query_string_new1;
                                } else {
                                    $query_string_new1 = "&" . strtolower($columns[$u]) . "=" . MakeURLSafe(strtolower($original_value));
                                    // this is added to pass the listing value
                                    $GLOBALS['QualifierLink'] = $this->path . "/search.php?search_query=" . $get_mmy_links . $get_all_param_links . $query_string_new1;
                                }
                                $GLOBALS['QualifierId'] = $Qualifier_id;
                                $GLOBALS['QualifierValue'] = ucwords($value);
                                $GLOBALS['QualifierCount'] = $countfilterdata[$columns[$u]][$original_value]['count'];
                                //$dyn_filter .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilterValuesHoverImage");
                                //$dyn_filter .= "<li><a href='$query_string_new1'>".$value."</a> (".$countfilterdata[$columns[$u]][$value]['count'].")</li>";
                                if ($count_pqvq < 11) {
                                    $dyn_filter .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilterValuesHoverImage");
                                } else {
                                    $extra .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilterValuesHoverImage");
                                }
                                $count_pqvq++;
                            }
                        }
                        $dyn_filter = "<ul>" . $dyn_filter . "</ul>";
                        if ($count_pqvq > 11) {
                            $GLOBALS['FilterID'] = $GLOBALS['dynid'];
                            $GLOBALS['ExtraValues'] = $extra;
                            $dyn_filter .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideFilterMoreLink");
                        }
                        if ($dyn_flag == 1) {
                            //$str = "search_query=".$links.$model_link."&column=model";
                            $GLOBALS['Dyndisplay1'] = "showlist";
                            $GLOBALS['Dyndisplay'] = "hidelist";
                            $GLOBALS['Dynimage'] = "imgHdrDropDownIconright.gif";
                            $GLOBALS['DynFilterArrow'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilterImage");
                            $GLOBALS['DynmenuFilter1'] = $dyn_filter;
                            $GLOBALS['DynmenuFilter'] = "";
                            $GLOBALS['JSfunction'] = "getvalueswithajax('" . $GLOBALS['dynid'] . "','{$str}');checkanimate('" . $GLOBALS['dynid'] . "')";
                            //$GLOBALS['Dynimage'] = "imgHdrDropDownIconright.gif";
                        } else {
                            $GLOBALS['Dyndisplay1'] = "hidelist";
                            $GLOBALS['Dyndisplay'] = "showlist";
                            $GLOBALS['Dynimage'] = "imgHdrDropDownIcon.gif";
                            $GLOBALS['DynFilterArrow'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilterImage");
                            $GLOBALS['DynmenuFilter'] = $dyn_filter;
                            $GLOBALS['DynmenuFilter1'] = "";
                            $GLOBALS['JSfunction'] = "checkanimate('" . $GLOBALS['dynid'] . "')";
                        }
                        /* Filter Title related assiciation */
                        $CurrentItem = $qvalue_mapping_array[0];
                        if ($CurrentItem['qimage'] == "" && $CurrentItem['qcomments'] == "" && $CurrentItem['qname'] == "") {
                            $CurrentItem = $ParentAssoc[0];
                        }
                        if (isset($CurrentItem['qname']) && !empty($CurrentItem['qname'])) {
                            $GLOBALS['Dynmainmenu'] = $CurrentItem['qname'];
                        } else {
                            $GLOBALS['Dynmainmenu'] = $title;
                        }
                        $mover_comment = "";
                        if (isset($CurrentItem) && !empty($CurrentItem['qcomments'])) {
                            $mover_comment = $CurrentItem['qcomments'];
                        }
                        $mover_image = "";
                        if (isset($CurrentItem['qimage']) && !empty($CurrentItem['qimage'])) {
                            $file = realpath(ISC_BASE_PATH . '/' . GetConfig('ImageDirectory') . '/' . $CurrentItem['qimage']);
                            if (file_exists($file)) {
                                $mover_image = $GLOBALS['SITEPATH'] . "/" . GetConfig('ImageDirectory') . "/" . $CurrentItem['qimage'];
                            }
                        }
                        $GLOBALS['MouseoverFn'] = "loadHoverImage(event, '" . $mover_image . "', '" . $mover_comment . "');";
                        $GLOBALS['MouseoutFn'] = "hideTip();";
                        $dyn_output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductDynFilter");
                        //$dyn_filter .=  $filter3;
                        if ($dyn_flag == 1) {
                            $dyn_bottom .= $dyn_output;
                        } else {
                            $dyn_top .= $dyn_output;
                        }
                        $dyn_filter = "";
                        //$dyn_filter .=  $filter3;
                    }
                }
            }
            $dyn_filter = $dyn_top . $dyn_bottom;
            /* form action */
            $qry_string = $_SERVER['QUERY_STRING'];
            if (isset($_REQUEST['page'])) {
                $page = $_REQUEST['page'];
                $search_link = str_ireplace('&page=' . $page, '', $qry_string);
            } else {
                $search_link = $qry_string;
            }
            $GLOBALS['formaction'] = "search.php?" . $search_link;
        } else {
            $GLOBALS['HideSideProductFiltersPanelPrice'] = "none";
        }
        $dyn_filter = $dyn_top . $dyn_bottom;
        $GLOBALS['DynFilter'] = $dyn_filter;
        if (!isset($params['flag_srch_category']) || $params['flag_srch_category'] == 0 || !eregi('search.php', $_SERVER['REQUEST_URI'])) {
            $GLOBALS['HideSideProductFiltersPanelPrice'] = "none";
        } else {
            $GLOBALS['HideSideProductFiltersPanelPrice'] = "block";
        }
        $GLOBALS['FromPrice'] = "0.00";
        if (isset($_REQUEST['price_from'])) {
            $GLOBALS['FromPrice'] = $_REQUEST['price_from'];
        }
        if (isset($_REQUEST['price_to'])) {
            $GLOBALS['ToPrice'] = $_REQUEST['price_to'];
        }
        if (empty($output1) && empty($output2) && empty($output)) {
            $this->DontDisplay = true;
        }
        /*$output = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseSnippets($output, $GLOBALS['SNIPPETS']);
        		$GLOBALS['SNIPPETS']['SideProductFilter1'] = $output;*/
    }
Esempio n. 3
0
 /**
  *	Run the full text searches to find matching products
  */
 function DoSearch($Start, &$Search_Result, &$Search_Count)
 {
     $category_ids = array();
     $params = $this->_searchterms;
     // Build the search query using our terms & the fields we want
     $searchQueries = BuildProductSearchQuery($this->_searchterms);
     $orderby = "";
     /* the below 4 lines has been added to group by SKU or by catid as same sku was showing in multiple products by vikas*/
     if (isset($params['flag_srch_brand']) && $params['flag_srch_brand'] == 0 && $GLOBALS['BRAND_SERIES_FLAG'] == 0 && (!isset($params['srch_category']) || isset($params['category'])) && !isset($params['partnumber'])) {
         $GLOBALS['results_page_flag'] = 1;
         $group = " group by p.brandseriesid ";
         $orderby = $searchQueries['orderby'];
         $seo_query = "select brandname , brandpagetitle , brandmetakeywords , brandmetadesc  , controlscript , trackingscript from [|PREFIX|]brands where brandname = '" . $params['brand'] . "'";
         $seo_result = $GLOBALS['ISC_CLASS_DB']->Query($seo_query);
         $seo_array = $GLOBALS['ISC_CLASS_DB']->Fetch($seo_result);
         /* the below lines assign meta discription, keywords and title for the brand*/
         if (isset($seo_array['brandmetakeywords'])) {
             $GLOBALS['ISC_CLASS_TEMPLATE']->SetMetaKeywords($seo_array['brandmetakeywords']);
         }
         if (isset($seo_array['brandmetadesc'])) {
             $GLOBALS['ISC_CLASS_TEMPLATE']->SetMetaDescription($seo_array['brandmetadesc']);
         }
         if ($seo_array['brandpagetitle'] != "") {
             $this->_pagetitle = $seo_array['brandpagetitle'];
         } else {
             $this->_pagetitle = $seo_array['brandname'];
         }
         $GLOBALS['CategoryTrackingCodeTop'] = isset($seo_array['controlscript']) ? $seo_array['controlscript'] : '';
         $GLOBALS['CategoryTrackingCodeBottom'] = isset($seo_array['trackingscript']) ? $seo_array['trackingscript'] : '';
     } else {
         if (isset($params['flag_srch_category']) && $params['flag_srch_category'] == 0 && (!isset($GLOBALS['BRAND_SERIES_FLAG']) || isset($GLOBALS['BRAND_SERIES_FLAG']) && $GLOBALS['BRAND_SERIES_FLAG'] == 0) && !isset($params['partnumber'])) {
             $GLOBALS['results_page_flag'] = 0;
             $group = " group by c.categoryid ";
             $orderby = $searchQueries['orderby'];
             /* below template variables are added for subcategory page to add category specific tracking code*/
             if (isset($params['srch_category'])) {
                 $selected_catg = end($params['srch_category']);
                 if ($selected_catg != '') {
                     $script_query = "select catname , catpagetitle , catmetakeywords , catmetadesc , controlscript , trackingscript from [|PREFIX|]categories where categoryid = " . $selected_catg;
                     $script_result = $GLOBALS['ISC_CLASS_DB']->Query($script_query);
                     $script_array = $GLOBALS['ISC_CLASS_DB']->Fetch($script_result);
                     $GLOBALS['CategoryTrackingCodeTop'] = $script_array['controlscript'];
                     $GLOBALS['CategoryTrackingCodeBottom'] = $script_array['trackingscript'];
                     /* the below lines assign meta discription, keywords and title for the categories*/
                     $GLOBALS['ISC_CLASS_TEMPLATE']->SetMetaKeywords($script_array['catmetakeywords']);
                     $GLOBALS['ISC_CLASS_TEMPLATE']->SetMetaDescription($script_array['catmetadesc']);
                     if ($script_array['catpagetitle'] != "") {
                         $this->_pagetitle = $script_array['catpagetitle'];
                     } else {
                         $this->_pagetitle = $script_array['catname'];
                     }
                 }
             }
         } else {
             $GLOBALS['results_page_flag'] = 2;
             $group = " group by p.productid ";
             if (isset($_REQUEST['orderby']) && !empty($_REQUEST['orderby'])) {
                 if ($_REQUEST['orderby'] == "brandname") {
                     $orderby = " order by brandname " . (isset($_REQUEST['sortby']) ? $_REQUEST['sortby'] : "asc") . " , seriesname ";
                 } else {
                     $orderby = " order by " . $_REQUEST['orderby'] . " ";
                 }
             } else {
                 $orderby = " order by p.prodprice ";
             }
             if (isset($_REQUEST['sortby']) && !empty($_REQUEST['sortby'])) {
                 $orderby .= $_REQUEST['sortby'];
             } else {
                 $orderby .= " asc";
             }
             if (isset($params['brand'])) {
                 $seo_query = "select brandname , brandpagetitle , brandmetakeywords , brandmetadesc from [|PREFIX|]brands where brandname = '" . $params['brand'] . "'";
                 $seo_result = $GLOBALS['ISC_CLASS_DB']->Query($seo_query);
                 $brand_array = $GLOBALS['ISC_CLASS_DB']->Fetch($seo_result);
                 $GLOBALS['ISC_CLASS_TEMPLATE']->SetMetaKeywords($brand_array['brandmetakeywords']);
                 $GLOBALS['ISC_CLASS_TEMPLATE']->SetMetaDescription($brand_array['brandmetadesc']);
                 if ($brand_array['brandpagetitle'] != "") {
                     $this->_pagetitle = $brand_array['brandpagetitle'];
                 } else {
                     $this->_pagetitle = $brand_array['brandname'];
                 }
             }
             if (isset($params['series'])) {
                 $seo_query = "select seriesname , seriespagetitle , seriesmetakeywords , seriesmetadesc from [|PREFIX|]brand_series where seriesname = '" . $params['series'] . "'";
                 $seo_result = $GLOBALS['ISC_CLASS_DB']->Query($seo_query);
                 $series_array = $GLOBALS['ISC_CLASS_DB']->Fetch($seo_result);
                 /* the below lines assign meta discription, keywords and title for the brand*/
                 if (!empty($series_array['seriesmetakeywords'])) {
                     $GLOBALS['ISC_CLASS_TEMPLATE']->SetMetaKeywords($series_array['seriesmetakeywords']);
                 }
                 if (!empty($series_array['seriesmetadesc'])) {
                     $GLOBALS['ISC_CLASS_TEMPLATE']->SetMetaDescription($series_array['seriesmetadesc']);
                 }
                 if (!empty($series_array['seriespagetitle'])) {
                     $this->_pagetitle = $series_array['seriespagetitle'];
                 } else {
                     $this->_pagetitle = $series_array['seriesname'];
                 }
             } else {
                 if (isset($params['srch_category']) && !isset($params['category'])) {
                     $selected_catg = end($params['srch_category']);
                     if ($selected_catg != '') {
                         $script_query = "select catname , catpagetitle , catmetakeywords , catmetadesc , controlscript , trackingscript from [|PREFIX|]categories where categoryid = " . $selected_catg;
                         $script_result = $GLOBALS['ISC_CLASS_DB']->Query($script_query);
                         $script_array = $GLOBALS['ISC_CLASS_DB']->Fetch($script_result);
                         $GLOBALS['CategoryTrackingCodeTop'] = $script_array['controlscript'];
                         $GLOBALS['CategoryTrackingCodeBottom'] = $script_array['trackingscript'];
                         /* the below lines assign meta discription, keywords and title for the categories */
                         $GLOBALS['ISC_CLASS_TEMPLATE']->SetMetaKeywords($script_array['catmetakeywords']);
                         $GLOBALS['ISC_CLASS_TEMPLATE']->SetMetaDescription($script_array['catmetadesc']);
                         if ($script_array['catpagetitle'] != "") {
                             $this->_pagetitle = $script_array['catpagetitle'];
                         } else {
                             $this->_pagetitle = $script_array['catname'];
                         }
                     }
                 }
             }
         }
     }
     /* the below three lines has been added to group by SKU as same sku was showing in multiple products */
     $searchQueries['query'] .= $group . $GLOBALS['having_query'] . $orderby;
     $searchQueries['countQuery'] .= $group . $GLOBALS['having_query'];
     /*
     $searchQueries['query'] .= $group.$orderby;
     $searchQueries['countQuery'] .= $group;
     */
     //$searchQueries['countQuery'] = "select count(*) from ( ".$searchQueries['countQuery']." ) p ";
     $count_res = $GLOBALS['ISC_CLASS_DB']->Query($searchQueries['countQuery']);
     $Search_Count = $GLOBALS['ISC_CLASS_DB']->CountResult($count_res);
     // Run the query
     //$Search_Count = $GLOBALS['ISC_CLASS_DB']->FetchOne($searchQueries['countQuery']);
     // Add the limit
     $searchQueries['query'] .= $GLOBALS['ISC_CLASS_DB']->AddLimit($Start, GetConfig('CategoryProductsPerPage'));
     $Search_Result = $GLOBALS['ISC_CLASS_DB']->Query($searchQueries['query']);
     $GLOBALS['DoSearchQuery'] = $searchQueries['query'];
 }
    function SetPanelSettings()
    {
        $output = "";
        $all_makes = array('CHEVROLET', 'GMC', 'FORD', 'DODGE', 'TOYOTA', 'NISSAN', 'HONDA', 'JEEP', 'HYUNDAI', 'CHRYSLER', 'INFINITI', 'LEXUS');
        $colours = array('Red', 'Navy', 'Green', 'Brown', 'Black', 'Silver', 'Dark Gray', 'Tan', 'White');
        $prod_make = array();
        $prod_model = array();
        $prod_year = array();
        $prod_price = array();
        $prod_categoryid = array();
        $count_categoryid = array();
        $brand_id = array();
        $make_link = "";
        $model_link = "";
        $model_flag_link = 0;
        $submodel_link = "";
        $year_link = "";
        $sub_modelrow = array();
        $GLOBALS['SITEPATH'] = GetConfig('ShopPath');
        // Get the link to the "all brands" page
        $GLOBALS['AllBrandsLink'] = BrandLink();
        $params = $this->searchterms;
        if (empty($params)) {
            $params['dynfilters'] = array();
        }
        /*--- Here when brand series is searched directly , brand series is set in seesion to be accessed in other pages --- */
        if (isset($params['brand_series']) && !empty($params['brand_series'])) {
            $_SESSION['searchterms']['brand_series'] = $params['brand_series'];
        }
        // Build the search query using our terms & the fields we want
        $column_concat = " p.productid , p.prodcode , group_concat(DISTINCT c.categoryid separator '~') as categoryid, group_concat(DISTINCT prodbrandid separator '~') as prodbrandid ";
        $column_concat .= " , group_concat(DISTINCT v.prodmake separator '~') as prodmake , group_concat(DISTINCT v.prodmodel separator '~') as prodmodel , group_concat(DISTINCT v.prodsubmodel separator '~') as prodsubmodel , group_concat(v.prodstartyear separator '~') as prodstartyear , group_concat(v.prodendyear separator '~') as prodendyear ";
        if (isset($params['catuniversal']) && $params['catuniversal'] == 1) {
            // this condition has been added as universal category shd be shown only PQ's
            $column_names = $GLOBALS['p_cols'];
            for ($j = 0; $j < count($column_names); $j++) {
                $column_concat .= " , group_concat(DISTINCT " . $column_names[$j] . " separator '~') as  " . $column_names[$j];
            }
        } else {
            if (isset($params['make']) && !empty($params['make']) && (isset($params['model']) && !empty($params['model']) && (!isset($params['model_flag']) || $params['model_flag'] == 1)) && isset($params['year']) && !empty($params['year']) && isset($GLOBALS['ISC_SRCH_CATG_ID'])) {
                $column_names = array_merge($GLOBALS['v_cols'], $GLOBALS['p_cols']);
                for ($j = 0; $j < count($column_names); $j++) {
                    if (stristr($column_names[$j], 'VQbedsize')) {
                        $column_names[$j] = 'VQbedsize';
                    }
                    if (stristr($column_names[$j], 'VQcabsize')) {
                        $column_names[$j] = 'VQcabsize';
                    }
                    if (eregi('^(vq)', $column_names[$j])) {
                        // the below 2 cases are added for checking only in bedsize and cabsize
                        if ($column_names[$j] == 'VQbedsize' or $column_names[$j] == 'VQcabsize') {
                            if (strcasecmp($column_names[$j], 'VQbedsize') == 0) {
                                $column_concat .= " , group_concat( DISTINCT if( v.bedsize_generalname != '', v.bedsize_generalname, v.VQbedsize ) separator '~' ) as  " . $column_names[$j];
                            } else {
                                $column_concat .= " , group_concat( DISTINCT if( v.cabsize_generalname != '', v.cabsize_generalname, v.VQcabsize ) separator '~' ) as  " . $column_names[$j];
                            }
                        } else {
                            $column_concat .= " , group_concat(DISTINCT v." . $column_names[$j] . " separator '~') as  " . $column_names[$j];
                        }
                    } else {
                        if (eregi('^(pq)', $column_names[$j])) {
                            $column_concat .= " , group_concat(DISTINCT " . $column_names[$j] . " separator '~') as  " . $column_names[$j];
                        }
                    }
                }
            }
        }
        $searchQueries = BuildProductSearchQuery($this->searchterms);
        $searchQueries['query'] = str_replace('USE INDEX (categoryid)', 'USE INDEX (PRIMARY)', $searchQueries['query']);
        //$searchQueries['query'] = str_replace('temp.*',$column_concat,$searchQueries['query']);
        $searchQueries['query'] = str_replace($GLOBALS['srch_where'], $column_concat, $searchQueries['query']);
        $searchQueries['query'] .= " group by p.productid ";
        $Search_Result1 = $GLOBALS['ISC_CLASS_DB']->Query($searchQueries['query']);
        $numrows = $GLOBALS['ISC_CLASS_DB']->CountResult($Search_Result1);
        $flag = 0;
        // this flag is used to avoid executing query again and again for submodels
        $filterdata = array();
        $countfilterdata = array();
        $sku = array();
        $count_model['all']['count'] = 0;
        $sub_model_flag = 0;
        $sub_catg = "";
        if (!isset($params['model_flag']) || isset($params['model_flag']) && $params['model_flag'] == 1) {
            $model_flag_link = 1;
        }
        $strtocheck = '^(vq|pq)';
        if (isset($_REQUEST['sub_category'])) {
            $sub_catg = "&sub_category=" . $_REQUEST['sub_category'];
        }
        if (isset($params['brand_series'])) {
            $sub_catg .= "&brand_series=" . $params['brand_series'];
        }
        while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($Search_Result1)) {
            $temp_prod_year = array();
            $grp_make = explode("~", $row['prodmake']);
            $grp_model = explode("~", $row['prodmodel']);
            if ($row['prodsubmodel'] != '~') {
                $grp_submodel = explode("~", $row['prodsubmodel']);
            } else {
                $grp_submodel = "";
            }
            $grp_startyear = explode("~", $row['prodstartyear']);
            $grp_endyear = explode("~", $row['prodendyear']);
            $grp_brandid = explode("~", $row['prodbrandid']);
            $grp_categoryid = explode("~", $row['categoryid']);
            $columns = array_keys($row);
            foreach ($row as $key => $val) {
                if (eregi($strtocheck, $key)) {
                    $grp_dyn = explode('~', $row[$key]);
                    for ($g = 0; $g < count($grp_dyn); $g++) {
                        $val = strtolower($grp_dyn[$g]);
                        if (!empty($val)) {
                            $filter_value = explode(";", $val);
                            for ($k = 0; $k < count($filter_value); $k++) {
                                $val = $filter_value[$k];
                                if (!isset($filterdata[$key])) {
                                    $filterdata[$key][] = $val;
                                    $countfilterdata[$key][$val]['count'] = 1;
                                } else {
                                    if (!in_array($val, $filterdata[$key])) {
                                        $filterdata[$key][] = $val;
                                        $countfilterdata[$key][$val]['count'] = 1;
                                    } else {
                                        $countfilterdata[$key][$val]['count']++;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            $prod_id[] = $row['productid'];
            for ($g = 0; $g < count($grp_brandid); $g++) {
                if ($grp_brandid[$g] != 0) {
                    $brand_id[] = $grp_brandid[$g];
                }
            }
            for ($g = 0; $g < count($grp_categoryid); $g++) {
                if ($grp_categoryid[$g] != "") {
                    if (!in_array($grp_categoryid[$g], $prod_categoryid)) {
                        $prod_categoryid[] = $grp_categoryid[$g];
                        $count_categoryid[$grp_categoryid[$g]]['count'] = 1;
                    } else {
                        $count_categoryid[$grp_categoryid[$g]]['count']++;
                    }
                }
            }
            for ($g = 0; $g < count($grp_make); $g++) {
                if ($grp_make[$g] != '') {
                    $product_make = strtoupper($grp_make[$g]);
                    if ($product_make != "NON-SPEC VEHICLE") {
                        // this condition is addded not to show "NON-SPEC VEHICLE" in list
                        if (!in_array($product_make, $prod_make)) {
                            $prod_make[] = $product_make;
                            $count_make[$product_make]['count'] = 1;
                        } else {
                            $count_make[$product_make]['count']++;
                        }
                    }
                }
            }
            if (isset($params['submodel']) && !empty($params['submodel'])) {
                $sub_model_flag = 1;
                if (!in_array($params['submodel'], $prod_model)) {
                    $prod_model[] = $params['submodel'];
                    $count_model[$params['submodel']]['count'] = 1;
                } else {
                    $count_model[$params['submodel']]['count']++;
                }
            } else {
                if (isset($params['model']) && !empty($params['model']) && $model_flag_link == 1) {
                    for ($g = 0; $g < count($grp_submodel); $g++) {
                        if (!empty($grp_submodel[$g])) {
                            $sub_model_flag = 1;
                            if (!in_array($grp_submodel[$g], $prod_model)) {
                                $prod_model[] = $grp_submodel[$g];
                                $count_model[$grp_submodel[$g]]['count'] = 1;
                            } else {
                                $count_model[$grp_submodel[$g]]['count']++;
                            }
                        } else {
                            if (empty($grp_submodel[$g])) {
                                if (!in_array('ALL', $prod_model)) {
                                    $prod_model[] = 'ALL';
                                    $count_model['ALL']['count'] = 1;
                                } else {
                                    $count_model['ALL']['count']++;
                                }
                            }
                        }
                    }
                } else {
                    for ($g = 0; $g < count($grp_model); $g++) {
                        if (strtolower($grp_model[$g]) != 'all') {
                            // this condition is added not to show "All" in list
                            $sub_model_flag = 1;
                            if (!in_array($grp_model[$g], $prod_model)) {
                                $prod_model[] = $grp_model[$g];
                                $count_model[$grp_model[$g]]['count'] = 1;
                            } else {
                                $count_model[$grp_model[$g]]['count']++;
                            }
                        }
                    }
                }
            }
            for ($g = 0; $g < count($grp_startyear); $g++) {
                $prod_start_year = $grp_startyear[$g];
                $prod_end_year = $grp_endyear[$g];
                if (empty($prod_end_year)) {
                    $prod_end_year = $prod_start_year;
                }
                if (strtolower($prod_start_year) != "all") {
                    // this condition is addded not to show "All" in list
                    if (is_numeric($prod_start_year) && is_numeric($prod_end_year)) {
                        $prod_year_diff = $prod_end_year - $prod_start_year;
                    }
                    if (!is_numeric($prod_start_year) && !is_numeric($prod_end_year)) {
                        if (!in_array($prod_start_year, $temp_prod_year)) {
                            $temp_prod_year[] = $prod_start_year;
                        }
                    } else {
                        if (isset($params['year']) && !empty($params['year'])) {
                            if (in_array($params['year'], $prod_year)) {
                                $count_year[$params['year']]['count']++;
                            } else {
                                $prod_year[] = $params['year'];
                                $count_year[$params['year']]['count'] = 1;
                            }
                        } else {
                            for ($i = 0; $i <= $prod_year_diff; $i++) {
                                $actual_year = $prod_start_year + $i;
                                if (!in_array($actual_year, $temp_prod_year)) {
                                    $temp_prod_year[] = $actual_year;
                                }
                            }
                        }
                    }
                }
            }
            for ($k = 0; $k < count($temp_prod_year); $k++) {
                if (!in_array($temp_prod_year[$k], $prod_year)) {
                    $prod_year[] = $temp_prod_year[$k];
                    $count_year[$temp_prod_year[$k]]['count'] = 1;
                } else {
                    $count_year[$temp_prod_year[$k]]['count']++;
                }
            }
        }
        $prod_make_new = array_unique($prod_make);
        asort($prod_make_new);
        $prod_model_new = array_unique($prod_model);
        asort($prod_model_new);
        $prod_year_new = array_unique($prod_year);
        arsort($prod_year_new);
        $srch_qry = isset($params['search_query']) ? $params['search_query'] : (isset($params['search_query_adv']) ? $params['search_query_adv'] : '');
        $srch_qry = urlencode($srch_qry);
        $brand_id = array_unique($brand_id);
        $brand_id = array_values($brand_id);
        if (isset($params['make']) && !empty($params['make'])) {
            $make_link = "&make=" . urlencode($params['make']);
        }
        if (isset($params['year']) && !empty($params['year'])) {
            $year_link = "&year=" . $params['year'];
        }
        if (isset($params['model']) && !empty($params['model'])) {
            $model_link = "&model=" . urlencode($params['model']);
        }
        if (isset($params['model_flag']) && $params['model_flag'] == 0) {
            $model_link .= "&model_flag=0";
        }
        if (isset($params['submodel']) && !empty($params['submodel'])) {
            $submodel_link = "&submodel=" . urlencode($params['submodel']);
        }
        if (isset($params['partnumber'])) {
            $_GET['partnumber'] = $params['partnumber'];
        }
        $query_string_array = $_GET;
        if (isset($params['make'])) {
            $query_string_array['make'] = $params['make'];
        }
        if (isset($params['model'])) {
            $query_string_array['model'] = $params['model'];
        }
        if (isset($params['model_flag']) && $params['model_flag'] == 0) {
            $query_string_array['model_flag'] = $params['model_flag'];
        }
        if (isset($params['year'])) {
            $query_string_array['year'] = $params['year'];
        }
        foreach ($params['dynfilters'] as $key => $value) {
            $query_string_array[$key] = $value;
        }
        $query_string_array['search_query'] = $srch_qry;
        unset($query_string_array['page'], $query_string_array['search_key'], $query_string_array['x'], $query_string_array['y'], $query_string_array['sortby'], $query_string_array['orderby'], $query_string_array['change'], $query_string_array['product'], $query_string_array['refer']);
        $mmy_string_array = $query_string_array;
        unset($mmy_string_array['make'], $mmy_string_array['model'], $mmy_string_array['submodel'], $mmy_string_array['year'], $mmy_string_array['search_query']);
        $mmy_string_new1 = "";
        foreach ($mmy_string_array as $mmy_key => $mmy_val) {
            $mmy_string_new1 .= "&" . $mmy_key . "=" . $mmy_val;
        }
        $dyn_filter = "";
        // this is the main variable which is used for assigning to the global variable
        $dyn_top = "";
        // this is the variable which will remain on top of the filters
        $dyn_bottom = "";
        // this is the variable which will remain at bottom of the filters
        $dyn_flag = 0;
        // this is the variable which will check which are at top or bottom in the filters, 0 for top and 1 for bottom
        if (isset($params['make']) || isset($params['model']) && $model_flag_link == 1 || isset($params['year'])) {
            $mmy_clear_links = $this->path . "/search.php?search_query=" . urlencode($params['search_query']);
            if (isset($params['brand'])) {
                $mmy_clear_links .= "&brand=" . $params['brand'];
            }
            $GLOBALS['DynMsg'] = "<a href='" . $mmy_clear_links . "&change=1'>Clear my Vehicle</a>";
            $GLOBALS['RemoveBackgroundImage'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("RemoveBgImage");
        }
        if (isset($params['make']) && (isset($params['model']) && $model_flag_link == 1) && isset($params['year']) && !isset($_REQUEST['change'])) {
            // if MMY is selected
            $GLOBALS['MyVehicleAreaHeader'] = $params['year'] . " " . $params['make'] . " " . $params['model'];
            $GLOBALS['DynmenuFilter'] = "";
        } else {
            $GLOBALS['MyVehicleAreaHeader'] = "Choose My Vehicle";
            $GLOBALS['DynmenuFilter'] = "";
        }
        /*-------- Year -----------------------------------------*/
        $GLOBALS['MouseoverFn'] = "this.style.cursor='pointer'";
        $extra_year = "";
        //if( !empty($make_link) || !empty($year_link) || !empty($model_link) ) {
        if (empty($year_link) || !empty($year_link)) {
            $GLOBALS['dynid'] = "prod_year";
            $GLOBALS['Dynmainmenu'] = "Year";
            $output2 = "";
            $year_counter = 1;
            if (count($prod_year_new) > 0) {
                foreach ($prod_year_new as $key => $value) {
                    if (!isset($_REQUEST['change'])) {
                        // when clicked on "clear my vehicle", need to pass the value in the search query to get all Make and year
                        $GLOBALS['BrandLink'] = "{$this->path}/search.php?search_query=" . $srch_qry;
                    } else {
                        $GLOBALS['BrandLink'] = "{$this->path}/search.php?search_query={$value}";
                    }
                    if (!empty($make_link)) {
                        $GLOBALS['BrandLink'] .= $make_link;
                    }
                    if (!empty($model_link)) {
                        $GLOBALS['BrandLink'] .= $model_link;
                    }
                    if (!empty($submodel_link) && isset($_REQUEST['submodel'])) {
                        $GLOBALS['BrandLink'] .= $submodel_link;
                    }
                    if (!empty($year_link)) {
                        $GLOBALS['BrandLink'] .= $year_link;
                    } else {
                        $GLOBALS['BrandLink'] .= "&year=" . $value;
                    }
                    $GLOBALS['BrandLink'] .= $mmy_string_new1;
                    $GLOBALS['BrandLink'] .= $sub_catg;
                    $GLOBALS['BrandName'] = isc_html_escape($value);
                    $GLOBALS['BrandCount'] = $count_year[$value]['count'];
                    if (!empty($year_link)) {
                        if ($GLOBALS['BrandName'] == 'ALL' && $GLOBALS['BrandName'] != $params['year']) {
                            $GLOBALS['BrandName'] = $params['year'];
                            //$output2 .= "<li>".$params['year']."</li>";
                            $output2 .= "<li></li>";
                        } else {
                            $GLOBALS['BrandName'] = $value;
                            //$output2 .= "<li>$value</li>";
                            $output2 .= "<li></li>";
                        }
                        $dyn_flag = 1;
                        break;
                        // break has been added to display only single listing.
                    } else {
                        $dyn_flag = 0;
                        if ($year_counter < 11) {
                            $output2 .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilter3");
                            $year_counter++;
                        } else {
                            $extra_year .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilter3");
                        }
                    }
                }
            } else {
                if (isset($params['year'])) {
                    $dyn_flag = 1;
                    $GLOBALS['BrandName'] = $params['year'];
                    $output2 .= "<li>" . $params['year'] . "</li>";
                }
            }
            $output2 = "<ul>" . $output2 . "</ul>";
            /* the below code is used to apply more link if records exceed 10 */
            if ($year_counter > 11) {
                $GLOBALS['FilterID'] = "year";
                $GLOBALS['ExtraValues'] = $extra_year;
                $output2 .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideFilterMoreLink");
            }
            $output2 = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseSnippets($output2, $GLOBALS['SNIPPETS']);
            //if( !empty($_REQUEST['year']) && !empty($year_link) ) {
            $links_year = $srch_qry;
            if (!empty($year_link)) {
                $links_year .= $year_link;
                if (!empty($make_link)) {
                    $links_year .= $make_link;
                }
                if (!empty($model_link) && isset($_REQUEST['model'])) {
                    $links_year .= $model_link;
                }
                if (!empty($submodel_link) && isset($_REQUEST['submodel'])) {
                    $links_year .= $submodel_link;
                }
            }
            if (isset($params['brand'])) {
                $links_year .= "&brand=" . $params['brand'];
            }
            if (isset($params['brand_series'])) {
                $links_year .= "&brand_series=" . $params['brand_series'];
            }
            /* this below lines are not to display the year when clear is clicked */
            if (isset($_REQUEST['change'])) {
                $GLOBALS['BrandName'] = "";
            }
            if ($dyn_flag == 1 || isset($_REQUEST['change'])) {
                $str = "search_query=" . $links_year . $sub_catg . "&column=year";
                $GLOBALS['Dyndisplay1'] = "block";
                $GLOBALS['Dyndisplay'] = "none";
                $GLOBALS['Dynimage'] = "imgHdrDropDownIconright.gif";
                $GLOBALS['DynFilterArrow'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilterImage");
                //$GLOBALS['DynFilterArrow'] .= "&nbsp;&nbsp;&nbsp;".$GLOBALS['BrandName'];
                $GLOBALS['DynmenuFilter1'] = $output2;
                $GLOBALS['DynmenuFilter'] = "";
                $GLOBALS['JSfunction'] = "getvalueswithajax('" . $GLOBALS['dynid'] . "','{$str}');checkanimate('" . $GLOBALS['dynid'] . "')";
            } else {
                $GLOBALS['BrandName'] = "";
                $GLOBALS['Dyndisplay1'] = "none";
                $GLOBALS['Dyndisplay'] = "block";
                $GLOBALS['Dynimage'] = "imgHdrDropDownIconright.gif";
                $GLOBALS['DynFilterArrow'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilterImage");
                $GLOBALS['DynmenuFilter'] = $output2;
                $GLOBALS['DynmenuFilter1'] = "";
                $GLOBALS['JSfunction'] = "checkanimate('" . $GLOBALS['dynid'] . "')";
                if (empty($year_link)) {
                    $GLOBALS['DynmenuFilter'] = "";
                    $str = "search_query=" . $links_year . $sub_catg . "&column=year";
                    $GLOBALS['JSfunction'] .= ";getvalueswithajax('" . $GLOBALS['dynid'] . "','{$str}')";
                }
            }
            $GLOBALS['mmyid'] = "mmy_year";
            $dyn_output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("MyVehicleAreaSearch");
            $dyn_filter = $dyn_output;
            //$GLOBALS['SNIPPETS']['SideProductFilter3'] = $output2;
        } else {
            $GLOBALS['HideSideProductFiltersPanelYear'] = "none";
        }
        if ($dyn_flag == 1 && !isset($_REQUEST['change'])) {
            $dyn_top .= $dyn_filter;
        } else {
            $dyn_top .= $dyn_filter;
        }
        $dyn_filter = "";
        /*-------- Make -----------------------------------------*/
        $GLOBALS['dynid'] = "prod_make";
        $GLOBALS['Dynmainmenu'] = "Make";
        if (isset($make_link) && !empty($make_link)) {
            if (count($prod_make_new) > 0) {
                foreach ($prod_make_new as $key => $value) {
                    if (!isset($_REQUEST['change'])) {
                        // when clicked on "clear my vehicle", need to pass the value in the search query to get all Make and year
                        $GLOBALS['BrandLink'] = "{$this->path}/search.php?search_query=" . $srch_qry . "&make=" . $value;
                    } else {
                        $GLOBALS['BrandLink'] = "{$this->path}/search.php?search_query={$value}&make=" . $value;
                    }
                    if (isset($_REQUEST['model']) && empty($_REQUEST['model'])) {
                        $GLOBALS['BrandLink'] .= "&model=";
                    }
                    if (isset($_REQUEST['year'])) {
                        $GLOBALS['BrandLink'] .= "&year=" . $_REQUEST['year'];
                    }
                    $GLOBALS['BrandLink'] .= $sub_catg;
                    $GLOBALS['BrandName'] = isc_html_escape($value);
                    /* this below patch is temporary used when categories with make 'NON-SPEC VEHICLE' are used when searched by redefine category */
                    if (isset($params['catuniversal']) && $params['catuniversal'] == 1 || $GLOBALS['BrandName'] == 'NON-SPEC VEHICLE' && $GLOBALS['BrandName'] != $params['make']) {
                        $GLOBALS['BrandName'] = $params['make'];
                    }
                    if (isset($count_make[$value]['count'])) {
                        $GLOBALS['BrandCount'] = $count_make[$value]['count'];
                    } else {
                        $GLOBALS['BrandCount'] = 0;
                    }
                    $output .= "<li></li>";
                    break;
                    // break has been added to display only single listing.
                }
            } else {
                if (isset($params['make'])) {
                    $GLOBALS['BrandName'] = $params['make'];
                    $output .= "<li></li>";
                    //                     $output .= "<li>".$_REQUEST['make']."</li>";
                }
            }
            $dyn_flag = 1;
            $output = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseSnippets($output, $GLOBALS['SNIPPETS']);
        } else {
            $dyn_flag = 0;
            $temp_arr = array_diff($prod_make_new, $all_makes);
            $temp_count_make = "";
            $temp_no_count_make = "";
            $display_count = 1;
            foreach ($all_makes as $key => $value) {
                if (!isset($_REQUEST['change'])) {
                    // when clicked on "clear my vehicle", need to pass the value in the search query to get all Make and year
                    $GLOBALS['BrandLink'] = "{$this->path}/search.php?search_query=" . $srch_qry . "&make=" . $value;
                } else {
                    $GLOBALS['BrandLink'] = "{$this->path}/search.php?search_query={$value}&make=" . $value;
                }
                if (isset($_REQUEST['model']) && empty($_REQUEST['model'])) {
                    $GLOBALS['BrandLink'] .= "&model=";
                }
                if (isset($params['year'])) {
                    $GLOBALS['BrandLink'] .= "&year=" . $params['year'];
                }
                $GLOBALS['BrandLink'] .= $mmy_string_new1;
                $GLOBALS['BrandLink'] .= $sub_catg;
                $GLOBALS['BrandName'] = isc_html_escape($value);
                if (isset($count_make[$value]['count'])) {
                    $GLOBALS['BrandCount'] = $count_make[$value]['count'];
                } else {
                    $GLOBALS['BrandCount'] = 0;
                }
                /*if($GLOBALS['BrandCount'] == 0)
                  $temp_no_count_make .= "<li>$GLOBALS[BrandName] ($GLOBALS[BrandCount])</li>";*/
                if ($GLOBALS['BrandCount'] != 0) {
                    if ($display_count < 13) {
                        // this condiditon is applied to avoid long listing of make lsit
                        $temp_count_make .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilter1");
                    } else {
                        $temp_no_count_make .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilter1");
                    }
                    $display_count++;
                    //$output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilter1");
                }
            }
            if (count($temp_arr) > 0) {
                foreach ($temp_arr as $key => $value) {
                    if (!isset($_REQUEST['change'])) {
                        // when clicked on "clear my vehicle", need to pass the value in the search query to get all Make and year
                        $GLOBALS['BrandLink'] = "{$this->path}/search.php?search_query=" . $srch_qry . "&make=" . $value;
                    } else {
                        $GLOBALS['BrandLink'] = "{$this->path}/search.php?search_query={$value}&make=" . $value;
                    }
                    if (isset($_REQUEST['model']) && empty($_REQUEST['model'])) {
                        $GLOBALS['BrandLink'] .= "&model=";
                    }
                    if (isset($params['year'])) {
                        $GLOBALS['BrandLink'] .= "&year=" . $params['year'];
                    }
                    $GLOBALS['BrandName'] = isc_html_escape($value);
                    if (isset($count_make[$value]['count'])) {
                        $GLOBALS['BrandCount'] = $count_make[$value]['count'];
                    } else {
                        $GLOBALS['BrandCount'] = 0;
                    }
                    $GLOBALS['BrandLink'] .= $mmy_string_new1;
                    $GLOBALS['BrandLink'] .= $sub_catg;
                    /*if($GLOBALS['BrandCount'] == 0)
                      $temp_no_count_make .= "<li>$GLOBALS[BrandName] ($GLOBALS[BrandCount])</li>";*/
                    if ($GLOBALS['BrandCount'] != 0) {
                        if ($display_count < 13) {
                            // this condiditon is applied to avoid long listing of make list
                            $temp_count_make .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilter1");
                        } else {
                            $temp_no_count_make .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilter1");
                        }
                        $display_count++;
                    }
                }
            }
            $output = "<ul>{$temp_count_make}</ul>";
            if ($display_count > 13) {
                $GLOBALS['FilterID'] = "make";
                $GLOBALS['ExtraValues'] = $temp_no_count_make;
                $output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideFilterMoreLink");
                //$output .= "<ul class='more'><li><a href=\"javascript:onclick=show_hide('make')\" id='make_more'>More...</a></li></ul>";
            }
            $output = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseSnippets($output, $GLOBALS['SNIPPETS']);
        }
        /* this below lines are not to display the make when clear is clicked */
        if (isset($_REQUEST['change'])) {
            $GLOBALS['BrandName'] = "";
        }
        if ($dyn_flag == 1 || isset($_REQUEST['change'])) {
            //$str = "search_query=".$srch_qry.$make_link."&model=".$year_link.$sub_catg."&column=make";
            $GLOBALS['Dyndisplay1'] = "block";
            $GLOBALS['Dyndisplay'] = "none";
            $GLOBALS['Dynimage'] = "imgHdrDropDownIconright.gif";
            $GLOBALS['DynFilterArrow'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilterImage");
            //$GLOBALS['DynFilterArrow'] .= "&nbsp;&nbsp;&nbsp;".$GLOBALS['BrandName'];
            $GLOBALS['DynmenuFilter1'] = "<ul>" . $output . "</ul>";
            $GLOBALS['DynmenuFilter'] = "";
            //$GLOBALS['JSfunction'] = "getvalueswithajax('".$GLOBALS['dynid']."','$str');checkanimate('".$GLOBALS['dynid']."')";
            //$GLOBALS['Dynimage'] = "imgHdrDropDownIconright.gif";
        } else {
            $GLOBALS['BrandName'] = "";
            $GLOBALS['Dyndisplay1'] = "none";
            $GLOBALS['Dyndisplay'] = "block";
            $GLOBALS['Dynimage'] = "imgHdrDropDownIconright.gif";
            $GLOBALS['DynFilterArrow'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilterImage");
            $GLOBALS['DynmenuFilter'] = $output;
            $GLOBALS['DynmenuFilter1'] = "";
            //$GLOBALS['JSfunction'] = "checkanimate('".$GLOBALS['dynid']."')";
            if (empty($make_link)) {
                $GLOBALS['DynmenuFilter'] = "";
            }
        }
        $str = "search_query=" . $srch_qry . $make_link . "&model=" . $year_link . $sub_catg . "&column=make";
        if (isset($params['brand'])) {
            $str .= "&brand=" . $params['brand'];
        }
        if (isset($params['brand_series'])) {
            $str .= "&brand_series=" . $params['brand_series'];
        }
        $GLOBALS['JSfunction'] = "getvalueswithajax('" . $GLOBALS['dynid'] . "','{$str}');checkanimate('" . $GLOBALS['dynid'] . "')";
        $GLOBALS['mmyid'] = "mmy_make";
        $dyn_output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("MyVehicleAreaSearch");
        $dyn_filter = $dyn_output;
        if ($dyn_flag == 1 && !isset($_REQUEST['change'])) {
            $dyn_top .= $dyn_filter;
        } else {
            $dyn_top .= $dyn_filter;
        }
        $dyn_filter = "";
        //$GLOBALS['SNIPPETS']['SideProductFilter1'] = $output;
        /*-------- Model -----------------------------------------*/
        if (!empty($make_link) || !empty($model_link)) {
            $GLOBALS['dynid'] = "prod_model";
            $GLOBALS['Dynmainmenu'] = 'Model';
            $output1 = "";
            $display_count = 1;
            $extra = "";
            if (count($prod_model_new) > 0 && $sub_model_flag == 1 && (!isset($params['catuniversal']) || $params['catuniversal'] == 0)) {
                $dyn_flag = 0;
                foreach ($prod_model_new as $key => $value) {
                    if (!empty($model_link) && $model_flag_link == 1) {
                        $GLOBALS['BrandLink'] = "{$this->path}/search.php?search_query=" . $srch_qry . $model_link . "&submodel=" . urlencode($value);
                    } else {
                        $GLOBALS['BrandLink'] = "{$this->path}/search.php?search_query=" . $srch_qry . "&model=" . urlencode($value);
                    }
                    if (!empty($make_link)) {
                        $GLOBALS['BrandLink'] .= $make_link;
                    }
                    if (!empty($model_link) && !isset($_REQUEST['model'])) {
                        // when searched " chevy silverado " and also to revert back to list of silverados
                        $GLOBALS['BrandLink'] .= "&list=" . $params['model'];
                    }
                    if (!empty($year_link)) {
                        $GLOBALS['BrandLink'] .= $year_link;
                    }
                    $mmy_string_new1 = str_ireplace('&model_flag=0', '', $mmy_string_new1);
                    $GLOBALS['BrandLink'] .= $mmy_string_new1;
                    $GLOBALS['BrandLink'] .= $sub_catg;
                    $GLOBALS['BrandName'] = isc_html_escape($value);
                    $GLOBALS['BrandCount'] = $count_model[$value]['count'];
                    if (isset($_REQUEST['submodel']) && !empty($_REQUEST['submodel'])) {
                        $dyn_flag = 1;
                        $GLOBALS['BrandName'] = $_REQUEST['submodel'];
                        //$output1 .= "<li>$_REQUEST[submodel]</li>";
                        $output1 .= "<li></li>";
                    } else {
                        if ($display_count < 11) {
                            $output1 .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilter2");
                        } else {
                            $extra .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilter2");
                        }
                        $display_count++;
                    }
                }
                /*if(count($prod_model_new) > 1 && isset($_REQUEST['model']) && !empty($_REQUEST['model']))
                  $output1 .= "<li><a href='".$GLOBALS['BrandLink']."'>ALL</a> (".$count_model['all']['count'].")</li>";*/
                $output1 = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseSnippets($output1, $GLOBALS['SNIPPETS']);
            } else {
                $dyn_flag = 1;
                $GLOBALS['BrandName'] = "";
                if (isset($params['model']) && (!isset($params['model_flag']) || $params['model_flag'] == 1)) {
                    $GLOBALS['BrandName'] = strtoupper($params['model']);
                    //$output1 = "<li>".strtoupper($_REQUEST['model'])."</li>";
                    $output1 = "<li></li>";
                }
            }
            $output1 = "<ul>" . $output1 . "</ul>";
            if ($display_count > 11) {
                $GLOBALS['FilterID'] = "model";
                $GLOBALS['ExtraValues'] = $extra;
                $output1 .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideFilterMoreLink");
                //$output .= "<ul class='more'><li><a href=\"javascript:onclick=show_hide('make')\" id='make_more'>More...</a></li></ul>";
            }
            $links = "";
            //if( ( !empty($model_link) || !empty($submodel_link) )) {
            $links = $srch_qry;
            if (isset($make_link)) {
                $links .= $make_link;
            }
            if (isset($params['year'])) {
                $links .= "&year=" . $params['year'];
            }
            if (!empty($submodel_link)) {
                // only shwing submodel
                $links .= $model_link . $submodel_link;
            } else {
                if (isset($_REQUEST['list'])) {
                    // when searched with "chevy silverado", silverado is auto selected as model. For that list is passed as paramater.
                    $links .= "";
                } else {
                    if (isset($_REQUEST['model']) && !empty($_REQUEST['model'])) {
                        // submodel listing page
                        $links .= $model_link;
                    }
                }
            }
            /*else {
                  $links .= "&model="; 
                  $links .= "&year="; 
              }*/
            $links .= $sub_catg;
            if (isset($params['brand'])) {
                $links .= "&brand=" . $params['brand'];
            }
            if (isset($params['brand_series'])) {
                $links .= "&brand_series=" . $params['brand_series'];
            }
            if (!empty($submodel_link)) {
                $links .= "&column=submodel";
            } else {
                $links .= "&column=model";
            }
            //*$output1 .= "<li><a class='thickbox' href='redefine_filters.php?search_query=".$links."'><b>Redefine Search...</b></a></li>";
            //}
            /* this below lines are not to display the make when clear is clicked */
            if (isset($_REQUEST['change'])) {
                $GLOBALS['BrandName'] = "";
            }
            if ($dyn_flag == 1 || isset($_REQUEST['change'])) {
                //*$str = "search_query=".$links;
                $GLOBALS['Dyndisplay1'] = "block";
                $GLOBALS['Dyndisplay'] = "none";
                $GLOBALS['Dynimage'] = "imgHdrDropDownIconright.gif";
                $GLOBALS['DynFilterArrow'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilterImage");
                //$GLOBALS['DynFilterArrow'] .= "&nbsp;&nbsp;&nbsp;".$GLOBALS['BrandName'];
                $GLOBALS['DynmenuFilter1'] = $output1;
                $GLOBALS['DynmenuFilter'] = "";
                //*$GLOBALS['JSfunction'] = "getvalueswithajax('".$GLOBALS['dynid']."','$str');checkanimate('".$GLOBALS['dynid']."')";
                //$GLOBALS['Dynimage'] = "imgHdrDropDownIconright.gif";
            } else {
                $GLOBALS['BrandName'] = "";
                $GLOBALS['Dyndisplay1'] = "none";
                $GLOBALS['Dyndisplay'] = "block";
                $GLOBALS['Dynimage'] = "imgHdrDropDownIconright.gif";
                $GLOBALS['DynFilterArrow'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilterImage");
                //*$GLOBALS['DynmenuFilter'] = $output1;
                $GLOBALS['DynmenuFilter1'] = "";
                //*$GLOBALS['JSfunction'] = "checkanimate('".$GLOBALS['dynid']."')";
            }
            $str = "search_query=" . $links;
            $GLOBALS['DynmenuFilter'] = "";
            $GLOBALS['JSfunction'] = "getvalueswithajax('" . $GLOBALS['dynid'] . "','{$str}');checkanimate('" . $GLOBALS['dynid'] . "')";
            $GLOBALS['mmyid'] = "mmy_model";
            $dyn_output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("MyVehicleAreaSearch");
            //$dyn_filter .=  $output1.$filter3;
            $dyn_filter = $dyn_output;
            //$GLOBALS['SNIPPETS']['SideProductFilter2'] = $output1;
        } else {
            $GLOBALS['mousedefaultpointer'] = "mousedefaultpointer";
            $GLOBALS['mmyid'] = "mmy_model";
            $GLOBALS['dynid'] = "prod_model";
            $GLOBALS['Dynmainmenu'] = 'Model';
            $GLOBALS['DynmenuFilter'] = "";
            //$GLOBALS['JSfunction'] = "checkanimate('".$GLOBALS['dynid']."')";
            $GLOBALS['JSfunction'] = "";
            $dyn_output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("MyVehicleAreaSearch");
            $dyn_filter = $dyn_output;
            //$GLOBALS['HideSideProductFiltersPanelModel'] = "none";
        }
        if ($dyn_flag == 1 && !isset($_REQUEST['change'])) {
            $dyn_top .= $dyn_filter;
        } else {
            $dyn_top .= $dyn_filter;
        }
        $dyn_filter = "";
        $filter1 = <<<P1
    <div class="Block BrandList Moveable" id="SideProductFilters" style="">
P1;
        $filter2 = <<<P1
       <div class="BlockContent">
        <ul>
P1;
        $filter3 = <<<P3
        </ul>
        </div>                
        </div>
P3;
        $GLOBALS['MyVehicleArea'] = $dyn_top;
        $GLOBALS['MyVehicleArea'] .= "<p id='fit'>Guaranteed to Fit Your Vehicle!</p>";
        if (isset($GLOBALS['DynMsg'])) {
            $GLOBALS['MyVehicleArea'] .= "<ul id='modifyvehicle'><li>" . $GLOBALS['DynMsg'] . "</li></ul>";
        }
        $dyn_top = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("MyVehicleArea");
        /************** Category Listing ********************/
        $str = "search_query=" . $srch_qry . $make_link . $model_link . $year_link . "&column=categories";
        $str .= isset($params['brand']) ? "&brand=" . $params['brand'] : '';
        $str .= isset($GLOBALS['ISC_SRCH_CATG_NAME']) ? "&catg_name=" . $GLOBALS['ISC_SRCH_CATG_NAME'] : '';
        $dyn_top .= $this->GetCategoryListing($prod_categoryid, $count_categoryid, $str);
        /*------------ Brand Filter --------------------*/
        if (count($brand_id) > 0 || isset($params['brand'])) {
            $title = "<h2>Brand</h2>";
            //$dyn_filter .=  $filter1.$title.$filter2;
            $brand_link = "";
            $GLOBALS['dynid'] = "dyn_brand";
            $GLOBALS['Dynmainmenu'] = "Brand";
            $count_brand = 1;
            $extra = "";
            $brand_string_array = $query_string_array;
            unset($brand_string_array['brand'], $brand_string_array['brand_series'], $brand_string_array['search_query']);
            $brand_string_new1 = "";
            foreach ($brand_string_array as $br_key => $br_val) {
                $brand_string_new1 .= "&" . $br_key . "=" . urlencode($br_val);
            }
            if (isset($params['brand']) && !empty($params['brand'])) {
                $dyn_flag = 1;
                $brand_query = "select brandname from [|PREFIX|]brands where brandid = " . $params['brand'];
                $brand_result = $GLOBALS['ISC_CLASS_DB']->Query($brand_query);
                $brand_row = $GLOBALS['ISC_CLASS_DB']->Fetch($brand_result);
                $dyn_filter .= <<<P2
        <li><img src='{$this->path}/templates/default/images/check.gif'>&nbsp;&nbsp;{$brand_row['brandname']}</li>
P2;
                if (strtolower($brand_row['brandname']) == strtolower(urldecode($srch_qry))) {
                    // if searched only by brand
                    $brandclearurl = "{$this->path}/search.php?search_query=brands";
                    $str = "search_query=";
                } else {
                    // if searched with other combinations
                    $search_query = trim(str_ireplace($brand_row['brandname'], '', urldecode($srch_qry)));
                    $brandclearurl = "{$this->path}/search.php?search_query=" . urlencode($search_query);
                    $str = "search_query=" . urlencode($search_query);
                }
                $str .= $brand_string_new1 . "&brand=" . $params['brand'] . "&column=prodbrandid";
                if (!empty($brand_string_new1)) {
                    $brandclearurl .= $brand_string_new1;
                }
                $GLOBALS['ClearURL'] = "<a href='{$brandclearurl}'>Clear</a>";
                //$dyn_filter .= "<li><a class='thickbox' href='redefine_filters.php?search_query=".$srch_qry.$brand_string_new1."&brand=&column=prodbrandid'><b>Redefine Search...</b></a></li>";
            } else {
                $dyn_flag = 0;
                $brand_query = "select brandid , brandname from [|PREFIX|]brands where brandid in ( " . implode(",", $brand_id) . " ) order by brandname asc ";
                $brand_result = $GLOBALS['ISC_CLASS_DB']->Query($brand_query);
                while ($brand_row = $GLOBALS['ISC_CLASS_DB']->Fetch($brand_result)) {
                    $GLOBALS['BrandName'] = $brand_row['brandname'];
                    $search_query = $srch_qry;
                    if (urldecode($srch_qry) == 'brands' || urldecode($srch_qry) == 'categories') {
                        $search_query = urlencode($GLOBALS['BrandName']);
                    }
                    $GLOBALS['BrandLink'] = "{$this->path}/search.php?search_query={$search_query}{$brand_string_new1}&brand=" . $brand_row['brandid'];
                    if ($count_brand < 11) {
                        $dyn_filter .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilter1");
                    } else {
                        $extra .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilter1");
                    }
                    $count_brand++;
                }
                $dyn_filter = "<ul>" . $dyn_filter . "</ul>";
                if ($count_brand > 11) {
                    $GLOBALS['FilterID'] = "brand";
                    $GLOBALS['ExtraValues'] = $extra;
                    $dyn_filter .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideFilterMoreLink");
                }
                //$GLOBALS['ClearURL'] = "$this->path/search.php?search_query=$srch_qry$brand_string_new1";
                $GLOBALS['ClearURL'] = "";
            }
            if ($dyn_flag == 1) {
                //$str = "search_query=".$links.$model_link."&column=model";
                $GLOBALS['Dyndisplay1'] = "showlist";
                $GLOBALS['Dyndisplay'] = "hidelist";
                $GLOBALS['Dynimage'] = "imgHdrDropDownIconright.gif";
                $GLOBALS['DynFilterArrow'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilterImage");
                $GLOBALS['DynmenuFilter1'] = $dyn_filter;
                $GLOBALS['DynmenuFilter'] = "";
                $GLOBALS['JSfunction'] = "getvalueswithajax('" . $GLOBALS['dynid'] . "','{$str}');checkanimate('" . $GLOBALS['dynid'] . "')";
                //$GLOBALS['Dynimage'] = "imgHdrDropDownIconright.gif";
            } else {
                $GLOBALS['Dyndisplay1'] = "hidelist";
                $GLOBALS['Dyndisplay'] = "showlist";
                $GLOBALS['Dynimage'] = "imgHdrDropDownIcon.gif";
                $GLOBALS['DynFilterArrow'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilterImage");
                $GLOBALS['DynmenuFilter'] = $dyn_filter;
                $GLOBALS['DynmenuFilter1'] = "";
                $GLOBALS['JSfunction'] = "checkanimate('" . $GLOBALS['dynid'] . "')";
            }
            $dyn_output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductDynFilter");
            $dyn_filter = $dyn_output;
            if ($dyn_flag == 1) {
                $dyn_bottom .= $dyn_filter;
            } else {
                $dyn_top .= $dyn_filter;
            }
            $dyn_filter = "";
        }
        /*-------- Other Filters -----------------------------------------*/
        if (!empty($make_link) && (!empty($model_link) && (!isset($params['model_flag']) || $params['model_flag'] == 1)) && !empty($year_link) && ($numrows > 0 || isset($_REQUEST['GO']) && $numrows > 0) && isset($GLOBALS['ISC_SRCH_CATG_ID'])) {
            //    include('includes/display/ProdDynamicFilters.php');
            $map_names = array();
            $filter_names = "select * from [|PREFIX|]qualifier_names";
            $filter_result = $GLOBALS['ISC_CLASS_DB']->Query($filter_names);
            while ($filter_row = $GLOBALS['ISC_CLASS_DB']->Fetch($filter_result)) {
                if ($filter_row['display_names'] != '') {
                    $map_names[$filter_row['column_name']]['name'] = $filter_row['display_names'];
                }
                $map_names[$filter_row['column_name']]['qid'] = $filter_row['qid'];
            }
            $query_string_new = $this->path . "/search.php?";
            //$dyn_filter = "";
            for ($u = 0; $u < count($columns); $u++) {
                // loop for the filters . Here columns are the filters.
                if (eregi('^(vq|pq)', $columns[$u])) {
                    // checking whether the name of the column starts with vq or pq
                    if (isset($filterdata[$columns[$u]]) && count($filterdata[$columns[$u]]) > 0) {
                        $filter_var = array('vq', 'pq');
                        $title = ucfirst(str_ireplace($filter_var, "", $columns[$u]));
                        $Qualifier_id = $map_names[$columns[$u]]['qid'];
                        $GLOBALS['CategoryId'] = isset($_REQUEST['sub_category']) ? $_REQUEST['sub_category'] : $GLOBALS['ISC_SRCH_CATG_ID'];
                        $this->GetAssocDetails($GLOBALS['CategoryId'], $Qualifier_id, $OwnAssoc, $ParentAssoc, $OwnValue, $ParentValue);
                        $qvalue_mapping_array = $OwnAssoc;
                        $GLOBALS['dynid'] = "dyn" . ($u + 1);
                        //$GLOBALS['Dynmainmenu'] = $title;
                        $dyn_filter = "";
                        $extra = "";
                        // this is used to hide the values if exceed 10
                        $count_pqvq = 1;
                        //$dyn_filter .=  $filter1.$title.$filter2;
                        for ($k = 0; $k < count($filterdata[$columns[$u]]); $k++) {
                            //$countfilterdata[$key][$val]['count']
                            $value = $filterdata[$columns[$u]][$k];
                            $original_value = $filterdata[$columns[$u]][$k];
                            $GLOBALS['HoverImage'] = "";
                            $GLOBALS['Comments'] = "";
                            /*-------------- Below code is used to cehck comments in subcategory and main category ------------ */
                            $CurrentValueItem = array();
                            $CurrentValueItem['vimage'] = '';
                            $CurrentValueItem['vname'] = '';
                            $CurrentValueItem['vcomments'] = '';
                            if (($m = array_search($value, $OwnValue)) !== false) {
                                $CurrentValueItem = $qvalue_mapping_array[$m];
                            }
                            if ($CurrentValueItem['vimage'] == "" && $CurrentValueItem['vcomments'] == "" && $CurrentValueItem['vname'] == "") {
                                if (($n = array_search($value, $ParentValue)) !== false) {
                                    $CurrentValueItem = $ParentAssoc[$n];
                                }
                            }
                            if ($CurrentValueItem['vname'] != "" && $CurrentValueItem['vimage'] != "" && $CurrentValueItem['vcomments'] != "") {
                                if (!empty($CurrentValueItem['vname'])) {
                                    $value = $CurrentValueItem['vname'];
                                }
                                if (!empty($CurrentValueItem['vimage'])) {
                                    $file = realpath(ISC_BASE_PATH . '/' . GetConfig('ImageDirectory') . '/' . $CurrentValueItem['vimage']);
                                    if (file_exists($file)) {
                                        $GLOBALS['HoverImage'] = $this->path . "/" . GetConfig('ImageDirectory') . "/" . $CurrentValueItem['vimage'];
                                    }
                                }
                                $GLOBALS['Comments'] = $CurrentValueItem['vcomments'];
                            }
                            /*-------------- Below code is used to cehck comments in subcategory and main category Ends ------------ */
                            if (isset($params['dynfilters'][$columns[$u]]) && !empty($params['dynfilters'][$columns[$u]])) {
                                $dyn_flag = 1;
                                $query_string_mod_array = $query_string_array;
                                //*$query_string_mod_array[$columns[$u]]= "";
                                //$query_string_new1 = $query_string_new;
                                //*$query_string_new1 = "redefine_filters.php?";
                                $query_string_new1 = "";
                                $qualifierclearurl = "search.php?";
                                foreach ($query_string_mod_array as $qs_key => $qs_val) {
                                    //*if($query_string_new1 != $query_string_new)
                                    if (!empty($query_string_new1)) {
                                        $query_string_new1 .= "&";
                                    }
                                    if ($qs_key != "search_query") {
                                        $qs_val = urlencode($qs_val);
                                    }
                                    $query_string_new1 .= $qs_key . "=" . $qs_val;
                                    if ($qs_key != $columns[$u]) {
                                        if ($qualifierclearurl != "search.php?") {
                                            $qualifierclearurl .= "&";
                                        }
                                        $qualifierclearurl .= $qs_key . "=" . $qs_val;
                                    }
                                }
                                if (strtolower($original_value) == strtolower($params['dynfilters'][$columns[$u]])) {
                                    $GLOBALS['ClearURL'] = "<a href='{$qualifierclearurl}'>Clear</a>";
                                    $dyn_filter .= "<li><img src='{$this->path}/templates/default/images/check.gif'>&nbsp;&nbsp;" . ucwords($value) . "</li>";
                                    //*$dyn_filter .= "<li><a class='thickbox' href='$query_string_new1&column=$columns[$u]'><b>Redefine search...</b></a></li>";
                                    $str = "{$query_string_new1}&column=" . $columns[$u];
                                    break;
                                }
                            } else {
                                $dyn_flag = 0;
                                $query_string_mod_array = $query_string_array;
                                $query_string_new1 = $query_string_new . "search_query=" . $query_string_mod_array['search_query'];
                                unset($query_string_mod_array['search_query']);
                                //if(array_key_exists($columns[$u],$query_string_mod_array)) {
                                //$query_string_mod_array[$columns[$u]] = $original_value;
                                //}
                                foreach ($query_string_mod_array as $qs_key => $qs_val) {
                                    if ($query_string_new1 != $query_string_new) {
                                        $query_string_new1 .= "&";
                                    }
                                    if ($qs_key != "search_query") {
                                        $qs_val = urlencode($qs_val);
                                    }
                                    $query_string_new1 .= $qs_key . "=" . $qs_val;
                                }
                                //$GLOBALS['ClearURL'] = $query_string_new1;
                                $GLOBALS['ClearURL'] = "";
                                $query_string_new1 .= "&" . $columns[$u] . "=" . urlencode($original_value);
                                // this is added to pass the listing value
                                $GLOBALS['QualifierLink'] = $query_string_new1;
                                $GLOBALS['QualifierId'] = $Qualifier_id;
                                $GLOBALS['QualifierValue'] = ucwords($value);
                                $GLOBALS['QualifierCount'] = $countfilterdata[$columns[$u]][$original_value]['count'];
                                //$dyn_filter .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilterValuesHoverImage");
                                //$dyn_filter .= "<li><a href='$query_string_new1'>".$value."</a> (".$countfilterdata[$columns[$u]][$value]['count'].")</li>";
                                if ($count_pqvq < 11) {
                                    $dyn_filter .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilterValuesHoverImage");
                                } else {
                                    $extra .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilterValuesHoverImage");
                                }
                                $count_pqvq++;
                            }
                        }
                        $dyn_filter = "<ul>" . $dyn_filter . "</ul>";
                        if ($count_pqvq > 11) {
                            $GLOBALS['FilterID'] = $GLOBALS['dynid'];
                            $GLOBALS['ExtraValues'] = $extra;
                            $dyn_filter .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideFilterMoreLink");
                        }
                        if ($dyn_flag == 1) {
                            //$str = "search_query=".$links.$model_link."&column=model";
                            $GLOBALS['Dyndisplay1'] = "showlist";
                            $GLOBALS['Dyndisplay'] = "hidelist";
                            $GLOBALS['Dynimage'] = "imgHdrDropDownIconright.gif";
                            $GLOBALS['DynFilterArrow'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilterImage");
                            $GLOBALS['DynmenuFilter1'] = $dyn_filter;
                            $GLOBALS['DynmenuFilter'] = "";
                            $GLOBALS['JSfunction'] = "getvalueswithajax('" . $GLOBALS['dynid'] . "','{$str}');checkanimate('" . $GLOBALS['dynid'] . "')";
                            //$GLOBALS['Dynimage'] = "imgHdrDropDownIconright.gif";
                        } else {
                            $GLOBALS['Dyndisplay1'] = "hidelist";
                            $GLOBALS['Dyndisplay'] = "showlist";
                            $GLOBALS['Dynimage'] = "imgHdrDropDownIcon.gif";
                            $GLOBALS['DynFilterArrow'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductFilterImage");
                            $GLOBALS['DynmenuFilter'] = $dyn_filter;
                            $GLOBALS['DynmenuFilter1'] = "";
                            $GLOBALS['JSfunction'] = "checkanimate('" . $GLOBALS['dynid'] . "')";
                        }
                        /* Filter Title related assiciation */
                        $CurrentItem = $qvalue_mapping_array[0];
                        if ($CurrentItem['qimage'] == "" && $CurrentItem['qcomments'] == "" && $CurrentItem['qname'] == "") {
                            $CurrentItem = $ParentAssoc[0];
                        }
                        if (isset($CurrentItem['qname']) && !empty($CurrentItem['qname'])) {
                            $GLOBALS['Dynmainmenu'] = $CurrentItem['qname'];
                        } else {
                            $GLOBALS['Dynmainmenu'] = $title;
                        }
                        $mover_comment = "";
                        if (isset($CurrentItem) && !empty($CurrentItem['qcomments'])) {
                            $mover_comment = $CurrentItem['qcomments'];
                        }
                        $mover_image = "";
                        if (isset($CurrentItem['qimage']) && !empty($CurrentItem['qimage'])) {
                            $file = realpath(ISC_BASE_PATH . '/' . GetConfig('ImageDirectory') . '/' . $CurrentItem['qimage']);
                            if (file_exists($file)) {
                                $mover_image = $GLOBALS['SITEPATH'] . "/" . GetConfig('ImageDirectory') . "/" . $CurrentItem['qimage'];
                            }
                        }
                        $GLOBALS['MouseoverFn'] = "loadHoverImage(event, '" . $mover_image . "', '" . $mover_comment . "');";
                        $GLOBALS['MouseoutFn'] = "hideTip();";
                        $dyn_output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductDynFilter");
                        //$dyn_filter .=  $filter3;
                        if ($dyn_flag == 1) {
                            $dyn_bottom .= $dyn_output;
                        } else {
                            $dyn_top .= $dyn_output;
                        }
                        $dyn_filter = "";
                        //$dyn_filter .=  $filter3;
                    }
                }
            }
            $dyn_filter = $dyn_top . $dyn_bottom;
            /* form action */
            $qry_string = $_SERVER['QUERY_STRING'];
            if (isset($_REQUEST['page'])) {
                $page = $_REQUEST['page'];
                $search_link = str_ireplace('&page=' . $page, '', $qry_string);
            } else {
                $search_link = $qry_string;
            }
            $GLOBALS['formaction'] = "search.php?" . $search_link;
        } else {
            $GLOBALS['HideSideProductFiltersPanelPrice'] = "none";
        }
        $dyn_filter = $dyn_top . $dyn_bottom;
        $GLOBALS['DynFilter'] = $dyn_filter;
        if (!isset($params['flag_srch_category']) || $params['flag_srch_category'] == 0 || !eregi('search.php', $_SERVER['REQUEST_URI'])) {
            $GLOBALS['HideSideProductFiltersPanelPrice'] = "none";
        } else {
            $GLOBALS['HideSideProductFiltersPanelPrice'] = "block";
        }
        $GLOBALS['FromPrice'] = "0.00";
        if (isset($_REQUEST['price_from'])) {
            $GLOBALS['FromPrice'] = $_REQUEST['price_from'];
        }
        if (isset($_REQUEST['price_to'])) {
            $GLOBALS['ToPrice'] = $_REQUEST['price_to'];
        }
        if (empty($output1) && empty($output2) && empty($output)) {
            $this->DontDisplay = true;
        }
        /*$output = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseSnippets($output, $GLOBALS['SNIPPETS']);
        		$GLOBALS['SNIPPETS']['SideProductFilter1'] = $output;*/
    }
 function DoAjaxSearch()
 {
     if (isset($_GET['search_query']) && isc_strlen($_GET['search_query']) >= 3) {
         $searchterms = BuildProductSearchTerms($_REQUEST);
         // Build the search query using our terms & the fields we want
         $searchQueries = BuildProductSearchQuery($searchterms);
         $Search_Count = $GLOBALS['ISC_CLASS_DB']->FetchOne($searchQueries['countQuery']);
         // No results?
         if ($Search_Count == 0) {
             exit;
         }
         // Add the limit
         $searchQueries['query'] .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, 5);
         $Search_Result = $GLOBALS['ISC_CLASS_DB']->Query($searchQueries['query']);
         while ($product = $GLOBALS['ISC_CLASS_DB']->Fetch($Search_Result)) {
             $product['imagefile'] = '';
             $products[$product['productid']] = $product;
         }
         // Fetch product images
         $productids = implode(",", array_keys($products));
         $query = sprintf("select imageprodid, imagefile from [|PREFIX|]product_images where imageprodid in (%s) and imageisthumb=2", $GLOBALS['ISC_CLASS_DB']->Quote($productids));
         $Result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         while ($productimage = $GLOBALS['ISC_CLASS_DB']->Fetch($Result)) {
             $products[$productimage['imageprodid']]['imagefile'] = $productimage['imagefile'];
         }
         $view_all = '';
         if ($Search_Count > 5) {
             $view_all = sprintf(' view_all="%s"', $this->EscapeEntity(sprintf('<a href="%s/search.php?search_query=%s">%s &raquo;</a>', $GLOBALS['ShopPathNormal'], $_REQUEST['search_query'], GetLang('QuickSearchViewAll'))));
         }
         echo '<?xml version="1.0"?>' . "\n";
         echo sprintf('<results type="%s" result_count="%s"%s>' . "\n", GetLang('QuickSearchProducts'), $Search_Count, $view_all);
         foreach ($products as $product) {
             if ($product['imagefile']) {
                 $image = sprintf("%s/%s/%s", $GLOBALS['ShopPathNormal'], GetConfig('ImageDirectory'), $product['imagefile']);
             } else {
                 $image = GetLang('QuickSearchNoImage');
             }
             if (GetConfig('EnableProductReviews')) {
                 $ratingimg = sprintf("%s/images/IcoRating%s.gif", $GLOBALS['TPL_PATH'], (int) $product['prodavgrating']);
             } else {
                 $ratingimg = '';
             }
             echo sprintf('<result title="%s" price="%s" url="%s" image="%s" ratingimg="%s" />' . "\n", $this->EscapeEntity($product['prodname']), $this->EscapeEntity(CalculateProductPrice_retail($product)), ProdLink($product['prodname']), $this->EscapeEntity($image), $this->EscapeEntity($ratingimg));
         }
         echo "</results>\n";
     }
 }
 function searchotherfilters($params, $selected_value)
 {
     $output = "";
     $column = $this->column;
     unset($this->items['column'], $this->items['random'], $this->items['search_query'], $this->items[$column], $this->items['abtesting']);
     if ($column == 'prodbrandid') {
         unset($this->items['brand'], $params['brand'], $params['flag_srch_brand']);
     }
     if ($column == 'model') {
         unset($this->items['model_flag']);
     }
     $items = $this->items;
     $params['search_query'] = MakeURLSafe($params['search_query']);
     if ($column == 'make' || $column == 'model' || $column == 'submodel' || $column == 'year') {
         if (isset($GLOBALS['ISC_SRCH_CATG_NAME'])) {
             $params['search_query'] = str_ireplace($GLOBALS['ISC_SRCH_CATG_NAME'], '', MakeURLNormal($params['search_query']));
         }
         unset($params['category'], $params['srch_category'], $params['brand'], $params['series'], $params['flag_srch_brand']);
         // here category & brand is commented to display all MMY need to be displayed for categories.
         /* 
         	The below condition is added as the bedsize and cabsize values are retained when clicking on YMM links.
         */
         if ($column == 'make' || $column == 'model' || $column == 'year') {
             unset($params['dynfilters'], $params['vqsbedsize'], $params['vqscabsize']);
         }
         /*if($column == 'year')
         		unset($params['make'],$params['model']);*/
         if ($column == 'make') {
             unset($params['year']);
         }
         if ($column == 'model') {
             if (!isset($params['catuniversal']) || $params['catuniversal'] == 1) {
                 // if category is universal then show all models else model is dependent of year
                 unset($params['catuniversal']);
             }
             //,$params['year']
         }
         $searchQueries = BuildProductSearchQuery($params);
         // this has been written seperately as we need to replace the category name with empty to ignore the category selected for redefine search
         if ($column == 'year') {
             $column_concat = " group_concat(v.prodstartyear separator '~') as prodstartyear , group_concat(v.prodendyear separator '~') as prodendyear";
         } else {
             $column_val = "prod" . $column;
             $column_concat = " group_concat(DISTINCT v.prod" . $column . " separator '~') as " . $column_val;
         }
     } else {
         $searchQueries = BuildProductSearchQuery($params);
         // this has been written seperately as we need to replace the category name with empty to ignore the category selected for redefine search
         $column_val = $column;
         if (strcasecmp($column_val, 'VQbedsize') == 0) {
             $column_concat = " group_concat( DISTINCT if( v.bedsize_generalname != '', v.bedsize_generalname, v.VQbedsize ) separator '~' ) as {$column} ";
         } else {
             if (strcasecmp($column_val, 'VQcabsize') == 0) {
                 $column_concat = " group_concat( DISTINCT if( v.cabsize_generalname != '', v.cabsize_generalname, v.VQcabsize ) separator '~' ) as {$column} ";
             } else {
                 $column_concat = " group_concat(DISTINCT {$column} separator '~') as {$column} ";
             }
         }
     }
     $searchQueries['query'] = str_replace('USE INDEX (categoryid)', 'USE INDEX (PRIMARY)', $searchQueries['query']);
     $searchQueries['query'] = str_replace($GLOBALS['srch_where'], $column_concat, $searchQueries['query']);
     $searchQueries['query'] .= " group by p.productid ";
     $Search_Result = $GLOBALS['ISC_CLASS_DB']->Query($searchQueries['query']);
     $numrows = $GLOBALS['ISC_CLASS_DB']->CountResult($Search_Result);
     if ($numrows > 0) {
         $filter_array = array();
         $count_filter_array = array();
         //echo "<p>Please click on any link from the below list.</p>";
         //echo "<div style='height:280px;overflow-y:auto;border:1px solid black'>";
         $z = 1;
         while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($Search_Result)) {
             if ($column == 'prodbrandid') {
                 $brandid = $row['prodbrandid'];
                 if ($brandid != 0) {
                     $qry = "select * from [|PREFIX|]brands where brandid = " . $brandid;
                     $res = $GLOBALS['ISC_CLASS_DB']->Query($qry);
                     $arr = $GLOBALS['ISC_CLASS_DB']->Fetch($res);
                     if (strtolower($selected_value) != strtolower($arr['brandname'])) {
                         $arr['brandname'] = ucwords(strtolower($arr['brandname']));
                         if (in_array($arr['brandname'], $filter_array)) {
                             $count_filter_array[$arr['brandname']]++;
                         } else {
                             $filter_array[$arr['brandid']] = $arr['brandname'];
                             $count_filter_array[$arr['brandname']] = 1;
                         }
                     }
                 }
             } else {
                 if ($column == 'submodel') {
                     $filters = explode('~', $row[$column_val]);
                     for ($j = 0; $j < count($filters); $j++) {
                         if (empty($filters[$j])) {
                             $filters[$j] = "ALL";
                         }
                         if (strtolower($selected_value) != strtolower($filters[$j])) {
                             $filters[$j] = ucwords($filters[$j]);
                             if (in_array($filters[$j], $filter_array)) {
                                 //echo "<li><a href='search.php?search_query=".$params['search_query']."$links&$column=".urlencode($filters[$j])."'>$filters[$j]</a></li>";
                                 $count_filter_array[$filters[$j]]++;
                             } else {
                                 $filter_array[] = $filters[$j];
                                 $count_filter_array[$filters[$j]] = 1;
                             }
                         }
                     }
                 } else {
                     if ($column == 'model') {
                         if (!empty($row[$column_val]) && $row[$column_val] != '~') {
                             $filters = explode('~', $row[$column_val]);
                             for ($j = 0; $j < count($filters); $j++) {
                                 $filter_value = explode(";", $filters[$j]);
                                 for ($k = 0; $k < count($filter_value); $k++) {
                                     if (strtolower($selected_value) != strtolower($filter_value[$k])) {
                                         $filter_value[$k] = strtoupper($filter_value[$k]);
                                         if (in_array($filter_value[$k], $filter_array)) {
                                             $count_filter_array[$filter_value[$k]]++;
                                         } else {
                                             $filter_array[] = $filter_value[$k];
                                             $count_filter_array[$filter_value[$k]] = 1;
                                         }
                                     }
                                 }
                             }
                         }
                     } else {
                         if ($column == 'make') {
                             if (!empty($row[$column_val]) && $row[$column_val] != '~') {
                                 $filters = explode('~', $row[$column_val]);
                                 for ($j = 0; $j < count($filters); $j++) {
                                     $filter_value = explode(";", $filters[$j]);
                                     for ($k = 0; $k < count($filter_value); $k++) {
                                         //if(strtolower($selected_value) != strtolower($filter_value[$k])) { // commented, as need to show all the makes
                                         if ($filter_value[$k] != "") {
                                             if (in_array($filter_value[$k], $filter_array)) {
                                                 //echo "<li><a href='search.php?search_query=".$params['search_query']."$links&$column=".urlencode($filters[$j])."'>$filters[$j]</a></li>";
                                                 $count_filter_array[$filter_value[$k]]++;
                                             } else {
                                                 $filter_array[] = $filter_value[$k];
                                                 $count_filter_array[$filter_value[$k]] = 1;
                                             }
                                         }
                                     }
                                 }
                             }
                         } else {
                             if ($column != 'year') {
                                 $row[$column_val] = trim($row[$column_val], '~');
                                 //$filters = explode('~',$row[$column_val]);
                                 $filters = preg_split('/[~;]+/', $row[$column_val]);
                                 $filters = array_unique($filters);
                                 $filters = array_values($filters);
                                 for ($j = 0; $j < count($filters); $j++) {
                                     if ($filters[$j] == '') {
                                         //Added by Simha
                                         $filters[$j] = "Others";
                                     }
                                     $filter_value = explode(";", $filters[$j]);
                                     for ($k = 0; $k < count($filter_value); $k++) {
                                         if (strtolower($selected_value) != strtolower($filter_value[$k])) {
                                             if (in_array($filter_value[$k], $filter_array)) {
                                                 //echo "<li><a href='search.php?search_query=".$params['search_query']."$links&$column=".urlencode($filters[$j])."'>$filters[$j]</a></li>";
                                                 $count_filter_array[$filter_value[$k]]++;
                                             } else {
                                                 $filter_array[] = $filter_value[$k];
                                                 $count_filter_array[$filter_value[$k]] = 1;
                                             }
                                         }
                                     }
                                 }
                             } else {
                                 // only for year filter
                                 $z++;
                                 $grp_startyear = explode("~", $row['prodstartyear']);
                                 $grp_endyear = explode("~", $row['prodendyear']);
                                 for ($g = 0; $g < count($grp_startyear); $g++) {
                                     $prod_start_year = $grp_startyear[$g];
                                     $prod_end_year = $grp_endyear[$g];
                                     if (is_numeric($prod_start_year) && is_numeric($prod_end_year)) {
                                         $prod_year_diff = $prod_end_year - $prod_start_year;
                                         for ($i = 0; $i <= $prod_year_diff; $i++) {
                                             $actual_year = $prod_start_year + $i;
                                             if (strtolower($selected_value) != $actual_year) {
                                                 if (in_array($actual_year, $filter_array)) {
                                                     //echo "<li><a href='search.php?search_query=".$params['search_query']."$links&$column=$actual_year'>$actual_year</a></li>";
                                                     $count_filter_array[$actual_year]++;
                                                 } else {
                                                     $filter_array[] = $actual_year;
                                                     $count_filter_array[$actual_year] = 1;
                                                 }
                                             }
                                         }
                                     } else {
                                         if (!is_numeric($prod_start_year) && !is_numeric($prod_end_year)) {
                                             if (strtolower($selected_value) != strtolower($prod_start_year)) {
                                                 if (in_array($prod_start_year, $filter_array)) {
                                                     //echo "<li><a href='search.php?search_query=".$params['search_query']."$links&$column=$prod_start_year'>$prod_start_year</a></li>";
                                                     $count_filter_array[$prod_start_year]++;
                                                 } else {
                                                     $filter_array[] = $prod_start_year;
                                                     $count_filter_array[$prod_start_year] = 1;
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if ($column == 'year') {
             rsort($filter_array);
         } else {
             if ($column == 'submodel') {
                 sort($filter_array);
             } else {
                 asort($filter_array);
             }
         }
         /* the below code has been added to move no-spec vehicle at the end of array */
         if (in_array('NON-SPEC VEHICLE', $filter_array)) {
             $mkey = array_search('NON-SPEC VEHICLE', $filter_array);
             unset($filter_array[$mkey]);
             $filter_array = array_values($filter_array);
             array_push($filter_array, 'NON-SPEC VEHICLE');
         }
         $output .= $this->showfiltervalues($filter_array, $count_filter_array, $params);
     } else {
         $output .= "<p>Sorry, there are no options available to select.</p>";
     }
     return $output;
 }
Esempio n. 7
0
		private function _BuildProductFeed($feedTitle, $feedDescription, $feedId, $sortField, $sortOrder, $searchTerms=array())
		{
			$this->_SetFeedDetails();

			$feed = new ISC_FEED_GENERATOR($feedId, $this->_type, (int)GetConfig('RSSCacheTime')*60);

			$channel = array(
				"title" => $feedTitle,
				"description" => $feedDescription,
				"link" => $GLOBALS['ShopPath'],
				'namespaces' => array(
					'isc' => array(
						//'http://dtd.interspire.com/rss/isc-1.0.dtd',
				        '',
						array(
							'store_title' => getConfig('StoreName')
						)
					)
				)
			);
			$feed->SetChannel($channel);

			// The magical Unreal Shopping Cart RSS feeds are actually just custom searches so pipe it off to our search function
			$searchterms = BuildProductSearchTerms($searchTerms);

			$searchQueries = BuildProductSearchQuery($searchterms, '', $sortField, $sortOrder);

			// Run the query
			$searchQueries['query'] .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, (int)GetConfig('RSSItemsLimit'));
			$result = $GLOBALS['ISC_CLASS_DB']->Query($searchQueries['query']);

			while($product = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
				if(isc_strlen($product['proddesc']) > 300) {
					$product['proddesc'] = isc_substr($product['proddesc'], 0, 298)."..";
				}

				$item = array(
					'title' => $product['prodname'],
					'date' => $product['proddateadded'],
					'link' => prodLink($product['prodname']),
					'namespaces' => array(
						'isc' => array(
							'description' => $product['proddesc'],
							'productid' => $product['productid'],
						)
					)
				);

				if($product['imagefile']) {
					$thumb = ImageThumb($product, ProdLink($product['prodname']));
					$product['proddesc'] = sprintf("<div style='float: right; padding: 10px;'>%s</div>%s", $thumb, $product['proddesc']);

					$image = new ISC_PRODUCT_IMAGE;
					$image->populateFromDatabaseRow($product);

					try {
						$item['namespaces']['isc']['thumb'] = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL, true);
					} catch (Exception $exception) { }

					try {
						$item['namespaces']['isc']['image'] = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_ZOOM, true);
					} catch (Exception $exception) { }

					unset ($image);
				}

				// Determine the price of this product
				$price = '';
				if (GetConfig('ShowProductPrice') && !$product['prodhideprice']) {
					$calcPrice = $product['prodcalculatedprice'];
					$plainPrice = formatProductPrice($product, $calcPrice, array(
						'strikeRetail' => false,
						'displayInclusive' => getConfig('taxDefaultTaxDisplayCatalog')
					));

					if($plainPrice) {
						$item['namespaces']['isc']['price'] = $plainPrice;
						$price = '<strong>'.getLang('Price').': '.$plainPrice.'</strong>';
					}
				}

				if(GetConfig('ShowProductRating')) {
					$ratingImage = $GLOBALS['IMG_PATH'].'/IcoRating'.(int)$product['prodavgrating'].'.gif';
					$item['namespaces']['isc']['rating'] = (int)$product['prodavgrating'];
					$item['namespaces']['isc']['rating_image'] = $ratingImage;

					$ratingImage = '<img src="'.$ratingImage.'" alt="" />';
				}
				else {
					$ratingImage = '';
				}

				$product['proddesc'] .= '<p>'.$price.' '.$ratingImage.'</p>';

				$item['description'] = $product['proddesc'];
				$feed->AddItem($item);
			}

			// Send the feed to the browser
			$feed->OutputFeed();

		}
Esempio n. 8
0
 /**
  *	Run the full text searches to find matching products
  */
 function DoSearch($Start, &$Search_Result, &$Search_Count)
 {
     $category_ids = array();
     if (isset($_REQUEST['pageid'])) {
         $pageid = (int) $_REQUEST['pageid'];
         $query = sprintf("select * from [|PREFIX|]abtesting_pages where pageid='%d' and pagestatus = 1", $GLOBALS['ISC_CLASS_DB']->Quote($pageid));
     } else {
         if (isset($GLOBALS['PathInfo'][1])) {
             $page = preg_replace('#\\.html$#i', '', $GLOBALS['PathInfo'][1]);
             $page = $GLOBALS['ISC_CLASS_DB']->Quote(MakeURLNormal($page));
             $query = sprintf("select * from [|PREFIX|]abtesting_pages where pagename='%s' and pagestatus = 1", $page);
         }
     }
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     $row = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
     if (!$row) {
         ob_end_clean();
         header("Location: " . GetConfig('ShopPath') . '/index.php');
         exit;
     }
     $temp_srch_qry = $_REQUEST['search_query'];
     if ($row['pagetype'] == 2) {
         $subcatg_qry = "select catname from [|PREFIX|]categories where categoryid = " . $row['pagecategoryid'];
         $subcatg_res = $GLOBALS['ISC_CLASS_DB']->Query($subcatg_qry);
         $subcatg_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($subcatg_res);
         $_REQUEST['search_query'] = $subcatg_arr['catname'];
         //$_REQUEST['search_query'] = $temp_cat_name;
     } else {
         if ($row['pagetype'] == 3) {
             $subcatg_qry = "select c.categoryid as catid , c.catname as childname , p.categoryid , p.catname \n\t\t\t\t\t\t\t\t\tfrom [|PREFIX|]categories c \n\t\t\t\t\t\t\t\t\tleft join [|PREFIX|]categories p on c.catparentid = p.categoryid\n\t\t\t\t\t\t\t\t\twhere c.categoryid = '" . $row['pagecategoryid'] . "'";
             $subcatg_res = $GLOBALS['ISC_CLASS_DB']->Query($subcatg_qry);
             $subcatg_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($subcatg_res);
             if ($subcatg_arr['categoryid'] != "") {
                 $_REQUEST['search_query'] = $subcatg_arr['catname'];
                 $_REQUEST['subcategory'] = $subcatg_arr['childname'];
             } else {
                 $_REQUEST['search_query'] = $subcatg_arr['childname'];
                 $_REQUEST['subcategory'] = $subcatg_arr['childname'];
             }
         }
     }
     // Set the incoming search terms
     $this->_searchterms = BuildProductSearchTerms($_REQUEST);
     //$this->_searchterms['search_query'] = $temp_srch_qry;
     $params = $this->_searchterms;
     if ($row['pagetype'] == 2 && isset($params['subcategory']) && $params['subcategory'] != "") {
         $row['pagetype'] = 3;
     }
     $GLOBALS['CatgDescandBrandImage'] = $row['pageheaderdesc'];
     $GLOBALS['CatgBrandSeriesFooter'] = $row['pagefooterdesc'];
     $GLOBALS['CategoryTrackingCodeTop'] = isset($row['pagecontrolscript']) ? $row['pagecontrolscript'] : '';
     $GLOBALS['CategoryTrackingCodeBottom'] = isset($row['pagetrackingscript']) ? $row['pagetrackingscript'] : '';
     $this->_pagetitle = $row['pagetitle'];
     $GLOBALS['pagetype'] = $row['pagetype'];
     if ($row['pagetype'] == 1) {
         $GLOBALS['results_page_flag'] = 1;
         $Search_Result = $row['pagecontent'];
         $Search_Count = 1;
         return;
     } else {
         if ($row['pagetype'] == 2) {
             $GLOBALS['results_page_flag'] = 0;
             $custom_cond = "";
             if (isset($params['brand'])) {
                 $custom_cond .= " and cp.brandname = '" . $params['brand'] . "' ";
             }
             if ($row['pagecontent'] == 1) {
                 if (isset($params['make']) || isset($params['model']) || isset($params['year'])) {
                     $concat_cond = "";
                     if (isset($params['make'])) {
                         $concat_cond .= " and ( v.prodmake = 'NON-SPEC VEHICLE' OR v.prodmake = '" . $params['make'] . "') ";
                     }
                     if (isset($params['model'])) {
                         $concat_cond .= " and ( v.prodmodel = 'all' OR v.prodmodel = '" . $params['model'] . "') ";
                     }
                     if (isset($params['year'])) {
                         $concat_cond .= " and ( v.prodstartyear = 'all' OR " . $params['year'] . " between v.prodstartyear and v.prodendyear) ";
                     }
                     $temp_query = " SELECT  group_concat(distinct cp.categoryid) as catid , group_concat(distinct cp.subcategoryid) as subcatid FROM [|PREFIX|]abtesting_custom_products cp INNER JOIN [|PREFIX|]abtesting_pages cc on cc.pageid=cp.pageid WHERE cp.enabled=1 and cc.pageid = " . $pageid . " ORDER BY cp.displayorder ASC ";
                     $temp_result = $GLOBALS['ISC_CLASS_DB']->Query($temp_query);
                     $temp_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($temp_result);
                     $ccatg_qry = " SELECT group_concat( distinct ca.categoryid) as catids from [|PREFIX|]categoryassociations ca inner join [|PREFIX|]import_variations v on v.productid = ca.productid where ca.categoryid in (" . $temp_arr['catid'] . "," . $temp_arr['subcatid'] . ") " . $concat_cond;
                     $ccatg_result = $GLOBALS['ISC_CLASS_DB']->Query($ccatg_qry);
                     $ccatg_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($ccatg_result);
                     $cc_query = " SELECT cp.productids, cp.categoryid, cp.subcategoryid, cp.brandid, cp.seriesid, cp.description FROM [|PREFIX|]abtesting_custom_products cp INNER JOIN [|PREFIX|]abtesting_pages cc on cc.pageid=cp.pageid WHERE cp.enabled=1 and cc.pageid = " . $pageid . " " . $custom_cond;
                     $ccatg_arr['catids'] = isset($ccatg_arr['catids']) && $ccatg_arr['catids'] != '' ? $ccatg_arr['catids'] : '';
                     $cc_query .= " and ( cp.categoryid in (" . $ccatg_arr['catids'] . ") OR cp.subcategoryid in (" . $ccatg_arr['catids'] . ") ) ";
                     $cc_query .= " ORDER BY cp.displayorder ASC ";
                 } else {
                     $cc_query = " SELECT cp.productids, cp.categoryid, cp.subcategoryid, cp.brandid, cp.seriesid, cp.description FROM [|PREFIX|]abtesting_custom_products cp INNER JOIN [|PREFIX|]abtesting_pages cc on cc.pageid=cp.pageid WHERE cp.enabled=1 and cc.pageid = " . $pageid . " " . $custom_cond . " ORDER BY cp.displayorder ASC ";
                 }
                 $cc_result = $GLOBALS['ISC_CLASS_DB']->Query($cc_query);
                 $total_count = $GLOBALS['ISC_CLASS_DB']->CountResult($cc_result);
                 $Search_Count = $total_count;
                 if ($total_count > 0) {
                     $GLOBALS['pagecontent'] = $row['pagecontent'];
                     $GLOBALS['CustomPage'] = "";
                     while ($ccrow = $GLOBALS['ISC_CLASS_DB']->Fetch($cc_result)) {
                         $GLOBALS['CustomPage'] .= $ccrow['description'];
                     }
                     return;
                 }
                 //2010-11-30 Ronnie modify
                 //return;
             }
             //2010-11-30 Ronnie add,no result show Dynamic content
             //echo "123".$total_count;
             if ($total_count == 0) {
                 $row['pagecontent'] = 0;
             }
             //echo "456".$row['pagecontent'];
             if ($row['pagecontent'] == 0) {
                 $getsubcatqry = "select group_concat(distinct c.categoryid) as catids from isc_categories c \n\t\t\t\t\t\twhere c.catparentid = " . $row['pagecategoryid'];
                 $gersubcatres = $GLOBALS['ISC_CLASS_DB']->Query($getsubcatqry);
                 $gersubcatarr = $GLOBALS['ISC_CLASS_DB']->Fetch($gersubcatres);
                 $gersubcatarr['catids'] .= "," . $row['pagecategoryid'];
                 $this->_searchterms['srch_category'] = $params['srch_category'] = explode(",", $gersubcatarr['catids']);
                 /*$count_qry = "SELECT count(p.productid) as tot FROM isc_products p LEFT JOIN isc_import_variations AS v ON v.productid = p.productid LEFT JOIN isc_categoryassociations ca on ca.productid = p.productid LEFT JOIN isc_categories c on c.categoryid = ca.categoryid LEFT JOIN isc_brands b on prodbrandid = b.brandid LEFT JOIN isc_brand_series AS bs ON bs.seriesid = p.brandseriesid WHERE 1=1 AND c.categoryid IN (".$gersubcatarr['catids'].") AND p.prodvisible='1' ".$concat_cond." ".$dynamic_cond." group by c.categoryid";
                 					
                 
                 					$catquery = "select c.catname , c.categoryid , c.catuniversal , c.catimagealt , c.featurepoints , c.videourlwidthheight , c.thumbnailvideoimage , c.pricerange , c.warrantyinfo , group_concat(DISTINCT brandname separator '~') as brandname , group_concat(DISTINCT p.brandseriesid separator '~') as seriesids , min(fp.prodfinalprice) as prodminprice , max(fp.prodfinalprice) as prodmaxprice , c.catimagefile as imagefile , c.cathoverimagefile , p.proddesc , prodwarranty , bs.seriesname, bs.displayname, p.brandseriesid , count(distinct p.productid) as totalproducts,floor(SUM(p.prodratingtotal)/SUM(p.prodnumratings)) AS prodavgrating from isc_products p LEFT JOIN isc_import_variations AS v ON v.productid = p.productid LEFT JOIN isc_categoryassociations ca on ca.productid = p.productid LEFT JOIN isc_categories c on c.categoryid = ca.categoryid LEFT JOIN isc_brands b on prodbrandid = b.brandid LEFT JOIN isc_brand_series AS bs ON bs.seriesid = p.brandseriesid LEFT JOIN isc_product_images pi ON (p.productid=pi.imageprodid AND pi.imageisthumb=1) LEFT JOIN isc_product_finalprice fp ON p.productid = fp.productid WHERE 1=1 AND c.categoryid IN (".$gersubcatarr['catids'].") AND p.prodvisible='1' ".$concat_cond." ".$dynamic_cond." group by c.categoryid ORDER BY c.catdeptid ASC, c.catsort ASC, c.catname ASC LIMIT 0, 16";
                 					$GLOBALS['SearchResults'] = $GLOBALS['ISC_CLASS_DB']->Query($catquery);*/
                 // Build the search query using our terms & the fields we want
                 $searchQueries = BuildProductSearchQuery($this->_searchterms);
                 $group = " group by c.categoryid ";
                 $orderby = $searchQueries['orderby'];
                 /* below template variables are added for subcategory page to add category specific tracking code*/
                 if (isset($params['srch_category'])) {
                     $selected_catg = end($params['srch_category']);
                     if ($selected_catg != '') {
                         $script_query = "select catname , catpagetitle , catmetakeywords , catmetadesc , controlscript , trackingscript from [|PREFIX|]categories where categoryid = " . $selected_catg;
                         $script_result = $GLOBALS['ISC_CLASS_DB']->Query($script_query);
                         $script_array = $GLOBALS['ISC_CLASS_DB']->Fetch($script_result);
                         /* the below lines assign meta discription, keywords and title for the categories*/
                         $GLOBALS['ISC_CLASS_TEMPLATE']->SetMetaKeywords($script_array['catmetakeywords']);
                         $GLOBALS['ISC_CLASS_TEMPLATE']->SetMetaDescription($script_array['catmetadesc']);
                         if ($script_array['catpagetitle'] != "") {
                             $this->_pagetitle = $script_array['catpagetitle'];
                         } else {
                             $this->_pagetitle = ucwords($script_array['catname']);
                         }
                     }
                 }
             }
         } else {
             if ($row['pagetype'] == 3) {
                 $GLOBALS['results_page_flag'] = 2;
                 $this->_searchterms['srch_category'][] = $params['srch_category'][] = $row['pagecategoryid'];
                 // Build the search query using our terms & the fields we want
                 $searchQueries = BuildProductSearchQuery($this->_searchterms);
                 $group = " group by p.productid ";
                 if (isset($_REQUEST['orderby']) && !empty($_REQUEST['orderby'])) {
                     if ($_REQUEST['orderby'] == "brandname") {
                         $orderby = " order by brandname " . (isset($_REQUEST['sortby']) ? $_REQUEST['sortby'] : "asc") . " , seriesname ";
                     } else {
                         $orderby = " order by " . $_REQUEST['orderby'] . " ";
                     }
                 } else {
                     $orderby = " order by p.prodprice ";
                 }
                 if (isset($_REQUEST['sortby']) && !empty($_REQUEST['sortby'])) {
                     $orderby .= $_REQUEST['sortby'];
                 } else {
                     $orderby .= " asc";
                 }
             }
         }
     }
     /* the below three lines has been added to group by SKU as same sku was showing in multiple products */
     $searchQueries['query'] .= $group . $GLOBALS['having_query'] . $orderby;
     $searchQueries['countQuery'] .= $group . $GLOBALS['having_query'];
     //$searchQueries['countQuery'] = "select count(*) from ( ".$searchQueries['countQuery']." ) p ";
     $count_res = $GLOBALS['ISC_CLASS_DB']->Query($searchQueries['countQuery']);
     $Search_Count = $GLOBALS['ISC_CLASS_DB']->CountResult($count_res);
     // Add the limit
     $searchQueries['query'] .= $GLOBALS['ISC_CLASS_DB']->AddLimit($Start, GetConfig('CategoryProductsPerPage'));
     $Search_Result = $GLOBALS['ISC_CLASS_DB']->Query($searchQueries['query']);
     $GLOBALS['DoSearchQuery'] = $searchQueries['query'];
 }