1 | <?php |
---|
2 | /*************************************************************************** |
---|
3 | * cat_list.php * |
---|
4 | * ------------------- * |
---|
5 | * application : PhpWebGallery 1.3 <http://phpwebgallery.net> * |
---|
6 | * website : http://www.phpwebgallery.net * |
---|
7 | * author : Pierrick LE GALL <pierrick@z0rglub.com> * |
---|
8 | * * |
---|
9 | * $Id: cat_list.php 389 2004-03-12 23:15:45Z z0rglub $ |
---|
10 | * * |
---|
11 | ***************************************************************************/ |
---|
12 | |
---|
13 | /*************************************************************************** |
---|
14 | * * |
---|
15 | * This program is free software; you can redistribute it and/or modify * |
---|
16 | * it under the terms of the GNU General Public License as published by * |
---|
17 | * the Free Software Foundation; * |
---|
18 | * * |
---|
19 | ***************************************************************************/ |
---|
20 | include_once( './include/isadmin.inc.php' ); |
---|
21 | //------------------------------------------------ expand categories management |
---|
22 | // creation of the array containing the cat ids to expand |
---|
23 | // $page['tab_expand'] contains an array with the category ids |
---|
24 | // $page['expand'] contains the string to display in URL with comma |
---|
25 | |
---|
26 | // if there is less than $conf['max_LOV_categories'] categories, they are |
---|
27 | // all expande |
---|
28 | $query = 'SELECT COUNT(id) AS nb_total_categories'; |
---|
29 | $query.= ' FROM '.PREFIX_TABLE.'categories'; |
---|
30 | $query.= ';'; |
---|
31 | $row = mysql_fetch_array( mysql_query( $query ) ); |
---|
32 | if ( $row['nb_total_categories'] < $conf['max_LOV_categories'] |
---|
33 | or ( isset( $_GET['expand'] ) and $_GET['expand'] == 'all' ) ) |
---|
34 | { |
---|
35 | $page['tab_expand'] = array(); |
---|
36 | $page['expand'] = 'all'; |
---|
37 | } |
---|
38 | else |
---|
39 | { |
---|
40 | $page['tab_expand'] = array(); |
---|
41 | if ( isset ( $_GET['expand'] ) and $_GET['expand'] != 'all' ) |
---|
42 | { |
---|
43 | $tab_expand = explode( ',', $_GET['expand'] ); |
---|
44 | foreach ( $tab_expand as $id ) { |
---|
45 | if ( is_numeric( $id ) ) array_push( $page['tab_expand'], $id ); |
---|
46 | } |
---|
47 | } |
---|
48 | $page['tab_expand'] = array_unique( $page['tab_expand'] ); |
---|
49 | $page['expand'] = implode( ',', $page['tab_expand'] ); |
---|
50 | } |
---|
51 | //----------------------------------------------------- template initialization |
---|
52 | $sub = $vtp->Open( '../template/'.$user['template'].'/admin/cat_list.vtp' ); |
---|
53 | $tpl = array( 'cat_edit','cat_up','cat_down','cat_image_info', |
---|
54 | 'cat_permission','cat_update','cat_add','cat_parent','submit', |
---|
55 | 'cat_virtual','delete','cat_first','cat_last','errors_title' ); |
---|
56 | templatize_array( $tpl, 'lang', $sub ); |
---|
57 | $vtp->setGlobalVar( $sub, 'user_template', $user['template'] ); |
---|
58 | //--------------------------------------------------- adding a virtual category |
---|
59 | $errors = array(); |
---|
60 | if ( isset( $_POST['submit'] ) ) |
---|
61 | { |
---|
62 | // is the given category name only containing blank spaces ? |
---|
63 | if ( preg_match( '/^\s*$/', $_POST['virtual_name'] ) ) |
---|
64 | array_push( $errors, $lang['cat_error_name'] ); |
---|
65 | // does the uppercat id exists in the database ? |
---|
66 | if ( $_POST['associate'] == '' |
---|
67 | or $_POST['associate'] == '-1' ) |
---|
68 | { |
---|
69 | $_POST['associate'] = -1; |
---|
70 | } |
---|
71 | else if ( !is_numeric( $_POST['associate'] ) ) |
---|
72 | { |
---|
73 | array_push( $errors, $lang['cat_unknown_id'] ); |
---|
74 | } |
---|
75 | else |
---|
76 | { |
---|
77 | $query = 'SELECT id'; |
---|
78 | $query.= ' FROM '.PREFIX_TABLE.'categories'; |
---|
79 | $query.= ' WHERE id = '.$_POST['associate']; |
---|
80 | $query.= ';'; |
---|
81 | if ( mysql_num_rows( mysql_query( $query ) ) == 0 ) |
---|
82 | array_push( $errors, $lang['cat_unknown_id'] ); |
---|
83 | } |
---|
84 | |
---|
85 | if ( count( $errors ) == 0 ) |
---|
86 | { |
---|
87 | // we have then to add the virtual category |
---|
88 | $query = 'INSERT INTO '.PREFIX_TABLE.'categories'; |
---|
89 | $query.= ' (name,id_uppercat) VALUES '; |
---|
90 | if ( $_POST['associate'] == -1 ) |
---|
91 | { |
---|
92 | $_POST['associate'] = 'NULL'; |
---|
93 | } |
---|
94 | $query.= " ('".$_POST['virtual_name']."',".$_POST['associate'].")"; |
---|
95 | $query.= ';'; |
---|
96 | mysql_query( $query ); |
---|
97 | synchronize_all_users(); |
---|
98 | } |
---|
99 | } |
---|
100 | //--------------------------------------------------------------- rank updates |
---|
101 | if ( isset( $_GET['up'] ) and is_numeric( $_GET['up'] ) ) |
---|
102 | { |
---|
103 | // 1. searching level (id_uppercat) |
---|
104 | // and rank of the category to move |
---|
105 | $query = 'SELECT id_uppercat,rank'; |
---|
106 | $query.= ' FROM '.PREFIX_TABLE.'categories'; |
---|
107 | $query.= ' WHERE id = '.$_GET['up']; |
---|
108 | $query.= ';'; |
---|
109 | $row = mysql_fetch_array( mysql_query( $query ) ); |
---|
110 | $level = $row['id_uppercat']; |
---|
111 | $rank = $row['rank']; |
---|
112 | // 2. searching the id and the rank of the category |
---|
113 | // just above at the same level |
---|
114 | $query = 'SELECT id,rank'; |
---|
115 | $query.= ' FROM '.PREFIX_TABLE.'categories'; |
---|
116 | $query.= ' WHERE rank < '.$rank; |
---|
117 | if ( $level == '' ) |
---|
118 | { |
---|
119 | $query.= ' AND id_uppercat IS NULL'; |
---|
120 | } |
---|
121 | else |
---|
122 | { |
---|
123 | $query.= ' AND id_uppercat = '.$level; |
---|
124 | } |
---|
125 | $query.= ' ORDER BY rank DESC'; |
---|
126 | $query.= ' LIMIT 0,1'; |
---|
127 | $query.= ';'; |
---|
128 | $row = mysql_fetch_array( mysql_query( $query ) ); |
---|
129 | $new_rank = $row['rank']; |
---|
130 | $replaced_cat = $row['id']; |
---|
131 | // 3. exchanging ranks between the two categories |
---|
132 | $query = 'UPDATE '.PREFIX_TABLE.'categories'; |
---|
133 | $query.= ' SET rank = '.$new_rank; |
---|
134 | $query.= ' WHERE id = '.$_GET['up']; |
---|
135 | $query.= ';'; |
---|
136 | mysql_query( $query ); |
---|
137 | $query = 'UPDATE '.PREFIX_TABLE.'categories'; |
---|
138 | $query.= ' SET rank = '.$rank; |
---|
139 | $query.= ' WHERE id = '.$replaced_cat; |
---|
140 | $query.= ';'; |
---|
141 | mysql_query( $query ); |
---|
142 | } |
---|
143 | if ( isset( $_GET['down'] ) and is_numeric( $_GET['down'] ) ) |
---|
144 | { |
---|
145 | // 1. searching level (id_uppercat) |
---|
146 | // and rank of the category to move |
---|
147 | $query = 'SELECT id_uppercat,rank'; |
---|
148 | $query.= ' FROM '.PREFIX_TABLE.'categories'; |
---|
149 | $query.= ' WHERE id = '.$_GET['down']; |
---|
150 | $query.= ';'; |
---|
151 | $row = mysql_fetch_array( mysql_query( $query ) ); |
---|
152 | $level = $row['id_uppercat']; |
---|
153 | $rank = $row['rank']; |
---|
154 | // 2. searching the id and the rank of the category |
---|
155 | // just below at the same level |
---|
156 | $query = 'SELECT id,rank'; |
---|
157 | $query.= ' FROM '.PREFIX_TABLE.'categories'; |
---|
158 | $query.= ' WHERE rank > '.$rank; |
---|
159 | if ( $level == '' ) |
---|
160 | { |
---|
161 | $query.= ' AND id_uppercat IS NULL'; |
---|
162 | } |
---|
163 | else |
---|
164 | { |
---|
165 | $query.= ' AND id_uppercat = '.$level; |
---|
166 | } |
---|
167 | $query.= ' ORDER BY rank ASC'; |
---|
168 | $query.= ' LIMIT 0,1'; |
---|
169 | $query.= ';'; |
---|
170 | $row = mysql_fetch_array( mysql_query( $query ) ); |
---|
171 | $new_rank = $row['rank']; |
---|
172 | $replaced_cat = $row['id']; |
---|
173 | // 3. exchanging ranks between the two categories |
---|
174 | $query = 'UPDATE '.PREFIX_TABLE.'categories'; |
---|
175 | $query.= ' SET rank = '.$new_rank; |
---|
176 | $query.= ' WHERE id = '.$_GET['down']; |
---|
177 | $query.= ';'; |
---|
178 | mysql_query( $query ); |
---|
179 | $query = 'UPDATE '.PREFIX_TABLE.'categories'; |
---|
180 | $query.= ' SET rank = '.$rank; |
---|
181 | $query.= ' WHERE id = '.$replaced_cat; |
---|
182 | $query.= ';'; |
---|
183 | mysql_query( $query ); |
---|
184 | } |
---|
185 | if ( isset( $_GET['last'] ) and is_numeric( $_GET['last'] ) ) |
---|
186 | { |
---|
187 | // 1. searching level (id_uppercat) of the category to move |
---|
188 | $query = 'SELECT id_uppercat,rank'; |
---|
189 | $query.= ' FROM '.PREFIX_TABLE.'categories'; |
---|
190 | $query.= ' WHERE id = '.$_GET['last']; |
---|
191 | $query.= ';'; |
---|
192 | $row = mysql_fetch_array( mysql_query( $query ) ); |
---|
193 | $level = $row['id_uppercat']; |
---|
194 | // 2. searching the highest rank of the categories of the same parent |
---|
195 | $query = 'SELECT MAX(rank) AS max_rank'; |
---|
196 | $query.= ' FROM '.PREFIX_TABLE.'categories'; |
---|
197 | $query.= ' WHERE id_uppercat'; |
---|
198 | if ( $level == '' ) $query.= ' IS NULL'; |
---|
199 | else $query.= ' = '.$level; |
---|
200 | $query.= ';'; |
---|
201 | $row = mysql_fetch_array( mysql_query( $query ) ); |
---|
202 | $max_rank = $row['max_rank']; |
---|
203 | // 3. updating the rank of our category to be after the previous max rank |
---|
204 | $query = 'UPDATE '.PREFIX_TABLE.'categories'; |
---|
205 | $query.= ' SET rank = '.($max_rank + 1); |
---|
206 | $query.= ' WHERE id = '.$_GET['last']; |
---|
207 | $query.= ';'; |
---|
208 | mysql_query( $query ); |
---|
209 | } |
---|
210 | if ( isset( $_GET['first'] ) and is_numeric( $_GET['first'] ) ) |
---|
211 | { |
---|
212 | // to place our category as first, we simply say that is rank is 0, then |
---|
213 | // reordering will move category ranks correctly (first rank should be 1 |
---|
214 | // and not 0) |
---|
215 | $query = 'UPDATE '.PREFIX_TABLE.'categories'; |
---|
216 | $query.= ' SET rank = 0'; |
---|
217 | $query.= ' WHERE id = '.$_GET['first']; |
---|
218 | $query.= ';'; |
---|
219 | mysql_query( $query ); |
---|
220 | } |
---|
221 | if ( isset( $_GET['delete'] ) and is_numeric( $_GET['delete'] ) ) |
---|
222 | { |
---|
223 | delete_category( $_GET['delete'] ); |
---|
224 | synchronize_all_users(); |
---|
225 | } |
---|
226 | //------------------------------------------------------------------ reordering |
---|
227 | function ordering( $id_uppercat ) |
---|
228 | { |
---|
229 | $rank = 1; |
---|
230 | |
---|
231 | $query = 'SELECT id'; |
---|
232 | $query.= ' FROM '.PREFIX_TABLE.'categories'; |
---|
233 | if ( !is_numeric( $id_uppercat ) ) |
---|
234 | { |
---|
235 | $query.= ' WHERE id_uppercat IS NULL'; |
---|
236 | } |
---|
237 | else |
---|
238 | { |
---|
239 | $query.= ' WHERE id_uppercat = '.$id_uppercat; |
---|
240 | } |
---|
241 | $query.= ' ORDER BY rank ASC, dir ASC'; |
---|
242 | $query.= ';'; |
---|
243 | $result = mysql_query( $query ); |
---|
244 | while ( $row = mysql_fetch_array( $result ) ) |
---|
245 | { |
---|
246 | $query = 'UPDATE '.PREFIX_TABLE.'categories'; |
---|
247 | $query.= ' SET rank = '.$rank; |
---|
248 | $query.= ' WHERE id = '.$row['id']; |
---|
249 | $query.= ';'; |
---|
250 | mysql_query( $query ); |
---|
251 | $rank++; |
---|
252 | ordering( $row['id'] ); |
---|
253 | } |
---|
254 | } |
---|
255 | ordering( 'NULL' ); |
---|
256 | //-------------------------------------------------------------- errors display |
---|
257 | if ( count( $errors ) != 0 ) |
---|
258 | { |
---|
259 | $vtp->addSession( $sub, 'errors' ); |
---|
260 | foreach ( $errors as $error ) { |
---|
261 | $vtp->addSession( $sub, 'li' ); |
---|
262 | $vtp->setVar( $sub, 'li.content', $error ); |
---|
263 | $vtp->closeSession( $sub, 'li' ); |
---|
264 | } |
---|
265 | $vtp->closeSession( $sub, 'errors' ); |
---|
266 | } |
---|
267 | //---------------------------------------------------------------- page display |
---|
268 | function display_cat_manager( $id_uppercat, $indent, |
---|
269 | $uppercat_visible, $level ) |
---|
270 | { |
---|
271 | global $lang,$conf,$sub,$vtp,$page; |
---|
272 | |
---|
273 | // searching the min_rank and the max_rank of the category |
---|
274 | $query = 'SELECT MIN(rank) AS min, MAX(rank) AS max'; |
---|
275 | $query.= ' FROM '.PREFIX_TABLE.'categories'; |
---|
276 | if ( !is_numeric( $id_uppercat ) ) |
---|
277 | { |
---|
278 | $query.= ' WHERE id_uppercat IS NULL'; |
---|
279 | } |
---|
280 | else |
---|
281 | { |
---|
282 | $query.= ' WHERE id_uppercat = '.$id_uppercat; |
---|
283 | } |
---|
284 | $query.= ';'; |
---|
285 | $result = mysql_query( $query ); |
---|
286 | $row = mysql_fetch_array( $result ); |
---|
287 | if ( !isset( $row['min'] ) ) $row['min'] = 0; |
---|
288 | if ( !isset( $row['max'] ) ) $row['max'] = 0; |
---|
289 | $min_rank = $row['min']; |
---|
290 | $max_rank = $row['max']; |
---|
291 | |
---|
292 | // will we use <th> or <td> lines ? |
---|
293 | $td = 'td'; |
---|
294 | $class = ''; |
---|
295 | if ( $level > 0 ) $class = 'row'.$level; |
---|
296 | else $td = 'th'; |
---|
297 | |
---|
298 | $query = 'SELECT id,name,dir,nb_images,status,rank,site_id,visible'; |
---|
299 | $query.= ' FROM '.PREFIX_TABLE.'categories'; |
---|
300 | if ( !is_numeric( $id_uppercat ) ) |
---|
301 | { |
---|
302 | $query.= ' WHERE id_uppercat IS NULL'; |
---|
303 | } |
---|
304 | else |
---|
305 | { |
---|
306 | $query.= ' WHERE id_uppercat = '.$id_uppercat; |
---|
307 | } |
---|
308 | $query.= ' ORDER BY rank ASC'; |
---|
309 | $query.= ';'; |
---|
310 | $result = mysql_query( $query ); |
---|
311 | while ( $row = mysql_fetch_array( $result ) ) |
---|
312 | { |
---|
313 | $subcat_visible = true; |
---|
314 | if ( !isset( $row['dir'] ) ) $row['dir'] = ''; |
---|
315 | |
---|
316 | $vtp->addSession( $sub, 'cat' ); |
---|
317 | // is the category expanded or not ? |
---|
318 | if ( $page['expand'] == 'all' ) |
---|
319 | { |
---|
320 | $vtp->addSession( $sub, 'bullet_wo_link' ); |
---|
321 | $vtp->closeSession( $sub, 'bullet_wo_link' ); |
---|
322 | } |
---|
323 | else if ( in_array( $row['id'], $page['tab_expand'] ) ) |
---|
324 | { |
---|
325 | $vtp->addSession( $sub, 'bullet_expanded' ); |
---|
326 | $tab_expand = array_diff( $page['tab_expand'], array( $row['id'] ) ); |
---|
327 | $expand = implode( ',', $tab_expand ); |
---|
328 | $url = './admin.php?page=cat_list&expand='.$expand; |
---|
329 | $vtp->setVar( $sub, 'bullet_expanded.link', add_session_id( $url ) ); |
---|
330 | $vtp->closeSession( $sub, 'bullet_expanded' ); |
---|
331 | } |
---|
332 | else |
---|
333 | { |
---|
334 | $vtp->addSession( $sub, 'bullet_collapsed' ); |
---|
335 | $tab_expand = array_merge( $page['tab_expand'], array( $row['id'] ) ); |
---|
336 | $expand = implode( ',', $tab_expand ); |
---|
337 | $url = './admin.php?page=cat_list&expand='.$expand; |
---|
338 | $vtp->setVar( $sub, 'bullet_collapsed.link', add_session_id( $url ) ); |
---|
339 | $vtp->closeSession( $sub, 'bullet_collapsed' ); |
---|
340 | } |
---|
341 | |
---|
342 | $vtp->setVar( $sub, 'cat.td', $td ); |
---|
343 | $vtp->setVar( $sub, 'cat.class', $class ); |
---|
344 | $vtp->setVar( $sub, 'cat.indent', $indent ); |
---|
345 | $vtp->setVar( $sub, 'cat.name', $row['name'] ); |
---|
346 | |
---|
347 | if ( $row['dir'] != '' ) |
---|
348 | { |
---|
349 | $vtp->addSession( $sub, 'storage' ); |
---|
350 | $vtp->setVar( $sub, 'storage.dir', $row['dir'] ); |
---|
351 | $vtp->closeSession( $sub, 'storage' ); |
---|
352 | // category can't be deleted |
---|
353 | $vtp->addSession( $sub, 'no_delete' ); |
---|
354 | $vtp->closeSession( $sub, 'no_delete' ); |
---|
355 | } |
---|
356 | else |
---|
357 | { |
---|
358 | $vtp->addSession( $sub, 'virtual' ); |
---|
359 | $vtp->closeSession( $sub, 'virtual' ); |
---|
360 | // category can be deleted |
---|
361 | $vtp->addSession( $sub, 'delete' ); |
---|
362 | $url = './admin.php?page=cat_list&expand='.$page['expand']; |
---|
363 | $url.= '&delete='.$row['id']; |
---|
364 | $vtp->setVar( $sub, 'delete.delete_url', add_session_id( $url ) ); |
---|
365 | $vtp->closeSession( $sub, 'delete' ); |
---|
366 | } |
---|
367 | if ( $row['visible'] == 'false' or !$uppercat_visible ) |
---|
368 | { |
---|
369 | $subcat_visible = false; |
---|
370 | $vtp->setVar( $sub, 'cat.invisible', $lang['cat_invisible'] ); |
---|
371 | } |
---|
372 | if ( $row['status'] == 'private' ) |
---|
373 | { |
---|
374 | $vtp->setVar( $sub, 'cat.private', $lang['private'] ); |
---|
375 | } |
---|
376 | $vtp->setVar( $sub, 'cat.nb_picture', $row['nb_images'] ); |
---|
377 | $url = add_session_id( './admin.php?page=cat_modify&cat='.$row['id'] ); |
---|
378 | $vtp->setVar( $sub, 'cat.edit_url', $url ); |
---|
379 | if ( $row['rank'] != $min_rank ) |
---|
380 | { |
---|
381 | $vtp->addSession( $sub, 'up' ); |
---|
382 | $url = './admin.php?page=cat_list&expand='.$page['expand']; |
---|
383 | $url.= '&up='.$row['id']; |
---|
384 | $vtp->setVar( $sub, 'up.up_url', add_session_id( $url ) ); |
---|
385 | $vtp->closeSession( $sub, 'up' ); |
---|
386 | } |
---|
387 | else if ( $min_rank != $max_rank ) |
---|
388 | { |
---|
389 | $vtp->addSession( $sub, 'no_up' ); |
---|
390 | $url = './admin.php?page=cat_list&expand='.$page['expand']; |
---|
391 | $url.= '&last='.$row['id']; |
---|
392 | $vtp->setVar( $sub, 'no_up.last_url', add_session_id( $url ) ); |
---|
393 | $vtp->closeSession( $sub, 'no_up' ); |
---|
394 | } |
---|
395 | if ( $row['rank'] != $max_rank ) |
---|
396 | { |
---|
397 | $vtp->addSession( $sub, 'down' ); |
---|
398 | $url = './admin.php?page=cat_list&expand='.$page['expand']; |
---|
399 | $url.= '&down='.$row['id']; |
---|
400 | $vtp->setVar( $sub, 'down.down_url', add_session_id( $url ) ); |
---|
401 | $vtp->closeSession( $sub, 'down' ); |
---|
402 | } |
---|
403 | else if ( $min_rank != $max_rank ) |
---|
404 | { |
---|
405 | $vtp->addSession( $sub, 'no_down' ); |
---|
406 | $url = './admin.php?page=cat_list&expand='.$page['expand']; |
---|
407 | $url.= '&first='.$row['id']; |
---|
408 | $vtp->setVar( $sub, 'no_down.first_url', add_session_id( $url ) ); |
---|
409 | $vtp->closeSession( $sub, 'no_down' ); |
---|
410 | } |
---|
411 | if ( $row['nb_images'] > 0 ) |
---|
412 | { |
---|
413 | $vtp->addSession( $sub, 'image_info' ); |
---|
414 | $url = './admin.php?page=infos_images&cat_id='.$row['id']; |
---|
415 | $vtp->setVar( $sub, 'image_info.image_info_url', add_session_id($url) ); |
---|
416 | $vtp->closeSession( $sub, 'image_info' ); |
---|
417 | } |
---|
418 | else |
---|
419 | { |
---|
420 | $vtp->addSession( $sub, 'no_image_info' ); |
---|
421 | $vtp->closeSession( $sub, 'no_image_info' ); |
---|
422 | } |
---|
423 | if ( $row['status'] == 'private' ) |
---|
424 | { |
---|
425 | $vtp->addSession( $sub, 'permission' ); |
---|
426 | $url=add_session_id('./admin.php?page=cat_perm&cat_id='.$row['id']); |
---|
427 | $vtp->setVar( $sub, 'permission.url', $url ); |
---|
428 | $vtp->closeSession( $sub, 'permission' ); |
---|
429 | } |
---|
430 | else |
---|
431 | { |
---|
432 | $vtp->addSession( $sub, 'no_permission' ); |
---|
433 | $vtp->closeSession( $sub, 'no_permission' ); |
---|
434 | } |
---|
435 | // you can individually update a category only if it is on the main site |
---|
436 | // and if it's not a virtual category (a category is virtual if there is |
---|
437 | // no directory associated) |
---|
438 | if ( $row['site_id'] == 1 and $row['dir'] != '' ) |
---|
439 | { |
---|
440 | $vtp->addSession( $sub, 'update' ); |
---|
441 | $url = add_session_id('./admin.php?page=update&update='.$row['id']); |
---|
442 | $vtp->setVar( $sub, 'update.update_url', $url ); |
---|
443 | $vtp->closeSession( $sub, 'update' ); |
---|
444 | } |
---|
445 | else |
---|
446 | { |
---|
447 | $vtp->addSession( $sub, 'no_update' ); |
---|
448 | $vtp->closeSession( $sub, 'no_update' ); |
---|
449 | } |
---|
450 | |
---|
451 | $vtp->closeSession( $sub, 'cat' ); |
---|
452 | |
---|
453 | if ( in_array( $row['id'], $page['tab_expand'] ) |
---|
454 | or $page['expand'] == 'all') |
---|
455 | display_cat_manager( $row['id'], $indent.str_repeat( ' ', 4 ), |
---|
456 | $subcat_visible, $level + 1 ); |
---|
457 | } |
---|
458 | } |
---|
459 | display_cat_manager( 'NULL', str_repeat( ' ', 4 ), true, 0 ); |
---|
460 | // add a virtual category ? |
---|
461 | // We only show a List Of Values if the number of categories is less than |
---|
462 | // $conf['max_LOV_categories'] |
---|
463 | $query = 'SELECT COUNT(id) AS nb_total_categories'; |
---|
464 | $query.= ' FROM '.PREFIX_TABLE.'categories'; |
---|
465 | $query.= ';'; |
---|
466 | $row = mysql_fetch_array( mysql_query( $query ) ); |
---|
467 | if ( $row['nb_total_categories'] < $conf['max_LOV_categories'] ) |
---|
468 | { |
---|
469 | $vtp->addSession( $sub, 'associate_LOV' ); |
---|
470 | $vtp->addSession( $sub, 'associate_cat' ); |
---|
471 | $vtp->setVar( $sub, 'associate_cat.value', '-1' ); |
---|
472 | $vtp->setVar( $sub, 'associate_cat.content', '' ); |
---|
473 | $vtp->closeSession( $sub, 'associate_cat' ); |
---|
474 | $page['plain_structure'] = get_plain_structure( true ); |
---|
475 | $structure = create_structure( '', array() ); |
---|
476 | display_categories( $structure, ' ' ); |
---|
477 | $vtp->closeSession( $sub, 'associate_LOV' ); |
---|
478 | } |
---|
479 | // else, we only display a small text field, we suppose the administrator |
---|
480 | // knows the id of its category |
---|
481 | else |
---|
482 | { |
---|
483 | $vtp->addSession( $sub, 'associate_text' ); |
---|
484 | $vtp->closeSession( $sub, 'associate_text' ); |
---|
485 | } |
---|
486 | //----------------------------------------------------------- sending html code |
---|
487 | $vtp->Parse( $handle , 'sub', $sub ); |
---|
488 | ?> |
---|