2003-05-09 14:42:42 +02:00
|
|
|
<?php
|
|
|
|
/***************************************************************************
|
|
|
|
* category.php *
|
|
|
|
* ------------------- *
|
2003-08-24 09:40:56 +02:00
|
|
|
* application : PhpWebGallery 1.3 <http://phpwebgallery.net> *
|
|
|
|
* author : Pierrick LE GALL <pierrick@z0rglub.com> *
|
|
|
|
* *
|
|
|
|
* $Id$
|
2003-05-09 14:42:42 +02:00
|
|
|
* *
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* *
|
|
|
|
* 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 *
|
|
|
|
* the Free Software Foundation; *
|
|
|
|
* *
|
|
|
|
***************************************************************************/
|
|
|
|
// determine the initial instant to indicate the generation time of this page
|
|
|
|
$t1 = explode( ' ', microtime() );
|
|
|
|
$t2 = explode( '.', $t1[0] );
|
|
|
|
$t2 = $t1[1].'.'.$t2[1];
|
|
|
|
//----------------------------------------------------------- personnal include
|
|
|
|
include_once( './include/init.inc.php' );
|
2003-07-27 10:24:10 +02:00
|
|
|
//---------------------------------------------------------------------- logout
|
|
|
|
if ( $_GET['act'] == 'logout' and isset( $_COOKIE['id'] ) )
|
|
|
|
{
|
|
|
|
// 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
|
2003-07-21 21:47:14 +02:00
|
|
|
// creating the plain structure : array of all the available categories and
|
|
|
|
// their relative informations, see the definition of the function
|
|
|
|
// get_plain_structure for further details.
|
|
|
|
$page['plain_structure'] = get_plain_structure();
|
|
|
|
|
2003-05-09 14:42:42 +02:00
|
|
|
check_cat_id( $_GET['cat'] );
|
|
|
|
check_login_authorization();
|
|
|
|
if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) )
|
|
|
|
{
|
|
|
|
check_restrictions( $page['cat'] );
|
|
|
|
}
|
|
|
|
//-------------------------------------------------------------- initialization
|
|
|
|
// 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
|
|
|
}
|
2003-10-11 15:36:43 +02:00
|
|
|
if ( is_numeric( $page['cat'] ) )
|
|
|
|
{
|
|
|
|
// the category displayed (in the URL cat=23) must be seen in the menu ->
|
|
|
|
// parent categories must be expanded
|
|
|
|
$parent = $page['plain_structure'][$page['cat']]['id_uppercat'];
|
|
|
|
while ( $parent != '' )
|
|
|
|
{
|
|
|
|
array_push( $page['tab_expand'], $parent );
|
|
|
|
$parent = $page['plain_structure'][$parent]['id_uppercat'];
|
|
|
|
}
|
|
|
|
}
|
2003-05-09 14:42:42 +02:00
|
|
|
$page['expand'] = implode( ',', $page['tab_expand'] );
|
|
|
|
}
|
|
|
|
// in case of expanding all authorized cats
|
|
|
|
// The $page['expand'] equals 'all' and
|
|
|
|
// $page['tab_expand'] contains all the authorized cat ids
|
2003-07-21 21:47:14 +02:00
|
|
|
if ( $user['expand'] or $_GET['expand'] == 'all' )
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
|
|
|
$page['tab_expand'] = array();
|
|
|
|
$page['expand'] = 'all';
|
|
|
|
}
|
|
|
|
// 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'];
|
|
|
|
}
|
|
|
|
// 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
|
|
|
|
if ( is_numeric( $_GET['num'] ) and $_GET['num'] >= 0 )
|
|
|
|
{
|
|
|
|
$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)
|
|
|
|
$page['structure'] = create_structure( '', $user['restrictions'] );
|
|
|
|
$page['structure'] = update_structure( $page['structure'] );
|
2003-05-09 14:42:42 +02:00
|
|
|
initialize_category();
|
|
|
|
//----------------------------------------------------- template initialization
|
|
|
|
$vtp = new VTemplate;
|
|
|
|
$handle = $vtp->Open( './template/'.$user['template'].'/category.vtp' );
|
|
|
|
initialize_template();
|
2003-07-21 21:47:14 +02:00
|
|
|
$tpl = array(
|
|
|
|
'categories','hint_category','sub-cat','images_available','total',
|
|
|
|
'title_menu','nb_image_category','send_mail','title_send_mail',
|
|
|
|
'generation_time','connected_user','recent_image','days','generation_time',
|
|
|
|
'favorite_cat_hint','favorite_cat','stats','most_visited_cat_hint',
|
2003-09-17 22:11:57 +02:00
|
|
|
'most_visited_cat','recent_cat','recent_cat_hint','upload_picture',
|
|
|
|
'comments' );
|
2003-05-13 12:02:06 +02:00
|
|
|
templatize_array( $tpl, 'lang', $handle );
|
2003-05-09 14:42:42 +02:00
|
|
|
|
|
|
|
$tpl = array( 'mail_webmaster','webmaster','top_number','version','site_url' );
|
2003-05-13 12:02:06 +02:00
|
|
|
templatize_array( $tpl, 'conf', $handle );
|
2003-05-09 14:42:42 +02:00
|
|
|
|
2003-05-18 23:42:32 +02:00
|
|
|
$tpl = array( 'short_period','long_period','lien_collapsed', 'username' );
|
2003-05-13 12:02:06 +02:00
|
|
|
templatize_array( $tpl, 'user', $handle );
|
2003-05-09 14:42:42 +02:00
|
|
|
|
|
|
|
$tpl = array( 'title','navigation_bar','cat_comment','cat_nb_images' );
|
2003-05-13 12:02:06 +02:00
|
|
|
templatize_array( $tpl, 'page', $handle );
|
2003-05-09 14:42:42 +02:00
|
|
|
|
|
|
|
// special global template vars
|
|
|
|
$vtp->setGlobalVar( $handle, 'icon_short', get_icon( time() ) );
|
|
|
|
$icon_long = get_icon( time() - ( $user['short_period'] * 24 * 60 * 60 + 1 ) );
|
|
|
|
$vtp->setGlobalVar( $handle, 'icon_long', $icon_long );
|
2003-07-21 21:47:14 +02:00
|
|
|
$nb_total_pictures = count_images( $page['structure'] );
|
2003-05-09 14:42:42 +02:00
|
|
|
$vtp->setGlobalVar( $handle, 'nb_total_pictures',$nb_total_pictures );
|
|
|
|
//------------------------------------------------------------- categories menu
|
|
|
|
// normal categories
|
2003-07-21 21:47:14 +02:00
|
|
|
foreach ( $page['structure'] as $category ) {
|
|
|
|
// display category is a function relative to the template
|
|
|
|
display_category( $category, ' ', $handle );
|
|
|
|
}
|
2003-05-09 14:42:42 +02:00
|
|
|
// favorites cat
|
|
|
|
if ( !$user['is_the_guest'] )
|
|
|
|
{
|
|
|
|
$vtp->addSession( $handle, 'favorites' );
|
2003-07-21 21:47:14 +02:00
|
|
|
$url = './category.php?cat=fav&expand='.$page['expand'];
|
|
|
|
$vtp->setVar( $handle, 'favorites.url', add_session_id( $url ) );
|
2003-05-09 14:42:42 +02:00
|
|
|
// searching the number of favorite picture
|
2003-05-21 23:45:46 +02:00
|
|
|
$query = 'SELECT COUNT(*) AS count';
|
|
|
|
$query.= ' FROM '.PREFIX_TABLE.'favorites';
|
|
|
|
$query.= ' WHERE user_id = '.$user['id'].';';
|
2003-05-09 14:42:42 +02:00
|
|
|
$result = mysql_query( $query );
|
|
|
|
$row = mysql_fetch_array( $result );
|
|
|
|
$vtp->setVar( $handle, 'favorites.nb_favorites', $row['count'] );
|
|
|
|
$vtp->closeSession( $handle, 'favorites' );
|
|
|
|
}
|
|
|
|
// most visited pictures category
|
2003-07-21 21:47:14 +02:00
|
|
|
$url = './category.php?cat=most_visited&expand='.$page['expand'];
|
|
|
|
$vtp->setGlobalVar( $handle, 'most_visited_url', add_session_id( $url ) );
|
2003-05-09 14:42:42 +02:00
|
|
|
// recent pictures
|
2003-07-21 21:47:14 +02:00
|
|
|
$url = './category.php?cat=recent&expand='.$page['expand'];
|
|
|
|
$vtp->setGlobalVar( $handle, 'recent_url', add_session_id( $url ) );
|
2003-05-09 14:42:42 +02:00
|
|
|
//--------------------------------------------------------------------- summary
|
|
|
|
$vtp->addSession( $handle, 'summary' );
|
|
|
|
$vtp->setVar( $handle, 'summary.url', './identification.php' );
|
|
|
|
if ( !$user['is_the_guest'] )
|
|
|
|
{
|
|
|
|
$vtp->setVar( $handle, 'summary.title', '' );
|
2003-07-21 21:47:14 +02:00
|
|
|
$vtp->setVar( $handle, 'summary.name',replace_space($lang['change_login']));
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$vtp->setVar( $handle, 'summary.title', $lang['hint_login'] );
|
2003-10-05 13:37:05 +02:00
|
|
|
$vtp->setVar( $handle, 'summary.name', replace_space( $lang['menu_login']));
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
|
|
|
$vtp->closeSession( $handle, 'summary' );
|
|
|
|
// links for registered users
|
|
|
|
if ( !$user['is_the_guest'] )
|
|
|
|
{
|
|
|
|
// logout link
|
|
|
|
$vtp->addSession( $handle, 'summary' );
|
2003-07-27 10:24:10 +02:00
|
|
|
$vtp->setVar( $handle, 'summary.url', './category.php?act=logout' );
|
2003-05-09 14:42:42 +02:00
|
|
|
$vtp->setVar( $handle, 'summary.title', '' );
|
|
|
|
$vtp->setVar( $handle, 'summary.name', replace_space( $lang['logout'] ) );
|
|
|
|
$vtp->closeSession( $handle, 'summary' );
|
|
|
|
// customization link
|
|
|
|
$vtp->addSession( $handle, 'summary' );
|
|
|
|
$url = './profile.php?cat='.$page['cat'];
|
|
|
|
$url.= '&expand='.$page['expand'];
|
|
|
|
if ( $page['cat'] == 'search' )
|
|
|
|
{
|
2003-05-25 10:31:39 +02:00
|
|
|
$url.= '&search='.$_GET['search'].'&mode='.$_GET['mode'];
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
|
|
|
$vtp->setVar( $handle, 'summary.url', add_session_id( $url ) );
|
|
|
|
$vtp->setVar( $handle, 'summary.title', $lang['hint_customize'] );
|
|
|
|
$vtp->setVar( $handle, 'summary.name', replace_space( $lang['customize'] ) );
|
|
|
|
$vtp->closeSession( $handle, 'summary' );
|
|
|
|
}
|
|
|
|
// search link
|
|
|
|
$vtp->addSession( $handle, 'summary' );
|
|
|
|
$vtp->setVar( $handle, 'summary.url', add_session_id( './search.php' ) );
|
|
|
|
$vtp->setVar( $handle, 'summary.title', $lang['hint_search'] );
|
|
|
|
$vtp->setVar( $handle, 'summary.name', replace_space( $lang['search'] ) );
|
|
|
|
$vtp->closeSession( $handle, 'summary' );
|
2003-10-04 18:08:53 +02:00
|
|
|
// comments link
|
|
|
|
$vtp->addSession( $handle, 'summary' );
|
|
|
|
$vtp->setVar( $handle, 'summary.url', add_session_id( './comments.php' ) );
|
|
|
|
$vtp->setVar( $handle, 'summary.title', $lang['hint_comments'] );
|
|
|
|
$vtp->setVar( $handle, 'summary.name', replace_space( $lang['comments'] ) );
|
|
|
|
$vtp->closeSession( $handle, 'summary' );
|
2003-05-09 14:42:42 +02:00
|
|
|
// about link
|
|
|
|
$vtp->addSession( $handle, 'summary' );
|
2003-07-21 21:47:14 +02:00
|
|
|
$vtp->setVar( $handle, 'summary.url', './about.php?'.
|
|
|
|
str_replace( '&', '&', $_SERVER['QUERY_STRING'] ) );
|
2003-05-09 14:42:42 +02:00
|
|
|
$vtp->setVar( $handle, 'summary.title', $lang['hint_about'] );
|
|
|
|
$vtp->setVar( $handle, 'summary.name', replace_space( $lang['about'] ) );
|
|
|
|
$vtp->closeSession( $handle, 'summary' );
|
|
|
|
// administration link
|
|
|
|
if ( $user['status'] == 'admin' )
|
|
|
|
{
|
|
|
|
$vtp->addSession( $handle, 'summary' );
|
|
|
|
$vtp->setVar( $handle, 'summary.url',
|
2003-11-03 22:35:24 +01:00
|
|
|
add_session_id( './admin.php' ) );
|
2003-05-09 14:42:42 +02:00
|
|
|
$vtp->setVar( $handle, 'summary.title', $lang['hint_admin'] );
|
|
|
|
$vtp->setVar( $handle, 'summary.name', replace_space( $lang['admin'] ) );
|
|
|
|
$vtp->closeSession( $handle, 'summary' );
|
|
|
|
}
|
|
|
|
//-------------------------------------------------------------- category title
|
|
|
|
if ( isset ( $page['cat'] ) )
|
|
|
|
{
|
|
|
|
if ( is_numeric( $page['cat'] ) )
|
|
|
|
{
|
|
|
|
$cat_title = get_cat_display_name( $page['cat_name'], '<br />',
|
|
|
|
'font-style:italic;' );
|
|
|
|
$vtp->setGlobalVar( $handle, "cat_title", $cat_title );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( $page['cat'] == 'search' )
|
|
|
|
{
|
|
|
|
$page['title'].= ' : <span style="font-style:italic;">';
|
|
|
|
$page['title'].= $_GET['search']."</span>";
|
|
|
|
}
|
|
|
|
$page['title'] = replace_space( $page['title'] );
|
|
|
|
$vtp->setGlobalVar( $handle, "cat_title", $page['title'] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$vtp->setGlobalVar( $handle, "cat_title",
|
|
|
|
replace_space( $lang['no_category'] ) );
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------ thumbnails
|
|
|
|
if ( isset( $page['cat'] ) and $page['cat_nb_images'] != 0 )
|
|
|
|
{
|
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';
|
|
|
|
$query.= ' FROM '.PREFIX_TABLE.'images AS i';
|
|
|
|
$query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category 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 );
|
|
|
|
|
|
|
|
$vtp->addSession( $handle, 'thumbnails' );
|
|
|
|
$vtp->addSession( $handle, 'line' );
|
2003-05-21 23:45:46 +02:00
|
|
|
// iteration counter to use a new <tr> every "$nb_image_line" pictures
|
2003-05-25 10:31:39 +02:00
|
|
|
$cell_number = 1;
|
|
|
|
// iteration counter to be sure not to create too much lines in the table
|
|
|
|
$line_number = 1;
|
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
|
2003-08-30 17:54:37 +02:00
|
|
|
if ( $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
|
2003-08-30 17:54:37 +02:00
|
|
|
if ( $row['name'] != '' ) $name = $row['name'];
|
|
|
|
else $name = str_replace( '_', ' ', $file );
|
|
|
|
|
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 );
|
2003-05-09 14:42:42 +02:00
|
|
|
// sending vars to display
|
|
|
|
$vtp->addSession( $handle, 'thumbnail' );
|
|
|
|
$vtp->setVar( $handle, 'thumbnail.url', add_session_id( $url_link ) );
|
|
|
|
$vtp->setVar( $handle, 'thumbnail.src', $thumbnail_url );
|
|
|
|
$vtp->setVar( $handle, 'thumbnail.alt', $row['file'] );
|
|
|
|
$vtp->setVar( $handle, 'thumbnail.title', $thumbnail_title );
|
|
|
|
$vtp->setVar( $handle, 'thumbnail.name', $name );
|
|
|
|
$vtp->setVar( $handle, 'thumbnail.icon', get_icon( $date ) );
|
|
|
|
|
|
|
|
if ( $conf['show_comments'] and $user['show_nb_comments'] )
|
|
|
|
{
|
|
|
|
$vtp->addSession( $handle, 'nb_comments' );
|
2003-05-21 23:45:46 +02:00
|
|
|
$query = 'SELECT COUNT(*) AS nb_comments';
|
|
|
|
$query.= ' FROM '.PREFIX_TABLE.'comments';
|
|
|
|
$query.= ' 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' );
|
|
|
|
}
|
|
|
|
|
|
|
|
$vtp->closeSession( $handle, 'thumbnail' );
|
|
|
|
|
2003-05-25 10:31:39 +02:00
|
|
|
if ( $cell_number++ == $user['nb_image_line'] )
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2003-05-25 10:31:39 +02:00
|
|
|
// creating a new line
|
2003-05-09 14:42:42 +02:00
|
|
|
$vtp->closeSession( $handle, 'line' );
|
2003-05-25 10:31:39 +02:00
|
|
|
// the number of the next cell is 1
|
|
|
|
$cell_number = 1;
|
|
|
|
// we only create a new line if it does not exceed the maximum line
|
|
|
|
// per page for the logged user
|
|
|
|
if ( $line_number++ < $user['nb_line_page'] )
|
|
|
|
{
|
|
|
|
$vtp->addSession( $handle, 'line' );
|
|
|
|
}
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$vtp->closeSession( $handle, 'thumbnails' );
|
|
|
|
}
|
2003-07-21 21:47:14 +02:00
|
|
|
//-------------------------------------------------------------- empty category
|
|
|
|
elseif ( ( isset( $page['cat'] )
|
|
|
|
and is_numeric( $page['cat'] )
|
|
|
|
and $page['cat_nb_images'] == 0 )
|
|
|
|
or $_GET['cat'] == '' )
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
|
|
|
$vtp->addSession( $handle, 'thumbnails' );
|
|
|
|
$vtp->addSession( $handle, 'line' );
|
2003-05-21 23:45:46 +02:00
|
|
|
|
2003-07-21 21:47:14 +02:00
|
|
|
$subcats = get_non_empty_subcat_ids( $page['cat'] );
|
2003-05-25 10:31:39 +02:00
|
|
|
$cell_number = 1;
|
2003-07-21 21:47:14 +02:00
|
|
|
$i = 0;
|
|
|
|
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';
|
|
|
|
$query.= ' FROM '.PREFIX_TABLE.'categories';
|
|
|
|
$query.= ' WHERE id = '.$non_empty_id;
|
|
|
|
$row = mysql_fetch_array( mysql_query( $query ) );
|
|
|
|
|
2003-08-30 17:54:37 +02:00
|
|
|
$query = 'SELECT file,tn_ext,storage_category_id';
|
2003-05-21 23:45:46 +02:00
|
|
|
$query.= ' FROM '.PREFIX_TABLE.'images';
|
2003-08-30 17:54:37 +02:00
|
|
|
$query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
|
|
|
|
$query.= ' WHERE category_id = '.$non_empty_id;
|
2003-09-19 23:41:42 +02:00
|
|
|
// if the category has a representative picture, this is its thumbnail
|
|
|
|
// tha will be displayed !
|
|
|
|
if ( $row['representative_picture_id'] != '' )
|
|
|
|
$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;
|
2003-05-09 14:42:42 +02:00
|
|
|
if ( !in_array( $page['cat'], $page['tab_expand'] ) )
|
|
|
|
{
|
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
|
|
|
|
$vtp->addSession( $handle, 'thumbnail' );
|
|
|
|
$vtp->setVar( $handle, 'thumbnail.url', add_session_id( $url_link ) );
|
2003-07-21 21:47:14 +02:00
|
|
|
$vtp->setVar( $handle, 'thumbnail.src', $thumbnail_link );
|
2003-05-09 14:42:42 +02:00
|
|
|
$vtp->setVar( $handle, 'thumbnail.alt', $image_row['file'] );
|
|
|
|
$vtp->setVar( $handle, 'thumbnail.title', $thumbnail_title );
|
|
|
|
$vtp->setVar( $handle, 'thumbnail.name', $name );
|
|
|
|
$vtp->setVar( $handle, 'thumbnail.icon', get_icon( $date ) );
|
|
|
|
$vtp->closeSession( $handle, 'thumbnail' );
|
|
|
|
|
2003-05-25 10:31:39 +02:00
|
|
|
if ( $cell_number++ == $user['nb_image_line'] )
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
|
|
|
$vtp->closeSession( $handle, 'line' );
|
2003-05-25 10:31:39 +02:00
|
|
|
$cell_number = 1;
|
|
|
|
// we open a new line if the subcat was not the last one
|
2003-07-21 21:47:14 +02:00
|
|
|
if ( $i++ < count( $subcats ) - 1 )
|
2003-05-25 10:31:39 +02:00
|
|
|
{
|
|
|
|
$vtp->addSession( $handle, 'line' );
|
|
|
|
}
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
|
|
|
}
|
2003-07-21 21:47:14 +02:00
|
|
|
if ( $i < count( $subcats ) - 1 )
|
2003-05-25 10:31:39 +02:00
|
|
|
{
|
|
|
|
$vtp->closeSession( $handle, 'line' );
|
|
|
|
}
|
2003-05-09 14:42:42 +02:00
|
|
|
$vtp->closeSession( $handle, 'thumbnails' );
|
|
|
|
}
|
|
|
|
//------------------------------------------------------- category informations
|
|
|
|
if ( isset ( $page['cat'] ) )
|
|
|
|
{
|
|
|
|
$vtp->addSession( $handle, 'cat_infos' );
|
|
|
|
// navigation bar
|
|
|
|
if ( $page['navigation_bar'] != '' )
|
|
|
|
{
|
|
|
|
$vtp->addSession( $handle, 'navigation' );
|
|
|
|
$vtp->closeSession( $handle, 'navigation' );
|
|
|
|
}
|
|
|
|
// category comment
|
|
|
|
if ( isset( $page['comment'] ) and $page['comment'] != '' )
|
|
|
|
{
|
2003-05-18 23:42:32 +02:00
|
|
|
$vtp->addSession( $handle, 'comment' );
|
|
|
|
$vtp->setVar( $handle, 'comment.cat_comment', $page['comment'] );
|
|
|
|
$vtp->closeSession( $handle, 'comment' );
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
|
|
|
// total number of pictures in the category
|
|
|
|
if ( is_numeric( $page['cat'] ) )
|
|
|
|
{
|
|
|
|
$vtp->setVar( $handle, 'cat_infos.cat_name',
|
|
|
|
get_cat_display_name( $page['cat_name'], ' - ',
|
|
|
|
'font-style:italic;' ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$vtp->setVar( $handle, 'cat_infos.cat_name', $page['title'] );
|
|
|
|
}
|
|
|
|
// upload a picture in the category
|
2003-07-25 23:33:41 +02:00
|
|
|
if ( $page['cat_site_id'] == 1
|
|
|
|
and $conf['upload_available']
|
|
|
|
and $page['cat_uploadable'] )
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
|
|
|
$vtp->addSession( $handle, 'upload' );
|
|
|
|
$url = './upload.php?cat='.$page['cat'].'&expand='.$page['expand'];
|
|
|
|
$vtp->setVar( $handle, 'upload.url', add_session_id( $url ) );
|
|
|
|
$vtp->closeSession( $handle, 'upload' );
|
|
|
|
}
|
|
|
|
$vtp->closeSession( $handle, 'cat_infos' );
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------ log informations
|
|
|
|
pwg_log( 'category', $page['title'] );
|
|
|
|
mysql_close();
|
|
|
|
//------------------------------------------------------------- generation time
|
|
|
|
$time = get_elapsed_time( $t2, get_moment() );
|
|
|
|
$vtp->setGlobalVar( $handle, 'time', $time );
|
|
|
|
//----------------------------------------------------------- html code display
|
|
|
|
$code = $vtp->Display( $handle, 0 );
|
|
|
|
echo $code;
|
|
|
|
?>
|