  |
1 | 1 | | <?php |
| |
2 | 2 | | /* |
  |
3 | | - | $Id: account.php 207 2005-09-26 01:29:31 +0200 (Mo, 26 Sep 2005) hpdl $ |
| |
| 3 | + | $Id: $ |
|
4 | 4 | | |
| |
5 | 5 | | osCommerce, Open Source E-Commerce Solutions |
| |
6 | 6 | | http://www.oscommerce.com |
| |
7 | 7 | | |
  |
8 | | - | Copyright (c) 2005 osCommerce |
| |
| 8 | + | Copyright (c) 2007 osCommerce |
|
9 | 9 | | |
| |
10 | 10 | | This program is free software; you can redistribute it and/or modify |
| |
11 | 11 | | it under the terms of the GNU General Public License v2 (1991) |
| |
12 | 12 | | as published by the Free Software Foundation. |
| |
13 | 13 | | */ |
| |
14 | 14 | | |
  |
| 15 | + | /** |
| |
| 16 | + | * The osC_Category class manages category information |
| |
| 17 | + | */ |
| |
| 18 | + | |
|
15 | 19 | | class osC_Category { |
  |
16 | | - | var $_data = array(); |
|
17 | 20 | | |
  |
18 | | - | function osC_Category($id) { |
| |
| 21 | + | /** |
| |
| 22 | + | * An array containing the category information |
| |
| 23 | + | * |
| |
| 24 | + | * @var array |
| |
| 25 | + | * @access private |
| |
| 26 | + | */ |
| |
| 27 | + | |
| |
| 28 | + | private $_data = array(); |
| |
| 29 | + | |
| |
| 30 | + | /** |
| |
| 31 | + | * Constructor |
| |
| 32 | + | * |
| |
| 33 | + | * @param int $id The ID of the category to retrieve information from |
| |
| 34 | + | * @access public |
| |
| 35 | + | */ |
| |
| 36 | + | |
| |
| 37 | + | public function __construct($id) { |
|
19 | 38 | | global $osC_CategoryTree; |
| |
20 | 39 | | |
  |
21 | | - | if ($osC_CategoryTree->exists($id)) { |
| |
| 40 | + | if ( $osC_CategoryTree->exists($id) ) { |
|
22 | 41 | | $this->_data = $osC_CategoryTree->getData($id); |
| |
23 | 42 | | } |
| |
24 | 43 | | } |
| |
25 | 44 | | |
  |
26 | | - | function getID() { |
| |
| 45 | + | /** |
| |
| 46 | + | * Return the ID of the assigned category |
| |
| 47 | + | * |
| |
| 48 | + | * @access public |
| |
| 49 | + | * @return integer |
| |
| 50 | + | */ |
| |
| 51 | + | |
| |
| 52 | + | public function getID() { |
|
27 | 53 | | return $this->_data['id']; |
| |
28 | 54 | | } |
| |
29 | 55 | | |
  |
30 | | - | function getTitle() { |
| |
| 56 | + | /** |
| |
| 57 | + | * Return the title of the assigned category |
| |
| 58 | + | * |
| |
| 59 | + | * @access public |
| |
| 60 | + | * @return string |
| |
| 61 | + | */ |
| |
| 62 | + | |
| |
| 63 | + | public function getTitle() { |
|
31 | 64 | | return $this->_data['name']; |
| |
32 | 65 | | } |
| |
33 | 66 | | |
  |
34 | | - | function getImage() { |
| |
| 67 | + | /** |
| |
| 68 | + | * Return the image of the assigned category |
| |
| 69 | + | * |
| |
| 70 | + | * @access public |
| |
| 71 | + | * @return string |
| |
| 72 | + | */ |
| |
| 73 | + | |
| |
| 74 | + | public function getImage() { |
|
35 | 75 | | return $this->_data['image']; |
| |
36 | 76 | | } |
| |
37 | 77 | | |
  |
38 | | - | function hasParent() { |
| |
39 | | - | if ($this->_data['parent_id'] > 0) { |
| |
40 | | - | return true; |
| |
41 | | - | } |
| |
| 78 | + | /** |
| |
| 79 | + | * Check if the assigned category has a parent category |
| |
| 80 | + | * |
| |
| 81 | + | * @access public |
| |
| 82 | + | * @return boolean |
| |
| 83 | + | */ |
|
42 | 84 | | |
  |
43 | | - | return false; |
| |
| 85 | + | public function hasParent() { |
| |
| 86 | + | return ( $this->_data['parent_id'] > 0 ); |
|
44 | 87 | | } |
| |
45 | 88 | | |
  |
46 | | - | function getParent() { |
| |
| 89 | + | /** |
| |
| 90 | + | * Return the parent ID of the assigned category |
| |
| 91 | + | * |
| |
| 92 | + | * @access public |
| |
| 93 | + | * @return integer |
| |
| 94 | + | */ |
| |
| 95 | + | |
| |
| 96 | + | public function getParent() { |
|
47 | 97 | | return $this->_data['parent_id']; |
| |
48 | 98 | | } |
| |
49 | 99 | | |
  |
50 | | - | function getPath() { |
| |
| 100 | + | /** |
| |
| 101 | + | * Return the breadcrumb path of the assigned category |
| |
| 102 | + | * |
| |
| 103 | + | * @access public |
| |
| 104 | + | * @return string |
| |
| 105 | + | */ |
| |
| 106 | + | |
| |
| 107 | + | public function getPath() { |
|
51 | 108 | | global $osC_CategoryTree; |
| |
52 | 109 | | |
| |
53 | 110 | | return $osC_CategoryTree->buildBreadcrumb($this->_data['id']); |
| |
54 | 111 | | } |
  |
| 112 | + | |
| |
| 113 | + | /** |
| |
| 114 | + | * Return specific information from the assigned category |
| |
| 115 | + | * |
| |
| 116 | + | * @access public |
| |
| 117 | + | * @return mixed |
| |
| 118 | + | */ |
| |
| 119 | + | |
| |
| 120 | + | public function getData($keyword) { |
| |
| 121 | + | return $this->_data[$keyword]; |
| |
| 122 | + | } |
  |
55 | 123 | | } |
| |
56 | 124 | | ?> |