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

Zen Cart 源代码 product_prev_next.php




下载文件

文件名: product_prev_next.php
文件类型: PHP文件
文件大小: 4.69 KiB
MD5: 6f2f1d935c740bd872806a18195184d4

product_prev_next.php - 关闭高亮
  1. <?php
  2. /**
  3.  *  product_prev_next.php
  4.  *
  5.  * @package productTypes
  6.  * @copyright Copyright 2003-2006 Zen Cart Development Team
  7.  * @copyright Portions Copyright 2003 osCommerce
  8.  * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
  9.  * @version $Id: product_prev_next.php 6912 2007-09-02 02:23:45Z drbyte $
  10.  */
  11. if (!defined('IS_ADMIN_FLAG')) {
  12.   die('Illegal Access');
  13. }
  14. // bof: previous next
  15. if (PRODUCT_INFO_PREVIOUS_NEXT != 0) {
  16.  
  17.   // sort order
  18.   switch(PRODUCT_INFO_PREVIOUS_NEXT_SORT) {
  19.     case (0):
  20.     $prev_next_order= ' order by LPAD(p.products_id,11,"0")';
  21.     break;
  22.     case (1):
  23.     $prev_next_order= " order by pd.products_name";
  24.     break;
  25.     case (2):
  26.     $prev_next_order= " order by p.products_model";
  27.     break;
  28.     case (3):
  29.     $prev_next_order= " order by p.products_price_sorter, pd.products_name";
  30.     break;
  31.     case (4):
  32.     $prev_next_order= " order by p.products_price_sorter, p.products_model";
  33.     break;
  34.     case (5):
  35.     $prev_next_order= " order by pd.products_name, p.products_model";
  36.     break;
  37.     case (6):
  38.     $prev_next_order= ' order by LPAD(p.products_sort_order,11,"0"), pd.products_name';
  39.     break;
  40.     default:
  41.     $prev_next_order= " order by pd.products_name";
  42.     break;
  43.   }
  44.  
  45. /*
  46.   if (!$current_category_id || SHOW_CATEGORIES_ALWAYS == 1) {
  47.     $sql = "SELECT categories_id
  48.             from   " . TABLE_PRODUCTS_TO_CATEGORIES . "
  49.             where  products_id ='" .  (int)$_GET['products_id']
  50.     . "'";
  51.     $cPath_row = $db->Execute($sql);
  52.     $current_category_id = $cPath_row->fields['categories_id'];
  53.     $cPath = $current_category_id;
  54.   }
  55. */
  56.  
  57.  
  58. //  if (!$current_category_id || !$cPath) {
  59.   if ($cPath < 1) {
  60.     $cPath = zen_get_product_path((int)$_GET['products_id']);
  61. //    $_GET['$cPath'] = $cPath;
  62.     $cPath_array = zen_parse_category_path($cPath);
  63.     $cPath = implode('_', $cPath_array);
  64.     $current_category_id = $cPath_array[(sizeof($cPath_array)-1)];
  65.  
  66. //    $current_category_id = $cPath;
  67.   }
  68.  
  69.  
  70.   $sql = "select p.products_id, p.products_model, p.products_price_sorter, pd.products_name, p.products_sort_order
  71.          from   " . TABLE_PRODUCTS . " p, "
  72.   . TABLE_PRODUCTS_DESCRIPTION . " pd, "
  73.   . TABLE_PRODUCTS_TO_CATEGORIES . " ptc
  74.          where  p.products_status = '1' and p.products_id = pd.products_id and pd.language_id= '" . (int)$_SESSION['languages_id'] . "' and p.products_id = ptc.products_id and ptc.categories_id = '" . (int)$current_category_id . "'" .
  75.   $prev_next_order;
  76.  
  77.   $products_ids = $db->Execute($sql);
  78.   $products_found_count = $products_ids->RecordCount();
  79.  
  80.   while (!$products_ids->EOF) {
  81.     $id_array[] = $products_ids->fields['products_id'];
  82.     $products_ids->MoveNext();
  83.   }
  84.  
  85.   // if invalid product id skip
  86.   if (is_array($id_array)) {
  87.     reset ($id_array);
  88.     $counter = 0;
  89.     foreach ($id_array as $key => $value) {
  90.       if ($value == (int)$_GET['products_id']) {
  91.         $position = $counter;
  92.         if ($key == 0) {
  93.           $previous = -1; // it was the first to be found
  94.         } else {
  95.           $previous = $id_array[$key - 1];
  96.         }
  97.         if (isset($id_array[$key + 1]) && $id_array[$key + 1]) {
  98.           $next_item = $id_array[$key + 1];
  99.         } else {
  100.           $next_item = $id_array[0];
  101.         }
  102.       }
  103.       $last = $value;
  104.       $counter++;
  105.     }
  106.  
  107.     if ($previous == -1) $previous = $last;
  108.  
  109.     $sql = "select categories_name
  110.            from   " . TABLE_CATEGORIES_DESCRIPTION . "
  111.            where  categories_id = " . (int)$current_category_id . " AND language_id = '" . (int)$_SESSION['languages_id'] . "'";
  112.  
  113.     $category_name_row = $db->Execute($sql);
  114.   } // if is_array
  115.  
  116.   // previous_next button and product image settings
  117.   // include products_image status 0 = off 1= on
  118.   // 0 = button only 1= button and product image 2= product image only
  119.   $previous_button = zen_image_button(BUTTON_IMAGE_PREVIOUS, BUTTON_PREVIOUS_ALT);
  120.   $next_item_button = zen_image_button(BUTTON_IMAGE_NEXT, BUTTON_NEXT_ALT);
  121.   $previous_image = zen_get_products_image($previous, PREVIOUS_NEXT_IMAGE_WIDTH, PREVIOUS_NEXT_IMAGE_HEIGHT);
  122.   $next_item_image = zen_get_products_image($next_item, PREVIOUS_NEXT_IMAGE_WIDTH, PREVIOUS_NEXT_IMAGE_HEIGHT);
  123.   if (SHOW_PREVIOUS_NEXT_STATUS == 0) {
  124.     $previous_image = '';
  125.     $next_item_image = '';
  126.   } else {
  127.     if (SHOW_PREVIOUS_NEXT_IMAGES >= 1) {
  128.       if (SHOW_PREVIOUS_NEXT_IMAGES == 2) {
  129.         $previous_button = '';
  130.         $next_item_button = '';
  131.       }
  132.       if ($previous == $next_item) {
  133.         $previous_image = '';
  134.         $next_item_image = '';
  135.       }
  136.     } else {
  137.       $previous_image = '';
  138.       $next_item_image = '';
  139.     }
  140.   }
  141. }
  142. // eof: previous next
  143. ?>