keywords2categories / includes / extra / default / listing_sql / category_keywords.php @ 6
Historie | Anzeigen | Annotieren | Download (6,51 KB)
1 |
<?php
|
---|---|
2 |
/* -----------------------------------------------------------------------------------------
|
3 |
Modul Kategorie-Keywords f?r modified eCommerce Shopsoftware 2.0.6.0
|
4 |
Autor: Daniel Lonn [www.webknecht.net]
|
5 |
Released under the GNU General Public License
|
6 |
---------------------------------------------------------------------------------------*/
|
7 |
|
8 |
if(defined('MODULE_CATEGORY_KEYWORDS_STATUS') |
9 |
&& MODULE_CATEGORY_KEYWORDS_STATUS == 'True' |
10 |
&& (basename($PHP_SELF) == FILENAME_ADVANCED_SEARCH_RESULT || basename($PHP_SELF) == 'autocomplete.php') |
11 |
&& $categories_id == false // adv. search: subcategories not selected |
12 |
&& sizeof($search_keywords) > 0 |
13 |
) { |
14 |
$sql_categories_keywords = ''; |
15 |
$where_str_cat = " ( "; |
16 |
|
17 |
for ($i = 0, $n = sizeof($search_keywords); $i < $n; $i ++) { |
18 |
switch ($search_keywords[$i]) { |
19 |
case '(' : |
20 |
case ')' : |
21 |
case 'and' : |
22 |
case 'or' : |
23 |
$where_str .= " ".$search_keywords[$i]." "; |
24 |
break;
|
25 |
default :
|
26 |
$ent_keyword = encode_htmlentities($search_keywords[$i]); |
27 |
$ent_keyword = $ent_keyword != $search_keywords[$i] ? xtc_db_input($ent_keyword) : false; |
28 |
$keyword = xtc_db_input($search_keywords[$i]); |
29 |
$where_str_cat .= " ( "; |
30 |
$where_str_cat .= "cd.categories_keywords LIKE ('%".$keyword."%') "; |
31 |
$where_str_cat .= $ent_keyword ? "OR cd.categories_keywords LIKE ('%".$ent_keyword."%') " : ''; |
32 |
|
33 |
if (MODULE_CATEGORY_KEYWORDS_INCLUDE_CATEGORIES == 'True' && strlen($keyword) > 2) { |
34 |
$where_str_cat .= "OR cd.categories_name LIKE ('%".$keyword."%') "; |
35 |
$where_str_cat .= $ent_keyword ? "OR cd.categories_name LIKE ('%".$ent_keyword."%') " : ''; |
36 |
$where_str_cat .= "OR cd.categories_heading_title LIKE ('%".$keyword."%') "; |
37 |
$where_str_cat .= $ent_keyword ? "OR cd.categories_heading_title LIKE ('%".$ent_keyword."%') " : ''; |
38 |
} |
39 |
|
40 |
$where_str_cat .= " ) OR "; |
41 |
break;
|
42 |
} |
43 |
} |
44 |
if($where_str_cat != " ( "){ |
45 |
$where_str_cat = substr($where_str_cat, 0, strlen($where_str_cat)-3); |
46 |
$where_str_cat .= " ) "; |
47 |
$listing_sql_categories = "Select * from ".TABLE_CATEGORIES." c LEFT JOIN ".TABLE_CATEGORIES_DESCRIPTION." cd on c.categories_id = cd.categories_id where $where_str_cat AND cd.language_id = '".(int)$_SESSION['languages_id']."' AND c.categories_status = '1' " .CATEGORIES_CONDITIONS_C; |
48 |
$categories_query = xtc_db_query($listing_sql_categories); |
49 |
$categories_keyword_content = array(); |
50 |
$arr_categories_affected = array(); |
51 |
while ($categories = xtc_db_fetch_array($categories_query)) { |
52 |
if(!in_array($categories['categories_id'], $arr_categories_affected)){ |
53 |
$arr_categories_affected[]=$categories['categories_id']; |
54 |
} |
55 |
if(MODULE_CATEGORY_KEYWORDS_SHOW == 'True') { |
56 |
$cPath_new = xtc_category_link($categories['categories_id'],$categories['categories_name']); |
57 |
$image = ''; |
58 |
if ($categories['categories_image'] != '') { |
59 |
$image = DIR_WS_IMAGES.'categories/'.$categories['categories_image']; |
60 |
if(!file_exists($image)){ |
61 |
$image = DIR_WS_IMAGES.'categories/noimage.gif'; |
62 |
} |
63 |
$image = $image; |
64 |
} |
65 |
$categories_keyword_content[] = array ('CATEGORIES_NAME' => $categories['categories_name'], |
66 |
'CATEGORIES_HEADING_TITLE' => $categories['categories_heading_title'], |
67 |
'CATEGORIES_IMAGE' => (($image != '') ? DIR_WS_BASE . $image : ''), |
68 |
'CATEGORIES_LINK' => xtc_href_link(FILENAME_DEFAULT, $cPath_new), |
69 |
'CATEGORIES_DESCRIPTION' => $categories['categories_description']); |
70 |
} |
71 |
} |
72 |
|
73 |
if(count($arr_categories_affected)>0){ |
74 |
$str_categories = ",".join($arr_categories_affected, ",").","; |
75 |
$sql_categories_keywords = " (INSTR('$str_categories', concat(',',p2c.categories_id,',')))"; |
76 |
} |
77 |
} |
78 |
if($sql_categories_keywords){ |
79 |
$listing_sql_keywords = "SELECT p.products_id |
80 |
FROM ".TABLE_PRODUCTS." p |
81 |
JOIN ".TABLE_PRODUCTS_TO_CATEGORIES." AS p2c ON (p.products_id = p2c.products_id) "; |
82 |
if($pfrom_check != '' || $pto_check != '') { |
83 |
$listing_sql_keywords .= "LEFT OUTER JOIN ".TABLE_SPECIALS." AS s ON (p.products_id = s.products_id) ".SPECIALS_CONDITIONS_S." "; |
84 |
} |
85 |
if($NeedTax) { |
86 |
$listing_sql_keywords .= " LEFT OUTER JOIN ".TABLE_TAX_RATES." tr ON (p.products_tax_class_id = tr.tax_class_id) |
87 |
LEFT OUTER JOIN ".TABLE_ZONES_TO_GEO_ZONES." gz ON (tr.tax_zone_id = gz.geo_zone_id) "; |
88 |
} |
89 |
$listing_sql_keywords .= "WHERE p.products_status = '1' |
90 |
".PRODUCTS_CONDITIONS_P." |
91 |
AND $sql_categories_keywords $pfrom_check $pto_check";
|
92 |
if($manu_check!="") { |
93 |
$listing_sql_keywords .= " AND p.manufacturers_id = '".$manufacturers_id."' "; |
94 |
} |
95 |
if($NeedTax) { |
96 |
$listing_sql_keywords .= " AND (gz.zone_country_id IS NULL OR gz.zone_country_id = '0' OR gz.zone_country_id = '".(int) $_SESSION['customer_country_id']."') |
97 |
AND (gz.zone_id is null OR gz.zone_id = '0' OR gz.zone_id = '".(int) $_SESSION['customer_zone_id']."')"; |
98 |
} |
99 |
|
100 |
$keywords_query = xtc_db_query($listing_sql_keywords); |
101 |
$arr_included_products=array(); |
102 |
while ($products_from_keywords = xtc_db_fetch_array($keywords_query)) { |
103 |
$arr_included_products[] = "'" . $products_from_keywords['products_id'] . "'"; |
104 |
} |
105 |
if(count($arr_included_products)>0){ |
106 |
$listing_sql = str_replace("WHERE p.products_id IN (", "WHERE p.products_id IN (".join($arr_included_products, ",") . ",", $listing_sql); |
107 |
|
108 |
} |
109 |
|
110 |
} |
111 |
} |
112 |
|
113 |
?>
|