Changeset 345 for trunk/admin/cat_list.php
- Timestamp:
- Feb 2, 2004, 1:55:18 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/cat_list.php
r226 r345 19 19 ***************************************************************************/ 20 20 include_once( './admin/include/isadmin.inc.php' ); 21 21 22 //----------------------------------------------------- template initialization 22 23 $sub = $vtp->Open( './template/'.$user['template'].'/admin/cat_list.vtp' ); 23 24 $tpl = array( 'cat_edit','cat_up','cat_down','cat_image_info', 24 25 'cat_permission','cat_update','cat_add','cat_parent','submit', 25 'cat_virtual','delete','cat_first','cat_last' );26 'cat_virtual','delete','cat_first','cat_last','errors_title' ); 26 27 templatize_array( $tpl, 'lang', $sub ); 27 28 $vtp->setGlobalVar( $sub, 'user_template', $user['template'] ); … … 30 31 if ( isset( $_POST['submit'] ) ) 31 32 { 32 if ( !preg_match( '/^\s*$/', $_POST['virtual_name'] ) ) 33 // is the given category name only containing blank spaces ? 34 if ( preg_match( '/^\s*$/', $_POST['virtual_name'] ) ) 35 array_push( $errors, $lang['cat_error_name'] ); 36 // does the uppercat id exists in the database ? 37 if ( $_POST['associate'] == '' ) 38 { 39 $_POST['associate'] = -1; 40 } 41 else if ( !is_numeric( $_POST['associate'] ) ) 42 { 43 array_push( $errors, $lang['cat_unknown_id'] ); 44 } 45 else 46 { 47 $query = 'SELECT id'; 48 $query.= ' FROM '.PREFIX_TABLE.'categories'; 49 $query.= ' WHERE id = '.$_POST['associate']; 50 $query.= ';'; 51 if ( mysql_num_rows( mysql_query( $query ) ) == 0 ) 52 array_push( $errors, $lang['cat_unknown_id'] ); 53 } 54 55 if ( count( $errors ) == 0 ) 33 56 { 34 57 // we have then to add the virtual category … … 42 65 $query.= ';'; 43 66 mysql_query( $query ); 44 } 45 else 46 { 47 array_push( $errors, $lang['cat_error_name'] ); 67 synchronize_all_users(); 48 68 } 49 69 } … … 172 192 { 173 193 delete_category( $_GET['delete'] ); 194 synchronize_all_users(); 174 195 } 175 196 //------------------------------------------------------------------ reordering … … 234 255 $result = mysql_query( $query ); 235 256 $row = mysql_fetch_array( $result ); 257 if ( !isset( $row['min'] ) ) $row['min'] = 0; 258 if ( !isset( $row['max'] ) ) $row['max'] = 0; 236 259 $min_rank = $row['min']; 237 260 $max_rank = $row['max']; … … 259 282 { 260 283 $subcat_visible = true; 284 if ( !isset( $row['dir'] ) ) $row['dir'] = ''; 261 285 262 286 $vtp->addSession( $sub, 'cat' ); 287 // is the category expanded or not ? 288 if ( isset($page['expand']) && $page['expand'] == 'all' ) 289 { 290 $vtp->addSession( $sub, 'bullet_wo_link' ); 291 $vtp->closeSession( $sub, 'bullet_wo_link' ); 292 } 293 else if ( isset($page['tab_expand']) && in_array( $row['id'], $page['tab_expand'] ) ) 294 { 295 $vtp->addSession( $sub, 'bullet_expanded' ); 296 $tab_expand = array_diff( $page['tab_expand'], array( $row['id'] ) ); 297 $expand = implode( ',', $tab_expand ); 298 $url = './admin.php?page=cat_list&expand='.$expand; 299 $vtp->setVar( $sub, 'bullet_expanded.link', add_session_id( $url ) ); 300 $vtp->closeSession( $sub, 'bullet_expanded' ); 301 } 302 else 303 { 304 $vtp->addSession( $sub, 'bullet_collapsed' ); 305 $tab_expand = array_merge( $page['tab_expand'], array( $row['id'] ) ); 306 $expand = implode( ',', $tab_expand ); 307 $url = './admin.php?page=cat_list&expand='.$expand; 308 $vtp->setVar( $sub, 'bullet_collapsed.link', add_session_id( $url ) ); 309 $vtp->closeSession( $sub, 'bullet_collapsed' ); 310 } 311 263 312 $vtp->setVar( $sub, 'cat.td', $td ); 264 313 $vtp->setVar( $sub, 'cat.class', $class ); 265 314 $vtp->setVar( $sub, 'cat.indent', $indent ); 266 315 $vtp->setVar( $sub, 'cat.name', $row['name'] ); 267 $vtp->setVar( $sub, 'cat.id', $row['id'] ); 316 268 317 if ( $row['dir'] != '' ) 269 318 { … … 281 330 // category can be deleted 282 331 $vtp->addSession( $sub, 'delete' ); 283 $url = './admin.php?page=cat_list&delete='.$row['id']; 332 $url = './admin.php?page=cat_list&expand='.$page['expand']; 333 $url.= '&delete='.$row['id']; 284 334 $vtp->setVar( $sub, 'delete.delete_url', add_session_id( $url ) ); 285 335 $vtp->closeSession( $sub, 'delete' ); … … 300 350 { 301 351 $vtp->addSession( $sub, 'up' ); 302 $ vtp->setVar( $sub, 'up.id', $row['id'] );303 $url = add_session_id( './admin.php?page=cat_list&up='.$row['id'] );304 $vtp->setVar( $sub, 'up.up_url', $url);352 $url = './admin.php?page=cat_list&expand='.$page['expand']; 353 $url.= '&up='.$row['id']; 354 $vtp->setVar( $sub, 'up.up_url', add_session_id( $url ) ); 305 355 $vtp->closeSession( $sub, 'up' ); 306 356 } … … 308 358 { 309 359 $vtp->addSession( $sub, 'no_up' ); 310 $ vtp->setVar( $sub, 'no_up.id', $row['id'] );311 $url = add_session_id( './admin.php?page=cat_list&last='.$row['id']);312 $vtp->setVar( $sub, 'no_up.last_url', $url);360 $url = './admin.php?page=cat_list&expand='.$page['expand']; 361 $url.= '&last='.$row['id']; 362 $vtp->setVar( $sub, 'no_up.last_url', add_session_id( $url ) ); 313 363 $vtp->closeSession( $sub, 'no_up' ); 314 364 } … … 316 366 { 317 367 $vtp->addSession( $sub, 'down' ); 318 $ vtp->setVar( $sub, 'down.id', $row['id'] );319 $url = add_session_id( './admin.php?page=cat_list&down='.$row['id']);320 $vtp->setVar( $sub, 'down.down_url', $url);368 $url = './admin.php?page=cat_list&expand='.$page['expand']; 369 $url.= '&down='.$row['id']; 370 $vtp->setVar( $sub, 'down.down_url', add_session_id( $url ) ); 321 371 $vtp->closeSession( $sub, 'down' ); 322 372 } … … 324 374 { 325 375 $vtp->addSession( $sub, 'no_down' ); 326 $ vtp->setVar( $sub, 'no_down.id', $row['id'] );327 $url = add_session_id('./admin.php?page=cat_list&first='.$row['id']);328 $vtp->setVar( $sub, 'no_down.first_url', $url);376 $url = './admin.php?page=cat_list&expand='.$page['expand']; 377 $url.= '&first='.$row['id']; 378 $vtp->setVar( $sub, 'no_down.first_url', add_session_id( $url ) ); 329 379 $vtp->closeSession( $sub, 'no_down' ); 330 380 } … … 332 382 { 333 383 $vtp->addSession( $sub, 'image_info' ); 334 $url = add_session_id( './admin.php?page=infos_images&cat_id=' 335 .$row['id'] ); 336 $vtp->setVar( $sub, 'image_info.image_info_url', $url ); 384 $url = './admin.php?page=infos_images&cat_id='.$row['id']; 385 $vtp->setVar( $sub, 'image_info.image_info_url', add_session_id($url) ); 337 386 $vtp->closeSession( $sub, 'image_info' ); 338 387 } … … 372 421 $vtp->closeSession( $sub, 'cat' ); 373 422 374 display_cat_manager( $row['id'], $indent.str_repeat( ' ', 4 ), 375 $subcat_visible, $level + 1 ); 423 if ( in_array( $row['id'], $page['tab_expand'] ) 424 or $page['expand'] == 'all') 425 display_cat_manager( $row['id'], $indent.str_repeat( ' ', 4 ), 426 $subcat_visible, $level + 1 ); 376 427 } 377 428 } 378 429 display_cat_manager( 'NULL', str_repeat( ' ', 4 ), true, 0 ); 379 430 // add a virtual category ? 380 $vtp->addSession( $sub, 'associate_cat' ); 381 $vtp->setVar( $sub, 'associate_cat.value', '-1' ); 382 $vtp->setVar( $sub, 'associate_cat.content', '' ); 383 $vtp->closeSession( $sub, 'associate_cat' ); 384 $page['plain_structure'] = get_plain_structure(); 385 $structure = create_structure( '', array() ); 386 display_categories( $structure, ' ' ); 431 // We only show a List Of Values if the number of categories is less than 432 // $conf['max_LOV_categories'] 433 $query = 'SELECT COUNT(id) AS nb_total_categories'; 434 $query.= ' FROM '.PREFIX_TABLE.'categories'; 435 $query.= ';'; 436 $row = mysql_fetch_array( mysql_query( $query ) ); 437 if ( $row['nb_total_categories'] < $conf['max_LOV_categories'] ) 438 { 439 $vtp->addSession( $sub, 'associate_LOV' ); 440 $vtp->addSession( $sub, 'associate_cat' ); 441 $vtp->setVar( $sub, 'associate_cat.value', '-1' ); 442 $vtp->setVar( $sub, 'associate_cat.content', '' ); 443 $vtp->closeSession( $sub, 'associate_cat' ); 444 $page['plain_structure'] = get_plain_structure( true ); 445 $structure = create_structure( '', array() ); 446 display_categories( $structure, ' ' ); 447 $vtp->closeSession( $sub, 'associate_LOV' ); 448 } 449 // else, we only display a small text field, we suppose the administrator 450 // knows the id of its category 451 else 452 { 453 $vtp->addSession( $sub, 'associate_text' ); 454 $vtp->closeSession( $sub, 'associate_text' ); 455 } 387 456 //----------------------------------------------------------- sending html code 388 457 $vtp->Parse( $handle , 'sub', $sub );
Note: See TracChangeset
for help on using the changeset viewer.