diff options
Diffstat (limited to '')
-rw-r--r-- | include/category_default.inc.php | 12 | ||||
-rw-r--r-- | include/functions_category.inc.php | 27 |
2 files changed, 34 insertions, 5 deletions
diff --git a/include/category_default.inc.php b/include/category_default.inc.php index 409829282..6eba15e8c 100644 --- a/include/category_default.inc.php +++ b/include/category_default.inc.php @@ -38,7 +38,7 @@ $array_cat_directories = array(); $query = ' -SELECT DISTINCT(id),file,date_available +SELECT DISTINCT(id),file,date_available,category_id ,tn_ext,name,filesize,storage_category_id,average_rate FROM '.IMAGES_TABLE.' AS i INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id=ic.image_id @@ -113,7 +113,15 @@ while ($row = mysql_fetch_array($result)) } $thumbnail_title .= ' : '.$filesize.' KB'; // url link on picture.php page - $url_link = PHPWG_ROOT_PATH.'picture.php?cat='.$page['cat']; + $url_link = PHPWG_ROOT_PATH.'picture.php?'; + if ($page['cat'] == 'random') + { + $url_link.= 'cat='.$row['category_id']; + } + else + { + $url_link.= 'cat='.$page['cat']; + } $url_link.= '&image_id='.$row['id']; if ($page['cat'] == 'search') { diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php index 9a65ef997..c9485d17b 100644 --- a/include/functions_category.inc.php +++ b/include/functions_category.inc.php @@ -65,7 +65,8 @@ function check_restrictions( $category_id ) * - equals 'best_rated' * - equals 'recent_pics' * - equals 'recent_cats' - * _ equals 'calendar' + * - equals 'calendar' + * - equals 'random' * * The function fills the global var $page['cat'] and returns nothing * @@ -98,7 +99,8 @@ function check_cat_id( $cat ) or $cat == 'best_rated' or $cat == 'recent_pics' or $cat == 'recent_cats' - or $cat == 'calendar' ) + or $cat == 'calendar' + or $cat == 'random' ) { $page['cat'] = $cat; } @@ -414,6 +416,7 @@ function get_site_url( $category_id ) // - most visited pictures // - best rated pictures // - recent pictures +// - random pictures // 3. determination of the title of the page // 4. creation of the navigation bar function initialize_category( $calling_page = 'category' ) @@ -732,7 +735,7 @@ SELECT COUNT(DISTINCT(id)) AS nb_total_images if (isset($forbidden)) { - $page['where'] = ' AND '.$forbidden; + $page['where'].= ' AND '.$forbidden; } $conf['order_by'] = ' ORDER BY average_rate DESC, id ASC'; @@ -762,6 +765,24 @@ SELECT COUNT(1) AS count $page['nb_image_page'] = $conf['top_number'] - $page['start']; } } + else if ($page['cat'] == 'random') + { + $page['title'] = $lang['random_cat']; + + if (isset($forbidden)) + { + $page['where'] = 'WHERE '.$forbidden; + } + else + { + $page['where'] = 'WHERE 1=1'; + } + + $conf['order_by'] = ' ORDER BY RAND()'; + + $page['cat_nb_images'] = $conf['top_number']; + $page['nb_image_page'] = $page['cat_nb_images']; + } if (isset($query)) { |