Changeset 534
- Timestamp:
- Sep 24, 2004, 1:41:23 AM (20 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/remote_site.php
r526 r534 160 160 161 161 /** 162 * read $listing_file and update a remote site according to its id 163 * 164 * @param string listing_file 165 * @param int site_id 166 * @return void 167 */ 168 function update_remote_site($listing_file, $site_id) 169 { 170 global $lang, $counts, $template, $removes, $errors; 171 172 if (@fopen($listing_file, 'r')) 173 { 174 $counts = array( 175 'new_elements' => 0, 176 'new_categories' => 0, 177 'del_elements' => 0, 178 'del_categories' => 0 179 ); 180 $removes = array(); 181 182 $xml_content = getXmlCode($listing_file); 183 insert_remote_category($xml_content, $site_id, 'NULL', 0); 184 update_category(); 185 186 $template->assign_block_vars( 187 'update', 188 array( 189 'NB_NEW_CATEGORIES'=>$counts['new_categories'], 190 'NB_DEL_CATEGORIES'=>$counts['del_categories'], 191 'NB_NEW_ELEMENTS'=>$counts['new_elements'], 192 'NB_DEL_ELEMENTS'=>$counts['del_elements'] 193 )); 194 195 if (count($removes) > 0) 196 { 197 $template->assign_block_vars('update.removes', array()); 198 } 199 foreach ($removes as $remove) 200 { 201 $template->assign_block_vars('update.removes.remote_remove', 202 array('NAME'=>$remove)); 203 } 204 } 205 else 206 { 207 array_push($errors, $lang['remote_site_listing_not_found']); 208 } 209 } 210 211 /** 162 212 * searchs the "dir" node of the xml_dir given and insert the contained 163 213 * categories if the are not in the database yet. The function also deletes … … 319 369 ;'; 320 370 $result = mysql_query($query); 371 $to_delete = array(); 321 372 while ($row = mysql_fetch_array($result)) 322 373 { 323 374 if (!in_array($row['file'], $xml_files)) 324 375 { 325 array_push($removes, $row['file']); 326 delete_element($row['id']); 327 } 328 } 376 // local_dir is cached 377 if (!isset($local_dir)) 378 { 379 $local_dir = get_local_dir($category_id); 380 } 381 array_push($removes, $local_dir.$row['file']); 382 array_push($to_delete, $row['id']); 383 } 384 } 385 delete_elements($to_delete); 329 386 330 387 $database_elements = array(); … … 443 500 'L_REMOTE_SITE_REMOVED_TITLE'=>$lang['remote_site_removed_title'], 444 501 'L_REMOTE_SITE_REMOVED'=>$lang['remote_site_removed'], 502 'L_REMOTE_SITE_LOCAL_FOUND'=>$lang['remote_site_local_found'], 503 'L_REMOTE_SITE_LOCAL_NEW'=>$lang['remote_site_local_new'], 504 'L_REMOTE_SITE_LOCAL_UPDATE'=>$lang['remote_site_local_update'], 445 505 446 506 'F_ACTION'=>add_session_id(PHPWG_ROOT_PATH.'admin.php?page=remote_site') … … 524 584 if (isset($_GET['action'])) 525 585 { 526 $query = ' 586 if (isset($page['site'])) 587 { 588 $query = ' 527 589 SELECT galleries_url 528 590 FROM '.SITES_TABLE.' 529 591 WHERE id = '.$page['site'].' 530 592 ;'; 531 $row= mysql_fetch_array(mysql_query($query));532 $clf = $row['galleries_url'].'create_listing_file.php';533 593 list($galleries_url) = mysql_fetch_array(mysql_query($query)); 594 } 595 534 596 switch($_GET['action']) 535 597 { … … 537 599 { 538 600 delete_site($page['site']); 539 601 540 602 $template->assign_block_vars( 541 603 'confirmation', 542 604 array( 543 'CONTENT'=>$ row['galleries_url'].' '.$lang['remote_site_deleted']605 'CONTENT'=>$galleries_url.' '.$lang['remote_site_deleted'] 544 606 )); 545 607 … … 548 610 case 'generate' : 549 611 { 550 $title = $ row['galleries_url'].' : '.$lang['remote_site_generate'];612 $title = $galleries_url.' : '.$lang['remote_site_generate']; 551 613 $template->assign_vars(array('REMOTE_SITE_TITLE'=>$title)); 552 remote_output($ clf.'?action=generate');614 remote_output($galleries_url.'create_listing_file.php?action=generate'); 553 615 break; 554 616 } 555 617 case 'update' : 556 618 { 557 $title = $ row['galleries_url'].' : '.$lang['remote_site_update'];619 $title = $galleries_url.' : '.$lang['remote_site_update']; 558 620 $template->assign_vars(array('REMOTE_SITE_TITLE'=>$title)); 621 update_remote_site($galleries_url.'listing.xml', $page['site']); 622 break; 623 } 624 case 'clean' : 625 { 626 $title = $galleries_url.' : '.$lang['remote_site_clean']; 627 $template->assign_vars(array('REMOTE_SITE_TITLE'=>$title)); 628 remote_output($galleries_url.'create_listing_file.php?action=clean'); 629 break; 630 } 631 case 'local_update' : 632 { 633 $local_listing = PHPWG_ROOT_PATH.'listing.xml'; 634 $xml_content = getXmlCode($local_listing); 635 $url = getAttribute(getChild($xml_content, 'informations'), 'url'); 636 637 // is the site already existing ? 638 $query = ' 639 SELECT id 640 FROM '.SITES_TABLE.' 641 WHERE galleries_url = \''.addslashes($url).'\' 642 ;'; 643 $result = mysql_query($query); 644 if (mysql_num_rows($result) == 0) 645 { 646 // we have to register this site in the database 647 $query = ' 648 INSERT INTO '.SITES_TABLE.' 649 (galleries_url) 650 VALUES 651 (\''.$url.'\') 652 ;'; 653 mysql_query($query); 654 $site_id = mysql_insert_id(); 655 } 656 else 657 { 658 // we get the already registered id 659 $row = mysql_fetch_array($result); 660 $site_id = $row['id']; 661 } 559 662 560 if (@fopen($row['galleries_url'].'listing.xml', 'r')) 561 { 562 $counts = array( 563 'new_elements' => 0, 564 'new_categories' => 0, 565 'del_elements' => 0, 566 'del_categories' => 0 567 ); 568 $removes = array(); 569 570 $xml_content = getXmlCode($row['galleries_url'].'listing.xml'); 571 insert_remote_category($xml_content, $page{'site'}, 'NULL', 0); 572 update_category(); 573 574 $template->assign_block_vars( 575 'update', 576 array( 577 'NB_NEW_CATEGORIES'=>$counts['new_categories'], 578 'NB_DEL_CATEGORIES'=>$counts['del_categories'], 579 'NB_NEW_ELEMENTS'=>$counts['new_elements'], 580 'NB_DEL_ELEMENTS'=>$counts['del_elements'] 581 )); 582 583 if (count($removes) > 0) 584 { 585 $template->assign_block_vars('update.removes', array()); 586 } 587 foreach ($removes as $remove) 588 { 589 $template->assign_block_vars('update.removes.remote_remove', 590 array('NAME'=>$remove)); 591 } 592 } 593 else 594 { 595 array_push($errors, $lang['remote_site_listing_not_found']); 596 } 663 $title = $url.' : '.$lang['remote_site_local_update']; 664 $template->assign_vars(array('REMOTE_SITE_TITLE'=>$title)); 665 update_remote_site($local_listing, $site_id); 597 666 break; 598 667 } 599 case 'clean' : 600 { 601 $title = $row['galleries_url'].' : '.$lang['remote_site_clean']; 602 $template->assign_vars(array('REMOTE_SITE_TITLE'=>$title)); 603 remote_output($clf.'?action=clean'); 604 break; 668 } 669 } 670 else 671 { 672 // we search a "local" listing.xml file 673 $local_listing = PHPWG_ROOT_PATH.'listing.xml'; 674 if (is_file($local_listing)) 675 { 676 $xml_content = getXmlCode($local_listing); 677 $url = getAttribute(getChild($xml_content, 'informations'), 'url'); 678 679 $base_url = PHPWG_ROOT_PATH.'admin.php?page=remote_site&action='; 680 681 $template->assign_block_vars( 682 'local', 683 array( 684 'URL' => $url, 685 'U_UPDATE' => add_session_id($base_url.'local_update') 686 ) 687 ); 688 689 // is the site already existing ? 690 $query = ' 691 SELECT COUNT(*) 692 FROM '.SITES_TABLE.' 693 WHERE galleries_url = \''.addslashes($url).'\' 694 ;'; 695 list($count) = mysql_fetch_array(mysql_query($query)); 696 if ($count == 0) 697 { 698 $template->assign_block_vars('local.new_site', array()); 605 699 } 606 700 } -
trunk/language/en_UK.iso-8859-1/admin.lang.php
r532 r534 1 1 <?php 2 2 // +-----------------------------------------------------------------------+ 3 // | en_UK/admin.lang.php|3 // | en_UK/admin.lang.php | 4 4 // +-----------------------------------------------------------------------+ 5 5 // | application : PhpWebGallery <http://phpwebgallery.net> | 6 // | branch : BSF (Best So Far) 6 // | branch : BSF (Best So Far) | 7 7 // +-----------------------------------------------------------------------+ 8 8 // | file : $RCSfile$ … … 67 67 $lang['remote_site_file_not_found'] = 'file create_listing_file.php on remote site was not found'; 68 68 $lang['remote_site_error'] = 'an error happened'; 69 $lang['remote_site_listing_not_found'] = ' remote listingfile was not found';69 $lang['remote_site_listing_not_found'] = 'listing.xml file was not found'; 70 70 $lang['remote_site_removed'] = 'was removed on remote site'; 71 71 $lang['remote_site_removed_title'] = 'Removed elements'; 72 72 $lang['remote_site_created'] = 'created'; 73 73 $lang['remote_site_deleted'] = 'deleted'; 74 $lang['remote_site_local_found'] = 'A local listing.xml file has been found for '; 75 $lang['remote_site_local_new'] = '(new site)'; 76 $lang['remote_site_local_update'] = 'read local listing.xml and update'; 74 77 75 78 // Categorie words -
trunk/template/default/admin/configuration.tpl
r527 r534 26 26 <tr> 27 27 <td><strong>{general.L_CONF_TN_PREFIX} :</strong><br /><span class="small">{general.L_CONF_TN_PREFIX_INFO}</span></td> 28 <td class="row1"><input type="text" size=" 3" maxlength="4" name="prefix_thumbnail" value="{general.THUMBNAIL_PREFIX}" /></td>28 <td class="row1"><input type="text" size="10" maxlength="10" name="prefix_thumbnail" value="{general.THUMBNAIL_PREFIX}" /></td> 29 29 </tr> 30 30 <tr> -
trunk/template/default/admin/remote_site.tpl
r526 r534 43 43 <!-- END remote_output --> 44 44 45 <!-- BEGIN local --> 46 <div class="remoteLocal"> 47 {L_REMOTE_SITE_LOCAL_FOUND} {local.URL} 48 <!-- BEGIN new_site --> 49 {L_REMOTE_SITE_LOCAL_NEW} 50 <!-- END new_site --> 51 [<a href="{local.U_UPDATE}">{L_REMOTE_SITE_LOCAL_UPDATE}</a>] 52 </div> 53 <!-- END local --> 54 45 55 <form action="{F_ACTION}" method="post"> 46 56 {L_REMOTE_SITE_CREATE} -
trunk/template/default/default.css
r531 r534 413 413 color:#ffe1e1; 414 414 } 415 416 div.remoteOutput, div.remoteLocal { 417 background-color:#444444; 418 border:1px solid black; 419 margin:10px; 420 text-align:left; 421 padding:5px; 422 } 423 424 li.remoteInfo { 425 color:gray; 426 } 427 428 li.remoteWarning { 429 color:#ffe1e1; 430 } 431 432 li.remoteError { 433 color:orange; 434 } 435 436 div.remoteLocal { 437 text-align:center; 438 }
Note: See TracChangeset
for help on using the changeset viewer.