Changeset 606
- Timestamp:
- Nov 17, 2004, 12:38:34 AM (19 years ago)
- Location:
- trunk
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/functions.php
r597 r606 785 785 } 786 786 } 787 788 /** 789 * inserts multiple lines in a table 790 * 791 * @param string table_name 792 * @param array dbields 793 * @param array inserts 794 * @return void 795 */ 796 function mass_inserts($table_name, $dbfields, $inserts) 797 { 798 // inserts all found categories 799 $query = ' 800 INSERT INTO '.$table_name.' 801 ('.implode(',', $dbfields).') 802 VALUES'; 803 foreach ($inserts as $insert_id => $insert) 804 { 805 $query.= ' 806 '; 807 if ($insert_id > 0) 808 { 809 $query.= ','; 810 } 811 $query.= '('; 812 foreach ($dbfields as $field_id => $dbfield) 813 { 814 if ($field_id > 0) 815 { 816 $query.= ','; 817 } 818 819 if (!isset($insert[$dbfield]) or $insert[$dbfield] == '') 820 { 821 $query.= 'NULL'; 822 } 823 else 824 { 825 $query.= "'".$insert[$dbfield]."'"; 826 } 827 } 828 $query.=')'; 829 } 830 $query.= ' 831 ;'; 832 pwg_query($query); 833 } 787 834 ?> -
trunk/admin/infos_images.php
r593 r606 320 320 while ($row = mysql_fetch_array($result)) 321 321 { 322 $thumbnail_url = get_thumbnail_src($row['file'], 323 $row['storage_category_id'], 324 @$row['tn_ext']); 322 $thumbnail_url = get_thumbnail_src($row['path'], @$row['tn_ext']); 325 323 326 324 $template->assign_block_vars( -
trunk/admin/picture_modify.php
r593 r606 200 200 $dir_path = get_cat_display_name($current_category['name'], '->', ''); 201 201 202 $thumbnail_url = get_thumbnail_src($row['file'], 203 $row['storage_category_id'], 204 @$row['tn_ext']); 202 $thumbnail_url = get_thumbnail_src($row['path'], @$row['tn_ext']); 205 203 206 204 $url_img = PHPWG_ROOT_PATH.'picture.php?image_id='.$_GET['image_id']; -
trunk/admin/remote_site.php
r602 r606 110 110 111 111 return $database_dirs; 112 }113 114 /**115 * inserts multiple lines in a table116 *117 * @param string table_name118 * @param array dbields119 * @param array inserts120 * @return void121 */122 function mass_inserts($table_name, $dbfields, $inserts)123 {124 // inserts all found categories125 $query = '126 INSERT INTO '.$table_name.'127 ('.implode(',', $dbfields).')128 VALUES';129 foreach ($inserts as $insert_id => $insert)130 {131 $query.= '132 ';133 if ($insert_id > 0)134 {135 $query.= ',';136 }137 $query.= '(';138 foreach ($dbfields as $field_id => $dbfield)139 {140 if ($field_id > 0)141 {142 $query.= ',';143 }144 145 if (!isset($insert[$dbfield]) or $insert[$dbfield] == '')146 {147 $query.= 'NULL';148 }149 else150 {151 $query.= "'".$insert[$dbfield]."'";152 }153 }154 $query.=')';155 }156 $query.= '157 ;';158 pwg_query($query);159 112 } 160 113 … … 419 372 'keywords', 420 373 'name', 421 'comment'); 374 'comment', 375 'path'); 422 376 foreach ($optional_atts as $att) 423 377 { … … 435 389 $dbfields = array('file','storage_category_id','date_available','tn_ext', 436 390 'filesize','width','height','date_creation','author', 437 'keywords','name','comment' );391 'keywords','name','comment','path'); 438 392 mass_inserts(IMAGES_TABLE, $dbfields, $inserts); 439 393 $counts{'new_elements'}+= count($inserts); -
trunk/admin/update.php
r602 r606 32 32 include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php'); 33 33 34 define('CURRENT_DATE', "'".date('Y-m-d')."'");34 define('CURRENT_DATE', date('Y-m-d')); 35 35 // +-----------------------------------------------------------------------+ 36 36 // | functions | … … 408 408 { 409 409 $insert = array(); 410 $insert['file'] = "'".$unregistered_element."'";410 $insert['file'] = $unregistered_element; 411 411 $insert['storage_category_id'] = $category_id; 412 412 $insert['date_available'] = CURRENT_DATE; 413 $insert['tn_ext'] = "'".$tn_ext."'"; 413 $insert['tn_ext'] = $tn_ext; 414 $insert['path'] = $dir.$unregistered_element; 414 415 415 416 $counts['new_elements']++; … … 447 448 448 449 $insert = array(); 449 $insert['file'] = "'".$unregistered_element."'"; 450 $insert['file'] = $unregistered_element; 451 $insert['path'] = $dir.$unregistered_element; 450 452 $insert['storage_category_id'] = $category_id; 451 453 $insert['date_available'] = CURRENT_DATE; 452 454 if ( $tn_ext != '' ) 453 455 { 454 $insert['tn_ext'] = "'".$tn_ext."'";456 $insert['tn_ext'] = $tn_ext; 455 457 } 456 458 if ( $representative_ext != '' ) 457 459 { 458 $insert['representative_ext'] = "'".$representative_ext."'";460 $insert['representative_ext'] = $representative_ext; 459 461 } 460 462 … … 476 478 $dbfields = array( 477 479 'file','storage_category_id','date_available','tn_ext' 478 ,'representative_ext' 480 ,'representative_ext','path' 479 481 ); 480 $query = ' 481 INSERT INTO '.IMAGES_TABLE.' 482 ('.implode(',', $dbfields).') 483 VALUES 484 '; 485 foreach ($inserts as $insert_id => $insert) 486 { 487 $query.= ' 488 '; 489 if ($insert_id > 0) 490 { 491 $query.= ','; 492 } 493 $query.= '('; 494 foreach ($dbfields as $field_id => $dbfield) 495 { 496 if ($field_id > 0) 497 { 498 $query.= ','; 499 } 500 501 if (!isset($insert[$dbfield]) or $insert[$dbfield] == '') 502 { 503 $query.= 'NULL'; 504 } 505 else 506 { 507 $query.= $insert[$dbfield]; 508 } 509 } 510 $query.=')'; 511 } 512 $query.= ' 513 ;'; 514 515 pwg_query($query); 482 mass_inserts(IMAGES_TABLE, $dbfields, $inserts); 516 483 517 484 // what are the ids of the pictures in the $category_id ? -
trunk/comments.php
r593 r606 141 141 // link to the full size picture 142 142 $query = ' 143 SELECT name,file,storage_category_id as cat_id,tn_ext 143 SELECT name,file,storage_category_id as cat_id,tn_ext,path 144 144 FROM '.IMAGES_TABLE.' 145 145 WHERE id = '.$row['image_id'].' … … 167 167 $name.= ' [ '.$subrow['file'].' ]'; 168 168 // source of the thumbnail picture 169 $thumbnail_src = get_thumbnail_src($subrow['file'], 170 $subrow['cat_id'], 171 @$subrow['tn_ext']); 169 $thumbnail_src = get_thumbnail_src($subrow['path'], @$subrow['tn_ext']); 172 170 // link to the full size picture 173 171 $url = PHPWG_ROOT_PATH.'picture.php?cat='.$category_id; -
trunk/include/category_calendar.inc.php
r593 r606 220 220 { 221 221 $query = ' 222 SELECT file,tn_ext,'.$conf['calendar_datefield'].', storage_category_id222 SELECT file,tn_ext,'.$conf['calendar_datefield'].',path 223 223 FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE.' 224 224 '.$page['where'].' … … 230 230 $row = mysql_fetch_array(pwg_query($query)); 231 231 232 $thumbnail_src = get_thumbnail_src($row['file'], 233 $row['storage_category_id'], 234 @$row['tn_ext']); 232 $thumbnail_src = get_thumbnail_src($row['path'], @$row['tn_ext']); 235 233 236 234 $name = $calendar_year.' ('.$nb_pics.')'; … … 267 265 { 268 266 $query = ' 269 SELECT file,tn_ext,'.$conf['calendar_datefield'].', storage_category_id267 SELECT file,tn_ext,'.$conf['calendar_datefield'].',path 270 268 FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE.' 271 269 '.$page['where'].' … … 278 276 $row = mysql_fetch_array(pwg_query($query)); 279 277 280 $thumbnail_src = get_thumbnail_src($row['file'], 281 $row['storage_category_id'], 282 @$row['tn_ext']); 278 $thumbnail_src = get_thumbnail_src($row['path'], @$row['tn_ext']); 283 279 284 280 $name = $lang['month'][$calendar_month]; … … 323 319 { 324 320 $query = ' 325 SELECT file,tn_ext,'.$conf['calendar_datefield'].', storage_category_id321 SELECT file,tn_ext,'.$conf['calendar_datefield'].',path 326 322 FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE.' 327 323 '.$page['where'].' … … 333 329 $row = mysql_fetch_array(pwg_query($query)); 334 330 335 $thumbnail_src = get_thumbnail_src($row['file'], 336 $row['storage_category_id'], 337 @$row['tn_ext']); 331 $thumbnail_src = get_thumbnail_src($row['path'], @$row['tn_ext']); 338 332 339 333 list($year,$month,$day) = explode('-', $calendar_day); … … 386 380 387 381 $query = ' 388 SELECT file,tn_ext,'.$conf['calendar_datefield'].', storage_category_id382 SELECT file,tn_ext,'.$conf['calendar_datefield'].',path 389 383 FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE.' 390 384 '.$page['where'].' … … 402 396 $row = mysql_fetch_array(pwg_query($query)); 403 397 404 $thumbnail_src = get_thumbnail_src($row['file'], 405 $row['storage_category_id'], 406 @$row['tn_ext']); 398 $thumbnail_src = get_thumbnail_src($row['path'], @$row['tn_ext']); 407 399 408 400 $thumbnail_title = $lang['calendar_picture_hint'].$name; -
trunk/include/category_default.inc.php
r605 r606 39 39 40 40 $query = ' 41 SELECT DISTINCT(id), file,date_available,category_id41 SELECT DISTINCT(id),path,file,date_available,category_id 42 42 ,tn_ext,name,filesize,storage_category_id,average_rate 43 43 FROM '.IMAGES_TABLE.' AS i … … 81 81 } 82 82 83 $thumbnail_url = get_thumbnail_src($row['file'], 84 $row['storage_category_id'], 85 @$row['tn_ext']); 83 $thumbnail_url = get_thumbnail_src($row['path'], @$row['tn_ext']); 86 84 87 85 // message in title for the thumbnail -
trunk/include/category_recent_cats.inc.php
r593 r606 67 67 68 68 $query = ' 69 SELECT id,file,tn_ext,storage_category_id69 SELECT path,file,tn_ext 70 70 FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE.' 71 71 WHERE category_id = '.$row['category_id'].' … … 76 76 LIMIT 0,1 77 77 ;'; 78 $subrow = mysql_fetch_array( pwg_query( $query ));78 $subrow = mysql_fetch_array(pwg_query($query)); 79 79 80 $thumbnail_src = get_thumbnail_src($subrow['file'], 81 $subrow['storage_category_id'], 82 @$subrow['tn_ext']); 80 $thumbnail_src = get_thumbnail_src($subrow['path'], @$subrow['tn_ext']); 83 81 84 82 $url_link = PHPWG_ROOT_PATH.'category.php?cat='.$row['category_id']; -
trunk/include/category_subcats.inc.php
r593 r606 65 65 66 66 $query = ' 67 SELECT file, tn_ext,storage_category_id67 SELECT file,path,tn_ext 68 68 FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE.' 69 69 WHERE category_id = '.$non_empty_id.' … … 87 87 $image_row = mysql_fetch_array($image_result); 88 88 89 $thumbnail_link = get_thumbnail_src($image_row['file'], 90 $image_row['storage_category_id'], 89 $thumbnail_link = get_thumbnail_src($image_row['path'], 91 90 @$image_row['tn_ext']); 92 91 -
trunk/include/functions.inc.php
r599 r606 571 571 * given element 572 572 * 573 * this function could have taken only the element id as parameter but to574 * optimize database access we directly ask file, storage category575 * identifier and extension since when this function is called,576 * PhpWebGallery should have all these infos. No need to retrieve them577 * another time in the database.578 *579 573 * the returned string can represente the filepath of the thumbnail or the 580 574 * filepath to the corresponding icon for non picture elements 581 575 * 582 * complete directories are cached to be used more than once during a page 583 * generation (many thumbnails of the same category on the same page) 584 * 585 * @param string file 586 * @param int storage_category_id 576 * @param string path 587 577 * @param string tn_ext 588 578 * @return string 589 579 */ 590 function get_thumbnail_src($file, $storage_category_id, $tn_ext = '') 591 { 592 global $conf, $user, $array_cat_directories; 593 594 if (!isset($array_cat_directories[$storage_category_id])) 595 { 596 $array_cat_directories[$storage_category_id] = 597 get_complete_dir($storage_category_id); 598 } 599 580 function get_thumbnail_src($path, $tn_ext = '') 581 { 582 global $conf, $user; 583 600 584 if ($tn_ext != '') 601 585 { 602 $src = $array_cat_directories[$storage_category_id]; 603 $src.= 'thumbnail/'.$conf['prefix_thumbnail']; 604 $src.= get_filename_wo_extension($file); 586 $src = substr_replace(get_filename_wo_extension($path), 587 '/thumbnail/'.$conf['prefix_thumbnail'], 588 strrpos($path,'/'), 589 1); 605 590 $src.= '.'.$tn_ext; 606 591 } … … 609 594 $src = PHPWG_ROOT_PATH; 610 595 $src.= 'template/'.$user['template'].'/mimetypes/'; 611 $src.= strtolower(get_extension($ file)).'.png';612 } 613 596 $src.= strtolower(get_extension($path)).'.png'; 597 } 598 614 599 return $src; 615 600 } -
trunk/install/dbscheme.txt
r602 r606 72 72 column:date_metadata_update table:images type:date nullable:Y 73 73 column:average_rate table:images type:float nullable:Y length:5,2 signed:N 74 column:path table:images type:varchar nullable:N length:255 binary:N 74 75 column:user_id table:rate type:smallint nullable:N length:5 signed:N 75 76 column:element_id table:rate type:mediumint nullable:N length:8 signed:N -
trunk/install/phpwebgallery_structure.sql
r602 r606 141 141 date_metadata_update date default NULL, 142 142 average_rate float(5,2) unsigned default NULL, 143 path varchar(255) NOT NULL default '', 143 144 PRIMARY KEY (id), 144 145 KEY images_i2 (date_available), -
trunk/picture.php
r605 r606 143 143 } 144 144 145 if ( !isset($array_cat_directories[$row['storage_category_id']])) 146 { 147 $array_cat_directories[$row['storage_category_id']] = 148 get_complete_dir( $row['storage_category_id'] ); 149 } 150 $cat_directory = $array_cat_directories[$row['storage_category_id']]; 145 $cat_directory = dirname($row['path']); 151 146 $file_wo_ext = get_filename_wo_extension($row['file']); 152 147 … … 166 161 if ($picture[$i]['is_picture']) 167 162 { 168 $picture[$i]['src'] = $ cat_directory.$row['file'];163 $picture[$i]['src'] = $row['path']; 169 164 // if we are working on the "current" element, we search if there is a 170 165 // high quality picture … … 182 177 if (!$picture[$i]['is_picture']) 183 178 { 184 $picture[$i]['download'] = $cat_directory.$row['file']; 185 } 186 187 $picture[$i]['thumbnail'] = get_thumbnail_src($row['file'], 188 $row['storage_category_id'], 189 @$row['tn_ext']); 179 $picture[$i]['download'] = $row['path']; 180 } 181 182 $picture[$i]['thumbnail'] = get_thumbnail_src($row['path'], @$row['tn_ext']); 190 183 191 184 if ( !empty( $row['name'] ) ) -
trunk/tools/create_listing_file.php
r593 r606 311 311 function get_pictures($dir, $indent) 312 312 { 313 global $conf ;313 global $conf, $page; 314 314 315 315 // fs means FileSystem : $fs_files contains files in the filesystem found … … 322 322 323 323 $elements = array(); 324 325 $print_dir = preg_replace('/^\.\//', '', $dir); 326 $print_dir = preg_replace('/\/*$/', '/', $print_dir); 324 327 325 328 foreach ($fs_files as $fs_file) … … 327 330 $element = array(); 328 331 $element['file'] = $fs_file; 332 $element['path'] = $page['url'].$print_dir.$fs_file; 329 333 $element['filesize'] = floor(filesize($dir.'/'.$fs_file) / 1024); 330 334 … … 421 425 $attributes = array('file','tn_ext','representative_ext','filesize', 422 426 'width','height','date_creation','author','keywords', 423 'name','comment' );427 'name','comment','path'); 424 428 foreach ($elements as $element) 425 429 { … … 464 468 $end = strrpos($_SERVER['PHP_SELF'], '/') + 1; 465 469 $local_folder = substr($_SERVER['PHP_SELF'], 0, $end); 466 $ url= 'http://'.$_SERVER['HTTP_HOST'].$local_folder;470 $page['url'] = 'http://'.$_SERVER['HTTP_HOST'].$local_folder; 467 471 468 $listing.= ' url="'.$ url.'"';472 $listing.= ' url="'.$page['url'].'"'; 469 473 $listing.= '/>'."\n"; 470 474
Note: See TracChangeset
for help on using the changeset viewer.