- new special category : random pictures

- reorganisation of special categories menu : template is used only for
  template. A special category is presented as the template tells to do so.

- favorites becomes just another special category

- bug correction for best rated category : wrong MySQL query if user has
  forbidden categories (see include/functions_category.inc.php diff)


git-svn-id: http://piwigo.org/svn/trunk@510 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
z0rglub
2004-09-01 21:39:29 +00:00
parent f13b345dcf
commit 2dbc66da3b
5 changed files with 106 additions and 45 deletions
+65 -30
View File
@@ -133,19 +133,7 @@ $template->assign_vars(array(
'L_SUBCAT' => $lang['sub-cat'],
'L_IMG_AVAILABLE' => $lang['images_available'],
'L_TOTAL' => $lang['total'],
'L_FAVORITE_HINT' => $lang['favorite_cat_hint'],
'L_FAVORITE' => $lang['favorite_cat'],
'L_SPECIAL_CATEGORIES' => $lang['special_categories'],
'L_MOST_VISITED_HINT' => $lang['most_visited_cat_hint'],
'L_MOST_VISITED' => $lang['most_visited_cat'],
'L_BEST_RATED_HINT' => $lang['best_rated_cat_hint'],
'L_BEST_RATED' => $lang['best_rated_cat'],
'L_RECENT_PICS_HINT' => $lang['recent_pics_cat_hint'],
'L_RECENT_PICS' => $lang['recent_pics_cat'],
'L_RECENT_CATS_HINT' => $lang['recent_cats_cat_hint'],
'L_RECENT_CATS' => $lang['recent_cats_cat'],
'L_CALENDAR' => $lang['calendar'],
'L_CALENDAR_HINT' => $lang['calendar_hint'],
'L_SUMMARY' => $lang['title_menu'],
'L_UPLOAD' => $lang['upload_picture'],
'L_COMMENT' => $lang['comments'],
@@ -166,29 +154,73 @@ $template->assign_vars(array(
'T_RECENT' => $icon_recent,
'U_HOME' => add_session_id( PHPWG_ROOT_PATH.'category.php' ),
'U_FAVORITE' => add_session_id( PHPWG_ROOT_PATH.'category.php?cat=fav' ),
'U_MOST_VISITED'=>add_session_id( PHPWG_ROOT_PATH.'category.php?cat=most_visited' ),
'U_BEST_RATED'=>add_session_id(PHPWG_ROOT_PATH.'category.php?cat=best_rated'),
'U_RECENT_PICS'=>add_session_id( PHPWG_ROOT_PATH.'category.php?cat=recent_pics' ),
'U_RECENT_CATS'=>add_session_id( PHPWG_ROOT_PATH.'category.php?cat=recent_cats' ),
'U_CALENDAR'=>add_session_id( PHPWG_ROOT_PATH.'category.php?cat=calendar' ),
'U_LOGOUT' => PHPWG_ROOT_PATH.'category.php?act=logout',
'U_ADMIN'=>add_session_id( PHPWG_ROOT_PATH.'admin.php' ),
'U_PROFILE'=>add_session_id(PHPWG_ROOT_PATH.'profile.php?'.str_replace( '&', '&', $_SERVER['QUERY_STRING'] ))
)
);
// authentification mode management
//---------------------------------------------------------- special categories
// favorites categories
if ( !$user['is_the_guest'] )
{
// searching the number of favorite picture
$query = 'SELECT COUNT(*) AS count';
$query.= ' FROM '.FAVORITES_TABLE.' WHERE user_id = '.$user['id'].';';
$result = mysql_query( $query );
$row = mysql_fetch_array( $result );
$template->assign_block_vars('favorites', array ('NB_FAV'=>$row['count']) );
$template->assign_block_vars('username', array());
$template->assign_block_vars(
'special_cat',
array(
'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=fav'),
'TITLE' => $lang['favorite_cat_hint'],
'NAME' => $lang['favorite_cat']
));
}
// most visited
$template->assign_block_vars(
'special_cat',
array(
'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=most_visited'),
'TITLE' => $lang['most_visited_cat_hint'],
'NAME' => $conf['top_number'].' '.$lang['most_visited_cat']
));
// best rated
$template->assign_block_vars(
'special_cat',
array(
'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=best_rated'),
'TITLE' => $lang['best_rated_cat_hint'],
'NAME' => $conf['top_number'].' '.$lang['best_rated_cat']
));
// random
$template->assign_block_vars(
'special_cat',
array(
'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=random'),
'TITLE' => $lang['random_cat_hint'],
'NAME' => $lang['random_cat']
));
// recent pics
$template->assign_block_vars(
'special_cat',
array(
'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=recent_pics'),
'TITLE' => $lang['recent_pics_cat_hint'],
'NAME' => $lang['recent_pics_cat']
));
// recent cats
$template->assign_block_vars(
'special_cat',
array(
'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=recent_cats'),
'TITLE' => $lang['recent_cats_cat_hint'],
'NAME' => $lang['recent_cats_cat']
));
// calendar
$template->assign_block_vars(
'special_cat',
array(
'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=calendar'),
'TITLE' => $lang['calendar_hint'],
'NAME' => $lang['calendar']
));
//--------------------------------------------------------------------- summary
if ( !$user['is_the_guest'] )
@@ -229,10 +261,13 @@ $template->assign_block_vars('summary', array(
//------------------------------------------------------ main part : thumbnails
if (isset($page['cat'])
and ((is_numeric($page['cat']) and $page['cat_nb_images'] != 0)
or $page['cat'] == 'search'
or $page['cat'] == 'most_visited'
or $page['cat'] == 'recent_pics'
or $page['cat'] == 'best_rated'))
or in_array($page['cat'],
array('search'
,'most_visited'
,'recent_pics'
,'best_rated'
,'random'
))))
{
include(PHPWG_ROOT_PATH.'include/category_default.inc.php');
}
+10 -2
View File
@@ -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')
{
+24 -3
View File
@@ -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))
{
+4 -2
View File
@@ -132,8 +132,8 @@ $lang['change_login'] = 'change login';
$lang['hint_login'] = 'identification enables site\'s appareance customization';
$lang['hint_customize'] = 'customize the appareance of the gallery';
$lang['hint_search'] = 'search';
$lang['favorite_cat'] = 'favorites';
$lang['favorite_cat_hint'] = 'display your favorites';
$lang['favorite_cat'] = 'my favorites';
$lang['favorite_cat_hint'] = 'display my favorites pictures';
$lang['about'] = 'about';
$lang['hint_about'] = 'more informations on PhpWebGallery...';
$lang['admin'] = 'Administration';
@@ -288,4 +288,6 @@ $lang['never_rated'] = 'You\'ve never rated this item';
$lang['no_rate'] = 'no rate';
$lang['rates'] = 'rates';
$lang['standard_deviation'] = 'STD';
$lang['random_cat'] = 'random pictures';
$lang['random_cat_hint'] = 'Displays a set of random pictures';
?>
+3 -8
View File
@@ -13,16 +13,11 @@
<div class="totalImages">[&nbsp;{NB_PICTURE}&nbsp;{L_TOTAL}&nbsp;]</div>
<br />
<ul class="menu">
<!-- BEGIN favorites -->
<li><a href="{U_FAVORITE}"><span title="{L_FAVORITE_HINT}">{L_FAVORITE}</span></a>&nbsp;<span class="menuInfoCat">[&nbsp;{favorites.NB_FAV}&nbsp;]</span></li>
<!-- END favorites -->
<li><span style="font-weight:bold;">{L_SPECIAL_CATEGORIES}</span></li>
<ul class="menu">
<li><a href="{U_MOST_VISITED}"><span title="{L_MOST_VISITED_HINT}">{TOP_NUMBER}&nbsp;{L_MOST_VISITED}</span></a></li>
<li><a href="{U_BEST_RATED}"><span title="{L_BEST_RATED_HINT}">{TOP_NUMBER}&nbsp;{L_BEST_RATED}</span></a></li>
<li><a href="{U_RECENT_PICS}"><span title="{L_RECENT_PICS_HINT}">{L_RECENT_PICS}</span></a> {T_SHORT}</li>
<li><a href="{U_RECENT_CATS}"><span title="{L_RECENT_CATS_HINT}">{L_RECENT_CATS}</span></a></li>
<li><a href="{U_CALENDAR}"><span title="{L_CALENDAR_HINT}">{L_CALENDAR}</span></a></li>
<!-- BEGIN special_cat -->
<li><a href="{special_cat.URL}" title="{special_cat.TITLE}">{special_cat.NAME}</a></li>
<!-- END special_cat -->
</ul>
</ul>
</div>