Quick Search:

View

Revision:

Diff

Diff from 1862 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/osCommerce/trunk/oscommerce/admin/includes/classes/category_tree.php

Annotated File View

hpdl
746
1 <?php
2 /*
3   $Id: category_tree.php 733 2006-08-20 15:32:32Z hpdl $
4
5   osCommerce, Open Source E-Commerce Solutions
6   http://www.oscommerce.com
7
hpdl
1862
8   Copyright (c) 2007 osCommerce
hpdl
746
9
hpdl
1498
10   This program is free software; you can redistribute it and/or modify
11   it under the terms of the GNU General Public License v2 (1991)
12   as published by the Free Software Foundation.
hpdl
746
13 */
14
15   require('../includes/classes/category_tree.php');
16
17   class osC_CategoryTree_Admin extends osC_CategoryTree {
hpdl
1862
18     protected $_show_total_products = true;
hpdl
746
19
hpdl
1862
20     function __constructor() {
hpdl
746
21       global $osC_Database, $osC_Language;
22
23       $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');
24       $Qcategories->bindTable(':table_categories', TABLE_CATEGORIES);
25       $Qcategories->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION);
26       $Qcategories->bindInt(':language_id', $osC_Language->getID());
27       $Qcategories->execute();
28
hpdl
1862
29       $this->_data = array();
hpdl
746
30
31       while ($Qcategories->next()) {
hpdl
1862
32         $this->_data[$Qcategories->valueInt('parent_id')][$Qcategories->valueInt('categories_id')] = array('name' => $Qcategories->value('categories_name'), 'image' => $Qcategories->value('categories_image'), 'count' => 0);
hpdl
746
33       }
34
35       $Qcategories->freeResult();
36
hpdl
1862
37       if ($this->_show_total_products === true) {
38         $this->_calculateProductTotals(false);
hpdl
746
39       }
40     }
41
42     function getPath($category_id, $level = 0, $separator = ' ') {
43       $path = '';
44
hpdl
1862
45       foreach ($this->_data as $parent => $categories) {
hpdl
746
46         foreach ($categories as $id => $info) {
47           if ($id == $category_id) {
48             if ($level < 1) {
49               $path = $info['name'];
50             } else {
51               $path = $info['name'] . $separator . $path;
52             }
53
54             if ($parent != $this->root_category_id) {
55               $path = $this->getPath($parent, $level+1, $separator) . $path;
56             }
57           }
58         }
59       }
60
61       return $path;
62     }
63   }
64 ?>