[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_listing.php

Zen Cart 源代码 product_listing.php




下载文件

文件名: product_listing.php
文件类型: PHP文件
文件大小: 16.37 KiB
MD5: 99512b2eca432bb82f67edcb69976b4e

product_listing.php - 关闭高亮
  1. <?php
  2. /**
  3.  * product_listing module
  4.  *
  5.  * @package modules
  6.  * @copyright Copyright 2003-2011 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_listing.php 18695 2011-05-04 05:24:19Z drbyte $
  10.  * UPDATED TO WORK WITH COLUMNAR PRODUCT LISTING For Zen Cart v1.3.6 - 10/25/2006
  11.  */
  12. if (!defined('IS_ADMIN_FLAG')) {
  13.   die('Illegal Access');
  14. }
  15. // Column Layout Support originally added for Zen Cart v 1.1.4 by Eric Stamper - 02/14/2004
  16. // Upgraded to be compatible with Zen-cart v 1.2.0d by Rajeev Tandon - Aug 3, 2004
  17. // Column Layout Support (Grid Layout) upgraded for v1.3.0 compatibility DrByte 04/04/2006
  18. // Column Layout Support (Grid Layout) upgraded for v1.5.0 compatibility and changed to customer control asarfraz July 26 2012
  19. // Modified for admin control of customer option by Glenn Herbert (gjh42) 2012-09-20   test 20120929 grid sorter
  20. //
  21. if (!defined('PRODUCT_LISTING_LAYOUT_STYLE')) define('PRODUCT_LISTING_LAYOUT_STYLE',(isset($_GET['view']) ? $_GET['view'] : 'rows'));
  22. if (!defined('PRODUCT_LISTING_COLUMNS_PER_ROW')) define('PRODUCT_LISTING_COLUMNS_PER_ROW',3);
  23. if (!defined('PRODUCT_LISTING_GRID_SORT')) define('PRODUCT_LISTING_GRID_SORT',0);
  24. $product_listing_layout_style = isset($_GET['view'])? $_GET['view']: PRODUCT_LISTING_LAYOUT_STYLE;
  25. $row = 0;
  26. $col = 0;
  27. $list_box_contents = array();
  28. $title = '';
  29.  
  30. $max_results = ($product_listing_layout_style=='columns' && PRODUCT_LISTING_COLUMNS_PER_ROW>0) ? (PRODUCT_LISTING_COLUMNS_PER_ROW * (int)(MAX_DISPLAY_PRODUCTS_LISTING/PRODUCT_LISTING_COLUMNS_PER_ROW)) : MAX_DISPLAY_PRODUCTS_LISTING;
  31.  
  32.  
  33. $show_submit = zen_run_normal();
  34. $listing_split = new splitPageResults($listing_sql, $max_results, 'p.products_id', 'page');
  35. $zco_notifier->notify('NOTIFY_MODULE_PRODUCT_LISTING_RESULTCOUNT', $listing_split->number_of_rows);
  36. $how_many = 0;
  37.  
  38. // Begin Row Layout Header
  39. if ($product_listing_layout_style == 'rows' or PRODUCT_LISTING_GRID_SORT) {     // For Column Layout (Grid Layout) add on module
  40.  
  41. $list_box_contents[0] = array('params' => 'class="productListing-rowheading"');
  42.  
  43. $zc_col_count_description = 0;
  44. $lc_align = '';
  45. for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
  46.   switch ($column_list[$col]) {
  47.     case 'PRODUCT_LIST_MODEL':
  48.     $lc_text = TABLE_HEADING_MODEL;
  49.     $lc_align = '';
  50.     $zc_col_count_description++;
  51.     break;
  52.     case 'PRODUCT_LIST_NAME':
  53.     $lc_text = TABLE_HEADING_PRODUCTS;
  54.     $lc_align = '';
  55.     $zc_col_count_description++;
  56.     break;
  57.     case 'PRODUCT_LIST_MANUFACTURER':
  58.     $lc_text = TABLE_HEADING_MANUFACTURER;
  59.     $lc_align = '';
  60.     $zc_col_count_description++;
  61.     break;
  62.     case 'PRODUCT_LIST_PRICE':
  63.     $lc_text = TABLE_HEADING_PRICE;
  64.     $lc_align = 'right' . (PRODUCTS_LIST_PRICE_WIDTH > 0 ? '" width="' . PRODUCTS_LIST_PRICE_WIDTH : '');
  65.     $zc_col_count_description++;
  66.     break;
  67.     case 'PRODUCT_LIST_QUANTITY':
  68.     $lc_text = TABLE_HEADING_QUANTITY;
  69.     $lc_align = 'right';
  70.     $zc_col_count_description++;
  71.     break;
  72.     case 'PRODUCT_LIST_WEIGHT':
  73.     $lc_text = TABLE_HEADING_WEIGHT;
  74.     $lc_align = 'right';
  75.     $zc_col_count_description++;
  76.     break;
  77.     case 'PRODUCT_LIST_IMAGE':
  78.     if ($product_listing_layout_style == 'rows') { //skip if grid
  79.       $lc_text = TABLE_HEADING_IMAGE;
  80.       $lc_align = 'center';
  81.       $zc_col_count_description++;
  82.     }
  83.     break;
  84.   }
  85.  
  86.   if ( ($column_list[$col] != 'PRODUCT_LIST_IMAGE') ) {
  87.     $lc_text = zen_create_sort_heading($_GET['sort'], $col+1, $lc_text);
  88.   }
  89.  
  90.  
  91.  
  92.   $list_box_contents[0][$col] = array('align' => $lc_align,
  93.                                       'params' => 'class="productListing-heading"',
  94.                                       'text' => $lc_text );
  95. }
  96.  
  97.   if ($product_listing_layout_style == 'columns') { //grid sort option
  98.     $grid_sort = $list_box_contents[0];
  99.     $list_box_contents = array();
  100.   }
  101. } // End Row Layout Header used in Column Layout (Grid Layout) add on module
  102.  
  103. /////////////  HEADER ROW ABOVE /////////////////////////////////////////////////
  104.  
  105. $num_products_count = $listing_split->number_of_rows;
  106.  
  107. if ($listing_split->number_of_rows > 0) {
  108.   $rows = 0;
  109.   // Used for Column Layout (Grid Layout) add on module
  110.   $column = 0; 
  111.   if ($product_listing_layout_style == 'columns') {
  112.     if ($num_products_count < PRODUCT_LISTING_COLUMNS_PER_ROW || PRODUCT_LISTING_COLUMNS_PER_ROW == 0 ) {
  113.       $col_width = floor(100/$num_products_count) - 0.5;
  114.     } else {
  115.       $col_width = floor(100/PRODUCT_LISTING_COLUMNS_PER_ROW) - 0.5;
  116.     }
  117.   }
  118.   // Used for Column Layout (Grid Layout) add on module
  119.  
  120.  
  121.   $listing = $db->Execute($listing_split->sql_query);
  122.   $extra_row = 0;
  123.   while (!$listing->EOF) {
  124.  
  125.     if ($product_listing_layout_style == 'rows') { // Used in Column Layout (Grid Layout) Add on module
  126.     $rows++;
  127.  
  128.     if ((($rows-$extra_row)/2) == floor(($rows-$extra_row)/2)) {
  129.       $list_box_contents[$rows] = array('params' => 'class="productListing-even"');
  130.     } else {
  131.       $list_box_contents[$rows] = array('params' => 'class="productListing-odd"');
  132.     }
  133.  
  134.     $cur_row = sizeof($list_box_contents) - 1;
  135.     }   // End of Conditional execution - only for row (regular style layout)
  136.  
  137.     $product_contents = array(); // Used For Column Layout (Grid Layout) Add on module
  138.  
  139.     for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
  140.       $lc_align = '';
  141.       switch ($column_list[$col]) {
  142.         case 'PRODUCT_LIST_MODEL':
  143.         $lc_align = '';
  144.         $lc_text = $listing->fields['products_model'];
  145.         break;
  146.         case 'PRODUCT_LIST_NAME':
  147.         $lc_align = '';
  148.         if (isset($_GET['manufacturers_id'])) {
  149.           $lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>' ;
  150.         } else {
  151.           $lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id'] > 0) ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>';
  152.         }
  153.         break;
  154.         case 'PRODUCT_LIST_MANUFACTURER':
  155.         $lc_align = '';
  156.         $lc_text = '<a href="' . zen_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing->fields['manufacturers_id']) . '">' . $listing->fields['manufacturers_name'] . '</a>';
  157.         break;
  158.         case 'PRODUCT_LIST_PRICE':
  159.         $lc_price = zen_get_products_display_price($listing->fields['products_id']) . '<br />';
  160.         $lc_align = 'right';
  161.         $lc_text =  $lc_price;
  162.  
  163.         // more info in place of buy now
  164.         $lc_button = '';
  165.         if (zen_has_product_attributes($listing->fields['products_id']) or PRODUCT_LIST_PRICE_BUY_NOW == '0') {
  166.           $lc_button = '<a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? $_GET['cPath'] : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
  167.         } else {
  168.           if (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART != 0) {
  169.             if (
  170.                 // not a hide qty box product
  171.                 $listing->fields['products_qty_box_status'] != 0 &&
  172.                 // product type can be added to cart
  173.                 zen_get_products_allow_add_to_cart($listing->fields['products_id']) != 'N'
  174.                 &&
  175.                 // product is not call for price
  176.                 $listing->fields['product_is_call'] == 0
  177.                 &&
  178.                 // product is in stock or customers may add it to cart anyway
  179.                 ($listing->fields['products_quantity'] > 0 || SHOW_PRODUCTS_SOLD_OUT_IMAGE == 0) ) {
  180.               $how_many++;
  181.             }
  182.             // hide quantity box
  183.             if ($listing->fields['products_qty_box_status'] == 0) {
  184.               $lc_button = '<a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT, 'class="listingBuyNowButton"') . '</a>';
  185.             } else {
  186.               $lc_button = TEXT_PRODUCT_LISTING_MULTIPLE_ADD_TO_CART . "<input type=\"text\" name=\"products_id[" . $listing->fields['products_id'] . "]\" value=\"0\" size=\"4\" />";
  187.             }
  188.           } else {
  189. // qty box with add to cart button
  190.             if (PRODUCT_LIST_PRICE_BUY_NOW == '2' && $listing->fields['products_qty_box_status'] != 0) {
  191.               $lc_button= zen_draw_form('cart_quantity', zen_href_link(zen_get_info_page($listing->fields['products_id']), zen_get_all_get_params(array('action')) . 'action=add_product&products_id=' . $listing->fields['products_id']), 'post', 'enctype="multipart/form-data"') . '<input type="text" name="cart_quantity" value="' . (zen_get_buy_now_qty($listing->fields['products_id'])) . '" maxlength="6" size="4" /><br />' . zen_draw_hidden_field('products_id', $listing->fields['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT) . '</form>';
  192.             } else {
  193.               $lc_button = '<a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT, 'class="listingBuyNowButton"') . '</a>';
  194.             }
  195.           }
  196.         }
  197.         $the_button = $lc_button;
  198.         $products_link = '<a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . ( ($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ? zen_get_generated_category_path_rev($_GET['filter_id']) : $_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id'])) . '&products_id=' . $listing->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
  199.         $lc_text .= '<br />' . zen_get_buy_now_button($listing->fields['products_id'], $the_button, $products_link) . '<br />' . zen_get_products_quantity_min_units_display($listing->fields['products_id']);
  200.         $lc_text .= '<br />' . (zen_get_show_product_switch($listing->fields['products_id'], 'ALWAYS_FREE_SHIPPING_IMAGE_SWITCH') ? (zen_get_product_is_always_free_shipping($listing->fields['products_id']) ? TEXT_PRODUCT_FREE_SHIPPING_ICON . '<br />' : '') : '');
  201.  
  202.         break;
  203.         case 'PRODUCT_LIST_QUANTITY':
  204.         $lc_align = 'right';
  205.         $lc_text = $listing->fields['products_quantity'];
  206.         break;
  207.         case 'PRODUCT_LIST_WEIGHT':
  208.         $lc_align = 'right';
  209.         $lc_text = $listing->fields['products_weight'];
  210.         break;
  211.         case 'PRODUCT_LIST_IMAGE':
  212.         $lc_align = 'center';
  213.         if ($listing->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) {
  214.           $lc_text = '';
  215.         } else {
  216.           if (isset($_GET['manufacturers_id'])) {
  217.             $lc_text = '<a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $listing->fields['products_image'], $listing->fields['products_name'], IMAGE_PRODUCT_LISTING_WIDTH, IMAGE_PRODUCT_LISTING_HEIGHT, 'class="listingProductImage"') . '</a>';
  218.           } else {
  219.             $lc_text = '<a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $listing->fields['products_image'], $listing->fields['products_name'], IMAGE_PRODUCT_LISTING_WIDTH, IMAGE_PRODUCT_LISTING_HEIGHT, 'class="listingProductImage"') . '</a>';
  220.           }
  221.         }
  222.         break;
  223.       }
  224.  
  225.       $product_contents[] = $lc_text; // Used For Column Layout (Grid Layout) Option
  226.  
  227.       if ($product_listing_layout_style == 'rows') {
  228.       $list_box_contents[$rows][$col] = array('align' => $lc_align,
  229.                                               'params' => 'class="productListing-data"',
  230.                                               'text'  => $lc_text);
  231.     }
  232.     }
  233.  
  234.     // add description and match alternating colors
  235.     //if (PRODUCT_LIST_DESCRIPTION > 0) {
  236.     //  $rows++;
  237.     //  if ($extra_row == 1) {
  238.     //    $list_box_description = "productListing-data-description-even";
  239.     //    $extra_row=0;
  240.     //  } else {
  241.     //    $list_box_description = "productListing-data-description-odd";
  242.     //    $extra_row=1;
  243.     //  }
  244.     //  $list_box_contents[$rows][] = array('params' => 'class="' . $list_box_description . '" colspan="' . $zc_col_count_description . '"',
  245.     //  'text' => zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION));
  246.     //}
  247.  
  248.     // Following code will be executed only if Column Layout (Grid Layout) option is chosen
  249.     if ($product_listing_layout_style == 'columns') {
  250.       $lc_text = implode('<br />', $product_contents);
  251.       $list_box_contents[$rows][$column] = array('params' => 'class="centerBoxContentsProducts centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
  252.                                                  'text'  => $lc_text);
  253.       $column ++;
  254.       if ($column >= PRODUCT_LISTING_COLUMNS_PER_ROW) {
  255.         $column = 0;
  256.         $rows ++;
  257.       }
  258.     }
  259.     // End of Code fragment for Column Layout (Grid Layout) option in add on module
  260.     $listing->MoveNext();
  261.   }
  262.   $error_categories = false;
  263. } else {
  264.   $list_box_contents = array();
  265.  
  266.   $list_box_contents[0] = array('params' => 'class="productListing-odd"');
  267.   $list_box_contents[0][] = array('params' => 'class="productListing-data"',
  268.                                               'text' => TEXT_NO_PRODUCTS);
  269.  
  270.   $error_categories = true;
  271. }
  272.  
  273. if (($how_many > 0 and $show_submit == true and $listing_split->number_of_rows > 0) and (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART == 1 or  PRODUCT_LISTING_MULTIPLE_ADD_TO_CART == 3) ) {
  274.   $show_top_submit_button = true;
  275. } else {
  276.   $show_top_submit_button = false;
  277. }
  278. if (($how_many > 0 and $show_submit == true and $listing_split->number_of_rows > 0) and (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART >= 2) ) {
  279.   $show_bottom_submit_button = true;
  280. } else {
  281.   $show_bottom_submit_button = false;
  282. }
  283.  
  284.  
  285.  
  286.   if ($how_many > 0 && PRODUCT_LISTING_MULTIPLE_ADD_TO_CART != 0 and $show_submit == true and $listing_split->number_of_rows > 0) {
  287.   // bof: multiple products
  288.     echo zen_draw_form('multiple_products_cart_quantity', zen_href_link(FILENAME_DEFAULT, zen_get_all_get_params(array('action')) . 'action=multiple_products_add_product'), 'post', 'enctype="multipart/form-data"');
  289.   }
  290.  
  291.