Changeset 12831 for trunk/admin/site_reader_local.php
- Timestamp:
- Jan 3, 2012, 9:21:13 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/site_reader_local.php
r12642 r12831 31 31 { 32 32 $this->site_url = $url; 33 global $conf; 34 if (!isset($conf['flip_file_ext'])) 35 { 36 $conf['flip_file_ext'] = array_flip($conf['file_ext']); 37 } 38 if (!isset($conf['flip_picture_ext'])) 39 { 40 $conf['flip_picture_ext'] = array_flip($conf['picture_ext']); 41 } 33 42 } 34 43 … … 69 78 * and $conf['picture_ext'] 70 79 * @param string $path recurse in this directory 71 * @return array like "pic.jpg"=>array(' tn_ext'=>'jpg' ... )80 * @return array like "pic.jpg"=>array('representative_ext'=>'jpg' ... ) 72 81 */ 73 82 function get_elements($path) 74 83 { 75 84 global $conf; 76 if (!isset($conf['flip_file_ext']))77 {78 $conf['flip_file_ext'] = array_flip($conf['file_ext']);79 }80 85 81 86 $subdirs = array(); … … 94 99 if ( isset($conf['flip_file_ext'][$extension]) ) 95 100 { 96 $tn_ext = $this->get_tn_ext($path, $filename_wo_ext); 101 $representative_ext = null; 102 if (! isset($conf['flip_picture_ext'][$extension]) ) 103 { 104 $representative_ext = $this->get_representative_ext($path, $filename_wo_ext); 105 } 97 106 $fs[ $path.'/'.$node ] = array( 98 ' tn_ext' => $tn_ext,107 'representative_ext' => $representative_ext, 99 108 ); 100 109 } … … 124 133 function get_update_attributes() 125 134 { 126 return array(' tn_ext', 'has_high', 'representative_ext');135 return array('representative_ext'); 127 136 } 128 137 … … 133 142 134 143 $filename = basename($file); 135 $dirname = dirname($file);136 $filename_wo_ext = get_filename_wo_extension($filename);137 144 $extension = get_extension($filename); 138 145 139 $data['tn_ext'] = $this->get_tn_ext($dirname, $filename_wo_ext); 140 $data['has_high'] = $this->get_has_high($dirname, $filename); 146 $representative_ext = null; 147 if (! isset($conf['flip_picture_ext'][$extension]) ) 148 { 149 $dirname = dirname($file); 150 $filename_wo_ext = get_filename_wo_extension($filename); 151 $representative_ext = $this->get_representative_ext($dirname, $filename_wo_ext); 152 } 141 153 142 if ( !isset($conf['flip_picture_ext'][$extension]) ) 143 { 144 $data['representative_ext'] = $this->get_representative_ext( 145 $dirname, $filename_wo_ext 146 ); 147 } 154 $data['representative_ext'] = $representative_ext; 148 155 return $data; 149 156 } … … 153 160 function get_metadata_attributes() 154 161 { 155 global $conf; 156 157 $update_fields = array('filesize', 'width', 'height', 'high_filesize', 'high_width', 'high_height'); 158 159 if ($conf['use_exif']) 160 { 161 $update_fields = 162 array_merge( 163 $update_fields, 164 array_keys($conf['use_exif_mapping']) 165 ); 166 } 167 168 if ($conf['use_iptc']) 169 { 170 $update_fields = 171 array_merge( 172 $update_fields, 173 array_keys($conf['use_iptc_mapping']) 174 ); 175 } 176 177 return $update_fields; 162 return get_sync_metadata_attributes(); 178 163 } 179 164 180 165 // returns a hash of attributes (metadata+filesize+width,...) for file 181 function get_element_metadata($ file, $has_high = false)166 function get_element_metadata($infos) 182 167 { 183 global $conf; 184 if (!is_file($file)) 185 { 186 return null; 187 } 188 189 $data = array(); 190 191 $data['filesize'] = floor(filesize($file)/1024); 192 193 if ($image_size = @getimagesize($file)) 194 { 195 $data['width'] = $image_size[0]; 196 $data['height'] = $image_size[1]; 197 } 198 199 if ($has_high) 200 { 201 $high_file = dirname($file).'/pwg_high/'.basename($file); 202 $data['high_filesize'] = floor(filesize($high_file)/1024); 203 204 if ($high_size = @getimagesize($high_file)) 205 { 206 $data['high_width'] = $high_size[0]; 207 $data['high_height'] = $high_size[1]; 208 } 209 } 210 211 if ($conf['use_exif']) 212 { 213 $exif = get_sync_exif_data($file); 214 if (count($exif) == 0 and isset($data['high_filesize'])) 215 { 216 $exif = get_sync_exif_data($high_file); 217 } 218 $data = array_merge($data, $exif); 219 } 220 221 if ($conf['use_iptc']) 222 { 223 $iptc = get_sync_iptc_data($file); 224 if (count($iptc) == 0 and isset($data['high_filesize'])) 225 { 226 $iptc = get_sync_iptc_data($high_file); 227 } 228 $data = array_merge($data, $iptc); 229 } 230 231 return $data; 168 return get_sync_metadata($infos); 232 169 } 233 170 … … 249 186 } 250 187 251 function get_tn_ext($path, $filename_wo_ext)252 {253 global $conf;254 255 $base_test =256 $path.'/thumbnail/'.$conf['prefix_thumbnail'].$filename_wo_ext.'.';257 258 foreach ($conf['picture_ext'] as $ext)259 {260 $test = $base_test.$ext;261 if (is_file($test))262 {263 return $ext;264 }265 }266 267 return null;268 }269 270 function get_has_high($path, $filename)271 {272 if (is_file($path.'/pwg_high/'.$filename))273 {274 return 'true';275 }276 277 return null;278 }279 188 280 189 }
Note: See TracChangeset
for help on using the changeset viewer.