2003-05-09 14:42:42 +02:00
|
|
|
<?php
|
2004-02-07 12:50:26 +01:00
|
|
|
// +-----------------------------------------------------------------------+
|
2004-02-12 00:20:38 +01:00
|
|
|
// | category.php |
|
2004-02-07 12:50:26 +01:00
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | application : PhpWebGallery <http://phpwebgallery.net> |
|
2004-02-12 00:20:38 +01:00
|
|
|
// | branch : BSF (Best So Far) |
|
2004-02-07 12:50:26 +01:00
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | file : $RCSfile$
|
|
|
|
// | last update : $Date$
|
|
|
|
// | last modifier : $Author$
|
|
|
|
// | revision : $Revision$
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | This program is free software; you can redistribute it and/or modify |
|
|
|
|
// | it under the terms of the GNU General Public License as published by |
|
2004-02-07 16:31:01 +01:00
|
|
|
// | the Free Software Foundation |
|
|
|
|
// | |
|
|
|
|
// | This program is distributed in the hope that it will be useful, but |
|
|
|
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
|
|
|
// | General Public License for more details. |
|
|
|
|
// | |
|
|
|
|
// | You should have received a copy of the GNU General Public License |
|
|
|
|
// | along with this program; if not, write to the Free Software |
|
|
|
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
|
|
|
// | USA. |
|
2004-02-07 12:50:26 +01:00
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
|
2004-02-07 16:31:01 +01:00
|
|
|
//--------------------------------------------------------------------- include
|
2004-02-02 01:55:18 +01:00
|
|
|
$phpwg_root_path = './';
|
2004-02-07 20:36:44 +01:00
|
|
|
include_once( $phpwg_root_path.'include/common.inc.php' );
|
2003-07-27 10:24:10 +02:00
|
|
|
//---------------------------------------------------------------------- logout
|
2004-02-02 01:55:18 +01:00
|
|
|
if ( isset( $_GET['act'] )
|
|
|
|
and $_GET['act'] == 'logout'
|
|
|
|
and isset( $_COOKIE['id'] ) )
|
2003-07-27 10:24:10 +02:00
|
|
|
{
|
|
|
|
// cookie deletion if exists
|
|
|
|
setcookie( 'id', '', 0, cookie_path() );
|
|
|
|
$url = 'category.php';
|
|
|
|
header( 'Request-URI: '.$url );
|
|
|
|
header( 'Content-Location: '.$url );
|
|
|
|
header( 'Location: '.$url );
|
|
|
|
exit();
|
|
|
|
}
|
2003-05-09 14:42:42 +02:00
|
|
|
//-------------------------------------------------- access authorization check
|
2004-02-02 01:55:18 +01:00
|
|
|
if ( isset( $_GET['cat'] ) ) check_cat_id( $_GET['cat'] );
|
2003-05-09 14:42:42 +02:00
|
|
|
check_login_authorization();
|
|
|
|
if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) )
|
|
|
|
{
|
|
|
|
check_restrictions( $page['cat'] );
|
|
|
|
}
|
|
|
|
//-------------------------------------------------------------- initialization
|
2004-02-02 01:55:18 +01:00
|
|
|
// detection of the start picture to display
|
|
|
|
if ( !isset( $_GET['start'] )
|
|
|
|
or !is_numeric( $_GET['start'] )
|
|
|
|
or ( is_numeric( $_GET['start'] ) and $_GET['start'] < 0 ) )
|
|
|
|
$page['start'] = 0;
|
|
|
|
else
|
|
|
|
$page['start'] = $_GET['start'];
|
|
|
|
|
|
|
|
initialize_category();
|
|
|
|
|
2003-05-09 14:42:42 +02:00
|
|
|
// creation of the array containing the cat ids to expand in the menu
|
|
|
|
// $page['tab_expand'] contains an array with the category ids
|
|
|
|
// $page['expand'] contains the string to display in URL with comma
|
|
|
|
$page['tab_expand'] = array();
|
|
|
|
if ( isset ( $_GET['expand'] ) and $_GET['expand'] != 'all' )
|
|
|
|
{
|
2003-07-21 21:47:14 +02:00
|
|
|
$tab_expand = explode( ',', $_GET['expand'] );
|
|
|
|
foreach ( $tab_expand as $id ) {
|
|
|
|
if ( is_numeric( $id ) ) array_push( $page['tab_expand'], $id );
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
2004-02-02 01:55:18 +01:00
|
|
|
}
|
|
|
|
if ( isset($page['cat']) && is_numeric( $page['cat'] ) )
|
|
|
|
{
|
|
|
|
// the category displayed (in the URL cat=23) must be seen in the menu ->
|
|
|
|
// parent categories must be expanded
|
|
|
|
$uppercats = explode( ',', $page['uppercats'] );
|
|
|
|
foreach ( $uppercats as $uppercat ) {
|
|
|
|
array_push( $page['tab_expand'], $uppercat );
|
2003-10-11 15:36:43 +02:00
|
|
|
}
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
2004-02-02 01:55:18 +01:00
|
|
|
$page['tab_expand'] = array_unique( $page['tab_expand'] );
|
|
|
|
$page['expand'] = implode( ',', $page['tab_expand'] );
|
2003-05-09 14:42:42 +02:00
|
|
|
// in case of expanding all authorized cats
|
|
|
|
// The $page['expand'] equals 'all' and
|
|
|
|
// $page['tab_expand'] contains all the authorized cat ids
|
2004-02-02 01:55:18 +01:00
|
|
|
if ( $user['expand']
|
|
|
|
or ( isset( $_GET['expand'] ) and $_GET['expand'] == 'all' ) )
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
|
|
|
$page['tab_expand'] = array();
|
|
|
|
$page['expand'] = 'all';
|
|
|
|
}
|
|
|
|
// Sometimes, a "num" is provided in the URL. It is the number
|
|
|
|
// of the picture to show. This picture must be in the thumbnails page.
|
|
|
|
// We have to find the right $page['start'] that show the num picture
|
|
|
|
// in this category
|
2004-02-02 01:55:18 +01:00
|
|
|
if ( isset( $_GET['num'] )
|
|
|
|
and is_numeric( $_GET['num'] )
|
|
|
|
and $_GET['num'] >= 0 )
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
|
|
|
$page['start'] = floor( $_GET['num'] / $user['nb_image_page'] );
|
|
|
|
$page['start']*= $user['nb_image_page'];
|
|
|
|
}
|
2003-07-21 21:47:14 +02:00
|
|
|
// creating the structure of the categories (useful for displaying the menu)
|
2004-02-02 01:55:18 +01:00
|
|
|
// creating the plain structure : array of all the available categories and
|
|
|
|
// their relative informations, see the definition of the function
|
|
|
|
// get_user_plain_structure for further details.
|
|
|
|
$page['plain_structure'] = get_user_plain_structure();
|
|
|
|
$page['structure'] = create_user_structure( '' );
|
2003-07-21 21:47:14 +02:00
|
|
|
$page['structure'] = update_structure( $page['structure'] );
|
2004-02-02 01:55:18 +01:00
|
|
|
|
2003-05-09 14:42:42 +02:00
|
|
|
//----------------------------------------------------- template initialization
|
2004-02-02 01:55:18 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// Start output of page
|
|
|
|
//
|
|
|
|
$title = $page['title'];
|
|
|
|
include('include/page_header.php');
|
|
|
|
|
2004-02-07 12:50:26 +01:00
|
|
|
$template->set_filenames( array('category'=>'category.tpl') );
|
2003-05-09 14:42:42 +02:00
|
|
|
initialize_template();
|
2004-02-07 12:50:26 +01:00
|
|
|
|
|
|
|
//-------------------------------------------------------------- category title
|
|
|
|
$cat_title = $lang['no_category'];
|
|
|
|
if ( isset ( $page['cat'] ) )
|
|
|
|
{
|
|
|
|
if ( is_numeric( $page['cat'] ) )
|
|
|
|
{
|
|
|
|
$cat_title = get_cat_display_name( $page['cat_name'], '<br />',
|
|
|
|
'font-style:italic;' );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( $page['cat'] == 'search' )
|
|
|
|
{
|
|
|
|
$page['title'].= ' : <span style="font-style:italic;">';
|
|
|
|
$page['title'].= $_GET['search']."</span>";
|
|
|
|
}
|
|
|
|
$page['title'] = replace_space( $page['title'] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$template->assign_vars(array(
|
|
|
|
'NB_PICTURE' => count_user_total_images(),
|
|
|
|
'TITLE' => $cat_title,
|
|
|
|
'USERNAME' => $user['username'],
|
|
|
|
|
|
|
|
'S_TOP'=>$conf['top_number'],
|
|
|
|
'S_SHORT_PERIOD'=>$user['short_period'],
|
|
|
|
'S_LONG_PERIOD'=>$user['long_period'],
|
|
|
|
'S_WEBMASTER'=>$conf['webmaster'],
|
|
|
|
'S_MAIL'=>$conf['mail_webmaster'],
|
|
|
|
|
|
|
|
'L_CATEGORIES' => $lang['categories'],
|
|
|
|
'L_HINT_CATEGORY' => $lang['hint_category'],
|
|
|
|
'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_STATS' => $lang['stats'],
|
|
|
|
'L_MOST_VISITED_HINT' => $lang['most_visited_cat_hint'],
|
|
|
|
'L_MOST_VISITED' => $lang['most_visited_cat'],
|
|
|
|
'L_RECENT_HINT' => $lang['recent_cat_hint'],
|
|
|
|
'L_RECENT' => $lang['recent_cat'],
|
|
|
|
'L_SUMMARY' => $lang['title_menu'],
|
|
|
|
'L_UPLOAD' => $lang['upload_picture'],
|
|
|
|
'L_COMMENT' => $lang['comments'],
|
|
|
|
'L_NB_IMG' => $lang['nb_image_category'],
|
|
|
|
'L_USER' => $lang['connected_user'],
|
|
|
|
'L_RECENT_IMAGE' => $lang['recent_image'],
|
|
|
|
'L_DAYS' => $lang['days'],
|
|
|
|
'L_SEND_MAIL' => $lang['send_mail'],
|
|
|
|
'L_TITLE_MAIL' => $lang['title_send_mail'],
|
|
|
|
|
|
|
|
'T_COLLAPSED' => $user['lien_collapsed'],
|
|
|
|
'T_SHORT'=>get_icon( time() ),
|
|
|
|
'T_LONG'=>get_icon( time() - ( $user['short_period'] * 24 * 60 * 60 + 1 ) ),
|
|
|
|
|
|
|
|
'U_HOME' => add_session_id( 'category.php' ),
|
|
|
|
'U_FAVORITE' => add_session_id( './category.php?cat=fav&expand='.$page['expand'] ),
|
|
|
|
'U_MOST_VISITED'=>add_session_id( './category.php?cat=most_visited&expand='.$page['expand'] ),
|
|
|
|
'U_RECENT'=>add_session_id( './category.php?cat=recent&expand='.$page['expand'] )
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2003-07-21 21:47:14 +02:00
|
|
|
foreach ( $page['structure'] as $category ) {
|
|
|
|
// display category is a function relative to the template
|
2004-02-07 12:50:26 +01:00
|
|
|
display_category( $category, ' ');
|
2003-07-21 21:47:14 +02:00
|
|
|
}
|
2004-02-07 12:50:26 +01:00
|
|
|
|
|
|
|
// favorites management
|
2003-05-09 14:42:42 +02:00
|
|
|
if ( !$user['is_the_guest'] )
|
|
|
|
{
|
|
|
|
// searching the number of favorite picture
|
2003-05-21 23:45:46 +02:00
|
|
|
$query = 'SELECT COUNT(*) AS count';
|
2004-02-07 12:50:26 +01:00
|
|
|
$query.= ' FROM '.FAVORITES_TABLE.' WHERE user_id = '.$user['id'].';';
|
2003-05-09 14:42:42 +02:00
|
|
|
$result = mysql_query( $query );
|
|
|
|
$row = mysql_fetch_array( $result );
|
2004-02-07 12:50:26 +01:00
|
|
|
$template->assign_block_vars('favorites', array ('NB_FAV'=>$row['count']) );
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
|
|
|
//--------------------------------------------------------------------- summary
|
2004-02-07 12:50:26 +01:00
|
|
|
$sum_title = '';
|
|
|
|
$sum_name='';
|
|
|
|
$sum_url = '';
|
2003-05-09 14:42:42 +02:00
|
|
|
if ( !$user['is_the_guest'] )
|
|
|
|
{
|
2004-02-07 12:50:26 +01:00
|
|
|
$sum_name=replace_space($lang['logout']);
|
|
|
|
$sum_url = 'category.php?act=logout';
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-02-07 12:50:26 +01:00
|
|
|
$sum_title = $lang['hint_login'];
|
|
|
|
$sum_name=replace_space( $lang['menu_login']);
|
|
|
|
$sum_url = 'identification.php';
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
2004-02-07 12:50:26 +01:00
|
|
|
$template->assign_block_vars('summary', array(
|
|
|
|
'TITLE'=>$sum_title,
|
|
|
|
'NAME'=>$sum_name,
|
|
|
|
'U_SUMMARY'=>add_session_id( $sum_url ),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
// customization link
|
2003-05-09 14:42:42 +02:00
|
|
|
if ( !$user['is_the_guest'] )
|
|
|
|
{
|
2004-02-07 12:50:26 +01:00
|
|
|
$template->assign_block_vars('summary', array(
|
|
|
|
'TITLE'=>$lang['hint_customize'],
|
|
|
|
'NAME'=>$lang['customize'],
|
|
|
|
'U_SUMMARY'=>add_session_id('profile.php?'.str_replace( '&', '&', $_SERVER['QUERY_STRING'] )),
|
|
|
|
));
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
2004-02-07 12:50:26 +01:00
|
|
|
|
2003-05-09 14:42:42 +02:00
|
|
|
// search link
|
2004-02-07 12:50:26 +01:00
|
|
|
$template->assign_block_vars('summary', array(
|
|
|
|
'TITLE'=>$lang['hint_search'],
|
|
|
|
'NAME'=>$lang['search'],
|
|
|
|
'U_SUMMARY'=>add_session_id( 'search.php' ),
|
|
|
|
));
|
|
|
|
|
2003-10-04 18:08:53 +02:00
|
|
|
// comments link
|
2004-02-07 12:50:26 +01:00
|
|
|
$template->assign_block_vars('summary', array(
|
|
|
|
'TITLE'=>$lang['hint_comments'],
|
|
|
|
'NAME'=>$lang['comments'],
|
|
|
|
'U_SUMMARY'=>add_session_id( 'comments.php' ),
|
|
|
|
));
|
|
|
|
|
2003-05-09 14:42:42 +02:00
|
|
|
// about link
|
2004-02-07 12:50:26 +01:00
|
|
|
$template->assign_block_vars('summary', array(
|
|
|
|
'TITLE'=>$lang['hint_about'],
|
|
|
|
'NAME'=>$lang['about'],
|
|
|
|
'U_SUMMARY'=>add_session_id( 'about.php?'.str_replace( '&', '&', $_SERVER['QUERY_STRING'] ) )
|
|
|
|
));
|
|
|
|
|
2003-05-09 14:42:42 +02:00
|
|
|
// administration link
|
|
|
|
if ( $user['status'] == 'admin' )
|
|
|
|
{
|
2004-02-07 12:50:26 +01:00
|
|
|
$template->assign_block_vars('summary', array(
|
|
|
|
'TITLE'=>$lang['hint_admin'],
|
|
|
|
'NAME'=>$lang['admin'],
|
|
|
|
'U_SUMMARY'=>add_session_id( 'admin.php' )
|
|
|
|
));
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
2004-02-07 12:50:26 +01:00
|
|
|
|
2003-05-09 14:42:42 +02:00
|
|
|
//------------------------------------------------------------------ thumbnails
|
2004-02-07 12:50:26 +01:00
|
|
|
if ( isset( $page['cat'] ) && $page['cat_nb_images'] != 0 )
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2003-08-30 17:54:37 +02:00
|
|
|
$array_cat_directories = array();
|
2003-05-09 14:42:42 +02:00
|
|
|
|
2003-09-05 21:27:45 +02:00
|
|
|
$query = 'SELECT distinct(id),file,date_available,tn_ext,name,filesize';
|
|
|
|
$query.= ',storage_category_id';
|
2004-02-02 01:55:18 +01:00
|
|
|
$query.= ' FROM '.IMAGES_TABLE.' AS i';
|
|
|
|
$query.=' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id=ic.image_id';
|
2003-05-09 14:42:42 +02:00
|
|
|
$query.= $page['where'];
|
|
|
|
$query.= $conf['order_by'];
|
2003-05-21 23:45:46 +02:00
|
|
|
$query.= ' LIMIT '.$page['start'].','.$page['nb_image_page'];
|
2003-05-09 14:42:42 +02:00
|
|
|
$query.= ';';
|
|
|
|
$result = mysql_query( $query );
|
|
|
|
|
2004-02-07 12:50:26 +01:00
|
|
|
$template->assign_block_vars('thumbnails', array());
|
|
|
|
|
2003-05-21 23:45:46 +02:00
|
|
|
// iteration counter to use a new <tr> every "$nb_image_line" pictures
|
2004-02-07 12:50:26 +01:00
|
|
|
$cell_number = 0;
|
2003-05-25 10:31:39 +02:00
|
|
|
// iteration counter to be sure not to create too much lines in the table
|
2004-02-07 12:50:26 +01:00
|
|
|
$line_number = 0;
|
|
|
|
|
2003-05-09 14:42:42 +02:00
|
|
|
while ( $row = mysql_fetch_array( $result ) )
|
|
|
|
{
|
2003-09-05 21:27:45 +02:00
|
|
|
// retrieving the storage dir of the picture
|
2004-02-02 01:55:18 +01:00
|
|
|
if ( !isset($array_cat_directories[$row['storage_category_id']]))
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2003-08-30 17:54:37 +02:00
|
|
|
$array_cat_directories[$row['storage_category_id']] =
|
|
|
|
get_complete_dir( $row['storage_category_id'] );
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
2003-08-30 17:54:37 +02:00
|
|
|
$cat_directory = $array_cat_directories[$row['storage_category_id']];
|
|
|
|
|
2003-05-21 23:45:46 +02:00
|
|
|
$file = get_filename_wo_extension( $row['file'] );
|
2003-05-09 14:42:42 +02:00
|
|
|
// name of the picture
|
2004-02-02 01:55:18 +01:00
|
|
|
if ( isset( $row['name'] ) and $row['name'] != '' ) $name = $row['name'];
|
|
|
|
else $name = str_replace( '_', ' ', $file );
|
2003-08-30 17:54:37 +02:00
|
|
|
|
2003-05-09 14:42:42 +02:00
|
|
|
if ( $page['cat'] == 'search' )
|
|
|
|
{
|
|
|
|
$name = replace_search( $name, $_GET['search'] );
|
|
|
|
}
|
|
|
|
// thumbnail url
|
|
|
|
$thumbnail_url = $cat_directory;
|
2003-05-27 22:56:13 +02:00
|
|
|
$thumbnail_url.= 'thumbnail/'.$conf['prefix_thumbnail'];
|
2003-05-09 14:42:42 +02:00
|
|
|
$thumbnail_url.= $file.'.'.$row['tn_ext'];
|
|
|
|
// message in title for the thumbnail
|
2003-05-21 23:45:46 +02:00
|
|
|
$thumbnail_title = $row['file'];
|
2003-05-09 14:42:42 +02:00
|
|
|
if ( $row['filesize'] == '' )
|
2003-09-20 23:44:57 +02:00
|
|
|
$poids = floor( filesize( $cat_directory.$row['file'] ) / 1024 );
|
2003-05-09 14:42:42 +02:00
|
|
|
else
|
|
|
|
$poids = $row['filesize'];
|
2003-05-21 23:45:46 +02:00
|
|
|
$thumbnail_title .= ' : '.$poids.' KB';
|
2003-05-09 14:42:42 +02:00
|
|
|
// url link on picture.php page
|
|
|
|
$url_link = './picture.php?cat='.$page['cat'];
|
|
|
|
$url_link.= '&image_id='.$row['id'].'&expand='.$page['expand'];
|
|
|
|
if ( $page['cat'] == 'search' )
|
|
|
|
{
|
2003-05-25 10:31:39 +02:00
|
|
|
$url_link.= '&search='.$_GET['search'].'&mode='.$_GET['mode'];
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
|
|
|
// date of availability for creation icon
|
2003-05-25 10:31:39 +02:00
|
|
|
list( $year,$month,$day ) = explode( '-', $row['date_available'] );
|
|
|
|
$date = mktime( 0, 0, 0, $month, $day, $year );
|
2004-02-07 12:50:26 +01:00
|
|
|
|
|
|
|
// sending vars to display
|
|
|
|
if (!$cell_number && ( $line_number< $user['nb_line_page']))
|
|
|
|
{
|
|
|
|
$template->assign_block_vars('thumbnails.line', array());
|
|
|
|
$cell_number = 0;
|
|
|
|
$line_number++;
|
|
|
|
}
|
|
|
|
if ( $cell_number++ == $user['nb_image_line'] -1) $cell_number = 0;
|
|
|
|
|
|
|
|
$template->assign_block_vars('thumbnails.line.thumbnail', array(
|
|
|
|
'IMAGE'=>$thumbnail_url,
|
|
|
|
'IMAGE_ALT'=>$row['file'],
|
|
|
|
'IMAGE_TITLE'=>$thumbnail_title,
|
|
|
|
'IMAGE_NAME'=>$name,
|
|
|
|
'IMAGE_TS'=>get_icon( $date ),
|
|
|
|
|
|
|
|
'U_IMG_LINK'=>add_session_id( $url_link )
|
|
|
|
));
|
|
|
|
|
|
|
|
if ( $conf['show_comments'] && $user['show_nb_comments'] )
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
|
|
|
$vtp->addSession( $handle, 'nb_comments' );
|
2003-05-21 23:45:46 +02:00
|
|
|
$query = 'SELECT COUNT(*) AS nb_comments';
|
2004-02-02 01:55:18 +01:00
|
|
|
$query.= ' FROM '.COMMENTS_TABLE.' WHERE image_id = '.$row['id'];
|
2003-07-21 21:47:14 +02:00
|
|
|
$query.= " AND validated = 'true'";
|
2003-05-09 14:42:42 +02:00
|
|
|
$query.= ';';
|
|
|
|
$row = mysql_fetch_array( mysql_query( $query ) );
|
|
|
|
$vtp->setVar( $handle, 'nb_comments.nb', $row['nb_comments'] );
|
|
|
|
$vtp->closeSession( $handle, 'nb_comments' );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-07-21 21:47:14 +02:00
|
|
|
//-------------------------------------------------------------- empty category
|
2004-02-07 12:50:26 +01:00
|
|
|
else
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2004-02-02 01:55:18 +01:00
|
|
|
$subcats=array();
|
|
|
|
if (isset($page['cat'])) $subcats = get_non_empty_subcat_ids( $page['cat'] );
|
|
|
|
else $subcats = get_non_empty_subcat_ids( '' );
|
2004-02-07 12:50:26 +01:00
|
|
|
$cell_number = 0;
|
2003-07-21 21:47:14 +02:00
|
|
|
$i = 0;
|
2004-02-07 12:50:26 +01:00
|
|
|
|
|
|
|
$template->assign_block_vars('thumbnails', array());
|
|
|
|
|
|
|
|
foreach ( $subcats as $subcat_id => $non_empty_id )
|
|
|
|
{
|
2003-09-19 23:41:42 +02:00
|
|
|
$name = '<img src="'.$user['lien_collapsed'].'" style="border:none;"';
|
|
|
|
$name.= ' alt=">"/> ';
|
|
|
|
$name.= '[ <span style="font-weight:bold;">';
|
|
|
|
$name.= $page['plain_structure'][$subcat_id]['name'];
|
2003-05-10 13:40:38 +02:00
|
|
|
$name.= '</span> ]';
|
2003-08-30 17:54:37 +02:00
|
|
|
|
2003-09-19 23:41:42 +02:00
|
|
|
// searching the representative picture of the category
|
|
|
|
$query = 'SELECT representative_picture_id';
|
2004-02-02 01:55:18 +01:00
|
|
|
$query.= ' FROM '.CATEGORIES_TABLE.' WHERE id = '.$non_empty_id;
|
|
|
|
$query.= ';';
|
2003-09-19 23:41:42 +02:00
|
|
|
$row = mysql_fetch_array( mysql_query( $query ) );
|
|
|
|
|
2003-08-30 17:54:37 +02:00
|
|
|
$query = 'SELECT file,tn_ext,storage_category_id';
|
2004-02-02 01:55:18 +01:00
|
|
|
$query.= ' FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE;
|
2003-08-30 17:54:37 +02:00
|
|
|
$query.= ' WHERE category_id = '.$non_empty_id;
|
2004-02-02 01:55:18 +01:00
|
|
|
$query.= ' AND id = image_id';
|
2003-09-19 23:41:42 +02:00
|
|
|
// if the category has a representative picture, this is its thumbnail
|
2004-02-02 01:55:18 +01:00
|
|
|
// that will be displayed !
|
|
|
|
if ( isset( $row['representative_picture_id'] ) )
|
2003-09-19 23:41:42 +02:00
|
|
|
$query.= ' AND id = '.$row['representative_picture_id'];
|
|
|
|
else
|
|
|
|
$query.= ' ORDER BY RAND()';
|
2003-05-21 23:45:46 +02:00
|
|
|
$query.= ' LIMIT 0,1';
|
2003-05-09 14:42:42 +02:00
|
|
|
$query.= ';';
|
|
|
|
$image_result = mysql_query( $query );
|
2003-07-21 21:47:14 +02:00
|
|
|
$image_row = mysql_fetch_array( $image_result );
|
2003-05-09 14:42:42 +02:00
|
|
|
|
2003-05-25 10:31:39 +02:00
|
|
|
$file = get_filename_wo_extension( $image_row['file'] );
|
2003-05-09 14:42:42 +02:00
|
|
|
|
|
|
|
// creating links for thumbnail and associated category
|
2003-08-30 17:54:37 +02:00
|
|
|
$thumbnail_link = get_complete_dir( $image_row['storage_category_id'] );
|
2003-07-21 21:47:14 +02:00
|
|
|
$thumbnail_link.= 'thumbnail/'.$conf['prefix_thumbnail'];
|
|
|
|
$thumbnail_link.= $file.'.'.$image_row['tn_ext'];
|
2003-05-09 14:42:42 +02:00
|
|
|
|
2003-05-25 10:31:39 +02:00
|
|
|
$thumbnail_title = $lang['hint_category'];
|
2003-05-09 14:42:42 +02:00
|
|
|
|
2003-07-21 21:47:14 +02:00
|
|
|
$url_link = './category.php?cat='.$subcat_id;
|
2004-02-02 01:55:18 +01:00
|
|
|
if ( isset($page['cat'])&& !in_array( $page['cat'], $page['tab_expand'] ) )
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2003-05-25 10:31:39 +02:00
|
|
|
array_push( $page['tab_expand'], $page['cat'] );
|
2003-05-09 14:42:42 +02:00
|
|
|
$page['expand'] = implode( ',', $page['tab_expand'] );
|
|
|
|
}
|
|
|
|
$url_link.= '&expand='.$page['expand'];
|
2003-09-15 23:48:21 +02:00
|
|
|
// we add the category to explore in the expand list
|
|
|
|
if ( $page['expand'] != '' ) $url_link.= ',';
|
|
|
|
$url_link.= $subcat_id;
|
|
|
|
|
2003-09-19 23:41:42 +02:00
|
|
|
$date = $page['plain_structure'][$subcat_id]['date_last'];
|
2003-05-09 14:42:42 +02:00
|
|
|
|
|
|
|
// sending vars to display
|
2004-02-07 12:50:26 +01:00
|
|
|
if (!$cell_number && $i < count( $subcats ))
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2004-02-07 12:50:26 +01:00
|
|
|
$template->assign_block_vars('thumbnails.line', array());
|
|
|
|
$cell_number = 0;
|
|
|
|
$i++;
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
2004-02-07 12:50:26 +01:00
|
|
|
if ( $cell_number++ == $user['nb_image_line'] -1) $cell_number = 0;
|
|
|
|
|
|
|
|
$template->assign_block_vars('thumbnails.line.thumbnail', array(
|
|
|
|
'IMAGE'=>$thumbnail_link,
|
|
|
|
'IMAGE_ALT'=>$image_row['file'],
|
|
|
|
'IMAGE_TITLE'=>$thumbnail_title,
|
|
|
|
'IMAGE_NAME'=>$name,
|
|
|
|
'IMAGE_TS'=>get_icon( $date ),
|
|
|
|
|
|
|
|
'U_IMG_LINK'=>add_session_id( $url_link )
|
|
|
|
));
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------- category informations
|
|
|
|
if ( isset ( $page['cat'] ) )
|
|
|
|
{
|
2004-02-07 12:50:26 +01:00
|
|
|
$cat_name='';
|
2003-05-09 14:42:42 +02:00
|
|
|
// total number of pictures in the category
|
|
|
|
if ( is_numeric( $page['cat'] ) )
|
|
|
|
{
|
2004-02-07 12:50:26 +01:00
|
|
|
$cat_name=get_cat_display_name( $page['cat_name'],' - ','font-style:italic;' );
|
2004-02-02 01:55:18 +01:00
|
|
|
// upload a picture in the category
|
|
|
|
if ( $page['cat_site_id'] == 1
|
|
|
|
and $conf['upload_available']
|
|
|
|
and $page['cat_uploadable'] )
|
|
|
|
{
|
|
|
|
$url = './upload.php?cat='.$page['cat'].'&expand='.$page['expand'];
|
2004-02-07 12:50:26 +01:00
|
|
|
$template->assign_block_vars('upload',array('U_UPLOAD'=>add_session_id( $url )));
|
2004-02-02 01:55:18 +01:00
|
|
|
}
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-02-07 12:50:26 +01:00
|
|
|
$cat_name= $page['title'];
|
|
|
|
}
|
|
|
|
$template->assign_block_vars('cat_infos',array(
|
|
|
|
'CAT_NAME'=>$cat_name,
|
|
|
|
'NB_IMG_CAT' => $page['cat_nb_images']
|
|
|
|
));
|
|
|
|
|
|
|
|
// navigation bar
|
|
|
|
if ( $page['navigation_bar'] != '' )
|
|
|
|
{
|
|
|
|
$template->assign_block_vars('cat_infos.navigation',array('NAV_BAR' => $page['navigation_bar']));
|
|
|
|
}
|
|
|
|
// category comment
|
|
|
|
if ( isset( $page['comment'] ) and $page['comment'] != '' )
|
|
|
|
{
|
|
|
|
$template->assign_block_vars('cat_infos.navigation',array('COMMENTS' => $page['cat_comment']));
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------ log informations
|
|
|
|
pwg_log( 'category', $page['title'] );
|
|
|
|
mysql_close();
|
2004-02-02 01:55:18 +01:00
|
|
|
|
2004-02-07 12:50:26 +01:00
|
|
|
$template->pparse('category');
|
2004-02-02 01:55:18 +01:00
|
|
|
include('include/page_tail.php');
|
2004-02-12 00:20:38 +01:00
|
|
|
?>
|