PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/includes/modules/product_listing.php

http://daocart.googlecode.com/
PHP | 223 lines | 172 code | 21 blank | 30 comment | 53 complexity | 9c413941df3fe639475557531537db60 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, BSD-3-Clause
  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. */
  11. if (!defined('IS_ADMIN_FLAG')) {
  12. die('Illegal Access');
  13. }
  14. $show_submit = zen_run_normal();
  15. $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_PRODUCTS_LISTING, 'p.products_id', 'page');
  16. $zco_notifier->notify('NOTIFY_MODULE_PRODUCT_LISTING_RESULTCOUNT', $listing_split->number_of_rows);
  17. $how_many = 0;
  18. $list_box_contents[0] = array('params' => 'class="productListing-rowheading"');
  19. $zc_col_count_description = 0;
  20. $lc_align = '';
  21. for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
  22. switch ($column_list[$col]) {
  23. case 'PRODUCT_LIST_MODEL':
  24. $lc_text = TABLE_HEADING_MODEL;
  25. $lc_align = '';
  26. $zc_col_count_description++;
  27. break;
  28. case 'PRODUCT_LIST_NAME':
  29. $lc_text = TABLE_HEADING_PRODUCTS;
  30. $lc_align = '';
  31. $zc_col_count_description++;
  32. break;
  33. case 'PRODUCT_LIST_MANUFACTURER':
  34. $lc_text = TABLE_HEADING_MANUFACTURER;
  35. $lc_align = '';
  36. $zc_col_count_description++;
  37. break;
  38. case 'PRODUCT_LIST_PRICE':
  39. $lc_text = TABLE_HEADING_PRICE;
  40. $lc_align = 'right' . (PRODUCTS_LIST_PRICE_WIDTH > 0 ? '" width="' . PRODUCTS_LIST_PRICE_WIDTH : '');
  41. $zc_col_count_description++;
  42. break;
  43. case 'PRODUCT_LIST_QUANTITY':
  44. $lc_text = TABLE_HEADING_QUANTITY;
  45. $lc_align = 'right';
  46. $zc_col_count_description++;
  47. break;
  48. case 'PRODUCT_LIST_WEIGHT':
  49. $lc_text = TABLE_HEADING_WEIGHT;
  50. $lc_align = 'right';
  51. $zc_col_count_description++;
  52. break;
  53. case 'PRODUCT_LIST_IMAGE':
  54. $lc_text = TABLE_HEADING_IMAGE;
  55. $lc_align = 'center';
  56. $zc_col_count_description++;
  57. break;
  58. }
  59. if ( ($column_list[$col] != 'PRODUCT_LIST_IMAGE') ) {
  60. $lc_text = zen_create_sort_heading($_GET['sort'], $col+1, $lc_text);
  61. }
  62. $list_box_contents[0][$col] = array('align' => $lc_align,
  63. 'params' => 'class="productListing-heading"',
  64. 'text' => $lc_text );
  65. }
  66. if ($listing_split->number_of_rows > 0) {
  67. $rows = 0;
  68. $listing = $db->Execute($listing_split->sql_query);
  69. $extra_row = 0;
  70. while (!$listing->EOF) {
  71. $rows++;
  72. if ((($rows-$extra_row)/2) == floor(($rows-$extra_row)/2)) {
  73. $list_box_contents[$rows] = array('params' => 'class="productListing-even"');
  74. } else {
  75. $list_box_contents[$rows] = array('params' => 'class="productListing-odd"');
  76. }
  77. $cur_row = sizeof($list_box_contents) - 1;
  78. for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
  79. $lc_align = '';
  80. switch ($column_list[$col]) {
  81. case 'PRODUCT_LIST_MODEL':
  82. $lc_align = '';
  83. $lc_text = $listing->fields['products_model'];
  84. break;
  85. case 'PRODUCT_LIST_NAME':
  86. $lc_align = '';
  87. if (isset($_GET['manufacturers_id'])) {
  88. $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>' ;
  89. } else {
  90. $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>';
  91. }
  92. break;
  93. case 'PRODUCT_LIST_MANUFACTURER':
  94. $lc_align = '';
  95. $lc_text = '<a href="' . zen_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing->fields['manufacturers_id']) . '">' . $listing->fields['manufacturers_name'] . '</a>';
  96. break;
  97. case 'PRODUCT_LIST_PRICE':
  98. $lc_price = zen_get_products_display_price($listing->fields['products_id']) . '<br />';
  99. $lc_align = 'right';
  100. $lc_text = $lc_price;
  101. // more info in place of buy now
  102. $lc_button = '';
  103. if (zen_has_product_attributes($listing->fields['products_id']) or PRODUCT_LIST_PRICE_BUY_NOW == '0') {
  104. $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>';
  105. } else {
  106. if (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART != 0) {
  107. if (
  108. // not a hide qty box product
  109. $listing->fields['products_qty_box_status'] != 0 &&
  110. // product type can be added to cart
  111. zen_get_products_allow_add_to_cart($listing->fields['products_id']) != 'N'
  112. &&
  113. // product is not call for price
  114. $listing->fields['product_is_call'] == 0
  115. &&
  116. // product is in stock or customers may add it to cart anyway
  117. ($listing->fields['products_quantity'] > 0 || SHOW_PRODUCTS_SOLD_OUT_IMAGE == 0) ) {
  118. $how_many++;
  119. }
  120. // hide quantity box
  121. if ($listing->fields['products_qty_box_status'] == 0) {
  122. $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>';
  123. } else {
  124. $lc_button = TEXT_PRODUCT_LISTING_MULTIPLE_ADD_TO_CART . "<input type=\"text\" name=\"products_id[" . $listing->fields['products_id'] . "]\" value=\"0\" size=\"4\" />";
  125. }
  126. } else {
  127. // qty box with add to cart button
  128. if (PRODUCT_LIST_PRICE_BUY_NOW == '2' && $listing->fields['products_qty_box_status'] != 0) {
  129. $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>';
  130. } else {
  131. $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>';
  132. }
  133. }
  134. }
  135. $the_button = $lc_button;
  136. $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>';
  137. $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']);
  138. $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 />' : '') : '');
  139. break;
  140. case 'PRODUCT_LIST_QUANTITY':
  141. $lc_align = 'right';
  142. $lc_text = $listing->fields['products_quantity'];
  143. break;
  144. case 'PRODUCT_LIST_WEIGHT':
  145. $lc_align = 'right';
  146. $lc_text = $listing->fields['products_weight'];
  147. break;
  148. case 'PRODUCT_LIST_IMAGE':
  149. $lc_align = 'center';
  150. if ($listing->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) {
  151. $lc_text = '';
  152. } else {
  153. if (isset($_GET['manufacturers_id'])) {
  154. $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>';
  155. } else {
  156. $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>';
  157. }
  158. }
  159. break;
  160. }
  161. $list_box_contents[$rows][$col] = array('align' => $lc_align,
  162. 'params' => 'class="productListing-data"',
  163. 'text' => $lc_text);
  164. }
  165. // add description and match alternating colors
  166. //if (PRODUCT_LIST_DESCRIPTION > 0) {
  167. // $rows++;
  168. // if ($extra_row == 1) {
  169. // $list_box_description = "productListing-data-description-even";
  170. // $extra_row=0;
  171. // } else {
  172. // $list_box_description = "productListing-data-description-odd";
  173. // $extra_row=1;
  174. // }
  175. // $list_box_contents[$rows][] = array('params' => 'class="' . $list_box_description . '" colspan="' . $zc_col_count_description . '"',
  176. // 'text' => zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION));
  177. //}
  178. $listing->MoveNext();
  179. }
  180. $error_categories = false;
  181. } else {
  182. $list_box_contents = array();
  183. $list_box_contents[0] = array('params' => 'class="productListing-odd"');
  184. $list_box_contents[0][] = array('params' => 'class="productListing-data"',
  185. 'text' => TEXT_NO_PRODUCTS);
  186. $error_categories = true;
  187. }
  188. 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) ) {
  189. $show_top_submit_button = true;
  190. } else {
  191. $show_top_submit_button = false;
  192. }
  193. if (($how_many > 0 and $show_submit == true and $listing_split->number_of_rows > 0) and (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART >= 2) ) {
  194. $show_bottom_submit_button = true;
  195. } else {
  196. $show_bottom_submit_button = false;
  197. }
  198. if ($how_many > 0 && PRODUCT_LISTING_MULTIPLE_ADD_TO_CART != 0 and $show_submit == true and $listing_split->number_of_rows > 0) {
  199. // bof: multiple products
  200. 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"');
  201. }
  202. ?>