- Timestamp:
- Aug 31, 2004, 12:00:46 AM (20 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/category.php
r478 r507 126 126 'TITLE' => $template_title, 127 127 'USERNAME' => $user['username'], 128 'TOP_ VISITED'=>$conf['top_number'],128 'TOP_NUMBER'=>$conf['top_number'], 129 129 'MENU_CATEGORIES_CONTENT'=>$page['menu'], 130 130 … … 139 139 'L_MOST_VISITED_HINT' => $lang['most_visited_cat_hint'], 140 140 'L_MOST_VISITED' => $lang['most_visited_cat'], 141 'L_BEST_RATED_HINT' => $lang['best_rated_cat_hint'], 142 'L_BEST_RATED' => $lang['best_rated_cat'], 141 143 'L_RECENT_PICS_HINT' => $lang['recent_pics_cat_hint'], 142 144 'L_RECENT_PICS' => $lang['recent_pics_cat'], … … 167 169 'U_FAVORITE' => add_session_id( PHPWG_ROOT_PATH.'category.php?cat=fav' ), 168 170 'U_MOST_VISITED'=>add_session_id( PHPWG_ROOT_PATH.'category.php?cat=most_visited' ), 171 'U_BEST_RATED'=>add_session_id(PHPWG_ROOT_PATH.'category.php?cat=best_rated'), 169 172 'U_RECENT_PICS'=>add_session_id( PHPWG_ROOT_PATH.'category.php?cat=recent_pics' ), 170 173 'U_RECENT_CATS'=>add_session_id( PHPWG_ROOT_PATH.'category.php?cat=recent_cats' ), … … 229 232 or $page['cat'] == 'search' 230 233 or $page['cat'] == 'most_visited' 231 or $page['cat'] == 'recent_pics')) 234 or $page['cat'] == 'recent_pics' 235 or $page['cat'] == 'best_rated')) 232 236 { 233 237 include(PHPWG_ROOT_PATH.'include/category_default.inc.php'); -
trunk/include/config.inc.php
r505 r507 55 55 // $conf['picture_ext'] must bea subset of $conf['file_ext'] 56 56 $conf['picture_ext'] = array('jpg','JPG','png','PNG','gif','GIF'); 57 $conf['top_number'] = 10; 57 $conf['top_number'] = 10; // used for "best rated" and "most visited" 58 58 $conf['anti-flood_time'] = 60; // seconds between 2 comments : 0 to disable 59 59 $conf['max_LOV_categories'] = 50; … … 91 91 92 92 $conf['calendar_datefield'] = 'date_creation'; 93 $conf['rate'] = true; 93 94 ?> -
trunk/include/constants.php
r486 r507 59 59 define('WAITING_TABLE', $table_prefix.'waiting'); 60 60 define('IMAGE_METADATA_TABLE', $table_prefix.'image_metadata'); 61 define('RATE_TABLE', $table_prefix.'rate'); 61 62 ?> -
trunk/include/functions.inc.php
r496 r507 506 506 exit(); 507 507 } 508 509 /** 510 * returns $_SERVER['QUERY_STRING'] whitout keys given in parameters 511 * 512 * @param array $rejects 513 * @returns string 514 */ 515 function get_query_string_diff($rejects = array()) 516 { 517 $query_string = ''; 518 519 $str = $_SERVER['QUERY_STRING']; 520 parse_str($str, $vars); 521 522 $is_first = true; 523 foreach ($vars as $key => $value) 524 { 525 if (!in_array($key, $rejects)) 526 { 527 if ($is_first) 528 { 529 $query_string.= '?'; 530 $is_first = false; 531 } 532 else 533 { 534 $query_string.= '&'; 535 } 536 $query_string.= $key.'='.$value; 537 } 538 } 539 540 return $query_string; 541 } 508 542 ?> -
trunk/include/functions_category.inc.php
r503 r507 725 725 } 726 726 } 727 else if ($page['cat'] == 'best_rated') 728 { 729 $page['title'] = $conf['top_number'].' '.$lang['best_rated_cat']; 730 731 $page['where'] = ' WHERE average_rate IS NOT NULL'; 732 733 if (isset($forbidden)) 734 { 735 $page['where'] = ' AND '.$forbidden; 736 } 737 738 $conf['order_by'] = ' ORDER BY average_rate DESC, id ASC'; 739 740 // $page['cat_nb_images'] equals $conf['top_number'] unless there 741 // are less rated items 742 $query =' 743 SELECT COUNT(1) AS count 744 FROM '.IMAGES_TABLE.' 745 '.$page['where'].' 746 ;'; 747 $row = mysql_fetch_array(mysql_query($query)); 748 if ($row['count'] < $conf['top_number']) 749 { 750 $page['cat_nb_images'] = $row['count']; 751 } 752 else 753 { 754 $page['cat_nb_images'] = $conf['top_number']; 755 } 756 unset($query); 757 758 759 if (isset($page['start']) 760 and ($page['start']+$user['nb_image_page']>=$conf['top_number'])) 761 { 762 $page['nb_image_page'] = $conf['top_number'] - $page['start']; 763 } 764 } 727 765 728 766 if (isset($query)) -
trunk/install/dbscheme.txt
r487 r507 9 9 table:image_category 10 10 table:images 11 table:rate 11 12 table:sessions 12 13 table:sites … … 69 70 column:representative_ext table:images type:varchar nullable:N length:4 binary:N 70 71 column:date_metadata_update table:images type:date nullable:N 72 column:average_rate table:images type:float nullable:N length:5,2 signed:N 73 column:user_id table:rate type:smallint nullable:Y length:5 signed:N 74 column:element_id table:rate type:mediumint nullable:Y length:8 signed:N 75 column:rate table:rate type:tinyint nullable:Y length:2 signed:N 71 76 column:id table:sessions type:varchar nullable:Y length:255 binary:Y 72 77 column:user_id table:sessions type:smallint nullable:Y length:5 signed:N … … 115 120 PK:image_category_pk table:image_category column:category_id 116 121 PK:images_pk table:images column:id 122 PK:rate_pk table:rate column:user_id 123 PK:rate_pk table:rate column:element_id 117 124 PK:sessions_pk table:sessions column:id 118 125 PK:sites_pk table:sites column:id -
trunk/install/phpwebgallery_structure.sql
r486 r507 138 138 representative_ext varchar(4) default NULL, 139 139 date_metadata_update date default NULL, 140 average_rate float(5,2) unsigned default NULL, 140 141 PRIMARY KEY (id), 141 142 KEY images_i2 (date_available), 142 143 KEY images_i1 (storage_category_id) 144 ) TYPE=MyISAM; 145 146 -- 147 -- Table structure for table 'phpwebgallery_rate' 148 -- 149 150 DROP TABLE IF EXISTS phpwebgallery_rate; 151 CREATE TABLE phpwebgallery_rate ( 152 user_id smallint(5) unsigned NOT NULL default '0', 153 element_id mediumint(8) unsigned NOT NULL default '0', 154 rate tinyint(2) unsigned NOT NULL default '0', 155 PRIMARY KEY (user_id,element_id) 143 156 ) TYPE=MyISAM; 144 157 -
trunk/language/en_UK.iso-8859-1/common.lang.php
r499 r507 232 232 $lang['most_visited_cat_hint'] = 'displays most visited pictures'; 233 233 $lang['most_visited_cat'] = 'most visited'; 234 $lang['best_rated_cat_hint'] = 'displays pictures best rated';235 234 $lang['best_rated_cat'] = 'best rated'; 235 $lang['best_rated_cat_hint'] = 'displays best rated items'; 236 236 $lang['recent_pics_cat_hint'] = 'Displays most recent pictures'; 237 237 $lang['recent_pics_cat'] = 'Last pictures'; … … 280 280 $lang['picture_show_metadata'] = 'Show file metadata ?'; 281 281 $lang['picture_hide_metadata'] = 'Hide file metadata'; 282 $lang['to_rate'] = 'Rate'; 283 $lang['update_rate'] = 'Update your rating'; 284 $lang['element_rate'] = 'rate'; 285 $lang['already_rated'] = 'You\'ve already rated this item'; 286 $lang['never_rated'] = 'You\'ve never rated this item'; 287 $lang['no_rate'] = 'no rate'; 288 $lang['rates'] = 'rates'; 289 $lang['standard_deviation'] = 'STD'; 282 290 ?> -
trunk/picture.php
r496 r507 26 26 // +-----------------------------------------------------------------------+ 27 27 28 //----------------------------------------------------------- include 28 $rate_items = array(0,1,2,3,4,5); 29 //--------------------------------------------------------------------- include 29 30 define('PHPWG_ROOT_PATH','./'); 30 31 include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); … … 192 193 } 193 194 194 $picture[$i]['url'] = PHPWG_ROOT_PATH.'picture.php?image_id='.$row['id']; 195 $picture[$i]['url'].= '&cat='.$page['cat']; 196 if ( $page['cat'] == 'search' ) 197 { 198 $picture[$i]['url'].= '&search='.$_GET['search']; 199 } 200 if (isset($_GET['show_metadata'])) 201 { 202 $picture[$i]['url'].= '&show_metadata=1'; 203 } 195 $picture[$i]['url'] = PHPWG_ROOT_PATH.'picture.php'; 196 $picture[$i]['url'].= get_query_string_diff(array('image_id','add_fav')); 197 $picture[$i]['url'].= '&image_id='.$row['id']; 204 198 } 205 199 … … 214 208 $url_admin.= '&cat_id='.$page['cat']; 215 209 $url_admin.= '&image_id='.$_GET['image_id']; 216 210 //----------------------------------------------------------- rate registration 211 if (isset($_GET['rate']) 212 and $conf['rate'] 213 and !$user['is_the_guest'] 214 and in_array($_GET['rate'], $rate_items)) 215 { 216 $query = ' 217 DELETE 218 FROM '.RATE_TABLE.' 219 WHERE user_id = '.$user['id'].' 220 AND element_id = '.$_GET['image_id'].' 221 ;'; 222 mysql_query($query); 223 $query = ' 224 INSERT INTO '.RATE_TABLE.' 225 (user_id,element_id,rate) 226 VALUES 227 ('.$user['id'].','.$_GET['image_id'].','.$_GET['rate'].') 228 ;'; 229 mysql_query($query); 230 231 // update of images.average_rate field 232 $query = ' 233 SELECT ROUND(AVG(rate),2) AS average_rate 234 FROM '.RATE_TABLE.' 235 WHERE element_id = '.$_GET['image_id'].' 236 ;'; 237 $row = mysql_fetch_array(mysql_query($query)); 238 $query = ' 239 UPDATE '.IMAGES_TABLE.' 240 SET average_rate = '.$row['average_rate'].' 241 WHERE id = '.$_GET['image_id'].' 242 ;'; 243 mysql_query($query); 244 } 217 245 //--------------------------------------------------------- favorite management 218 246 if ( isset( $_GET['add_fav'] ) ) … … 537 565 if (empty($picture['current']['filesize'])) 538 566 { 539 if (!$picture[ $i]['is_picture'])567 if (!$picture['current']['is_picture']) 540 568 { 541 569 $filesize = floor(filesize($picture['current']['download'])/1024); … … 573 601 } 574 602 // number of visits 575 $template->assign_block_vars('info_line', array( 603 $template->assign_block_vars( 604 'info_line', 605 array( 576 606 'INFO'=>$lang['visited'], 577 607 'VALUE'=>$picture['current']['hit'].' '.$lang['times'] 578 608 )); 609 // rate results 610 if ($conf['rate']) 611 { 612 $query = ' 613 SELECT COUNT(rate) AS count 614 , ROUND(AVG(rate),2) AS average 615 , ROUND(STD(rate),2) AS STD 616 FROM '.RATE_TABLE.' 617 WHERE element_id = '.$picture['current']['id'].' 618 ;'; 619 $row = mysql_fetch_array(mysql_query($query)); 620 if ($row['count'] == 0) 621 { 622 $value = $lang['no_rate']; 623 } 624 else 625 { 626 $value = $row['average']; 627 $value.= ' ('; 628 $value.= $row['count'].' '.$lang['rates']; 629 $value.= ', '.$lang['standard_deviation'].' : '.$row['STD']; 630 $value.= ')'; 631 } 632 633 $template->assign_block_vars( 634 'info_line', 635 array( 636 'INFO' => $lang['element_rate'], 637 'VALUE' => $value 638 )); 639 } 579 640 //-------------------------------------------------------------------- metadata 580 641 if ($conf['show_exif'] or $conf['show_iptc']) … … 597 658 { 598 659 $url = PHPWG_ROOT_PATH.'picture.php'; 599 600 $str = $_SERVER['QUERY_STRING']; 601 parse_str($str, $get_vars); 602 $is_first = true; 603 foreach ($get_vars as $key => $value) 604 { 605 if ($key != 'show_metadata') 606 { 607 if ($is_first) 608 { 609 $url.= '?'; 610 $is_first = false; 611 } 612 else 613 { 614 $url.= '&'; 615 } 616 $url.= $key.'='.$value; 617 } 618 } 660 $url.= get_query_string_diff(array('show_metadata','add_fav')); 619 661 620 662 $template->assign_block_vars('hide_metadata', array('URL' => $url)); … … 709 751 } 710 752 } 753 //------------------------------------------------------------------- rate form 754 if ($conf['rate']) 755 { 756 $query = ' 757 SELECT rate 758 FROM '.RATE_TABLE.' 759 WHERE user_id = '.$user['id'].' 760 AND element_id = '.$_GET['image_id'].' 761 ;'; 762 $result = mysql_query($query); 763 if (mysql_num_rows($result) > 0) 764 { 765 $row = mysql_fetch_array($result); 766 $sentence = $lang['already_rated']; 767 $sentence.= ' ('.$row['rate'].'). '; 768 $sentence.= $lang['update_rate']; 769 } 770 else 771 { 772 $sentence = $lang['never_rated'].'. '.$lang['to_rate']; 773 } 774 $template->assign_block_vars( 775 'rate', 776 array('SENTENCE' => $sentence) 777 ); 778 779 780 foreach ($rate_items as $num => $mark) 781 { 782 if ($num > 0) 783 { 784 $separator = '|'; 785 } 786 else 787 { 788 $separator = ''; 789 } 790 791 $url = PHPWG_ROOT_PATH.'picture.php'; 792 $url.= get_query_string_diff(array('rate','add_fav')); 793 $url.= '&rate='.$mark; 794 795 $template->assign_block_vars( 796 'rate.rate_option', 797 array( 798 'OPTION' => $mark, 799 'URL' => $url, 800 'SEPARATOR' => $separator 801 )); 802 } 803 } 711 804 //------------------------------------------------------- favorite manipulation 712 805 if ( !$user['is_the_guest'] ) … … 720 813 if (!$row['nb_fav']) 721 814 { 722 $url = PHPWG_ROOT_PATH.'picture.php ?cat='.$page['cat'].'&image_id='.$_GET['image_id'];723 $url.= '&add_fav=1';724 if ( $page['cat'] == 'search' )725 { 726 $url.= '&search='.$_GET['search'];727 }728 $template->assign_block_vars('favorite',array(729 'FAVORITE_IMG' => PHPWG_ROOT_PATH.'template/'.$user['template'].'/theme/favorite.gif',730 731 732 'U_FAVORITE'=> add_session_id( $url )733 ));815 $url = PHPWG_ROOT_PATH.'picture.php'; 816 $url.= get_query_string_diff(array('rate','add_fav')); 817 $url.= '&add_fav=1'; 818 819 $template->assign_block_vars( 820 'favorite', 821 array( 822 'FAVORITE_IMG' => PHPWG_ROOT_PATH.'template/'.$user['template'].'/theme/favorite.gif', 823 'FAVORITE_HINT' =>$lang['add_favorites_hint'], 824 'FAVORITE_ALT' =>'[ '.$lang['add_favorites_alt'].' ]', 825 'U_FAVORITE' => $url 826 )); 734 827 } 735 828 else 736 829 { 737 $url = PHPWG_ROOT_PATH.'picture.php?cat='.$page['cat'].'&image_id='.$_GET['image_id']; 830 $url = PHPWG_ROOT_PATH.'picture.php'; 831 $url.= get_query_string_diff(array('rate','add_fav')); 738 832 $url.= '&add_fav=0'; 739 $template->assign_block_vars('favorite', array( 740 'FAVORITE_IMG' => PHPWG_ROOT_PATH.'template/'.$user['template'].'/theme/del_favorite.gif', 741 'FAVORITE_HINT' =>$lang['del_favorites_hint'], 742 'FAVORITE_ALT' =>'[ '.$lang['del_favorites_alt'].' ]', 743 'U_FAVORITE'=> add_session_id( $url ) 744 )); 833 834 $template->assign_block_vars( 835 'favorite', 836 array( 837 'FAVORITE_IMG' => PHPWG_ROOT_PATH.'template/'.$user['template'].'/theme/del_favorite.gif', 838 'FAVORITE_HINT' =>$lang['del_favorites_hint'], 839 'FAVORITE_ALT' =>'[ '.$lang['del_favorites_alt'].' ]', 840 'U_FAVORITE'=> $url 841 )); 745 842 } 746 843 } … … 762 859 763 860 // navigation bar creation 764 $url = PHPWG_ROOT_PATH.'picture.php?cat='.$page['cat'].'&image_id='.$_GET['image_id']; 765 if ( $page['cat'] == 'search' ) 766 { 767 $url.= '&search='.$_GET['search']; 768 } 769 if( !isset( $_GET['start'] ) 861 $url = PHPWG_ROOT_PATH.'picture.php'; 862 $url.= get_query_string_diff(array('rate','add_fav')); 863 864 if (!isset( $_GET['start'] ) 770 865 or !is_numeric( $_GET['start'] ) 771 866 or ( is_numeric( $_GET['start'] ) and $_GET['start'] < 0 ) ) -
trunk/template/default/category.tpl
r478 r507 19 19 <li><span style="font-weight:bold;">{L_SPECIAL_CATEGORIES}</span></li> 20 20 <ul class="menu"> 21 <li><a href="{U_MOST_VISITED}"><span title="{L_MOST_VISITED_HINT}">{TOP_VISITED} {L_MOST_VISITED}</span></a></li> 21 <li><a href="{U_MOST_VISITED}"><span title="{L_MOST_VISITED_HINT}">{TOP_NUMBER} {L_MOST_VISITED}</span></a></li> 22 <li><a href="{U_BEST_RATED}"><span title="{L_BEST_RATED_HINT}">{TOP_NUMBER} {L_BEST_RATED}</span></a></li> 22 23 <li><a href="{U_RECENT_PICS}"><span title="{L_RECENT_PICS_HINT}">{L_RECENT_PICS}</span></a> {T_SHORT}</li> 23 24 <li><a href="{U_RECENT_CATS}"><span title="{L_RECENT_CATS_HINT}">{L_RECENT_CATS}</span></a></li> -
trunk/template/default/picture.tpl
r493 r507 94 94 </table> 95 95 <!-- END metadata --> 96 97 <!-- BEGIN rate --> 98 <div> 99 {rate.SENTENCE} : 100 <!-- BEGIN rate_option --> 101 {rate.rate_option.SEPARATOR} <a href="{rate.rate_option.URL}">{rate.rate_option.OPTION}</a> 102 <!-- END rate_option --> 103 </div> 104 <!-- END rate --> 105 96 106 <!-- BEGIN modification --> 97 107 <div class="menu" style="text-align:center;margin:5px;">
Note: See TracChangeset
for help on using the changeset viewer.