[ 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/ -> music_genre_filter.php (source)

   1  <?php
   2  /**

   3   * music_genre_filter.php  for index filters

   4   *

   5   * index filter for the music product type

   6   * show the products of a specified music_genre

   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: music_genre_filter.php 4254 2006-08-25 00:30:56Z ajeh $

  14   */
  15  if (!defined('IS_ADMIN_FLAG')) {
  16    die('Illegal Access');
  17  }
  18    if (!isset($select_column_list)) $select_column_list = "";
  19  
  20    // show the products of a specified music_genre

  21    if (isset($_GET['music_genre_id']))
  22    {
  23      if (isset($_GET['filter_id']) && zen_not_null($_GET['filter_id']))
  24      {
  25        // We are asked to show only a specific category

  26        $listing_sql = "select " . $select_column_list . " p.products_id, p.products_type, 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
  27          from " . TABLE_PRODUCTS . " p, " .
  28          TABLE_PRODUCTS_DESCRIPTION . " pd, " .
  29          TABLE_PRODUCT_MUSIC_EXTRA . " pme left join " . TABLE_SPECIALS . " s on pme.products_id = s.products_id, " .
  30          TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " .
  31          TABLE_MUSIC_GENRE . " m
  32          where  m.music_genre_id = '" . (int)$_GET['music_genre_id'] . "'
  33            and p.products_id = pme.products_id
  34            and p.products_status = 1
  35            and pme.music_genre_id = '" . (int)$_GET['music_genre_id'] . "'
  36            and pme.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      } else {
  41        // We show them all

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

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

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

  74        if ($current_categories_id) {
  75          $listing_sql = "select " . $select_column_list . " p.products_id, p.products_type, m.music_genre_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
  76            from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " .
  77            TABLE_PRODUCTS . " p left join " . TABLE_MUSIC_GENRE . " m, " . TABLE_PRODUCT_MUSIC_EXTRA . " pme on pme.music_genre_id = m.music_genre_id, " .
  78            TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p2c.products_id = s.products_id
  79            where p.products_status = 1
  80              and p.products_id = p2c.products_id
  81              and pd.products_id = p2c.products_id
  82              and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
  83              and p2c.categories_id = '" . (int)$current_category_id . "'";
  84        } else {
  85          $listing_sql = "select " . $select_column_list . " p.products_id, p.products_type, m.music_genre_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_DESCRIPTION . " pd, " .
  87            TABLE_PRODUCTS . " p left join " . TABLE_MUSIC_GENRE . " m, " . TABLE_PRODUCT_MUSIC_EXTRA . " pme on pme.music_genre_id = m.music_genre_id, " .
  88            TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p2c.products_id = s.products_id
  89            where p.products_status = 1
  90              and p.products_id = p2c.products_id
  91              and pd.products_id = p2c.products_id
  92              and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";
  93        }
  94      }
  95    }
  96    // set the default sort order setting from the Admin when not defined by customer

  97    if (!isset($_GET['sort']) and PRODUCT_LISTING_DEFAULT_SORT_ORDER != '') {
  98      $_GET['sort'] = PRODUCT_LISTING_DEFAULT_SORT_ORDER;
  99    }
 100    $listing_sql = str_replace('m.manufacturers_name', 'm.music_genre_name as manufacturers_name', $listing_sql);
 101  
 102    if (isset($column_list)) {
 103      if ( (!isset($_GET['sort'])) || (!ereg('[1-8][ad]', $_GET['sort'])) || (substr($_GET['sort'], 0, 1) > sizeof($column_list)) )
 104      {
 105        for ($i=0, $n=sizeof($column_list); $i<$n; $i++)
 106        {
 107          if ($column_list[$i] == 'PRODUCT_LIST_NAME')
 108          {
 109            $_GET['sort'] = $i+1 . 'a';
 110            $listing_sql .= " order by p.products_sort_order, pd.products_name";
 111            break;
 112          }
 113        }
 114        // if set to nothing use products_sort_order and PRODUCTS_LIST_NAME is off

 115        if (PRODUCT_LISTING_DEFAULT_SORT_ORDER == '') {
 116          $_GET['sort'] = '20a';
 117        }
 118      } else {
 119        $sort_col = substr($_GET['sort'], 0 , 1);
 120        $sort_order = substr($_GET['sort'], 1);
 121        $listing_sql .= ' order by ';
 122        switch ($column_list[$sort_col-1])
 123        {
 124          case 'PRODUCT_LIST_MODEL':
 125          $listing_sql .= "p.products_model " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
 126          break;
 127          case 'PRODUCT_LIST_NAME':
 128          $listing_sql .= "pd.products_name " . ($sort_order == 'd' ? 'desc' : '');
 129          break;
 130          case 'PRODUCT_LIST_MANUFACTURER':
 131          $listing_sql .= "m.music_genre_name " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
 132          break;
 133          case 'PRODUCT_LIST_QUANTITY':
 134          $listing_sql .= "p.products_quantity " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
 135          break;
 136          case 'PRODUCT_LIST_IMAGE':
 137          $listing_sql .= "pd.products_name";
 138          break;
 139          case 'PRODUCT_LIST_WEIGHT':
 140          $listing_sql .= "p.products_weight " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
 141          break;
 142          case 'PRODUCT_LIST_PRICE':
 143          //          $listing_sql .= "final_price " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";

 144          $listing_sql .= "p.products_price_sorter " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
 145          break;
 146        }
 147      }
 148    }
 149    // optional Product List Filter

 150    if (PRODUCT_LIST_FILTER > 0)
 151    {
 152      if (isset($_GET['music_genre_id']))
 153      {
 154        $filterlist_sql = "select distinct c.categories_id as id, cd.categories_name as name
 155          from " . TABLE_PRODUCTS . " p, " .
 156          TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " .
 157          TABLE_CATEGORIES . " c, " .
 158          TABLE_CATEGORIES_DESCRIPTION . " cd, " .
 159          TABLE_PRODUCT_MUSIC_EXTRA . " pme
 160          where p.products_status = 1
 161            and pme.products_id = p2c.products_id
 162            and p2c.categories_id = c.categories_id
 163            and p2c.categories_id = cd.categories_id
 164            and cd.language_id = '" . (int)$_SESSION['languages_id'] . "'
 165            and pme.music_genre_id = '" . (int)$_GET['music_genre_id'] . "'
 166          order by cd.categories_name";
 167      } else {
 168        $filterlist_sql= "select distinct m.music_genre_id as id, m.music_genre_name as name
 169          from " . TABLE_PRODUCTS . " p, " .
 170          TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " .
 171          TABLE_PRODUCT_MUSIC_EXTRA . " pme, " .
 172          TABLE_MUSIC_GENRE . " m
 173          where p.products_status = 1
 174            and pme.music_genre_id = m.music_genre_id
 175            and p.products_id = p2c.products_id
 176            and p2c.categories_id = '" . (int)$current_category_id . "'
 177          order by m.music_genre_name";
 178      }
 179      $getoption_set =  false;
 180      $filterlist = $db->Execute($filterlist_sql);
 181      $do_filter_list = false;
 182      if ($filterlist->RecordCount() > 1)
 183      {
 184        $do_filter_list = true;
 185        if (isset($_GET['music_genre_id']))
 186        {
 187          //die('here');

 188          $getoption_set =  true;
 189          $get_option_variable = 'music_genre_id';
 190          $options = array(array('id' => '', 'text' => TEXT_ALL_CATEGORIES));
 191        } else {
 192          $options = array(array('id' => '', 'text' => TEXT_ALL_MUSIC_GENRE));
 193        }
 194        while (!$filterlist->EOF) {
 195          $options[] = array('id' => $filterlist->fields['id'], 'text' => $filterlist->fields['name']);
 196          $filterlist->MoveNext();
 197        }
 198      }
 199    }
 200  
 201    // Get the right image for the top-right

 202    $image = DIR_WS_TEMPLATE_IMAGES . 'table_background_list.gif';
 203    if ($current_category_id) {
 204  
 205      $sql = "select categories_image from " . TABLE_CATEGORIES . "
 206                  where  categories_id = '" . (int)$current_category_id . "'";
 207  
 208      $image_name = $db->Execute($sql);
 209      $image = $image_name->fields['categories_image'];
 210    }
 211  ?>


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