Advertisement
gadlol

osCommerce products_listing.php Products as tiles

Jul 21st, 2015
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 11.76 KB | None | 0 0
  1. <?php
  2. /*
  3.   $Id$
  4.  
  5.   osCommerce, Open Source E-Commerce Solutions
  6.   http://www.oscommerce.com
  7.  
  8.   Copyright (c) 2010 osCommerce
  9.  
  10.   Released under the GNU General Public License
  11. */
  12.  
  13.   $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_SEARCH_RESULTS, 'p.products_id');
  14. ?>
  15.  
  16. <?php
  17.   if ($messageStack->size('product_action') > 0) {
  18.     echo $messageStack->output('product_action');
  19.   }
  20. ?>
  21.  
  22.   <div class="contentText">
  23.  
  24. <?php
  25.   if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
  26. ?>
  27. <div class="row">
  28.   <div class="col-sm-6 pagenumber hidden-xs">
  29.     <?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?>
  30.   </div>
  31.   <div class="col-sm-6">
  32.     <div class="pull-right pagenav"><ul class="pagination"><?php echo $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></ul></div>
  33.     <span class="pull-right"><?php echo TEXT_RESULT_PAGE; ?></span>
  34.   </div>
  35. </div>
  36. <?php
  37.   }
  38.  
  39.   if ($listing_split->number_of_rows > 0) { ?>
  40.     <div class="well well-sm">
  41.       <div class="btn-group btn-group-sm pull-right">
  42.         <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
  43.           <?php echo TEXT_SORT_BY; ?><span class="caret"></span>
  44.         </button>
  45.  
  46.         <ul class="dropdown-menu text-left">
  47.           <?php
  48.           $lc_show_model = false;
  49.           $lc_show_manu = false;
  50.           $lc_show_qty = false;
  51.           $lc_show_lbs = false;
  52.           for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
  53.             switch ($column_list[$col]) {
  54.               case 'PRODUCT_LIST_MODEL':
  55.               $lc_text = TABLE_HEADING_MODEL;
  56.                   $lc_show_model = true;
  57.               break;
  58.               case 'PRODUCT_LIST_NAME':
  59.               $lc_text = TABLE_HEADING_PRODUCTS;
  60.               break;
  61.               case 'PRODUCT_LIST_MANUFACTURER':
  62.               $lc_text = TABLE_HEADING_MANUFACTURER;
  63.                   $lc_show_manu = true;
  64.               break;
  65.               case 'PRODUCT_LIST_PRICE':
  66.               $lc_text = TABLE_HEADING_PRICE;
  67.               break;
  68.               case 'PRODUCT_LIST_QUANTITY':
  69.               $lc_text = TABLE_HEADING_QUANTITY;
  70.               $lc_show_qty = true;
  71.               break;
  72.               case 'PRODUCT_LIST_WEIGHT':
  73.               $lc_text = TABLE_HEADING_WEIGHT;
  74.               $lc_show_lbs = true;
  75.               break;
  76.               case 'PRODUCT_LIST_IMAGE':
  77.               $lc_text = TABLE_HEADING_IMAGE;
  78.               break;
  79.               case 'PRODUCT_LIST_BUY_NOW':
  80.               $lc_text = TABLE_HEADING_BUY_NOW;
  81.               break;
  82.               case 'PRODUCT_LIST_ID':
  83.               $lc_text = TABLE_HEADING_LATEST_ADDED;
  84.               break;
  85.             }
  86.  
  87.             if ( ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW') && ($column_list[$col] != 'PRODUCT_LIST_IMAGE') ) {
  88.               $lc_text = tep_create_sort_heading($HTTP_GET_VARS['sort'], $col+1, $lc_text);
  89.                 echo '        <li>' . $lc_text . '</li>';
  90.             }
  91.           }
  92.               ?>
  93.         </ul>
  94.       </div>
  95.  
  96.     <?php
  97.     if (MODULE_HEADER_TAGS_GRID_LIST_VIEW_STATUS == 'True') {
  98.       ?>
  99.       <strong><?php echo TEXT_VIEW; ?></strong>
  100.       <div class="btn-group">
  101.         <a href="#" id="list" class="btn btn-default btn-sm"><span class="glyphicon glyphicon-th-list"></span><?php echo TEXT_VIEW_LIST; ?></a>
  102.         <a href="#" id="grid" class="btn btn-default btn-sm"><span class="glyphicon glyphicon-th"></span><?php echo TEXT_VIEW_GRID; ?></a>
  103.       </div>
  104.       <?php
  105.     }
  106.     ?>
  107.     <div class="clearfix"></div>
  108.   </div>
  109.  
  110.   <?php
  111.   $listing_query = tep_db_query($listing_split->sql_query);
  112.  
  113.   $prod_list_contents = NULL;
  114.   $products_listings=array();
  115.   while ($listing = tep_db_fetch_array($listing_query)) {
  116.  
  117.     $products_listings[]=$listing;
  118.  
  119.     //$prod_list_contents .= disp_product($listing,isset($sort)?$sort:'',$cPath,$lc_show_manu,$lc_show_model,$lc_show_qty,$lc_show_lbs);
  120.  
  121.   }
  122.   ?>
  123.      
  124.     <div id="products">
  125.      
  126.       <div id="products0" class="row list-group visible-lg-block">
  127.         <div class="col-lg-4">
  128. <?php foreach($products_listings as $clKey => $cl){
  129. if($clKey%3 == 0) echo disp_product($cl,isset($sort)?$sort:'',$cPath,$lc_show_manu,$lc_show_model,$lc_show_qty,$lc_show_lbs);
  130. } ?>
  131.         </div>
  132.         <div class="col-lg-4">
  133. <?php foreach($products_listings as $clKey => $cl){
  134. if($clKey%3 == 1) echo disp_product($cl,isset($sort)?$sort:'',$cPath,$lc_show_manu,$lc_show_model,$lc_show_qty,$lc_show_lbs);
  135. } ?>
  136.         </div>
  137.         <div class="col-lg-4">
  138. <?php foreach($products_listings as $clKey => $cl){
  139. if($clKey%3 == 2) echo disp_product($cl,isset($sort)?$sort:'',$cPath,$lc_show_manu,$lc_show_model,$lc_show_qty,$lc_show_lbs);
  140. } ?>
  141.         </div>
  142.       </div>
  143.      
  144.       <div id="products1" class="row list-group visible-md-block">
  145.         <div class="col-md-6">
  146. <?php foreach($products_listings as $clKey => $cl){
  147. if($clKey%2 == 0) echo disp_product($cl,isset($sort)?$sort:'',$cPath,$lc_show_manu,$lc_show_model,$lc_show_qty,$lc_show_lbs);
  148. } ?>
  149.         </div>
  150.         <div class="col-md-6">
  151. <?php foreach($products_listings as $clKey => $cl){
  152. if($clKey%2 == 1) echo disp_product($cl,isset($sort)?$sort:'',$cPath,$lc_show_manu,$lc_show_model,$lc_show_qty,$lc_show_lbs);
  153. } ?>
  154.         </div>
  155.       </div>
  156.      
  157.       <div id="products2" class="row list-group visible-sm-block">
  158.         <div class="col-sm-6">
  159. <?php foreach($products_listings as $clKey => $cl){
  160. if($clKey%2 == 0) echo disp_product($cl,isset($sort)?$sort:'',$cPath,$lc_show_manu,$lc_show_model,$lc_show_qty,$lc_show_lbs);
  161. } ?>
  162.         </div>
  163.         <div class="col-sm-6">
  164. <?php foreach($products_listings as $clKey => $cl){
  165. if($clKey%2 == 1) echo disp_product($cl,isset($sort)?$sort:'',$cPath,$lc_show_manu,$lc_show_model,$lc_show_qty,$lc_show_lbs);
  166. } ?>
  167.         </div>
  168.       </div>
  169.      
  170.       <div id="products3" class="row grid-group visible-xs-block">
  171.         <div class="col-xs-12">
  172. <?php foreach($products_listings as $clKey => $cl){
  173.   echo disp_product($cl,isset($sort)?$sort:'',$cPath,$lc_show_manu,$lc_show_model,$lc_show_qty,$lc_show_lbs);
  174. } ?>
  175.         </div>
  176.       </div>
  177.   </div>
  178.   <?php
  179.  
  180.   //echo '<div id="products" class="row list-group">' . $prod_list_contents . '</div>';
  181. } else {
  182. ?>
  183.  
  184.   <div class="alert alert-info"><?php echo TEXT_NO_PRODUCTS; ?></div>
  185.  
  186. <?php
  187. }
  188.  
  189. if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
  190.   ?>
  191. <div class="row">
  192.   <div class="col-sm-6 pagenumber hidden-xs">
  193.     <?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?>
  194.   </div>
  195.   <div class="col-sm-6">
  196.     <div class="pull-right pagenav"><ul class="pagination"><?php echo $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></ul></div>
  197.     <span class="pull-right"><?php echo TEXT_RESULT_PAGE; ?></span>
  198.   </div>
  199. </div>
  200.   <?php
  201.   }
  202. ?>
  203.  
  204. </div>
  205.  
  206. <?php
  207. //this should be transfered to functions :: general.php
  208. function disp_product($listing,$sort,$cPath,$lc_show_manu,$lc_show_model,$lc_show_qty,$lc_show_lbs){
  209.  
  210.   global $currencies,$PHP_SELF;
  211.  
  212.   $prod_list_contents = '<div class="item list-group-item">';
  213.   $prod_list_contents .= '  <div class="productHolder equal-height">';
  214.   if (isset($HTTP_GET_VARS['manufacturers_id'])  && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
  215.     $prod_list_contents .= '    <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, NULL, NULL, 'img-responsive thumbnail group list-group-image') . '</a>';
  216.   } else {
  217.     $prod_list_contents .= '    <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, (isset($sort) ? 'sort=' . $sort . '&' : '') . ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, NULL, NULL, 'img-responsive thumbnail group list-group-image') . '</a>';
  218.   }
  219.   $prod_list_contents .= '    <div class="caption">';
  220.   $prod_list_contents .= '      <h2 class="group inner list-group-item-heading">';
  221.   if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
  222.     $prod_list_contents .= '    <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>';
  223.   } else {
  224.     $prod_list_contents .= '    <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>';
  225.   }
  226.   $prod_list_contents .= '      </h2>';
  227.  
  228.   $prod_list_contents .= '      <p class="group inner list-group-item-text">' . strip_tags($listing['products_description'], '<br>') . '&hellip;</p><div class="clearfix"></div>';
  229.  
  230.   // here it goes the extras, yuck
  231.   $extra_list_contents = NULL;
  232.   // manufacturer
  233.   if (($lc_show_manu == true) && ($listing['manufacturers_id'] !=  0)) $extra_list_contents .= '<dt>' . TABLE_HEADING_MANUFACTURER . '</dt><dd><a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a></dd>';
  234.   // model
  235.   if ( ($lc_show_model == true) && tep_not_null($listing['products_model'])) $extra_list_contents .= '<dt>' . TABLE_HEADING_MODEL . '</dt><dd>' . $listing['products_model'] . '</dd>';
  236.   // stock
  237.   if (($lc_show_qty == true) && (tep_get_products_stock($listing['products_id'])!= 0) ) $extra_list_contents .= '<dt>' . TABLE_HEADING_QUANTITY . '</dt><dd>' . tep_get_products_stock($listing['products_id']) . '</dd>';
  238.   // weight
  239.   if (($lc_show_lbs == true) && ($listing['products_weight'] != 0)) $extra_list_contents .= '<dt>' . TABLE_HEADING_WEIGHT . '</dt><dd>' . $listing['products_weight'] . '</dd>';
  240.  
  241.   if (tep_not_null($extra_list_contents)) {
  242.      $prod_list_contents .= '    <dl class="dl-horizontal list-group-item-text">';
  243.      $prod_list_contents .=  $extra_list_contents;
  244.      $prod_list_contents .= '    </dl>';
  245.   }
  246.  
  247.   $prod_list_contents .= '      <div class="row">';
  248.   if (tep_not_null($listing['specials_new_products_price'])) {
  249.     $prod_list_contents .= '      <div class="col-xs-6"><div class="btn-group" role="group"><button type="button" class="btn btn-default"><del>' .  $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</del></span>&nbsp;&nbsp;<span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</button></div></div>';
  250.   } else {
  251.     $prod_list_contents .= '      <div class="col-xs-6"><div class="btn-group" role="group"><button type="button" class="btn btn-default">' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</button></div></div>';
  252.   }
  253.   $prod_list_contents .= '       <div class="col-xs-6 text-right">' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']), NULL, NULL, 'btn-success btn-sm') . '</div>';
  254.   $prod_list_contents .= '      </div>';
  255.  
  256.   $prod_list_contents .= '    </div>';
  257.   $prod_list_contents .= '  </div>';
  258.   $prod_list_contents .= '</div>';
  259.  
  260.   return $prod_list_contents;
  261.  
  262. }
  263.  
  264.  
  265. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement