[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.01 KiB
MD5: 8028900c77ec4e7436346fffae2f9f7e

product_listing.php - 关闭高亮
  1. <?php
  2. /**
  3.  * product_listing module
  4.  *
  5.  * @package modules
  6.  * @copyright Copyright 2003-2007 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 6787 2007-08-24 14:06:33Z 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
  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. $product_listing_layout_style = isset($_GET['view'])? $_GET['view']: PRODUCT_LISTING_LAYOUT_STYLE;
  24. $row = 0;
  25. $col = 0;
  26. $list_box_contents = array();
  27. $title = '';
  28.  
  29. $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;
  30.  
  31.  
  32. $show_submit = zen_run_normal();
  33. $listing_split = new splitPageResults($listing_sql, $max_results, 'p.products_id', 'page');
  34. $zco_notifier->notify('NOTIFY_MODULE_PRODUCT_LISTING_RESULTCOUNT', $listing_split->number_of_rows);
  35. $how_many = 0;
  36.  
  37. // Begin Row Layout Header
  38. if ($product_listing_layout_style == 'rows') {      // For Column Layout (Grid Layout) add on module
  39.  
  40. $list_box_contents[0] = array('params' => 'class="productListing-rowheading"');
  41.  
  42. $zc_col_count_description = 0;
  43. $lc_align = '';
  44. for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
  45.   switch ($column_list[$col]) {
  46.     case 'PRODUCT_LIST_MODEL':
  47.     $lc_text = TABLE_HEADING_MODEL;
  48.     $lc_align = '';
  49.     $zc_col_count_description++;
  50.     break;
  51.     case 'PRODUCT_LIST_NAME':
  52.     $lc_text = TABLE_HEADING_PRODUCTS;
  53.     $lc_align = '';
  54.     $zc_col_count_description++;
  55.     break;
  56.     case 'PRODUCT_LIST_MANUFACTURER':
  57.     $lc_text = TABLE_HEADING_MANUFACTURER;
  58.     $lc_align = '';
  59.     $zc_col_count_description++;
  60.     break;
  61.     case 'PRODUCT_LIST_PRICE':
  62.     $lc_text = TABLE_HEADING_PRICE;
  63.     $lc_align = 'right' . (PRODUCTS_LIST_PRICE_WIDTH > 0 ? '" width="' . PRODUCTS_LIST_PRICE_WIDTH : '');
  64.     $zc_col_count_description++;
  65.     break;
  66.     case 'PRODUCT_LIST_QUANTITY':
  67.     $lc_text = TABLE_HEADING_QUANTITY;
  68.     $lc_align = 'right';
  69.     $zc_col_count_description++;
  70.     break;
  71.     case 'PRODUCT_LIST_WEIGHT':
  72.     $lc_text = TABLE_HEADING_WEIGHT;
  73.     $lc_align = 'right';
  74.     $zc_col_count_description++;
  75.     break;
  76.     case 'PRODUCT_LIST_IMAGE':
  77.     $lc_text = TABLE_HEADING_IMAGE;
  78.     $lc_align = 'center';
  79.     $zc_col_count_description++;
  80.     break;
  81.   }
  82.  
  83.   if ( ($column_list[$col] != 'PRODUCT_LIST_IMAGE') ) {
  84.     $lc_text = zen_create_sort_heading($_GET['sort'], $col+1, $lc_text);
  85.   }
  86.  
  87.  
  88.  
  89.   $list_box_contents[0][$col] = array('align' => $lc_align,
  90.                                       'params' => 'class="productListing-heading"',
  91.                                       'text' => $lc_text );
  92. }
  93.  
  94. } // End Row Layout Header used in Column Layout (Grid Layout) add on module
  95.  
  96. /////////////  HEADER ROW ABOVE /////////////////////////////////////////////////
  97.  
  98. $num_products_count = $listing_split->number_of_rows;
  99.  
  100. if ($listing_split->number_of_rows > 0) {
  101.   $rows = 0;
  102.   // Used for Column Layout (Grid Layout) add on module
  103.   $column = 0; 
  104.   if ($product_listing_layout_style == 'columns') {
  105.     if ($num_products_count < PRODUCT_LISTING_COLUMNS_PER_ROW || PRODUCT_LISTING_COLUMNS_PER_ROW == 0 ) {
  106.       $col_width = floor(100/$num_products_count) - 0.5;
  107.     } else {
  108.       $col_width = floor(100/PRODUCT_LISTING_COLUMNS_PER_ROW) - 0.5;
  109.     }
  110.   }
  111.   // Used for Column Layout (Grid Layout) add on module
  112.  
  113.  
  114.   $listing = $db->Execute($listing_split->sql_query);
  115.   $extra_row = 0;
  116.   while (!$listing->EOF) {
  117.  
  118.     if ($product_listing_layout_style == 'rows') { // Used in Column Layout (Grid Layout) Add on module
  119.     $rows++;
  120.  
  121.     if ((($rows-$extra_row)/2) == floor(($rows-$extra_row)/2)) {
  122.       $list_box_contents[$rows] = array('params' => 'class="productListing-even"');
  123.     } else {
  124.       $list_box_contents[$rows] = array('params' => 'class="productListing-odd"');
  125.     }
  126.  
  127.     $cur_row = sizeof($list_box_contents) - 1;
  128.     }   // End of Conditional execution - only for row (regular style layout)
  129.  
  130.     $product_contents = array(); // Used For Column Layout (Grid Layout) Add on module
  131.  
  132.     for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
  133.       $lc_align = '';
  134.       switch ($column_list[$col]) {
  135.         case 'PRODUCT_LIST_MODEL':
  136.         $lc_align = '';
  137.         $lc_text = $listing->fields['products_model'];
  138.         break;
  139.         case 'PRODUCT_LIST_NAME':
  140.         $lc_align = '';
  141.         if (isset($_GET['manufacturers_id'])) {
  142.           $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>' ;
  143.         } else {
  144.           $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>';
  145.         }
  146.         break;
  147.         case 'PRODUCT_LIST_MANUFACTURER':
  148.         $lc_align = '';
  149.         $lc_text = '<a href="' . zen_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing->fields['manufacturers_id']) . '">' . $listing->fields['manufacturers_name'] . '</a>';
  150.         break;
  151.         case 'PRODUCT_LIST_PRICE':
  152.         $lc_price = zen_get_products_display_price($listing->fields['products_id']) . '<br />';
  153.         $lc_align = 'right';
  154.         $lc_text =  $lc_price;
  155.  
  156.         // more info in place of buy now
  157.         $lc_button = '';
  158.         if (zen_has_product_attributes($listing->fields['products_id']) or PRODUCT_LIST_PRICE_BUY_NOW == '0') {
  159.           $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>';
  160.         } else {
  161.           if (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART != 0) {
  162.             if (
  163.                 // not a hide qty box product
  164.                 $listing->fields['products_qty_box_status'] != 0 &&
  165.                 // product type can be added to cart
  166.                 zen_get_products_allow_add_to_cart($listing->fields['products_id']) != 'N'
  167.                 &&
  168.                 // product is not call for price
  169.                 $listing->fields['product_is_call'] == 0
  170.                 &&
  171.                 // product is in stock or customers may add it to cart anyway
  172.                 ($listing->fields['products_quantity'] > 0 || SHOW_PRODUCTS_SOLD_OUT_IMAGE == 0) ) {
  173.               $how_many++;
  174.             }
  175.             // hide quantity box
  176.             if ($listing->fields['products_qty_box_status'] == 0) {
  177.               $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>';
  178.             } else {
  179.               $lc_button = TEXT_PRODUCT_LISTING_MULTIPLE_ADD_TO_CART . "<input type=\"text\" name=\"products_id[" . $listing->fields['products_id'] . "]\" value=\"0\" size=\"4\" />";
  180.             }
  181.           } else {
  182. // qty box with add to cart button
  183.             if (PRODUCT_LIST_PRICE_BUY_NOW == '2' && $listing->fields['products_qty_box_status'] != 0) {
  184.               $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>';
  185.             } else {
  186.               $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>';
  187.             }
  188.           }
  189.         }
  190.         $the_button = $lc_button;
  191.         $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>';
  192.         $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']);
  193.         $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 />' : '') : '');
  194.  
  195.         break;
  196.         case 'PRODUCT_LIST_QUANTITY':
  197.         $lc_align = 'right';
  198.         $lc_text = $listing->fields['products_quantity'];
  199.         break;
  200.         case 'PRODUCT_LIST_WEIGHT':
  201.         $lc_align = 'right';
  202.         $lc_text = $listing->fields['products_weight'];
  203.         break;
  204.         case 'PRODUCT_LIST_IMAGE':
  205.         $lc_align = 'center';
  206.         if ($listing->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) {
  207.           $lc_text = '';
  208.         } else {
  209.           if (isset($_GET['manufacturers_id'])) {
  210.             $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>';
  211.           } else {
  212.             $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>';
  213.           }
  214.         }
  215.         break;
  216.       }
  217.  
  218.       $product_contents[] = $lc_text; // Used For Column Layout (Grid Layout) Option
  219.  
  220.       if ($product_listing_layout_style == 'rows') {
  221.       $list_box_contents[$rows][$col] = array('align' => $lc_align,
  222.                                               'params' => 'class="productListing-data"',
  223.                                               'text'  => $lc_text);
  224.     }
  225.     }
  226.  
  227.     // add description and match alternating colors
  228.     //if (PRODUCT_LIST_DESCRIPTION > 0) {
  229.     //  $rows++;
  230.     //  if ($extra_row == 1) {
  231.     //    $list_box_description = "productListing-data-description-even";
  232.     //    $extra_row=0;
  233.     //  } else {
  234.     //    $list_box_description = "productListing-data-description-odd";
  235.     //    $extra_row=1;
  236.     //  }
  237.     //  $list_box_contents[$rows][] = array('params' => 'class="' . $list_box_description . '" colspan="' . $zc_col_count_description . '"',
  238.     //  'text' => zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION));
  239.     //}
  240.  
  241.     // Following code will be executed only if Column Layout (Grid Layout) option is chosen
  242.     if ($product_listing_layout_style == 'columns') {
  243.       $lc_text = implode('<br />', $product_contents);
  244.       $list_box_contents[$rows][$column] = array('params' => 'class="centerBoxContentsProducts centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
  245.                                                  'text'  => $lc_text);
  246.       $column ++;
  247.       if ($column >= PRODUCT_LISTING_COLUMNS_PER_ROW) {
  248.         $column = 0;
  249.         $rows ++;
  250.       }
  251.     }
  252.     // End of Code fragment for Column Layout (Grid Layout) option in add on module
  253.     $listing->MoveNext();
  254.   }
  255.   $error_categories = false;
  256. } else {
  257.   $list_box_contents = array();
  258.  
  259.   $list_box_contents[0] = array('params' => 'class="productListing-odd"');
  260.   $list_box_contents[0][] = array('params' => 'class="productListing-data"',
  261.                                               'text' => TEXT_NO_PRODUCTS);
  262.  
  263.   $error_categories = true;
  264. }
  265.  
  266. 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) ) {
  267.   $show_top_submit_button = true;
  268. } else {
  269.   $show_top_submit_button = false;
  270. }
  271. if (($how_many > 0 and $show_submit == true and $listing_split->number_of_rows > 0) and (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART >= 2) ) {
  272.   $show_bottom_submit_button = true;
  273. } else {
  274.   $show_bottom_submit_button = false;
  275. }
  276.  
  277.  
  278.  
  279.   if ($how_many > 0 && PRODUCT_LISTING_MULTIPLE_ADD_TO_CART != 0 and $show_submit == true and $listing_split->number_of_rows > 0) {
  280.   // bof: multiple products
  281.     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"');
  282.   }
  283.  
  284.