diff options
-rw-r--r-- | category.php | 95 | ||||
-rw-r--r-- | include/category_default.inc.php | 12 | ||||
-rw-r--r-- | include/functions_category.inc.php | 27 | ||||
-rw-r--r-- | language/en_UK.iso-8859-1/common.lang.php | 6 | ||||
-rw-r--r-- | template/default/category.tpl | 11 |
5 files changed, 106 insertions, 45 deletions
diff --git a/category.php b/category.php index 9ce531e53..4e763359c 100644 --- a/category.php +++ b/category.php @@ -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'); } 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)) { diff --git a/language/en_UK.iso-8859-1/common.lang.php b/language/en_UK.iso-8859-1/common.lang.php index 98184474e..25f9a8919 100644 --- a/language/en_UK.iso-8859-1/common.lang.php +++ b/language/en_UK.iso-8859-1/common.lang.php @@ -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'; ?>
\ No newline at end of file diff --git a/template/default/category.tpl b/template/default/category.tpl index d718784f5..83210e4a2 100644 --- a/template/default/category.tpl +++ b/template/default/category.tpl @@ -13,16 +13,11 @@ <div class="totalImages">[ {NB_PICTURE} {L_TOTAL} ]</div> <br /> <ul class="menu"> - <!-- BEGIN favorites --> - <li><a href="{U_FAVORITE}"><span title="{L_FAVORITE_HINT}">{L_FAVORITE}</span></a> <span class="menuInfoCat">[ {favorites.NB_FAV} ]</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} {L_MOST_VISITED}</span></a></li> - <li><a href="{U_BEST_RATED}"><span title="{L_BEST_RATED_HINT}">{TOP_NUMBER} {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> |