[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 源代码 record_company_filter.php

Zen Cart 源代码 record_company_filter.php




下载文件

文件名: record_company_filter.php
文件类型: PHP文件
文件大小: 11.6 KiB
MD5: 8e05242a8251eeb8116dc89f00eeda14

record_company_filter.php - 关闭高亮
  1. <?php
  2. /**
  3.  * record_company_filter.php  for index filters
  4.  *
  5.  * index filter for the music product type
  6.  * show the products of a specified record company
  7.  *
  8.  * @package productTypes
  9.  * @copyright Copyright 2003-2010 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: record_company_filter.php 15628 2010-03-07 01:21:55Z 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 record-company
  28.   if (isset($_GET['record_company_id']))
  29.   {
  30.     if (isset($_GET['filter_id']) && zen_not_null($_GET['filter_id']))
  31.     {
  32.       // We are asked to show only a specific category
  33.       $listing_sql = "select " . $select_column_list . " p.products_id, p.products_type, p.master_categories_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
  34.        from " . TABLE_PRODUCTS . " p, " .
  35.         TABLE_PRODUCTS_DESCRIPTION . " pd, " .
  36.         TABLE_PRODUCT_MUSIC_EXTRA . " pme left join " . TABLE_SPECIALS . " s on pme.products_id = s.products_id, " .
  37.         TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " .
  38.         TABLE_RECORD_COMPANY . " r
  39.        where r.record_company_id = '" . (int)$_GET['record_company_id'] . "'
  40.          and p.products_id = pme.products_id
  41.          and p.products_status = 1
  42.          and pme.record_company_id = r.record_company_id
  43.          and pme.products_id = p2c.products_id
  44.          and pd.products_id = p2c.products_id
  45.          and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
  46.          and p2c.categories_id = '" . (int)$_GET['filter_id'] . "'" .
  47.           $alpha_sort;
  48.     } else {
  49.       // We show them all
  50.       $listing_sql = "select " . $select_column_list . " pme.products_id, p.products_type, p.master_categories_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
  51.        from " . TABLE_PRODUCTS . " p, " .
  52.         TABLE_PRODUCTS_DESCRIPTION . " pd, " .
  53.         TABLE_PRODUCT_MUSIC_EXTRA . " pme left join " . TABLE_SPECIALS . " s on pme.products_id = s.products_id, " .
  54.         TABLE_RECORD_COMPANY . " r
  55.        where r.record_company_id = '" . (int)$_GET['record_company_id'] . "'
  56.          and p.products_id = pme.products_id
  57.          and p.products_status = 1
  58.          and pd.products_id = pme.products_id
  59.          and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
  60.          and pme.record_company_id = r.record_company_id" .
  61.           $alpha_sort;
  62.     }
  63.   } else {
  64.     // show the products in a given category
  65.     if (isset($_GET['filter_id']) && zen_not_null($_GET['filter_id']))
  66.     {
  67.       // We are asked to show only specific category
  68.       $listing_sql = "select " . $select_column_list . " p.products_id, p.products_type, p.master_categories_id, r.record_company_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
  69.        from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " .
  70.         TABLE_PRODUCTS_DESCRIPTION . " pd, " .
  71.         TABLE_RECORD_COMPANY . " r, " .
  72.         TABLE_PRODUCT_MUSIC_EXTRA . " pme, " .
  73.         TABLE_PRODUCTS_TO_CATEGORIES . " p2c
  74.        where p.products_status = 1
  75.          and pme.record_company_id = r.record_company_id
  76.          and r.record_company_id = '" . (int)$_GET['filter_id'] . "'
  77.          and p.products_id = p2c.products_id
  78.          and pd.products_id = p2c.products_id
  79.          and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
  80.          and p2c.categories_id = '" . (int)$current_category_id . "'" .
  81.           $alpha_sort;
  82.     } else {
  83.       // We show them all
  84.       if ($current_categories_id) {
  85.         $listing_sql = "select " . $select_column_list . " p.products_id, p.products_type, p.master_categories_id, r.record_company_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
  86.        from " . TABLE_PRODUCTS . " p, " .
  87.         TABLE_PRODUCTS_DESCRIPTION . " pd, " .
  88.         TABLE_PRODUCT_MUSIC_EXTRA . " pme left join " . TABLE_SPECIALS . " s on pme.products_id = s.products_id, " .
  89.         TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " .
  90.         TABLE_RECORD_COMPANY . " r
  91.        where  r.record_company_id = pme.record_company_id
  92.          and p.products_id = pme.products_id
  93.          and p.products_status = 1
  94.          and pd.products_id = pme.products_id
  95.          and p2c.products_id = p.products_id
  96.          and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
  97.          and p2c.categories_id = '" . (int)$current_category_id . "'" .
  98.           $alpha_sort;
  99.       } else {
  100.         $listing_sql = "select " . $select_column_list . " p.products_id, p.products_type, p.master_categories_id, r.record_company_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
  101.        from " . TABLE_PRODUCTS . " p, " .
  102.         TABLE_PRODUCTS_DESCRIPTION . " pd, " .
  103.         TABLE_PRODUCT_MUSIC_EXTRA . " pme left join " . TABLE_SPECIALS . " s on pme.products_id = s.products_id, " .
  104.         TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " .
  105.         TABLE_RECORD_COMPANY . " r
  106.        where r.record_company_id = pme.record_company_id
  107.          and p.products_id = pme.products_id
  108.          and p.products_status = 1
  109.          and pd.products_id = pme.products_id
  110.          and p2c.products_id = p.products_id
  111.          and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'" .
  112.           $alpha_sort;
  113.       }
  114.     }
  115.   }
  116.   // set the default sort order setting from the Admin when not defined by customer
  117.   if (!isset($_GET['sort']) and PRODUCT_LISTING_DEFAULT_SORT_ORDER != '') {
  118.     $_GET['sort'] = PRODUCT_LISTING_DEFAULT_SORT_ORDER;
  119.   }
  120.  
  121.   $listing_sql = str_replace('m.manufacturers_name', 'r.record_company_name as manufacturers_name', $listing_sql);
  122.  
  123.   if (isset($column_list)) {
  124.     if ( (!isset($_GET['sort'])) || (isset($_GET['sort']) && !preg_match('/[1-8][ad]/', $_GET['sort'])) || (substr($_GET['sort'], 0, 1) > sizeof($column_list)) )
  125.     {
  126.       for ($i=0, $n=sizeof($column_list); $i<$n; $i++)
  127.       {
  128.         if ($column_list[$i] == 'PRODUCT_LIST_NAME')
  129.         {
  130.           $_GET['sort'] = $i+1 . 'a';
  131.           $listing_sql .= " order by p.products_sort_order, pd.products_name";
  132.           break;
  133.         }
  134.       }
  135.       // if set to nothing use products_sort_order and PRODUCTS_LIST_NAME is off
  136.       if (PRODUCT_LISTING_DEFAULT_SORT_ORDER == '') {
  137.         $_GET['sort'] = '20a';
  138.       }
  139.     } else {
  140.       $sort_col = substr($_GET['sort'], 0 , 1);
  141.       $sort_order = substr($_GET['sort'], 1);
  142.       switch ($column_list[$sort_col-1])
  143.       {
  144.         case 'PRODUCT_LIST_MODEL':
  145.         $listing_sql .= " order by p.products_model " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
  146.         break;
  147.         case 'PRODUCT_LIST_NAME':
  148.         $listing_sql .= " order by pd.products_name " . ($sort_order == 'd' ? 'desc' : '');
  149.         break;
  150.         case 'PRODUCT_LIST_MANUFACTURER':
  151.         $listing_sql .= " order by r.record_company_name " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
  152.         break;
  153.         case 'PRODUCT_LIST_QUANTITY':
  154.         $listing_sql .= " order by p.products_quantity " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
  155.         break;
  156.         case 'PRODUCT_LIST_IMAGE':
  157.         $listing_sql .= " order by pd.products_name";
  158.         break;
  159.         case 'PRODUCT_LIST_WEIGHT':
  160.         $listing_sql .= " order by p.products_weight " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
  161.         break;
  162.         case 'PRODUCT_LIST_PRICE':
  163.         $listing_sql .= " order by p.products_price_sorter " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
  164.         break;
  165.       }
  166.     }
  167.   }
  168.   // optional Product List Filter
  169.   if (PRODUCT_LIST_FILTER > 0)
  170.   {
  171.     if (isset($_GET['record_company_id']))
  172.     {
  173.       $filterlist_sql = "select distinct c.categories_id as id, cd.categories_name as name
  174.        from " . TABLE_PRODUCTS . " p, " .
  175.         TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " .
  176.         TABLE_CATEGORIES . " c, " .
  177.         TABLE_CATEGORIES_DESCRIPTION . " cd, " .
  178.         TABLE_PRODUCT_MUSIC_EXTRA . " pme
  179.        where p.products_status = 1
  180.          and pme.products_id = p2c.products_id
  181.          and p.products_id = p2c.products_id
  182.          and p2c.categories_id = c.categories_id
  183.          and p2c.categories_id = cd.categories_id
  184.          and cd.language_id = '" . (int)$_SESSION['languages_id'] . "'
  185.          and pme.record_company_id = '" . (int)$_GET['record_company_id'] . "'
  186.        order by cd.categories_name";
  187.     } else {
  188.       $filterlist_sql= "select distinct r.record_company_id as id, r.record_company_name as name
  189.        from " . TABLE_PRODUCTS . " p, " .
  190.         TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " .
  191.         TABLE_PRODUCT_MUSIC_EXTRA . " pme, " .
  192.         TABLE_RECORD_COMPANY . " m
  193.        where p.products_status = 1
  194.          and pme.record_company_id = r.record_company_id
  195.          and p.products_id = p2c.products_id
  196.          and pme.products_id = p.products_id
  197.          and p2c.categories_id = '" . (int)$current_category_id . "'
  198.        order by r.record_company_name";
  199.     }
  200.     $getoption_set =  false;
  201.     $do_filter_list = false;
  202.     $filterlist = $db->Execute($filterlist_sql);
  203.     if ($filterlist->RecordCount() > 1)
  204.     {
  205.       $do_filter_list = true;
  206.       if (isset($_GET['record_company_id']))
  207.       {
  208.         $getoption_set =  true;
  209.         $get_option_variable = 'record_company_id';
  210.         $options = array(array('id' => '', 'text' => TEXT_ALL_CATEGORIES));
  211.       } else {
  212.         $options = array(array('id' => '', 'text' => TEXT_ALL_MUSIC_GENRE));
  213.       }
  214.       while (!$filterlist->EOF) {
  215.         $options[] = array('id' => $filterlist->fields['id'], 'text' => $filterlist->fields['name']);
  216.         $filterlist->MoveNext();
  217.       }
  218.     }
  219.   }
  220.