lars
committed
on 17 Feb 04
Fixed @returns -> @return
/tcl/bcms-category-procs.tcl (+6 -6)
62 62     {-category_id:required}
63 63 } {
64 64
65 65     deletes a category
66 66
67 67     @param category_id The category id of the category to delete
68 68
69 69 } {
70 70     db_exec_plsql delete_category {}
71 71 }
72 72
73 73
74 74 ad_proc -public bcms::category::get_category {
75 75    {-category_id:required}
76 76 } {
77 77
78 78     returns the data for a particular category
79 79
80 80     @param category_id The category id of the category to get the data
81 81
82       @returns an array with the following properties:
  82     @return an array with the following properties:
83 83     category_id, parent_id, heading, description, has_children
84 84
85 85 } {
86 86
87 87     if {[db_0or1row get_category {} -column_array category]} {
88 88         return [array get category]
89 89     } else {
90 90         return {}
91 91     }
92 92
93 93 }
94 94
95 95
96 96 ad_proc -public bcms::category::list_categories {
97 97     {-parent_id}
98 98     {-return_list:boolean}
99 99     {-multirow_name bcms_list_category}
100 100 } {
101 101
102 102     returns the categories under a parent
103 103
104 104     @parent_id                  id of the category which will list the category under it, if not supplied
105 105                                 it will list all the root keywords
106 106     @param multirow_name        you can supply your own multirow name
107 107     @param return_list          if supplied a list of ns_sets otherwise it
108 108                                 returns a multirow uses the multirow_name if given
109 109
110       @returns makes a multirow of categories or list of ns sets with the following properties:
  110     @return makes a multirow of categories or list of ns sets with the following properties:
111 111     category_id, parent_id, heading, description, has_children
112 112
113 113 } {
114 114
115 115     if {[info exists parent_id]} {
116 116         set where_str "parent_id = :parent_id"
117 117     } else {
118 118         set where_str "parent_id is null"
119 119     }
120 120
121 121     if {$return_list_p} {
122 122         # return a list of lists since its not easy to pass multirow from proc to proc
123 123         return [db_list_of_ns_sets get_categories {}]
124 124     } else {
125 125         # make a multirow, it is likely that this proc is not being called from another proc
126 126         db_multirow $multirow_name get_categories {}
127 127     }
128 128
129 129 }
130 130
131 131
132 132 ad_proc -public bcms::category::tree_categories {
133 133     {-parent_id:required}
134 134     {-return_list:boolean}
135 135     {-multirow_name bcms_tree_category}
136 136 } {
137 137
138 138     returns the all sub categories under the root id
139 139
140 140     @parent_id                  category id of root node of the tree to return
141 141     @param multirow_name        you can supply your own multirow name
142 142     @param return_list          if supplied a list of ns_sets otherwise it
143 143                                 returns a multirow uses the multirow_name if given
144 144
145       @returns all sub categories under the root_id with the following attributes:
  145     @return all sub categories under the root_id with the following attributes:
146 146     category_id, parent_id, heading, description, has_children, path
147 147 } {
148 148
149 149     if {$return_list_p} {
150 150         # return a list of lists since its not easy to pass multirow from proc to proc
151 151         return [db_list_of_ns_sets get_categories {}]
152 152     } else {
153 153         # make a multirow, it is likely that this proc is not being called from another proc
154 154         db_multirow $multirow_name get_categories {}
155 155     }
156 156
157 157 }
158 158
159 159
160 160 ad_proc -public bcms::category::get_category_path {
161 161     {-category_id:required}
162 162     {-root_id}
163 163     {-prepend_path ''}
164 164     {-multirow_name bcms_category_path}
165 165     {-return_list:boolean}
166 166 } {
167 167     returns a path from the root_id to the category_id
168 168
169 169     @param category_id       build the path to this category
170 170     @param root_id           build the path from this root, if not supplied it will use the root node of the
171 171                              current category
172 172     @param prepend_path      you can add a string to prepend the path column
173 173     @param multirow_name     you can supply your own multirow name
174 174     @param return_list       if supplied a list of ns_sets otherwise it
175 175                              returns a multirow uses the multirow_name if given
176 176
177       @returns a multirow/list with the following elements:
  177     @return a multirow/list with the following elements:
178 178     category_id, path, heading
179 179 } {
180 180
181 181     if {![info exists root_id]} {
182 182         # if the root_id does not exists then start from the root
183 183         array set root [bcms::category::get_root -category_id $category_id]
184 184         if {[array size root] > 0} {
185 185             set root_id $root(category_id)
186 186         } else {
187 187             ns_log notice "bcms: category does not exists"
188 188         }
189 189     }
190 190
191 191     if {$return_list_p} {
192 192         return [db_list_of_ns_sets get_category_path {}]
193 193     } else {
194 194         db_multirow $multirow_name get_category_path {}
195 195     }
196 196 }
197 197
198 198
199 199 ad_proc -public bcms::category::get_root {
200 200     {-category_id:required}
201 201 } {
202 202     gets the root id of a category tree, supplied with any category underneath it
203 203
204 204     @param category_id    a node of the category tree
205 205
206       @returns an array with the following properties:
  206     @return an array with the following properties:
207 207     category_id, parent_id, heading, description, has_children
208 208 } {
209 209
210 210     if {[db_0or1row get_root {} -column_array category]} {
211 211         return [array get category]
212 212     } else {
213 213         return {}
214 214     }
215 215
216 216 }
217 217