| 1 | <?php
|
|---|
| 2 | /* -----------------------------------------------------------------------------------------
|
|---|
| 3 | $Id: product_listing.php 5861 2013-10-01 12:50:02Z GTB $
|
|---|
| 4 |
|
|---|
| 5 | modified eCommerce Shopsoftware
|
|---|
| 6 | http://www.modified-shop.org
|
|---|
| 7 |
|
|---|
| 8 | Copyright (c) 2009 - 2013 [www.modified-shop.org]
|
|---|
| 9 | -----------------------------------------------------------------------------------------
|
|---|
| 10 | based on:
|
|---|
| 11 | (c) 2000-2001 The Exchange Project (earlier name of osCommerce)
|
|---|
| 12 | (c) 2002-2003 osCommerce(product_listing.php,v 1.42 2003/05/27); www.oscommerce.com
|
|---|
| 13 | (c) 2003 nextcommerce (product_listing.php,v 1.19 2003/08/1); www.nextcommerce.org
|
|---|
| 14 | (c) 2006 xt:Commerce (product_listing.php 1286 2005-10-07); www.xt-commerce.de
|
|---|
| 15 |
|
|---|
| 16 | Released under the GNU General Public License
|
|---|
| 17 | ---------------------------------------------------------------------------------------*/
|
|---|
| 18 |
|
|---|
| 19 | // todo: move to configuration ?
|
|---|
| 20 | defined('CATEGORIES_IMAGE_SHOW_NO_IMAGE') OR define('CATEGORIES_IMAGE_SHOW_NO_IMAGE', 'true');
|
|---|
| 21 | defined('MANUFACTURER_IMAGE_SHOW_NO_IMAGE') OR define('MANUFACTURER_IMAGE_SHOW_NO_IMAGE', 'false');
|
|---|
| 22 |
|
|---|
| 23 | $module_smarty = new Smarty;
|
|---|
| 24 | $module_smarty->caching = false;
|
|---|
| 25 | $module_smarty->assign('tpl_path', DIR_WS_BASE.'templates/'.CURRENT_TEMPLATE.'/');
|
|---|
| 26 |
|
|---|
| 27 | $result = true;
|
|---|
| 28 |
|
|---|
| 29 | // include needed functions
|
|---|
| 30 | require_once (DIR_FS_INC.'xtc_get_vpe_name.inc.php');
|
|---|
| 31 |
|
|---|
| 32 | $max_display_results = MAX_DISPLAY_SEARCH_RESULTS;
|
|---|
| 33 | if (strpos($PHP_SELF, FILENAME_ADVANCED_SEARCH_RESULT) !== false && defined('MAX_DISPLAY_ADVANCED_SEARCH_RESULTS') && MAX_DISPLAY_ADVANCED_SEARCH_RESULTS != '') {
|
|---|
| 34 | $max_display_results = MAX_DISPLAY_ADVANCED_SEARCH_RESULTS;
|
|---|
| 35 | $module_smarty->assign('SEARCH_RESULT', true);
|
|---|
| 36 | }
|
|---|
| 37 |
|
|---|
| 38 | $listing_split = new splitPageResults($listing_sql, (isset($_GET['page']) ? (int)$_GET['page'] : 1), $max_display_results, 'p.products_id');
|
|---|
| 39 |
|
|---|
| 40 | $module_content = $category = array();
|
|---|
| 41 | $image = '';
|
|---|
| 42 |
|
|---|
| 43 | if ($listing_split->number_of_rows > 0) {
|
|---|
| 44 | if (USE_PAGINATION_LIST == 'false') {
|
|---|
| 45 | $module_smarty->assign('NAVIGATION', '<div class="smallText" style="clear:both;">
|
|---|
| 46 | <div style="float:left;">'.$listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS).'</div>
|
|---|
| 47 | <div align="right">'.TEXT_RESULT_PAGE.' '.$listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, xtc_get_all_get_params(array ('page', 'info', 'x', 'y', 'keywords')).(isset($_GET['keywords'])?'&keywords='. urlencode($_GET['keywords']):'')).'</div>
|
|---|
| 48 | </div>');
|
|---|
| 49 | } else {
|
|---|
| 50 | $module_smarty->assign('DISPLAY_COUNT', $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS));
|
|---|
| 51 | $module_smarty->assign('DISPLAY_LINKS', $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, xtc_get_all_get_params(array ('page', 'info', 'x', 'y', 'keywords')).(isset($_GET['keywords'])?'&keywords='. urlencode($_GET['keywords']):'')));
|
|---|
| 52 | $module_smarty->caching = 0;
|
|---|
| 53 | $pagination = $module_smarty->fetch(CURRENT_TEMPLATE.'/module/pagination.html');
|
|---|
| 54 | $module_smarty->assign('NAVIGATION', $pagination);
|
|---|
| 55 | $module_smarty->assign('PAGINATION', $pagination);
|
|---|
| 56 | }
|
|---|
| 57 | } else {
|
|---|
| 58 | // no product found
|
|---|
| 59 | // sql for configuration: INSERT INTO `mod200r8016`.`configuration` (`configuration_id`, `configuration_key`, `configuration_value`, `configuration_group_id`, `sort_order`, `last_modified`, `date_added`, `use_function`, `set_function`) VALUES (NULL, 'SHOW_EMPTY_CATEGORY_DESCRIPTION', 'true', '8', '10', '2016-02-24 00:00:00', '2016-02-24 00:00:00', NULL, 'xtc_cfg_select_option(array(''true'', ''false''),'), (NULL, 'SHOW_EMPTY_CATEGORY_SERCHFIELD', 'true', '8', '11', '2016-02-24 00:00:00', '2016-02-24 00:00:00', NULL, 'xtc_cfg_select_option(array(''true'', ''false''),');
|
|---|
| 60 | // Show description if category contains no active items
|
|---|
| 61 | if (SHOW_EMPTY_CATEGORY_DESCRIPTION == 'true'){
|
|---|
| 62 | $result = true;
|
|---|
| 63 | } else {
|
|---|
| 64 | $result = false;
|
|---|
| 65 | }
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | if ($current_category_id != '0') {
|
|---|
| 69 |
|
|---|
| 70 | $category_query = xtDBquery("SELECT cd.categories_description,
|
|---|
| 71 | cd.categories_name,
|
|---|
| 72 | cd.categories_heading_title,
|
|---|
| 73 | c.listing_template,
|
|---|
| 74 | c.categories_image
|
|---|
| 75 | FROM ".TABLE_CATEGORIES." c
|
|---|
| 76 | JOIN ".TABLE_CATEGORIES_DESCRIPTION." cd
|
|---|
| 77 | ON (c.categories_id = cd.categories_id AND cd.language_id = '".$_SESSION['languages_id']."')
|
|---|
| 78 | WHERE c.categories_id = '".$current_category_id."'
|
|---|
| 79 | ".CATEGORIES_CONDITIONS_C."
|
|---|
| 80 | LIMIT 1");
|
|---|
| 81 | $category = xtc_db_fetch_array($category_query, true);
|
|---|
| 82 | if ($category['categories_image'] != '') {
|
|---|
| 83 | $image = DIR_WS_IMAGES.'categories/'.$category['categories_image'];
|
|---|
| 84 | if (!file_exists(DIR_FS_CATALOG.$image)) {
|
|---|
| 85 | if (CATEGORIES_IMAGE_SHOW_NO_IMAGE == 'true') {
|
|---|
| 86 | $image = DIR_WS_IMAGES.'categories/noimage.gif';
|
|---|
| 87 | } else {
|
|---|
| 88 | $image = '';
|
|---|
| 89 | }
|
|---|
| 90 | }
|
|---|
| 91 | }
|
|---|
| 92 | }
|
|---|
| 93 |
|
|---|
| 94 | if (isset($_GET['manufacturers_id']) && $_GET['manufacturers_id'] > 0) {
|
|---|
| 95 | $manufacturers_id = (int)$_GET['manufacturers_id'];
|
|---|
| 96 | } elseif (isset($_GET['filter_id']) && $_GET['filter_id'] > 0) {
|
|---|
| 97 | $manufacturers_id = (int)$_GET['filter_id'];
|
|---|
| 98 | }
|
|---|
| 99 |
|
|---|
| 100 | if (isset($manufacturers_id)) {
|
|---|
| 101 | $manu_query = xtDBquery("SELECT m.manufacturers_image,
|
|---|
| 102 | m.manufacturers_name,
|
|---|
| 103 | mi.manufacturers_description
|
|---|
| 104 | FROM ".TABLE_MANUFACTURERS." m
|
|---|
| 105 | JOIN " . TABLE_MANUFACTURERS_INFO . " mi
|
|---|
| 106 | ON (m.manufacturers_id = mi.manufacturers_id
|
|---|
| 107 | AND mi.languages_id = '" . (int)$_SESSION['languages_id'] . "')
|
|---|
| 108 | WHERE m.manufacturers_id = '".$manufacturers_id."'");
|
|---|
| 109 | $manu = xtc_db_fetch_array($manu_query, true);
|
|---|
| 110 | if ($manu['manufacturers_image'] != '') {
|
|---|
| 111 | $manu_image = DIR_WS_IMAGES.$manu['manufacturers_image'];
|
|---|
| 112 | if (!file_exists(DIR_FS_CATALOG.$manu_image)) {
|
|---|
| 113 | if (MANUFACTURER_IMAGE_SHOW_NO_IMAGE == 'true') {
|
|---|
| 114 | $manu_image = DIR_WS_IMAGES.'manufacturers/noimage.gif';
|
|---|
| 115 | } else {
|
|---|
| 116 | $manu_image = '';
|
|---|
| 117 | }
|
|---|
| 118 | }
|
|---|
| 119 | }
|
|---|
| 120 | if ($current_category_id != '0') {
|
|---|
| 121 | $module_smarty->assign('MANUFACTURER_IMAGE', ((isset($manu_image) && $manu_image != '') ? DIR_WS_BASE . $manu_image : ''));
|
|---|
| 122 | $module_smarty->assign('MANUFACTURER_NAME', $manu['manufacturers_name']);
|
|---|
| 123 | $module_smarty->assign('MANUFACTURER_DESCRIPTION', $manu['manufacturers_description']);
|
|---|
| 124 | $module_smarty->assign('MANUFACTURER_LINK', xtc_href_link(FILENAME_DEFAULT, xtc_manufacturer_link($manu['manufacturers_id'], $manu['manufacturers_name'])));
|
|---|
| 125 | } else {
|
|---|
| 126 | $category['categories_name'] = $manu['manufacturers_name'];
|
|---|
| 127 | $category['categories_description'] = $manu['manufacturers_description'];
|
|---|
| 128 | $image = ((isset($manu_image) && $manu_image != '') ? $manu_image : '');
|
|---|
| 129 | }
|
|---|
| 130 | }
|
|---|
| 131 |
|
|---|
| 132 | if ($current_category_id == '0' && isset($_GET['keywords'])) {
|
|---|
| 133 | $category['categories_name'] = TEXT_SEARCH_TERM . stripslashes(trim(urldecode($_GET['keywords'])));
|
|---|
| 134 | }
|
|---|
| 135 |
|
|---|
| 136 | if (isset($category['categories_heading_title']) && $category['categories_heading_title'] != '') {
|
|---|
| 137 | $list_title = $category['categories_heading_title'];
|
|---|
| 138 | } elseif (isset($category['categories_name']) && $category['categories_name'] != '') {
|
|---|
| 139 | $list_title = $category['categories_name'];
|
|---|
| 140 | }
|
|---|
| 141 |
|
|---|
| 142 | $module_smarty->assign('LIST_TITLE', isset($list_title) ? $list_title : '');
|
|---|
| 143 | $module_smarty->assign('CATEGORIES_NAME', isset($category['categories_name']) ? $category['categories_name'] : '');
|
|---|
| 144 | $module_smarty->assign('CATEGORIES_HEADING_TITLE', isset($category['categories_heading_title']) ? $category['categories_heading_title'] : '');
|
|---|
| 145 | $module_smarty->assign('CATEGORIES_DESCRIPTION', isset($category['categories_description']) ? $category['categories_description'] : '');
|
|---|
| 146 | $module_smarty->assign('CATEGORIES_IMAGE', ((isset($image) && $image != '') ? DIR_WS_BASE . $image : ''));
|
|---|
| 147 |
|
|---|
| 148 | $listing_query = xtDBquery($listing_split->sql_query);
|
|---|
| 149 | while ($listing = xtc_db_fetch_array($listing_query, true)) {
|
|---|
| 150 | $module_content[] = $product->buildDataArray($listing);
|
|---|
| 151 | }
|
|---|
| 152 | //} else {
|
|---|
| 153 | // no product found
|
|---|
| 154 | //$result = false;
|
|---|
| 155 | //}
|
|---|
| 156 |
|
|---|
| 157 | //include Categorie Listing
|
|---|
| 158 | include (DIR_WS_MODULES. 'categories_listing.php');
|
|---|
| 159 |
|
|---|
| 160 | if ($result != false) {
|
|---|
| 161 | // get default template
|
|---|
| 162 | if (empty($category['listing_template']) || $category['listing_template'] == 'default') {
|
|---|
| 163 | $files = array ();
|
|---|
| 164 | if ($dir = opendir(DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/module/product_listing/')) {
|
|---|
| 165 | while (($file = readdir($dir)) !== false) {
|
|---|
| 166 | if (is_file(DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/module/product_listing/'.$file) and (substr($file, -5) == ".html") and ($file != "index.html") and (substr($file, 0, 1) !=".")) {
|
|---|
| 167 | $files[] = $file;
|
|---|
| 168 | }
|
|---|
| 169 | }
|
|---|
| 170 | closedir($dir);
|
|---|
| 171 | }
|
|---|
| 172 | sort($files);
|
|---|
| 173 | $category['listing_template'] = $files[0];
|
|---|
| 174 | }
|
|---|
| 175 |
|
|---|
| 176 | $module_smarty->assign('MANUFACTURER_DROPDOWN', (isset($manufacturer_dropdown) ? $manufacturer_dropdown : ''));
|
|---|
| 177 | $module_smarty->assign('language', $_SESSION['language']);
|
|---|
| 178 | $module_smarty->assign('module_content', $module_content);
|
|---|
| 179 | // support for own manufacturers template
|
|---|
| 180 | $template = CURRENT_TEMPLATE.'/module/product_listing/'.$category['listing_template'];
|
|---|
| 181 | if (isset ($_GET['manufacturers_id']) && $_GET['manufacturers_id'] > 0 && strpos($PHP_SELF, FILENAME_ADVANCED_SEARCH_RESULT) === false) {
|
|---|
| 182 | if (is_file(DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/module/manufacturers_listing.html')) {
|
|---|
| 183 | $template = CURRENT_TEMPLATE.'/module/manufacturers_listing.html';
|
|---|
| 184 | }
|
|---|
| 185 | }
|
|---|
| 186 | // set cache ID
|
|---|
| 187 | if (!CacheCheck()) {
|
|---|
| 188 | $module_smarty->caching = 0;
|
|---|
| 189 | $module = $module_smarty->fetch(CURRENT_TEMPLATE.'/module/product_listing/'.$category['listing_template']);
|
|---|
| 190 | } else {
|
|---|
| 191 | $module_smarty->caching = 1;
|
|---|
| 192 | $module_smarty->cache_lifetime = CACHE_LIFETIME;
|
|---|
| 193 | $module_smarty->cache_modified_check = CACHE_CHECK;
|
|---|
| 194 |
|
|---|
| 195 | //setting/clearing params
|
|---|
| 196 | $get_params = isset($_GET['manufacturers_id']) && xtc_not_null($_GET['manufacturers_id']) ? '_'.(int)$_GET['manufacturers_id'] : '';
|
|---|
| 197 | $get_params .= isset($_GET['filter_id']) && xtc_not_null($_GET['filter_id']) ? '_'.(int)$_GET['filter_id'] : '';
|
|---|
| 198 | $get_params .= isset($_GET['page']) && $_GET['page'] > 0 ? '_'.(int)$_GET['page'] : '';
|
|---|
| 199 | $get_params .= isset($_GET['categories_id']) && xtc_not_null($_GET['categories_id']) ? '_'.(int)$_GET['categories_id'] : '';
|
|---|
| 200 | $get_params .= isset($_GET['keywords']) && !empty($_GET['keywords']) ? '_'.stripslashes(trim(urldecode($_GET['keywords']))) : '';
|
|---|
| 201 | $get_params .= isset($_GET['pfrom']) && !empty($_GET['pfrom']) ? '_'.stripslashes($_GET['pfrom']) : '';
|
|---|
| 202 | $get_params .= isset($_GET['pto']) && !empty($_GET['pto']) ? '_'.stripslashes($_GET['pto']) : '';
|
|---|
| 203 | $get_params .= isset($_GET['x']) && $_GET['x'] >= 0 ? '_'.(int)$_GET['x'] : '';
|
|---|
| 204 | $get_params .= isset($_GET['y']) && $_GET['y'] >= 0 ? '_'.(int)$_GET['y'] : '';
|
|---|
| 205 |
|
|---|
| 206 | $cache_id = md5($current_category_id.'_'.$_SESSION['language'].'_'.$_SESSION['customers_status']['customers_status_name'].'_'.$_SESSION['currency'].$get_params);
|
|---|
| 207 | $module = $module_smarty->fetch(CURRENT_TEMPLATE.'/module/product_listing/'.$category['listing_template'], $cache_id);
|
|---|
| 208 | }
|
|---|
| 209 |
|
|---|
| 210 | // Show empty Category and Searchfield (needs changes in template-file)
|
|---|
| 211 | if ((SHOW_EMPTY_CATEGORY_DESCRIPTION == 'true') && (SHOW_EMPTY_CATEGORY_SERCHFIELD == 'true')){
|
|---|
| 212 |
|
|---|
| 213 | $error = TEXT_PRODUCT_NOT_FOUND;
|
|---|
| 214 |
|
|---|
| 215 | $module_smarty->assign('language', $_SESSION['language']);
|
|---|
| 216 | $module_smarty->assign('ERROR', $error);
|
|---|
| 217 | $module_smarty->assign('BUTTON', '<a href="javascript:history.back(1)">'. xtc_image_button('button_back.gif', IMAGE_BUTTON_BACK).'</a>');
|
|---|
| 218 | $module_smarty->assign('language', $_SESSION['language']);
|
|---|
| 219 |
|
|---|
| 220 | // search field
|
|---|
| 221 | $module_smarty->assign('FORM_ACTION', xtc_draw_form('new_find', xtc_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', $request_type, false), 'get').xtc_hide_session_id());
|
|---|
| 222 | $module_smarty->assign('INPUT_SEARCH', xtc_draw_input_field('keywords', '', 'size="30" maxlength="30"'));
|
|---|
| 223 | $module_smarty->assign('BUTTON_SUBMIT', xtc_image_submit('button_search.gif', IMAGE_BUTTON_SEARCH));
|
|---|
| 224 | $module_smarty->assign('LINK_ADVANCED', xtc_href_link(FILENAME_ADVANCED_SEARCH));
|
|---|
| 225 | $module_smarty->assign('FORM_END', '</form>');
|
|---|
| 226 |
|
|---|
| 227 | $module_smarty->caching = 0;
|
|---|
| 228 |
|
|---|
| 229 | $smarty->assign('bestseller', true);
|
|---|
| 230 | }
|
|---|
| 231 |
|
|---|
| 232 | $smarty->assign('main_content', $module);
|
|---|
| 233 |
|
|---|
| 234 | } else {
|
|---|
| 235 |
|
|---|
| 236 | $error = TEXT_PRODUCT_NOT_FOUND;
|
|---|
| 237 | include_once (DIR_WS_MODULES.FILENAME_ERROR_HANDLER);
|
|---|
| 238 | }
|
|---|
| 239 | ?>
|
|---|