Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace:

Diff

1498
 
1862
 
1862
 
category_tree.php
_> 55   osCommerce, Open Source E-Commerce Solutions
  66   http://www.oscommerce.com
  77 
<> 8 -  Copyright (c) 2004 osCommerce
   8+  Copyright (c) 2007 osCommerce
99 
  1010   This program is free software; you can redistribute it and/or modify
  1111   it under the terms of the GNU General Public License v2 (1991)
     
 !
1515   require('../includes/classes/category_tree.php');
  1616 
  1717   class osC_CategoryTree_Admin extends osC_CategoryTree {
<> 18 -    var $show_category_product_count = true;
   18+    protected $_show_total_products = true;
1919 
<> 20 -    function osC_CategoryTree_Admin() {
   20+    function __constructor() {
2121       global $osC_Database, $osC_Language;
  2222 
  2323       $Qcategories = $osC_Database->query('select c.categories_id, c.parent_id, c.categories_image, cd.categories_name from :table_categories c, :table_categories_description cd where c.categories_id = cd.categories_id and cd.language_id = :language_id order by c.parent_id, c.sort_order, cd.categories_name');
     
 !
2626       $Qcategories->bindInt(':language_id', $osC_Language->getID());
  2727       $Qcategories->execute();
  2828 
<> 29 -      $this->data = array();
   29+      $this->_data = array();
3030 
  3131       while ($Qcategories->next()) {
<> 32 -        $this->data[$Qcategories->valueInt('parent_id')][$Qcategories->valueInt('categories_id')] = array('name' => $Qcategories->value('categories_name'), 'image' => $Qcategories->value('categories_image'), 'count' => 0);
   32+        $this->_data[$Qcategories->valueInt('parent_id')][$Qcategories->valueInt('categories_id')] = array('name' => $Qcategories->value('categories_name'), 'image' => $Qcategories->value('categories_image'), 'count' => 0);
3333       }
  3434 
  3535       $Qcategories->freeResult();
  3636 
<> 37 -      if ($this->show_category_product_count === true) {
  38 -        $this->calculateCategoryProductCount();
   37+      if ($this->_show_total_products === true) {
   38+        $this->_calculateProductTotals(false);
3939       }
  4040     }
  4141 
<> 42 -    function calculateCategoryProductCount() {
  43 -      global $osC_Database;
  44 -
  45 -      $totals = array();
  46 -
  47 -      $Qtotals = $osC_Database->query('select p2c.categories_id, count(*) as total from :table_products p, :table_products_to_categories p2c where p2c.products_id = p.products_id group by p2c.categories_id');
  48 -      $Qtotals->bindTable(':table_products', TABLE_PRODUCTS);
  49 -      $Qtotals->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
  50 -      $Qtotals->execute();
  51 -
  52 -      while ($Qtotals->next()) {
  53 -        $totals[$Qtotals->valueInt('categories_id')] = $Qtotals->valueInt('total');
  54 -      }
  55 -
  56 -      $Qtotals->freeResult();
  57 -
  58 -      foreach ($this->data as $parent => $categories) {
  59 -        foreach ($categories as $id => $info) {
  60 -          if (isset($totals[$id]) && ($totals[$id] > 0)) {
  61 -            $this->data[$parent][$id]['count'] = $totals[$id];
  62 -
  63 -            $parent_category = $parent;
  64 -            while ($parent_category != $this->root_category_id) {
  65 -              foreach ($this->data as $parent_parent => $parent_categories) {
  66 -                foreach ($parent_categories as $parent_category_id => $parent_category_info) {
  67 -                  if ($parent_category_id == $parent_category) {
  68 -                    $this->data[$parent_parent][$parent_category_id]['count'] += $this->data[$parent][$id]['count'];
  69 -
  70 -                    $parent_category = $parent_parent;
  71 -                    break 2;
  72 -                  }
  73 -                }
  74 -              }
  75 -            }
  76 -          }
  77 -        }
  78 -      }
  79 -
  80 -      unset($totals);
  81 -    }
  82 -
8342     function getPath($category_id, $level = 0, $separator = ' ') {
  8443       $path = '';
  8544 
<> 86 -      foreach ($this->data as $parent => $categories) {
   45+      foreach ($this->_data as $parent => $categories) {
<_ 8746         foreach ($categories as $id => $info) {
  8847           if ($id == $category_id) {
  8948             if ($level < 1) {