Quick Search:

View

Revision:

Diff

Diff from 1675 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/osCommerce/branches/hpdl/oscommerce/includes/classes/category.php

Annotated File View

hpdl
208
1 <?php
2 /*
hpdl
1675
3   $Id: $
hpdl
208
4
5   osCommerce, Open Source E-Commerce Solutions
6   http://www.oscommerce.com
7
hpdl
1675
8   Copyright (c) 2007 osCommerce
hpdl
208
9
hpdl
1497
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
208
13 */
14
hpdl
1675
15 /**
16  * The osC_Category class manages category information
17  */
18
hpdl
208
19   class osC_Category {
20
hpdl
1675
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) {
hpdl
299
38       global $osC_CategoryTree;
hpdl
208
39
hpdl
1675
40       if ( $osC_CategoryTree->exists($id) ) {
hpdl
299
41         $this->_data = $osC_CategoryTree->getData($id);
hpdl
208
42       }
43     }
44
hpdl
1675
45 /**
46  * Return the ID of the assigned category
47  *
48  * @access public
49  * @return integer
50  */
51
52     public function getID() {
hpdl
298
53       return $this->_data['id'];
54     }
hpdl
208
55
hpdl
1675
56 /**
57  * Return the title of the assigned category
58  *
59  * @access public
60  * @return string
61  */
62
63     public function getTitle() {
hpdl
298
64       return $this->_data['name'];
hpdl
208
65     }
66
hpdl
1675
67 /**
68  * Return the image of the assigned category
69  *
70  * @access public
71  * @return string
72  */
73
74     public function getImage() {
hpdl
298
75       return $this->_data['image'];
hpdl
208
76     }
hpdl
299
77
hpdl
1675
78 /**
79  * Check if the assigned category has a parent category
80  *
81  * @access public
82  * @return boolean
83  */
hpdl
299
84
hpdl
1675
85     public function hasParent() {
86       return ( $this->_data['parent_id'] > 0 );
hpdl
299
87     }
88
hpdl
1675
89 /**
90  * Return the parent ID of the assigned category
91  *
92  * @access public
93  * @return integer
94  */
95
96     public function getParent() {
hpdl
299
97       return $this->_data['parent_id'];
98     }
99
hpdl
1675
100 /**
101  * Return the breadcrumb path of the assigned category
102  *
103  * @access public
104  * @return string
105  */
106
107     public function getPath() {
hpdl
299
108       global $osC_CategoryTree;
109
110       return $osC_CategoryTree->buildBreadcrumb($this->_data['id']);
111     }
hpdl
1675
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     }
hpdl
208
123   }
124 ?>