Changeset 589 for trunk/admin/update.php
- Timestamp:
- Nov 1, 2004, 4:01:28 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/update.php
r587 r589 33 33 34 34 define('CURRENT_DATE', "'".date('Y-m-d')."'"); 35 //------------------------------------------------------------------- functions 35 // +-----------------------------------------------------------------------+ 36 // | functions | 37 // +-----------------------------------------------------------------------+ 38 36 39 /** 37 40 * order categories (update categories.rank database field) … … 119 122 // 2. we search pictures of the category only if the update is for all 120 123 // or a cat_id is specified 121 if ( isset($page['cat']) or $_GET['update'] == 'all')124 if ($_POST['sync'] == 'files') 122 125 { 123 126 $output.= insert_local_element($cat_directory, $id_uppercat); … … 240 243 241 244 // Recursive call on the sub-categories (not virtual ones) 242 $query = ' 245 if (!isset($_POST['cat']) 246 or (isset($_POST['subcats-included']) 247 and $_POST['subcats-included'] == 1)) 248 { 249 $query = ' 243 250 SELECT id 244 251 FROM '.CATEGORIES_TABLE.' 245 252 WHERE site_id = 1 246 253 '; 247 if (!is_numeric($id_uppercat))248 {249 $query.= ' AND id_uppercat IS NULL';250 }251 else252 {253 $query.= ' AND id_uppercat = '.$id_uppercat;254 }255 $query.= '254 if (!is_numeric($id_uppercat)) 255 { 256 $query.= ' AND id_uppercat IS NULL'; 257 } 258 else 259 { 260 $query.= ' AND id_uppercat = '.$id_uppercat; 261 } 262 $query.= ' 256 263 AND dir IS NOT NULL'; // virtual categories not taken 257 $query.= ' 258 ;'; 259 $result = pwg_query($query); 260 while ($row = mysql_fetch_array($result)) 261 { 262 $output.= insert_local_category($row['id']); 264 $query.= ' 265 ;'; 266 $result = pwg_query($query); 267 while ($row = mysql_fetch_array($result)) 268 { 269 $output.= insert_local_category($row['id']); 270 } 263 271 } 264 272 … … 543 551 return $output; 544 552 } 545 //----------------------------------------------------- template initialization 553 // +-----------------------------------------------------------------------+ 554 // | template initialization | 555 // +-----------------------------------------------------------------------+ 546 556 $template->set_filenames(array('update'=>'admin/update.tpl')); 547 557 548 $template->assign_vars(array( 549 'L_UPDATE_TITLE'=>$lang['update_default_title'], 550 'L_CAT_UPDATE'=>$lang['update_only_cat'], 551 'L_ALL_UPDATE'=>$lang['update_all'], 552 'L_RESULT_UPDATE'=>$lang['update_part_research'], 553 'L_NB_NEW_ELEMENTS'=>$lang['update_nb_new_elements'], 554 'L_NB_NEW_CATEGORIES'=>$lang['update_nb_new_categories'], 555 'L_NB_DEL_ELEMENTS'=>$lang['update_nb_del_elements'], 556 'L_NB_DEL_CATEGORIES'=>$lang['update_nb_del_categories'], 557 'L_UPDATE_SYNC_METADATA_QUESTION'=>$lang['update_sync_metadata_question'], 558 559 'U_CAT_UPDATE'=>add_session_id(PHPWG_ROOT_PATH.'admin.php?page=update&update=cats'), 560 'U_ALL_UPDATE'=>add_session_id(PHPWG_ROOT_PATH.'admin.php?page=update&update=all') 561 )); 562 //-------------------------------------------- introduction : choices of update 563 // Display choice if "update" var is not specified 564 if (!isset($_GET['update'])) 558 $base_url = PHPWG_ROOT_PATH.'admin.php?page=update'; 559 560 $template->assign_vars( 561 array( 562 'L_SUBMIT'=>$lang['submit'], 563 'L_UPDATE_TITLE'=>$lang['update_default_title'], 564 'L_UPDATE_SYNC_FILES'=>$lang['update_sync_files'], 565 'L_UPDATE_SYNC_DIRS'=>$lang['update_sync_dirs'], 566 'L_UPDATE_SYNC_ALL'=>$lang['update_sync_all'], 567 'L_UPDATE_SYNC_METADATA'=>$lang['update_sync_metadata'], 568 'L_UPDATE_SYNC_METADATA_NEW'=>$lang['update_sync_metadata_new'], 569 'L_UPDATE_SYNC_METADATA_ALL'=>$lang['update_sync_metadata_all'], 570 'L_UPDATE_CATS_SUBSET'=>$lang['update_cats_subset'], 571 'L_RESULT_UPDATE'=>$lang['update_part_research'], 572 'L_NB_NEW_ELEMENTS'=>$lang['update_nb_new_elements'], 573 'L_NB_NEW_CATEGORIES'=>$lang['update_nb_new_categories'], 574 'L_NB_DEL_ELEMENTS'=>$lang['update_nb_del_elements'], 575 'L_NB_DEL_CATEGORIES'=>$lang['update_nb_del_categories'], 576 'L_SEARCH_SUBCATS_INCLUDED'=>$lang['search_subcats_included'], 577 578 'U_SYNC_DIRS'=>add_session_id($base_url.'&update=dirs'), 579 'U_SYNC_ALL'=>add_session_id($base_url.'&update=all'), 580 'U_SYNC_METADATA_NEW'=>add_session_id($base_url.'&metadata=all:new'), 581 'U_SYNC_METADATA_ALL'=>add_session_id($base_url.'&metadata=all') 582 )); 583 // +-----------------------------------------------------------------------+ 584 // | introduction : choices | 585 // +-----------------------------------------------------------------------+ 586 if (!isset($_POST['submit'])) 565 587 { 566 $template->assign_block_vars('introduction',array()); 588 $template->assign_block_vars('introduction', array()); 589 590 $query = ' 591 SELECT id 592 FROM '.CATEGORIES_TABLE.' 593 WHERE site_id != 1 594 ;'; 595 $result = pwg_query($query); 596 while ($row = mysql_fetch_array($result)) 597 { 598 array_push($user['restrictions'], $row['id']); 599 } 600 $user['forbidden_categories'] = implode(',', $user['restrictions']); 601 $user['expand'] = true; 602 $structure = create_user_structure(''); 603 display_select_categories($structure, 604 ' ', 605 array(), 606 'introduction.category_option'); 567 607 } 568 //-------------------------------------------------- local update : ./galleries 569 else if (!isset($_GET['metadata'])) 608 // +-----------------------------------------------------------------------+ 609 // | synchronize files | 610 // +-----------------------------------------------------------------------+ 611 else if (isset($_POST['submit']) 612 and ($_POST['sync'] == 'dirs' or $_POST['sync'] == 'files')) 570 613 { 571 check_cat_id($_GET['update']);572 $start = get_moment();573 614 $counts = array( 574 615 'new_elements' => 0, … … 577 618 'del_categories' => 0 578 619 ); 579 580 if (isset($ page['cat']))581 { 582 $ categories = insert_local_category($page['cat']);620 621 if (isset($_POST['cat'])) 622 { 623 $opts['category_id'] = $_POST['cat']; 583 624 } 584 625 else 585 626 { 586 $categories = insert_local_category('NULL'); 587 } 627 $opts['category_id'] = 'NULL'; 628 } 629 630 $start = get_moment(); 631 $categories = insert_local_category($opts['category_id']); 588 632 echo get_elapsed_time($start,get_moment()).' for scanning directories<br />'; 633 589 634 $template->assign_block_vars( 590 635 'update', … … 596 641 'NB_DEL_ELEMENTS'=>$counts['del_elements'] 597 642 )); 598 if ($counts['new_elements'] > 0)599 {600 $url = PHPWG_ROOT_PATH.'admin.php?page=update&metadata=1';601 if (isset($page['cat']))602 {603 $url.= '&update='.$page['cat'];604 }605 $template->assign_block_vars(606 'update.sync_metadata',607 array(608 'U_URL' => add_session_id($url)609 ));610 }611 }612 //---------------------------------------- update informations about categories613 if (!isset($_GET['metadata'])614 and (isset($_GET['update'])615 or isset($page['cat'])616 or @is_file('./listing.xml') && DEBUG))617 {618 643 $start = get_moment(); 619 644 update_category('all'); … … 623 648 echo get_elapsed_time($start, get_moment()).' for ordering categories<br />'; 624 649 } 625 //---------------------------------------------------- metadata synchronization 626 if (isset($_GET['metadata'])) 650 // +-----------------------------------------------------------------------+ 651 // | synchronize metadata | 652 // +-----------------------------------------------------------------------+ 653 else if (isset($_POST['submit']) and preg_match('/^metadata/', $_POST['sync'])) 627 654 { 628 if (isset($_GET['update'])) 629 { 630 check_cat_id($_GET['update']); 631 } 632 655 // sync only never synchronized files ? 656 if ($_POST['sync'] == 'metadata_new') 657 { 658 $opts['only_new'] = true; 659 } 660 else 661 { 662 $opts['only_new'] = false; 663 } 664 $opts['category_id'] = ''; 665 $opts['recursive'] = true; 666 667 if (isset($_POST['cat'])) 668 { 669 $opts['category_id'] = $_POST['cat']; 670 // recursive ? 671 if (!isset($_POST['subcats-included']) or $_POST['subcats-included'] != 1) 672 { 673 $opts['recursive'] = false; 674 } 675 } 633 676 $start = get_moment(); 634 if (isset($page['cat'])) 635 { 636 $files = get_filelist($page['cat'],true,true); 637 } 638 else 639 { 640 $files = get_filelist('',true,true); 641 } 677 $files = get_filelist($opts['category_id'], 678 $opts['recursive'], 679 $opts['only_new']); 642 680 echo get_elapsed_time($start, get_moment()).' for get_filelist<br />'; 643 681 … … 646 684 echo get_elapsed_time($start, get_moment()).' for metadata update<br />'; 647 685 } 648 //----------------------------------------------------------- sending html code 686 // +-----------------------------------------------------------------------+ 687 // | sending html code | 688 // +-----------------------------------------------------------------------+ 649 689 $template->assign_var_from_handle('ADMIN_CONTENT', 'update'); 650 690 ?>
Note: See TracChangeset
for help on using the changeset viewer.