[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/includes/boxes/ -> categories.php (source)

   1  <?php
   2  /*

   3  $Id: categories.php 3 2006-05-27 04:59:07Z user $

   4  

   5    osCMax Power E-Commerce

   6    http://oscdox.com

   7  

   8    Copyright 2006 osCMax

   9  

  10    Released under the GNU General Public License

  11  */
  12  
  13  // Most of this file is changed or moved to BTS - Basic Template System - format.

  14  
  15     if ((USE_CACHE == 'true') && empty($SID)) {
  16       echo tep_cache_categories_box();
  17     } else {
  18  
  19       if ( DISPLAY_DHTML_MENU == 'Dhtml' ) {
  20         include (DIR_WS_BOXES . 'categories_dhtml.php');
  21     } elseif (DISPLAY_DHTML_MENU == 'CoolMenu') {
  22         include (DIR_WS_BOXES . 'coolmenu.php');
  23     } else {
  24  
  25  
  26    $boxHeading = BOX_HEADING_CATEGORIES;
  27    $corner_left = 'rounded';
  28    $corner_right = 'square';
  29    $box_base_name = 'categories'; // for easy unique box template setup (added BTSv1.2)

  30  
  31    $box_id = $box_base_name . 'Box';  // for CSS styling paulm (editted BTSv1.2)

  32  
  33    function tep_show_category($counter) {
  34      
  35  // BoF - Contribution Category Box Enhancement 1.1

  36      global $tree, $boxContent, $cPath_array, $cat_name;
  37  
  38      for ($i=0; $i<$tree[$counter]['level']; $i++) {
  39        $boxContent .= "&nbsp;&nbsp;";
  40      }
  41      $cPath_new = 'cPath=' . $tree[$counter]['path'];
  42      $boxContent .= '<a href="';
  43      $boxContent .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">';
  44     
  45      if (tep_has_category_subcategories($counter)) {
  46        $boxContent .= tep_image(DIR_WS_IMAGES . 'pointer_blue.gif', '');
  47      }
  48      else {
  49        $boxContent .= tep_image(DIR_WS_IMAGES . 'pointer_blue_light.gif', '');
  50      }
  51  
  52      if (isset($cPath_array) && in_array($counter, $cPath_array)) {
  53        $boxContent .= '<b>';
  54      }
  55      
  56      if ($cat_name == $tree[$counter]['name']) {
  57        $boxContent .= '<span class="errorText">';
  58      }
  59  
  60  // display category name

  61      $boxContent .= $tree[$counter]['name'];
  62  
  63                  if ($cat_name == $tree[$counter]['name']) {
  64                          $boxContent .= '</span>';
  65      }
  66  
  67      if (isset($cPath_array) && in_array($counter, $cPath_array)) {
  68        $boxContent .= '</b>';
  69      }
  70  //         EoF Category Box Enhancement

  71  
  72      $boxContent .= '</a>';
  73  
  74      if (SHOW_COUNTS == 'true') {
  75        $products_in_category = tep_count_products_in_category($counter);
  76        if ($products_in_category > 0) {
  77          $boxContent .= '&nbsp;(' . $products_in_category . ')';
  78        }
  79      }
  80  
  81      $boxContent .= '<br>';
  82  
  83      if ($tree[$counter]['next_id'] != false) {
  84        tep_show_category($tree[$counter]['next_id']);
  85      }
  86    }
  87  ?>
  88  <!-- categories //-->
  89  <?php
  90  // BoF - Contribution Category Box Enhancement 1.1

  91   if (isset($cPath_array)) {
  92                  for ($i=0, $n=sizeof($cPath_array); $i<$n; $i++) {
  93                                  $categories_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$cPath_array[$i] . "' and language_id = '" . (int)$languages_id . "'");
  94                                  if (tep_db_num_rows($categories_query) > 0)
  95                                  $categories = tep_db_fetch_array($categories_query);
  96                  }
  97          $cat_name = $categories['categories_name']; 
  98          }
  99  // EoF Category Box Enhancement

 100  
 101    $boxContent = '';
 102    $tree = array();
 103  
 104    $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");
 105    while ($categories = tep_db_fetch_array($categories_query))  {
 106      $tree[$categories['categories_id']] = array('name' => $categories['categories_name'],
 107                                                  'parent' => $categories['parent_id'],
 108                                                  'level' => 0,
 109                                                  'path' => $categories['categories_id'],
 110                                                  'next_id' => false);
 111  
 112      if (isset($parent_id)) {
 113        $tree[$parent_id]['next_id'] = $categories['categories_id'];
 114      }
 115  
 116      $parent_id = $categories['categories_id'];
 117  
 118      if (!isset($first_element)) {
 119        $first_element = $categories['categories_id'];
 120      }
 121    }
 122  
 123    //------------------------

 124    if (tep_not_null($cPath)) {
 125      $new_path = '';
 126      reset($cPath_array);
 127      while (list($key, $value) = each($cPath_array)) {
 128        unset($parent_id);
 129        unset($first_id);
 130        $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$value . "' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");
 131        if (tep_db_num_rows($categories_query)) {
 132          $new_path .= $value;
 133          while ($row = tep_db_fetch_array($categories_query)) {
 134            $tree[$row['categories_id']] = array('name' => $row['categories_name'],
 135                                                 'parent' => $row['parent_id'],
 136                                                 'level' => $key+1,
 137                                                 'path' => $new_path . '_' . $row['categories_id'],
 138                                                 'next_id' => false);
 139  
 140            if (isset($parent_id)) {
 141              $tree[$parent_id]['next_id'] = $row['categories_id'];
 142            }
 143  
 144            $parent_id = $row['categories_id'];
 145  
 146            if (!isset($first_id)) {
 147              $first_id = $row['categories_id'];
 148            }
 149  
 150            $last_id = $row['categories_id'];
 151          }
 152          $tree[$last_id]['next_id'] = $tree[$value]['next_id'];
 153          $tree[$value]['next_id'] = $first_id;
 154          $new_path .= '_';
 155        } else {
 156          break;
 157        }
 158      }
 159    }
 160    tep_show_category($first_element); 
 161  
 162  
 163  include (bts_select('boxes', $box_base_name)); // BTS 1.5

 164  }
 165  }
 166  ?><!-- categories_eof //-->


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7