aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/config.inc.php3
-rw-r--r--include/constants.php1
-rw-r--r--include/functions.inc.php34
-rw-r--r--include/functions_category.inc.php38
4 files changed, 75 insertions, 1 deletions
diff --git a/include/config.inc.php b/include/config.inc.php
index 269cd123a..f33e53ba3 100644
--- a/include/config.inc.php
+++ b/include/config.inc.php
@@ -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;
?>
diff --git a/include/constants.php b/include/constants.php
index 483965a9e..ccb2ecd34 100644
--- a/include/constants.php
+++ b/include/constants.php
@@ -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');
?>
diff --git a/include/functions.inc.php b/include/functions.inc.php
index c15149e20..df5b39e40 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -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;
+}
?> \ No newline at end of file
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index e82df1242..9a65ef997 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -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))
{