Changeset 1204 for trunk/admin
- Timestamp:
- Apr 19, 2006, 1:46:53 AM (19 years ago)
- Location:
- trunk/admin
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/site_reader_local.php
r1064 r1204 45 45 { 46 46 global $errors; 47 47 48 48 if (!is_dir($this->site_url)) 49 49 { … … 55 55 ) 56 56 ); 57 57 58 58 return false; 59 59 } 60 60 61 61 return true; 62 62 } … … 78 78 { 79 79 global $conf; 80 if (!isset($conf['flip_picture_ext']))81 {82 $conf['flip_picture_ext'] = array_flip($conf['picture_ext']);83 }84 80 if (!isset($conf['flip_file_ext'])) 85 81 { … … 98 94 $filename_wo_ext = get_filename_wo_extension($node); 99 95 100 // searching the thumbnail 101 $tn_ext = $this->get_tn_ext($path, $filename_wo_ext); 102 103 if (isset($conf['flip_picture_ext'][$extension])) 96 if ( isset($conf['flip_file_ext'][$extension]) ) 104 97 { 98 $tn_ext = $this->get_tn_ext($path, $filename_wo_ext); 105 99 $fs[ $path.'/'.$node ] = array( 106 100 'tn_ext' => $tn_ext, 107 'has_high' => $this->get_has_high($path, $node)108 101 ); 109 102 } 110 else if (isset($conf['flip_file_ext'][$extension]))111 { // file not a picture112 $representative_ext = $this->get_representative_ext($path, $filename_wo_ext);113 114 $fs[ $path.'/'.$node ] = array(115 'tn_ext' => $tn_ext,116 'representative_ext' => $representative_ext117 );118 }119 120 103 } 121 104 elseif (is_dir($path.'/'.$node) … … 141 124 142 125 // returns the name of the attributes that are supported for 143 // update/synchronization according to configuration126 // files update/synchronization 144 127 function get_update_attributes() 145 128 { 146 global $conf; 147 148 $update_fields = array( 149 'has_high', 'representative_ext', 'filesize', 'width', 'height' 150 ); 151 129 return array('tn_ext', 'has_high', 'representative_ext'); 130 } 131 132 function get_element_update_attributes($file) 133 { 134 global $conf; 135 $data = array(); 136 137 $filename = basename($file); 138 $dirname = dirname($file); 139 $filename_wo_ext = get_filename_wo_extension($filename); 140 $extension = get_extension($filename); 141 142 $data['tn_ext'] = $this->get_tn_ext($dirname, $filename_wo_ext); 143 $data['has_high'] = $this->get_has_high($dirname, $filename); 144 145 if ( !isset($conf['flip_picture_ext'][$extension]) ) 146 { 147 $data['representative_ext'] = $this->get_representative_ext( 148 $dirname, $filename_wo_ext 149 ); 150 } 151 return $data; 152 } 153 154 // returns the name of the attributes that are supported for 155 // metadata update/synchronization according to configuration 156 function get_metadata_attributes() 157 { 158 global $conf; 159 160 $update_fields = array('filesize', 'width', 'height'); 161 152 162 if ($conf['use_exif']) 153 163 { … … 167 177 ); 168 178 } 169 179 170 180 return $update_fields; 171 181 } 172 182 173 183 // returns a hash of attributes (metadata+filesize+width,...) for file 174 function get_element_ update_attributes($file)184 function get_element_metadata($file) 175 185 { 176 186 global $conf; … … 182 192 $data = array(); 183 193 184 $filename = basename($file);185 186 $data['has_high'] = $this->get_has_high(dirname($file), $filename);187 188 $data['representative_ext'] = $this->get_representative_ext(189 dirname($file),190 get_filename_wo_extension($filename)191 );192 193 194 $data['filesize'] = floor(filesize($file)/1024); 195 194 196 if ($image_size = @getimagesize($file)) 195 197 { … … 222 224 } 223 225 } 224 226 225 227 return $data; 226 228 } … … 246 248 { 247 249 global $conf; 248 250 249 251 $base_test = 250 252 $path.'/thumbnail/'.$conf['prefix_thumbnail'].$filename_wo_ext.'.'; 251 253 252 254 foreach ($conf['picture_ext'] as $ext) 253 255 { … … 258 260 } 259 261 } 260 262 261 263 return null; 262 264 } … … 268 270 return 'true'; 269 271 } 270 272 271 273 return null; 272 274 } -
trunk/admin/site_reader_remote.php
r1107 r1204 36 36 var $site_files; 37 37 var $insert_attributes; 38 var $ update_attributes;38 var $metadata_attributes; 39 39 40 40 function RemoteSiteReader($url, $listing_url) … … 42 42 $this->site_url = $url; 43 43 $this->insert_attributes = array( 44 'tn_ext', 'representative_ext', 'has_high'44 'tn_ext', 45 45 ); 46 46 $this->update_attributes = array( 47 'representative_ext', 'has_high', 'filesize', 'width', 'height' 47 'tn_ext', 'representative_ext', 'has_high', 48 ); 49 $this->metadata_attributes = array( 50 'filesize', 'width', 'height' 48 51 ); 49 52 … … 86 89 } 87 90 88 $this-> update_attributes = array_merge(89 $this-> update_attributes,91 $this->metadata_attributes = array_merge( 92 $this->metadata_attributes, 90 93 explode(',', getAttribute($info_xml_element, 'metadata')) 91 94 ); … … 155 158 156 159 // returns the name of the attributes that are supported for 157 // update/synchronization according to listing.xml160 // files update/synchronization 158 161 function get_update_attributes() 159 162 { … … 161 164 } 162 165 163 // returns a hash of attributes (metadata+filesize+width,...) for file164 166 function get_element_update_attributes($file) 165 167 { … … 167 169 $file, 168 170 $this->update_attributes 171 ); 172 } 173 174 // returns the name of the attributes that are supported for 175 // metadata update/synchronization according to listing.xml 176 function get_metadata_attributes() 177 { 178 return $this->metadata_attributes; 179 } 180 181 // returns a hash of attributes (metadata+width,...) for file 182 function get_element_metadata($file) 183 { 184 return $this->get_element_attributes( 185 $file, 186 $this->metadata_attributes 169 187 ); 170 188 } -
trunk/admin/site_update.php
r1122 r1204 104 104 if (isset($_POST['submit'])) 105 105 { 106 if (!isset($conf['flip_picture_ext'])) 107 { 108 $conf['flip_picture_ext'] = array_flip($conf['picture_ext']); 109 } 106 110 if ($site_reader->open()) 107 111 { … … 130 134 $counts['del_elements'] = 0; 131 135 $counts['new_elements'] = 0; 136 $counts['upd_elements'] = 0; 132 137 133 138 $start = get_moment(); … … 442 447 // thumbnail is mandatory and for non picture element, thumbnail and 443 448 // representative are optionnal 444 if ( in_array(get_extension($filename), $conf['picture_ext']))449 if ( isset( $conf['flip_picture_ext'][get_extension($filename)] ) ) 445 450 { 446 451 // if we found a thumnbnail corresponding to our picture... … … 452 457 'date_available' => CURRENT_DATE, 453 458 'tn_ext' => $fs[$path]['tn_ext'], 454 'has_high' => isset($fs[$path]['has_high'])455 ? $fs[$path]['has_high']456 : null,457 459 'path' => $path, 458 460 'storage_category_id' => $db_fulldirs[$dirname], … … 497 499 'date_available' => CURRENT_DATE, 498 500 'path' => $path, 499 'has_high' => isset($fs[$path]['has_high'])500 ? $fs[$path]['has_high']501 : null,502 501 'tn_ext' => isset($fs[$path]['tn_ext']) 503 502 ? $fs[$path]['tn_ext'] 504 : null,505 'representative_ext' => isset($fs[$path]['representative_ext'])506 ? $fs[$path]['representative_ext']507 503 : null, 508 504 'storage_category_id' => $db_fulldirs[$dirname], … … 635 631 // +-----------------------------------------------------------------------+ 636 632 if (isset($_POST['submit']) 637 and ($_POST['sync'] == 'dirs' or $_POST['sync'] == 'files')) 638 { 639 $template->assign_block_vars( 640 'update_result', 641 array( 642 'NB_NEW_CATEGORIES'=>$counts['new_categories'], 643 'NB_DEL_CATEGORIES'=>$counts['del_categories'], 644 'NB_NEW_ELEMENTS'=>$counts['new_elements'], 645 'NB_DEL_ELEMENTS'=>$counts['del_elements'], 646 'NB_ERRORS'=>count($errors), 647 )); 648 633 and ($_POST['sync'] == 'dirs' or $_POST['sync'] == 'files') 634 and !$general_failure ) 635 { 649 636 if (!$simulate) 650 637 { … … 661 648 echo ' -->'."\n"; 662 649 } 650 651 if ($_POST['sync'] == 'files') 652 { 653 $start = get_moment(); 654 $opts['category_id'] = ''; 655 $opts['recursive'] = true; 656 if (isset($_POST['cat'])) 657 { 658 $opts['category_id'] = $_POST['cat']; 659 if (!isset($_POST['subcats-included']) or $_POST['subcats-included'] != 1) 660 { 661 $opts['recursive'] = false; 662 } 663 } 664 $files = get_filelist($opts['category_id'], $site_id, 665 $opts['recursive'], 666 false); 667 echo '<!-- get_filelist : '; 668 echo get_elapsed_time($start, get_moment()); 669 echo ' -->'."\n"; 670 $start = get_moment(); 671 672 $datas = array(); 673 foreach ( $files as $id=>$file ) 674 { 675 $data = $site_reader->get_element_update_attributes($file); 676 if ( !is_array($data) ) 677 { 678 continue; 679 } 680 $extension = get_extension($file); 681 if ( isset($conf['flip_picture_ext'][$extension]) ) 682 { 683 if ( !isset($data['tn_ext']) ) 684 { 685 array_push( 686 $errors, 687 array( 688 'path' => $file, 689 'type' => 'PWG-UPDATE-2' 690 ) 691 ); 692 continue; 693 } 694 } 695 696 $data['id']=$id; 697 array_push($datas, $data); 698 } // end foreach file 699 700 $counts['upd_elements'] = count($datas); 701 if (!$simulate and count($datas)>0 ) 702 { 703 mass_updates( 704 IMAGES_TABLE, 705 // fields 706 array( 707 'primary' => array('id'), 708 'update' => $site_reader->get_update_attributes(), 709 ), 710 $datas 711 ); 712 } 713 echo '<!-- update files : '; 714 echo get_elapsed_time($start,get_moment()); 715 echo ' -->'."\n"; 716 }// end if sync files 717 } 718 719 // +-----------------------------------------------------------------------+ 720 // | synchronize files | 721 // +-----------------------------------------------------------------------+ 722 if (isset($_POST['submit']) 723 and ($_POST['sync'] == 'dirs' or $_POST['sync'] == 'files')) 724 { 725 $template->assign_block_vars( 726 'update_result', 727 array( 728 'NB_NEW_CATEGORIES'=>$counts['new_categories'], 729 'NB_DEL_CATEGORIES'=>$counts['del_categories'], 730 'NB_NEW_ELEMENTS'=>$counts['new_elements'], 731 'NB_DEL_ELEMENTS'=>$counts['del_elements'], 732 'NB_UPD_ELEMENTS'=>$counts['upd_elements'], 733 'NB_ERRORS'=>count($errors), 734 )); 663 735 } 664 736 … … 704 776 foreach ( $files as $id=>$file ) 705 777 { 706 $data = $site_reader->get_element_ update_attributes($file);778 $data = $site_reader->get_element_metadata($file); 707 779 if ( is_array($data) ) 708 780 { … … 719 791 $tags_of[$id] = array(); 720 792 } 721 793 722 794 foreach (explode(',', $data[$key]) as $tag_name) 723 795 { … … 748 820 array_merge( 749 821 array_diff( 750 $site_reader->get_ update_attributes(),822 $site_reader->get_metadata_attributes(), 751 823 // keywords and tags fields are managed separately 752 824 array('keywords', 'tags') … … 786 858 // used_metadata string is displayed to inform admin which metadata will be 787 859 // used from files for synchronization 788 $used_metadata = implode( ', ', $site_reader->get_ update_attributes());860 $used_metadata = implode( ', ', $site_reader->get_metadata_attributes()); 789 861 if ($site_is_remote and !isset($_POST['submit']) ) 790 862 {
Note: See TracChangeset
for help on using the changeset viewer.