[ Index ]
 

Code source de Zen Cart E-Commerce Shopping Cart 1.3.7.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/includes/index_filters/ -> default_filter.php (source)

   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-2006 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 4770 2006-10-17 05:12:23Z drbyte $

  14   */
  15  if (!defined('IS_ADMIN_FLAG')) {
  16    die('Illegal Access');
  17  }
  18    if (isset($_GET['alpha_filter_id']) && (int)$_GET['alpha_filter_id'] > 0) {
  19      $alpha_sort = " and pd.products_name LIKE '" . chr((int)$_GET['alpha_filter_id']) . "%' ";
  20    } else {
  21      $alpha_sort = '';
  22    }
  23    if (!isset($select_column_list)) $select_column_list = "";
  24     // show the products of a specified manufacturer

  25    if (isset($_GET['manufacturers_id']) && $_GET['manufacturers_id'] != '' ) {
  26      if (isset($_GET['filter_id']) && zen_not_null($_GET['filter_id'])) {
  27  // We are asked to show only a specific category

  28        $listing_sql = "select " . $select_column_list . " p.products_id, p.products_type, 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
  29         from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id , " .
  30         TABLE_PRODUCTS_DESCRIPTION . " pd, " .
  31         TABLE_MANUFACTURERS . " m, " .
  32         TABLE_PRODUCTS_TO_CATEGORIES . " p2c
  33         where p.products_status = 1
  34           and p.manufacturers_id = m.manufacturers_id
  35           and m.manufacturers_id = '" . (int)$_GET['manufacturers_id'] . "'
  36           and p.products_id = p2c.products_id
  37           and pd.products_id = p2c.products_id
  38           and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
  39           and p2c.categories_id = '" . (int)$_GET['filter_id'] . "'" .
  40           $alpha_sort;
  41      } else {
  42  // We show them all

  43        $listing_sql = "select " . $select_column_list . " p.products_id, p.products_type, 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
  44        from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " .
  45        TABLE_PRODUCTS_DESCRIPTION . " pd, " .
  46        TABLE_MANUFACTURERS . " m
  47        where p.products_status = 1
  48          and pd.products_id = p.products_id
  49          and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
  50          and p.manufacturers_id = m.manufacturers_id
  51          and m.manufacturers_id = '" . (int)$_GET['manufacturers_id'] . "'" .
  52          $alpha_sort;
  53      }
  54    } else {
  55  // show the products in a given category

  56      if (isset($_GET['filter_id']) && zen_not_null($_GET['filter_id'])) {
  57  // We are asked to show only specific category

  58        $listing_sql = "select " . $select_column_list . " p.products_id, p.products_type, 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
  59        from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " .
  60        TABLE_PRODUCTS_DESCRIPTION . " pd, " .
  61        TABLE_MANUFACTURERS . " m, " .
  62        TABLE_PRODUCTS_TO_CATEGORIES . " p2c
  63        where p.products_status = 1
  64          and p.manufacturers_id = m.manufacturers_id
  65          and m.manufacturers_id = '" . (int)$_GET['filter_id'] . "'
  66          and p.products_id = p2c.products_id
  67          and pd.products_id = p2c.products_id
  68          and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
  69          and p2c.categories_id = '" . (int)$current_category_id . "'" .
  70          $alpha_sort;
  71      } else {
  72  // We show them all

  73        $listing_sql = "select " . $select_column_list . " p.products_id, p.products_type, 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
  74         from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " .
  75         TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " .
  76         TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p2c.products_id = s.products_id
  77         where p.products_status = 1
  78           and p.products_id = p2c.products_id
  79           and pd.products_id = p2c.products_id
  80           and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
  81           and p2c.categories_id = '" . (int)$current_category_id . "'" .
  82           $alpha_sort;
  83      }
  84    }
  85  
  86  // set the default sort order setting from the Admin when not defined by customer

  87    if (!isset($_GET['sort']) and PRODUCT_LISTING_DEFAULT_SORT_ORDER != '') {
  88      $_GET['sort'] = PRODUCT_LISTING_DEFAULT_SORT_ORDER;
  89    }
  90  
  91    if (isset($column_list)) {
  92      if ((!isset($_GET['sort'])) || (isset($_GET['sort']) && !ereg('[1-8][ad]', $_GET['sort'])) || (substr($_GET['sort'], 0, 1) > sizeof($column_list)) ) {
  93        for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
  94          if (isset($column_list[$i]) && $column_list[$i] == 'PRODUCT_LIST_NAME') {
  95            $_GET['sort'] = $i+1 . 'a';
  96            $listing_sql .= " order by p.products_sort_order, pd.products_name";
  97            break;
  98          } else {
  99  // sort by products_sort_order when PRODUCT_LISTING_DEFAULT_SORT_ORDER is left blank

 100  // for reverse, descending order use:

 101  //       $listing_sql .= " order by p.products_sort_order desc, pd.products_name";

 102            $listing_sql .= " order by p.products_sort_order, pd.products_name";
 103            break;
 104          }
 105        }
 106  // if set to nothing use products_sort_order and PRODUCTS_LIST_NAME is off

 107        if (PRODUCT_LISTING_DEFAULT_SORT_ORDER == '') {
 108          $_GET['sort'] = '20a';
 109        }
 110      } else {
 111        $sort_col = substr($_GET['sort'], 0 , 1);
 112        $sort_order = substr($_GET['sort'], 1);
 113        $listing_sql .= ' order by ';
 114        switch ($column_list[$sort_col-1]) {
 115          case 'PRODUCT_LIST_MODEL':
 116            $listing_sql .= "p.products_model " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
 117            break;
 118          case 'PRODUCT_LIST_NAME':
 119            $listing_sql .= "pd.products_name " . ($sort_order == 'd' ? 'desc' : '');
 120            break;
 121          case 'PRODUCT_LIST_MANUFACTURER':
 122            $listing_sql .= "m.manufacturers_name " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
 123            break;
 124          case 'PRODUCT_LIST_QUANTITY':
 125            $listing_sql .= "p.products_quantity " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
 126            break;
 127          case 'PRODUCT_LIST_IMAGE':
 128            $listing_sql .= "pd.products_name";
 129            break;
 130          case 'PRODUCT_LIST_WEIGHT':
 131            $listing_sql .= "p.products_weight " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
 132            break;
 133          case 'PRODUCT_LIST_PRICE':
 134  //          $listing_sql .= "final_price " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";

 135            $listing_sql .= "p.products_price_sorter " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
 136            break;
 137        }
 138      }
 139    }
 140  // optional Product List Filter

 141    if (PRODUCT_LIST_FILTER > 0) {
 142      if (isset($_GET['manufacturers_id']) && $_GET['manufacturers_id'] != '') {
 143        $filterlist_sql = "select distinct c.categories_id as id, cd.categories_name as name
 144        from " . TABLE_PRODUCTS . " p, " .
 145        TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " .
 146        TABLE_CATEGORIES . " c, " .
 147        TABLE_CATEGORIES_DESCRIPTION . " cd
 148        where p.products_status = 1
 149          and p.products_id = p2c.products_id
 150          and p2c.categories_id = c.categories_id
 151          and p2c.categories_id = cd.categories_id
 152          and cd.language_id = '" . (int)$_SESSION['languages_id'] . "'
 153          and p.manufacturers_id = '" . (int)$_GET['manufacturers_id'] . "'
 154        order by cd.categories_name";
 155      } else {
 156        $filterlist_sql= "select distinct m.manufacturers_id as id, m.manufacturers_name as name
 157        from " . TABLE_PRODUCTS . " p, " .
 158        TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " .
 159        TABLE_MANUFACTURERS . " m
 160        where p.products_status = 1
 161          and p.manufacturers_id = m.manufacturers_id
 162          and p.products_id = p2c.products_id
 163          and p2c.categories_id = '" . (int)$current_category_id . "'
 164        order by m.manufacturers_name";
 165      }
 166      $do_filter_list = false;
 167      $filterlist = $db->Execute($filterlist_sql);
 168      if ($filterlist->RecordCount() > 1) {
 169          $do_filter_list = true;
 170        if (isset($_GET['manufacturers_id'])) {
 171          $getoption_set =  true;
 172          $get_option_variable = 'manufacturers_id';
 173          $options = array(array('id' => '', 'text' => TEXT_ALL_CATEGORIES));
 174        } else {
 175          $options = array(array('id' => '', 'text' => TEXT_ALL_MANUFACTURERS));
 176        }
 177        while (!$filterlist->EOF) {
 178          $options[] = array('id' => $filterlist->fields['id'], 'text' => $filterlist->fields['name']);
 179          $filterlist->MoveNext();
 180        }
 181      }
 182    }
 183  
 184  // Get the right image for the top-right

 185    $image = DIR_WS_TEMPLATE_IMAGES . 'table_background_list.gif';
 186    if (isset($_GET['manufacturers_id'])) {
 187      $sql = "select manufacturers_image
 188                from   " . TABLE_MANUFACTURERS . "
 189                where      manufacturers_id = '" . (int)$_GET['manufacturers_id'] . "'";
 190  
 191      $image_name = $db->Execute($sql);
 192      $image = $image_name->fields['manufacturers_image'];
 193  
 194    } elseif ($current_category_id) {
 195  
 196      $sql = "select categories_image from " . TABLE_CATEGORIES . "
 197              where  categories_id = '" . (int)$current_category_id . "'";
 198  
 199      $image_name = $db->Execute($sql);
 200      $image = $image_name->fields['categories_image'];
 201    }
 202  ?>


Généré le : Mon Nov 26 16:45:43 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics