Changeset 847 for trunk/picture.php
- Timestamp:
- Aug 21, 2005, 1:32:12 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/picture.php
r811 r847 96 96 FROM '.IMAGE_CATEGORY_TABLE.' 97 97 INNER JOIN '.CATEGORIES_TABLE.' ON category_id = id 98 WHERE image_id = '.$_GET['image_id']; 99 if ($user['forbidden_categories'] != '') 100 { 101 $query.= ' 102 AND category_id NOT IN ('.$user['forbidden_categories'].')'; 103 } 104 $query.= ' 98 WHERE image_id = '.$_GET['image_id'].' 99 AND category_id NOT IN ('.$user['forbidden_categories'].') 105 100 ;'; 106 101 $result = pwg_query($query); … … 488 483 } 489 484 490 // author491 $author = $creation_date = $size = $filesize = $lang['unavailable'];492 if ( !empty($picture['current']['author']) )493 {494 $search_url = PHPWG_ROOT_PATH.'category.php?cat=search';495 $search_url.= '&search=author:'.$picture['current']['author'];496 497 $author = '<a href="';498 $author .= add_session_id($search_url);499 $author .= '">'.$picture['current']['author'].'</a>';500 }501 502 // creation date503 if ( !empty($picture['current']['date_creation']) )504 {505 $creation_date = format_date($picture['current']['date_creation']);506 }507 508 // date of availability509 $availability_date = format_date($picture['current']['date_available'],510 'mysql_datetime');511 512 // size in pixels513 if ($picture['current']['is_picture'])514 {515 if ($original_width != $picture_size[0]516 or $original_height != $picture_size[1])517 {518 $size = '[ <a href="'.$picture['current']['src'].'" ';519 $size .= ' title="'.$lang['true_size'].'">';520 $size .= $original_width.'*'.$original_height.'</a> ]';521 }522 else523 {524 $size = $original_width.'*'.$original_height;525 }526 }527 528 // filesize529 if (empty($picture['current']['filesize']))530 {531 if (!$picture['current']['is_picture'])532 {533 $filesize = floor(filesize($picture['current']['download'])/1024);534 }535 else536 {537 $filesize = floor(filesize($picture['current']['src'])/1024);538 }539 }540 else541 {542 $filesize = $picture['current']['filesize'];543 }544 545 // number of visits546 $template->assign_block_vars(547 'info_line',548 array(549 'INFO'=>$lang['visited'],550 'VALUE'=>$picture['current']['hit'].' '.$lang['times']551 ));552 553 485 include(PHPWG_ROOT_PATH.'include/page_header.php'); 554 486 $template->set_filenames(array('picture'=>'picture.tpl')); … … 562 494 'WIDTH_IMG' => $picture_size[0], 563 495 'HEIGHT_IMG' => $picture_size[1], 564 'AUTHOR' => $author,565 'CREATION_DATE' => $creation_date,566 'AVAILABILITY_DATE' => $availability_date,567 'SIZE' => $size,568 'FILE_SIZE' => $filesize,569 496 570 497 'LEVEL_SEPARATOR' => $conf['level_separator'], … … 581 508 'L_DELETE' =>$lang['delete'], 582 509 'L_SUBMIT' =>$lang['submit'], 583 'L_AUTHOR' =>$lang['author'],584 510 'L_COMMENT' =>$lang['comment'], 585 511 'L_DOWNLOAD' => $lang['download'], … … 589 515 'L_UP_HINT' => $lang['home_hint'], 590 516 'L_UP_ALT' => $lang['home'], 591 'L_CREATION_DATE' => $lang['creation_date'],592 'L_AVAILABILITY_DATE' => $lang['registration_date'],593 'L_SIZE' => $lang['size'],594 'L_FILE' => $lang['file'],595 'L_FILE_SIZE' => $lang['size'],596 517 597 518 'U_HOME' => add_session_id(PHPWG_ROOT_PATH.'category.php'), … … 731 652 } 732 653 654 $infos = array(); 655 656 // author 657 if (!empty($picture['current']['author'])) 658 { 659 $infos['INFO_AUTHOR'] = 660 '<a href="'. 661 add_session_id( 662 PHPWG_ROOT_PATH.'category.php?cat=search'. 663 '&search=author:'.$picture['current']['author'] 664 ). 665 '">'.$picture['current']['author'].'</a>'; 666 } 667 else 668 { 669 $infos['INFO_AUTHOR'] = l10n('N/A'); 670 } 671 672 // creation date 673 if (!empty($picture['current']['date_creation'])) 674 { 675 $infos['INFO_CREATION_DATE'] = 676 '<a href="'. 677 add_session_id( 678 PHPWG_ROOT_PATH.'category.php?cat=search'. 679 '&search=date_creation:'.$picture['current']['date_creation'] 680 ). 681 '">'.format_date($picture['current']['date_creation']).'</a>'; 682 } 683 else 684 { 685 $infos['INFO_CREATION_DATE'] = l10n('N/A'); 686 } 687 688 // date of availability 689 $infos['INFO_AVAILABILITY_DATE'] = 690 '<a href="'. 691 add_session_id( 692 PHPWG_ROOT_PATH.'category.php?cat=search'. 693 '&search=date_available:'. 694 substr($picture['current']['date_available'], 0, 10) 695 ). 696 '">'. 697 format_date($picture['current']['date_available'], 'mysql_datetime'). 698 '</a>'; 699 700 // size in pixels 701 if ($picture['current']['is_picture']) 702 { 703 if ($original_width != $picture_size[0] 704 or $original_height != $picture_size[1]) 705 { 706 $infos['INFO_DIMENSIONS'] = 707 '<a href="'.$picture['current']['src'].'" title="'. 708 l10n('Original dimensions').'">'. 709 $original_width.'*'.$original_height.'</a>'; 710 } 711 else 712 { 713 $infos['INFO_DIMENSIONS'] = $original_width.'*'.$original_height; 714 } 715 } 716 else 717 { 718 $infos['INFO_DIMENSIONS'] = l10n('N/A'); 719 } 720 721 // filesize 722 if (!empty($picture['current']['filesize'])) 723 { 724 $infos['INFO_FILESIZE'] = 725 sprintf(l10n('%d Kb'), $picture['current']['filesize']); 726 } 727 else 728 { 729 $infos['INFO_FILESIZE'] = l10n('N/A'); 730 } 731 732 // number of visits 733 $infos['INFO_VISITS'] = $picture['current']['hit']; 734 735 // file 736 $infos['INFO_FILE'] = $picture['current']['file']; 737 733 738 // keywords 734 739 if (!empty($picture['current']['keywords'])) 735 740 { 736 $keywords = explode(',', $picture['current']['keywords']); 737 $content = ''; 738 $url = PHPWG_ROOT_PATH.'category.php?cat=search&search=keywords:'; 739 foreach ($keywords as $i => $keyword) 740 { 741 $local_url = add_session_id($url.$keyword); 742 if ($i > 0) 743 { 744 $content.= ','; 745 } 746 $content.= '<a href="'.$local_url.'">'.$keyword.'</a>'; 747 } 741 $infos['INFO_KEYWORDS'] = 742 preg_replace( 743 '/([^,]+)/', 744 '<a href="'. 745 add_session_id( 746 PHPWG_ROOT_PATH.'category.php?cat=search&search=keywords:$1' 747 ). 748 '">$1</a>', 749 $picture['current']['keywords'] 750 ); 751 } 752 else 753 { 754 $infos['INFO_KEYWORDS'] = l10n('N/A'); 755 } 756 757 $template->assign_vars($infos); 758 759 // related categories 760 foreach ($related_categories as $category) 761 { 748 762 $template->assign_block_vars( 749 ' keywords',763 'category', 750 764 array( 751 'INFO'=>$lang['keywords'], 752 'VALUE'=>$content 753 )); 754 } 755 756 // related categories 757 $cat_output = ''; 758 $page['show_comments'] = false; 759 foreach ($related_categories as $category) 760 { 761 if ($cat_output != '') 762 { 763 $cat_output.= '<br />'; 764 } 765 766 if (count($related_categories) > 3) 767 { 768 $cat_output .= get_cat_display_name_cache($category['uppercats']); 769 } 770 else 771 { 772 $cat_info = get_cat_info($category['category_id']); 773 $cat_output .= get_cat_display_name($cat_info['name']); 774 } 775 // the picture is commentable if it belongs at least to one category which 776 // is commentable 777 if ($category['commentable'] == 'true') 778 { 779 $page['show_comments'] = true; 780 } 781 } 782 $template->assign_block_vars( 783 'associated', 784 array( 785 'INFO' => $lang['categories'], 786 'VALUE' => $cat_output 787 )); 765 'LINE' => count($related_categories) > 3 766 ? get_cat_display_name_cache($category['uppercats']) 767 : get_cat_display_name_from_id($category['category_id']) 768 ) 769 ); 770 } 788 771 789 772 //------------------------------------------------------------------- metadata … … 894 877 if ($conf['rate']) 895 878 { 896 $query = 'SELECT COUNT(rate) AS count 879 $query = ' 880 SELECT COUNT(rate) AS count 897 881 , ROUND(AVG(rate),2) AS average 898 882 , ROUND(STD(rate),2) AS STD … … 907 891 else 908 892 { 909 $value = $row['average']; 910 $value.= ' ('; 911 $value.= $row['count'].' '.$lang['rates']; 912 $value.= ', '.$lang['standard_deviation'].' : '.$row['STD']; 913 $value.= ')'; 893 $value = sprintf( 894 l10n('%.2f (rated %d times, standard deviation = %.2f)'), 895 $row['average'], 896 $row['count'], 897 $row['STD'] 898 ); 914 899 } 915 900 … … 935 920 'rate', 936 921 array( 937 'INFO' => $lang['element_rate'], 938 'VALUE' => $value, 922 'CONTENT' => $value, 939 923 'SENTENCE' => $sentence 940 924 )); 925 926 $template->assign_block_vars('info_rate', array('CONTENT' => $value)); 927 928 $template->assign_vars( 929 array( 930 'INFO_RATE' => $value 931 ) 932 ); 941 933 942 934 foreach ($rate_items as $num => $mark) … … 967 959 968 960 //---------------------------------------------------- users's comments display 961 962 // the picture is commentable if it belongs at least to one category which 963 // is commentable 964 $page['show_comments'] = false; 965 foreach ($related_categories as $category) 966 { 967 if ($category['commentable'] == 'true') 968 { 969 $page['show_comments'] = true; 970 } 971 } 972 969 973 if ($page['show_comments']) 970 974 {
Note: See TracChangeset
for help on using the changeset viewer.