Changeset 393 for trunk/admin/update.php
- Timestamp:
- Mar 20, 2004, 1:52:37 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/update.php
r362 r393 26 26 // +-----------------------------------------------------------------------+ 27 27 28 include_once( './admin/include/isadmin.inc.php' );28 include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' ); 29 29 //------------------------------------------------------------------- functions 30 30 function insert_local_category( $id_uppercat ) … … 36 36 37 37 // 0. retrieving informations on the category to display 38 $cat_directory = './galleries';38 $cat_directory = PHPWG_ROOT_PATH.'galleries'; 39 39 if ( is_numeric( $id_uppercat ) ) 40 40 { 41 $query = 'SELECT name,uppercats,dir'; 42 $query.= ' FROM '.PREFIX_TABLE.'categories'; 41 $query = 'SELECT name,uppercats,dir FROM '.CATEGORIES_TABLE; 43 42 $query.= ' WHERE id = '.$id_uppercat; 44 43 $query.= ';'; … … 53 52 54 53 $database_dirs = array(); 55 $query = 'SELECT id,dir'; 56 $query.= ' FROM '.PREFIX_TABLE.'categories'; 54 $query = 'SELECT id,dir FROM '.CATEGORIES_TABLE; 57 55 $query.= ' WHERE id IN ('.$uppercats.')'; 58 56 $query.= ';'; … … 69 67 70 68 // 1. display the category name to update 71 $src = './template/'.$user['template'].'/admin/images/puce.gif'; 72 $output = '<img src="'.$src.'" alt=">" />'; 73 $output.= '<span style="font-weight:bold;">'.$name.'</span>'; 69 $output = '<ul class="menu">'; 70 $output.= '<li><strong>'.$name.'</strong>'; 74 71 $output.= ' [ '.$dir.' ]'; 75 $output.= '< div class="retrait">';72 $output.= '</li>'; 76 73 77 74 // 2. we search pictures of the category only if the update is for all … … 86 83 87 84 $sub_category_dirs = array(); 88 $query = 'SELECT id,dir'; 89 $query.= ' FROM '.PREFIX_TABLE.'categories'; 85 $query = 'SELECT id,dir FROM '.CATEGORIES_TABLE; 90 86 $query.= ' WHERE site_id = 1'; 91 87 if (!is_numeric($id_uppercat)) $query.= ' AND id_uppercat IS NULL'; … … 135 131 if ( count( $inserts ) > 0 ) 136 132 { 137 $query = 'INSERT INTO '. PREFIX_TABLE.'categories';133 $query = 'INSERT INTO '.CATEGORIES_TABLE; 138 134 $query.= ' (dir,name,site_id,id_uppercat,uppercats) VALUES '; 139 135 $query.= implode( ',', $inserts ); … … 141 137 mysql_query( $query ); 142 138 // updating uppercats field 143 $query = 'UPDATE '. PREFIX_TABLE.'categories';139 $query = 'UPDATE '.CATEGORIES_TABLE; 144 140 $query.= ' SET uppercats = '; 145 141 if ( $uppercats != '' ) $query.= "CONCAT('".$uppercats."',',',id)"; … … 154 150 // Recursive call on the sub-categories (not virtual ones) 155 151 $query = 'SELECT id'; 156 $query.= ' FROM '. PREFIX_TABLE.'categories';152 $query.= ' FROM '.CATEGORIES_TABLE; 157 153 $query.= ' WHERE site_id = 1'; 158 154 if (!is_numeric($id_uppercat)) $query.= ' AND id_uppercat IS NULL'; … … 168 164 if ( is_numeric( $id_uppercat ) ) 169 165 { 170 $output.= '</ div>';166 $output.= '</ul>'; 171 167 } 172 168 return $output; … … 188 184 // - don't have the associated thumbnail available anymore 189 185 $query = 'SELECT id,file,tn_ext'; 190 $query.= ' FROM '. PREFIX_TABLE.'images';186 $query.= ' FROM '.IMAGES_TABLE; 191 187 $query.= ' WHERE storage_category_id = '.$category_id; 192 188 $query.= ';'; … … 218 214 219 215 $registered_pictures = array(); 220 $query = 'SELECT file'; 221 $query.= ' FROM '.PREFIX_TABLE.'images'; 216 $query = 'SELECT file FROM '.IMAGES_TABLE; 222 217 $query.= ' WHERE storage_category_id = '.$category_id; 223 218 $query.= ';'; … … 234 229 235 230 $query = 'SELECT file,infos,validated'; 236 $query.= ' FROM '. PREFIX_TABLE.'waiting';231 $query.= ' FROM '.WAITING_TABLE; 237 232 $query.= ' WHERE storage_category_id = '.$category_id; 238 233 $query.= ';'; … … 294 289 295 290 // deleting the waiting element 296 $query = 'DELETE FROM '. PREFIX_TABLE.'waiting';291 $query = 'DELETE FROM '.WAITING_TABLE; 297 292 $query.= " WHERE file = '".$unregistered_picture."'"; 298 293 $query.= ' AND storage_category_id = '.$category_id; … … 337 332 { 338 333 // inserts all found pictures 339 $query = 'INSERT INTO '. PREFIX_TABLE.'images';334 $query = 'INSERT INTO '.IMAGES_TABLE; 340 335 $query.= ' (file,storage_category_id,date_available,tn_ext'; 341 336 $query.= ',filesize,width,height'; … … 350 345 351 346 $query = 'SELECT id'; 352 $query.= ' FROM '. PREFIX_TABLE.'images';347 $query.= ' FROM '.IMAGES_TABLE; 353 348 $query.= ' WHERE storage_category_id = '.$category_id; 354 349 $query.= ';'; … … 361 356 // recreation of the links between this storage category pictures and 362 357 // its storage category 363 $query = 'DELETE FROM '. PREFIX_TABLE.'image_category';358 $query = 'DELETE FROM '.IMAGE_CATEGORY_TABLE; 364 359 $query.= ' WHERE category_id = '.$category_id; 365 360 $query.= ' AND image_id IN ('.implode( ',', $ids ).')'; … … 367 362 mysql_query( $query ); 368 363 369 $query = 'INSERT INTO '. PREFIX_TABLE.'image_category';364 $query = 'INSERT INTO '.IMAGE_CATEGORY_TABLE; 370 365 $query.= '(category_id,image_id) VALUES '; 371 366 foreach ( $ids as $num => $image_id ) { … … 396 391 397 392 // 2. is the site already existing ? 398 $query = 'SELECT id'; 399 $query.= ' FROM '.PREFIX_TABLE.'sites'; 393 $query = 'SELECT id FROM '.SITES_TABLE; 400 394 $query.= " WHERE galleries_url = '".$url."'"; 401 395 $query.= ';'; … … 404 398 { 405 399 // we have to register this site in the database 406 $query = 'INSERT INTO '. PREFIX_TABLE.'sites';400 $query = 'INSERT INTO '.SITES_TABLE; 407 401 $query.= " (galleries_url) VALUES ('".$url."')"; 408 402 $query.= ';'; … … 438 432 { 439 433 $query = 'SELECT name,uppercats,dir'; 440 $query.= ' FROM '. PREFIX_TABLE.'categories';434 $query.= ' FROM '.CATEGORIES_TABLE; 441 435 $query.= ' WHERE id = '.$id_uppercat; 442 436 $query.= ';'; … … 468 462 // id_uppercat and site_id 469 463 $database_dirs = array(); 470 $query = 'SELECT id,dir'; 471 $query.= ' FROM '.PREFIX_TABLE.'categories'; 464 $query = 'SELECT id,dir FROM '.CATEGORIES_TABLE; 472 465 $query.= ' WHERE site_id = '.$site_id; 473 466 if (!is_numeric($id_uppercat)) $query.= ' AND id_uppercat IS NULL'; … … 509 502 if ( count( $inserts ) > 0 ) 510 503 { 511 $query = 'INSERT INTO '. PREFIX_TABLE.'categories';504 $query = 'INSERT INTO '.CATEGORIES_TABLE; 512 505 $query.= ' (dir,name,site_id,id_uppercat,uppercats) VALUES '; 513 506 $query.= implode( ',', $inserts ); … … 515 508 mysql_query( $query ); 516 509 // updating uppercats field 517 $query = 'UPDATE '. PREFIX_TABLE.'categories';510 $query = 'UPDATE '.CATEGORIES_TABLE; 518 511 $query.= ' SET uppercats = '; 519 512 if ( $uppercats != '' ) $query.= "CONCAT('".$uppercats."',',',id)"; … … 528 521 // Recursive call on the sub-categories (not virtual ones) 529 522 $query = 'SELECT id,dir'; 530 $query.= ' FROM '. PREFIX_TABLE.'categories';523 $query.= ' FROM '.CATEGORIES_TABLE; 531 524 $query.= ' WHERE site_id = '.$site_id; 532 525 if (!is_numeric($id_uppercat)) $query.= ' AND id_uppercat IS NULL'; … … 568 561 // we have to delete all the images from the database that are not in the 569 562 // directory anymore (not in the XML anymore) 570 $query = 'SELECT id,file'; 571 $query.= ' FROM '.PREFIX_TABLE.'images'; 563 $query = 'SELECT id,file FROM '.IMAGES_TABLE; 572 564 $query.= ' WHERE storage_category_id = '.$category_id; 573 565 $query.= ';'; … … 585 577 586 578 $database_pictures = array(); 587 $query = 'SELECT file'; 588 $query.= ' FROM '.PREFIX_TABLE.'images'; 579 $query = 'SELECT file FROM '.IMAGES_TABLE; 589 580 $query.= ' WHERE storage_category_id = '.$category_id; 590 581 $query.= ';'; … … 631 622 { 632 623 // inserts all found pictures 633 $query = 'INSERT INTO '. PREFIX_TABLE.'images';624 $query = 'INSERT INTO '.IMAGES_TABLE; 634 625 $query.= ' (file,storage_category_id,date_available,tn_ext'; 635 626 $query.= ',filesize,width,height)'; … … 642 633 $ids = array(); 643 634 644 $query = 'SELECT id'; 645 $query.= ' FROM '.PREFIX_TABLE.'images'; 635 $query = 'SELECT id FROM '.IMAGES_TABLE; 646 636 $query.= ' WHERE storage_category_id = '.$category_id; 647 637 $query.= ';'; … … 654 644 // recreation of the links between this storage category pictures and 655 645 // its storage category 656 $query = 'DELETE FROM '. PREFIX_TABLE.'image_category';646 $query = 'DELETE FROM '.IMAGE_CATEGORY_TABLE; 657 647 $query.= ' WHERE category_id = '.$category_id; 658 648 $query.= ' AND image_id IN ('.implode( ',', $ids ).')'; … … 660 650 mysql_query( $query ); 661 651 662 $query = 'INSERT INTO '. PREFIX_TABLE.'image_category';652 $query = 'INSERT INTO '.IMAGE_CATEGORY_TABLE; 663 653 $query.= '(category_id,image_id) VALUES '; 664 654 foreach ( $ids as $num => $image_id ) { … … 672 662 return $output; 673 663 } 664 674 665 //----------------------------------------------------- template initialization 675 $sub = $vtp->Open( './template/'.$user['template'].'/admin/update.vtp' ); 676 $tpl = array( 'update_default_title', 'update_only_cat', 'update_all', 677 'update_research_conclusion', 'update_deletion_conclusion', 678 'remote_site', 'update_part_research' ); 679 templatize_array( $tpl, 'lang', $sub ); 680 $vtp->setGlobalVar( $sub, 'user_template', $user['template'] ); 666 $template->set_filenames( array('update'=>'admin/update.tpl') ); 667 668 $template->assign_vars(array( 669 'L_UPDATE_TITLE'=>$lang['update_default_title'], 670 'L_CAT_UPDATE'=>$lang['update_only_cat'], 671 'L_ALL_UPDATE'=>$lang['update_all'], 672 'L_RESULT_UPDATE'=>$lang['update_part_research'], 673 'L_NEW_CATEGORY'=>$lang['update_research_conclusion'], 674 'L_DEL_CATEGORY'=>$lang['update_deletion_conclusion'], 675 676 'U_CAT_UPDATE'=>add_session_id( PHPWG_ROOT_PATH.'admin.php?page=update&update=cats' ), 677 'U_ALL_UPDATE'=>add_session_id( PHPWG_ROOT_PATH.'admin.php?page=update&update=all' ) 678 )); 679 680 $tpl = array('remote_site'); 681 681 //-------------------------------------------- introduction : choices of update 682 682 // Display choice if "update" var is not specified 683 683 if (!isset( $_GET['update'] )) 684 684 { 685 $vtp->addSession( $sub, 'introduction' ); 686 // only update the categories, not the pictures. 687 $url = add_session_id( './admin.php?page=update&update=cats' ); 688 $vtp->setVar( $sub, 'introduction.only_cat:url', $url ); 689 // update the entire tree folder 690 $url = add_session_id( './admin.php?page=update&update=all' ); 691 $vtp->setVar( $sub, 'introduction.all:url', $url ); 692 $vtp->closeSession( $sub, 'introduction' ); 685 $template->assign_block_vars('introduction',array()); 693 686 } 694 687 //-------------------------------------------------- local update : ./galleries … … 699 692 $count_new = 0; 700 693 $count_deleted = 0; 701 $vtp->addSession( $sub, 'local_update' );694 702 695 if ( isset( $page['cat'] ) ) 703 696 { … … 709 702 } 710 703 $end = get_moment(); 711 echo get_elapsed_time( $start, $end ).' for update <br />'; 712 $vtp->setVar( $sub, 'local_update.categories', $categories ); 713 $vtp->setVar( $sub, 'local_update.count_new', $count_new ); 714 $vtp->setVar( $sub, 'local_update.count_deleted', $count_deleted ); 715 $vtp->closeSession( $sub, 'local_update' ); 704 //echo get_elapsed_time( $start, $end ).' for update <br />'; 705 $template->assign_block_vars('update',array( 706 'CATEGORIES'=>$categories, 707 'NEW_CAT'=>$count_new, 708 'DEL_CAT'=>$count_deleted 709 )); 716 710 } 717 711 //------------------------------------------------- remote update : listing.xml … … 735 729 if ( isset( $_GET['update'] ) 736 730 or isset( $page['cat'] ) 737 or @is_file( './listing.xml' ) )731 or @is_file( './listing.xml' ) && DEBUG) 738 732 { 739 733 $start = get_moment(); … … 748 742 } 749 743 //----------------------------------------------------------- sending html code 750 $ vtp->Parse( $handle , 'sub', $sub);744 $template->assign_var_from_handle('ADMIN_CONTENT', 'update'); 751 745 ?>
Note: See TracChangeset
for help on using the changeset viewer.