add rating feature

git-svn-id: http://piwigo.org/svn/trunk@507 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
z0rglub 2004-08-30 22:00:46 +00:00
commit 0e2436f50a
11 changed files with 276 additions and 64 deletions

View file

@ -54,7 +54,7 @@ $conf['file_ext'] = array('jpg','JPG','png','PNG','gif','GIF'
,'mpg','zip','avi','mp3','ogg');
// $conf['picture_ext'] must bea subset of $conf['file_ext']
$conf['picture_ext'] = array('jpg','JPG','png','PNG','gif','GIF');
$conf['top_number'] = 10;
$conf['top_number'] = 10; // used for "best rated" and "most visited"
$conf['anti-flood_time'] = 60; // seconds between 2 comments : 0 to disable
$conf['max_LOV_categories'] = 50;
@ -90,4 +90,5 @@ $conf['show_exif_fields'] = array('Make',
// $conf['show_exif_fields'] = array('CameraMake','CameraModel','DateTime');
$conf['calendar_datefield'] = 'date_creation';
$conf['rate'] = true;
?>

View file

@ -58,4 +58,5 @@ define('USER_GROUP_TABLE', $table_prefix.'user_group');
define('USERS_TABLE', $table_prefix.'users');
define('WAITING_TABLE', $table_prefix.'waiting');
define('IMAGE_METADATA_TABLE', $table_prefix.'image_metadata');
define('RATE_TABLE', $table_prefix.'rate');
?>

View file

@ -505,4 +505,38 @@ function redirect( $url )
exit();
}
/**
* returns $_SERVER['QUERY_STRING'] whitout keys given in parameters
*
* @param array $rejects
* @returns string
*/
function get_query_string_diff($rejects = array())
{
$query_string = '';
$str = $_SERVER['QUERY_STRING'];
parse_str($str, $vars);
$is_first = true;
foreach ($vars as $key => $value)
{
if (!in_array($key, $rejects))
{
if ($is_first)
{
$query_string.= '?';
$is_first = false;
}
else
{
$query_string.= '&';
}
$query_string.= $key.'='.$value;
}
}
return $query_string;
}
?>

View file

@ -724,6 +724,44 @@ SELECT COUNT(DISTINCT(id)) AS nb_total_images
$page['where'].= ' AND '.$forbidden;
}
}
else if ($page['cat'] == 'best_rated')
{
$page['title'] = $conf['top_number'].' '.$lang['best_rated_cat'];
$page['where'] = ' WHERE average_rate IS NOT NULL';
if (isset($forbidden))
{
$page['where'] = ' AND '.$forbidden;
}
$conf['order_by'] = ' ORDER BY average_rate DESC, id ASC';
// $page['cat_nb_images'] equals $conf['top_number'] unless there
// are less rated items
$query ='
SELECT COUNT(1) AS count
FROM '.IMAGES_TABLE.'
'.$page['where'].'
;';
$row = mysql_fetch_array(mysql_query($query));
if ($row['count'] < $conf['top_number'])
{
$page['cat_nb_images'] = $row['count'];
}
else
{
$page['cat_nb_images'] = $conf['top_number'];
}
unset($query);
if (isset($page['start'])
and ($page['start']+$user['nb_image_page']>=$conf['top_number']))
{
$page['nb_image_page'] = $conf['top_number'] - $page['start'];
}
}
if (isset($query))
{