[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
Zen Cart 源代码 default_filter.php

Zen Cart 源代码 default_filter.php




下载文件

文件名: default_filter.php
文件类型: PHP文件
文件大小: 10.01 KiB
MD5: 1186138efb90338fcfcccfac911d3e3b

default_filter.php - 关闭高亮
  1. <?php
  2. /**
  3.  * default_filter.php  for index filters
  4.  *
  5.  * index filter for the default product type
  6.  * show the products of a specified manufacturer
  7.  *
  8.  * @package productTypes
  9.  * @copyright Copyright 2003-2009 Zen Cart Development Team
  10.  * @copyright Portions Copyright 2003 osCommerce
  11.  * @todo Need to add/fine-tune ability to override or insert entry-points on a per-product-type basis
  12.  * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
  13.  * @version $Id: default_filter.php 14870 2009-11-19 22:36:24Z drbyte $
  14.  */
  15. if (!defined('IS_ADMIN_FLAG')) {
  16.   die('Illegal Access');
  17. }
  18. if (isset($_GET['sort']) && strlen($_GET['sort']) > 3) {
  19.   $_GET['sort'] = substr($_GET['sort'], 0, 3);
  20. }
  21. if (isset($_GET['alpha_filter_id']) && (int)$_GET['alpha_filter_id'] > 0) {
  22.     $alpha_sort = " and pd.products_name LIKE '" . chr((int)$_GET['alpha_filter_id']) . "%' ";
  23.   } else {
  24.     $alpha_sort = '';
  25.   }
  26.   if (!isset($select_column_list)) $select_column_list = "";
  27.    // show the products of a specified manufacturer
  28.   if (isset($_GET['manufacturers_id']) && $_GET['manufacturers_id'] != '' ) {
  29.     if (isset($_GET['filter_id']) && zen_not_null($_GET['filter_id'])) {
  30. // We are asked to show only a specific category
  31.       $listing_sql = "select " . $select_column_list . " p.products_id, p.products_type, p.master_categories_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, pd.products_description, if(s.status = 1, s.specials_new_products_price, NULL) AS specials_new_products_price, IF(s.status = 1, s.specials_new_products_price, p.products_price) as final_price, p.products_sort_order, p.product_is_call, p.product_is_always_free_shipping, p.products_qty_box_status
  32.       from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id , " .
  33.        TABLE_PRODUCTS_DESCRIPTION . " pd, " .
  34.        TABLE_MANUFACTURERS . " m, " .
  35.        TABLE_PRODUCTS_TO_CATEGORIES . " p2c
  36.       where p.products_status = 1
  37.         and p.manufacturers_id = m.manufacturers_id
  38.         and m.manufacturers_id = '" . (int)$_GET['manufacturers_id'] . "'
  39.         and p.products_id = p2c.products_id
  40.         and pd.products_id = p2c.products_id
  41.         and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
  42.         and p2c.categories_id = '" . (int)$_GET['filter_id'] . "'" .
  43.          $alpha_sort;
  44.     } else {
  45. // We show them all
  46.       $listing_sql = "select " . $select_column_list . " p.products_id, p.products_type, p.master_categories_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, pd.products_description, IF(s.status = 1, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status = 1, s.specials_new_products_price, p.products_price) as final_price, p.products_sort_order, p.product_is_call, p.product_is_always_free_shipping, p.products_qty_box_status
  47.      from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " .
  48.       TABLE_PRODUCTS_DESCRIPTION . " pd, " .
  49.       TABLE_MANUFACTURERS . " m
  50.      where p.products_status = 1
  51.        and pd.products_id = p.products_id
  52.        and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
  53.        and p.manufacturers_id = m.manufacturers_id
  54.        and m.manufacturers_id = '" . (int)$_GET['manufacturers_id'] . "'" .
  55.         $alpha_sort;
  56.     }
  57.   } else {
  58. // show the products in a given category
  59.     if (isset($_GET['filter_id']) && zen_not_null($_GET['filter_id'])) {
  60. // We are asked to show only specific category
  61.       $listing_sql = "select " . $select_column_list . " p.products_id, p.products_type, p.master_categories_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, pd.products_description, IF(s.status = 1, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status = 1, s.specials_new_products_price, p.products_price) as final_price, p.products_sort_order, p.product_is_call, p.product_is_always_free_shipping, p.products_qty_box_status
  62.      from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " .
  63.       TABLE_PRODUCTS_DESCRIPTION . " pd, " .
  64.       TABLE_MANUFACTURERS . " m, " .
  65.       TABLE_PRODUCTS_TO_CATEGORIES . " p2c
  66.      where p.products_status = 1
  67.        and p.manufacturers_id = m.manufacturers_id
  68.        and m.manufacturers_id = '" . (int)$_GET['filter_id'] . "'
  69.        and p.products_id = p2c.products_id
  70.        and pd.products_id = p2c.products_id
  71.        and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
  72.        and p2c.categories_id = '" . (int)$current_category_id . "'" .
  73.         $alpha_sort;
  74.     } else {
  75. // We show them all
  76.       $listing_sql = "select " . $select_column_list . " p.products_id, p.products_type, p.master_categories_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, pd.products_description, IF(s.status = 1, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status =1, s.specials_new_products_price, p.products_price) as final_price, p.products_sort_order, p.product_is_call, p.product_is_always_free_shipping, p.products_qty_box_status
  77.       from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " .
  78.        TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " .
  79.        TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p2c.products_id = s.products_id
  80.       where p.products_status = 1
  81.         and p.products_id = p2c.products_id
  82.         and pd.products_id = p2c.products_id
  83.         and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
  84.         and p2c.categories_id = '" . (int)$current_category_id . "'" .
  85.          $alpha_sort;
  86.     }
  87.   }
  88.  
  89. // set the default sort order setting from the Admin when not defined by customer
  90.   if (!isset($_GET['sort']) and PRODUCT_LISTING_DEFAULT_SORT_ORDER != '') {
  91.     $_GET['sort'] = PRODUCT_LISTING_DEFAULT_SORT_ORDER;
  92.   }
  93.  
  94.   if (isset($column_list)) {
  95.     if ((!isset($_GET['sort'])) || (isset($_GET['sort']) && !preg_match('/[1-8][ad]/', $_GET['sort'])) || (substr($_GET['sort'], 0, 1) > sizeof($column_list)) ) {
  96.       for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
  97.         if (isset($column_list[$i]) && $column_list[$i] == 'PRODUCT_LIST_NAME') {
  98.           $_GET['sort'] = $i+1 . 'a';
  99.           $listing_sql .= " order by p.products_sort_order, pd.products_name";
  100.           break;
  101.         } else {
  102. // sort by products_sort_order when PRODUCT_LISTING_DEFAULT_SORT_ORDER is left blank
  103. // for reverse, descending order use:
  104. //       $listing_sql .= " order by p.products_sort_order desc, pd.products_name";
  105.           $listing_sql .= " order by p.products_sort_order, pd.products_name";
  106.           break;
  107.         }
  108.       }
  109. // if set to nothing use products_sort_order and PRODUCTS_LIST_NAME is off
  110.       if (PRODUCT_LISTING_DEFAULT_SORT_ORDER == '') {
  111.         $_GET['sort'] = '20a';
  112.       }
  113.     } else {
  114.       $sort_col = substr($_GET['sort'], 0 , 1);
  115.       $sort_order = substr($_GET['sort'], 1);
  116.       switch ($column_list[$sort_col-1]) {
  117.         case 'PRODUCT_LIST_MODEL':
  118.           $listing_sql .= " order by p.products_model " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
  119.           break;
  120.         case 'PRODUCT_LIST_NAME':
  121.           $listing_sql .= " order by pd.products_name " . ($sort_order == 'd' ? 'desc' : '');
  122.           break;
  123.         case 'PRODUCT_LIST_MANUFACTURER':
  124.           $listing_sql .= " order by m.manufacturers_name " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
  125.           break;
  126.         case 'PRODUCT_LIST_QUANTITY':
  127.           $listing_sql .= " order by p.products_quantity " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
  128.           break;
  129.         case 'PRODUCT_LIST_IMAGE':
  130.           $listing_sql .= " order by pd.products_name";
  131.           break;
  132.         case 'PRODUCT_LIST_WEIGHT':
  133.           $listing_sql .= " order by p.products_weight " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
  134.           break;
  135.         case 'PRODUCT_LIST_PRICE':
  136.           $listing_sql .= " order by p.products_price_sorter " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
  137.           break;
  138.       }
  139.     }
  140.   }
  141. // optional Product List Filter
  142.   if (PRODUCT_LIST_FILTER > 0) {
  143.     if (isset($_GET['manufacturers_id']) && $_GET['manufacturers_id'] != '') {
  144.       $filterlist_sql = "select distinct c.categories_id as id, cd.categories_name as name
  145.      from " . TABLE_PRODUCTS . " p, " .
  146.       TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " .
  147.       TABLE_CATEGORIES . " c, " .
  148.       TABLE_CATEGORIES_DESCRIPTION . " cd
  149.      where p.products_status = 1
  150.        and p.products_id = p2c.products_id
  151.        and p2c.categories_id = c.categories_id
  152.        and p2c.categories_id = cd.categories_id
  153.        and cd.language_id = '" . (int)$_SESSION['languages_id'] . "'
  154.        and p.manufacturers_id = '" . (int)$_GET['manufacturers_id'] . "'
  155.      order by cd.categories_name";
  156.     } else {
  157.       $filterlist_sql= "select distinct m.manufacturers_id as id, m.manufacturers_name as name
  158.      from " . TABLE_PRODUCTS . " p, " .
  159.       TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " .
  160.       TABLE_MANUFACTURERS . " m
  161.      where p.products_status = 1
  162.        and p.manufacturers_id = m.manufacturers_id
  163.        and p.products_id = p2c.products_id
  164.        and p2c.categories_id = '" . (int)$current_category_id . "'
  165.      order by m.manufacturers_name";
  166.     }
  167.     $do_filter_list = false;
  168.     $filterlist = $db->Execute($filterlist_sql);
  169.     if ($filterlist->RecordCount() > 1) {
  170.         $do_filter_list = true;
  171.       if (isset($_GET['manufacturers_id'])) {
  172.         $getoption_set =  true;
  173.         $get_option_variable = 'manufacturers_id';
  174.         $options = array(array('id' => '', 'text' => TEXT_ALL_CATEGORIES));
  175.       } else {
  176.         $options = array(array('id' => '', 'text' => TEXT_ALL_MANUFACTURERS));
  177.       }
  178.       while (!$filterlist->EOF) {
  179.         $options[] = array('id' => $filterlist->fields['id'], 'text' => $filterlist->fields['name']);
  180.         $filterlist->MoveNext();
  181.       }
  182.     }
  183.   }