mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-07-06 01:42:29 +02:00
initial revision
git-svn-id: http://piwigo.org/svn/trunk@440 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
@@ -0,0 +1,447 @@
|
||||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | category_calendar.inc.php |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | application : PhpWebGallery <http://phpwebgallery.net> |
|
||||
// | branch : BSF (Best So Far) |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | 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 |
|
||||
// | 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. |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
/**
|
||||
* This file is included by category.php to show thumbnails for the category
|
||||
* calendar
|
||||
*
|
||||
*/
|
||||
|
||||
// years of image availability
|
||||
$query = '
|
||||
SELECT YEAR(date_available) AS year, COUNT(id) AS count
|
||||
FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE.'
|
||||
'.$page['where'].'
|
||||
AND id = image_id
|
||||
GROUP BY year
|
||||
;';
|
||||
// echo '<pre>'.$query.'</pre>';
|
||||
$result = mysql_query($query);
|
||||
$calendar_years = array();
|
||||
while ($row = mysql_fetch_array($result))
|
||||
{
|
||||
$calendar_years[$row['year']] = $row['count'];
|
||||
}
|
||||
|
||||
// if the year requested is not among the available years, we unset the
|
||||
// variable
|
||||
if (isset($page['calendar_year'])
|
||||
and !isset($calendar_years[$page['calendar_year']]))
|
||||
{
|
||||
unset($page['calendar_year']);
|
||||
}
|
||||
|
||||
// years navigation bar creation
|
||||
$years_nav_bar = '';
|
||||
foreach ($calendar_years as $calendar_year => $nb_picture_year)
|
||||
{
|
||||
if (isset($page['calendar_year'])
|
||||
and $calendar_year == $page['calendar_year'])
|
||||
{
|
||||
$years_nav_bar.= ' <span class="selected">'.$calendar_year.'</span>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$url = PHPWG_ROOT_PATH.'category.php?cat=calendar';
|
||||
$url.= '&year='.$calendar_year;
|
||||
$url = add_session_id($url);
|
||||
$years_nav_bar.= ' <a href="'.$url.'">'.$calendar_year.'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign_block_vars(
|
||||
'calendar',
|
||||
array('YEARS_NAV_BAR' => $years_nav_bar)
|
||||
);
|
||||
|
||||
// months are calculated (to know which months are available, and how many
|
||||
// pictures per month we can find) only if a year is requested.
|
||||
if (isset($page['calendar_year']))
|
||||
{
|
||||
// creation of hash associating the number of the month in the year with
|
||||
// the number of picture for this month : $calendar_months
|
||||
$query = '
|
||||
SELECT DISTINCT(MONTH(date_available)) AS month, COUNT(id) AS count
|
||||
FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE.'
|
||||
'.$page['where'].'
|
||||
AND id = image_id
|
||||
AND YEAR(date_available) = '.$page['calendar_year'].'
|
||||
GROUP BY MONTH(date_available)
|
||||
;';
|
||||
$result = mysql_query($query);
|
||||
$calendar_months = array();
|
||||
while ($row = mysql_fetch_array($result))
|
||||
{
|
||||
$calendar_months[$row['month']] = $row['count'];
|
||||
}
|
||||
|
||||
// if a month is requested and is not among the available months, we unset
|
||||
// the requested month
|
||||
if (isset($page['calendar_month'])
|
||||
and !isset($calendar_months[$page['calendar_month']]))
|
||||
{
|
||||
unset($page['calendar_month']);
|
||||
}
|
||||
|
||||
// months navigation bar creation
|
||||
$months_nav_bar = '';
|
||||
foreach ($calendar_months as $calendar_month => $nb_picture_month)
|
||||
{
|
||||
if (isset($page['calendar_month'])
|
||||
and $calendar_month == $page['calendar_month'])
|
||||
{
|
||||
$months_nav_bar.= ' <span class="selected">';
|
||||
$months_nav_bar.= $lang['month'][(int)$calendar_month];
|
||||
$months_nav_bar.= '</span>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$url = PHPWG_ROOT_PATH.'category.php?cat=calendar&month=';
|
||||
$url.= $page['calendar_year'].'.'.sprintf('%02s', $calendar_month);
|
||||
$months_nav_bar.= ' ';
|
||||
$months_nav_bar.= '<a href="'.add_session_id($url).'">';
|
||||
$months_nav_bar.= $lang['month'][(int)$calendar_month];
|
||||
$months_nav_bar.= '</a>';
|
||||
}
|
||||
}
|
||||
$template->assign_block_vars(
|
||||
'calendar',
|
||||
array('MONTHS_NAV_BAR' => $months_nav_bar));
|
||||
}
|
||||
|
||||
/**
|
||||
* 4 sub-cases are possibles for the calendar category :
|
||||
*
|
||||
* 1. show years if no year is requested
|
||||
* 2. show months of the requested year if no month is requested
|
||||
* 3. show days of the {year,month} requested if no day requested
|
||||
* 4. show categories of the requested day (+ a special category gathering
|
||||
* all categories)
|
||||
*/
|
||||
|
||||
if (!isset($page['calendar_year']))
|
||||
{
|
||||
$nb_pics = count($calendar_years);
|
||||
}
|
||||
elseif (!isset($page['calendar_month']))
|
||||
{
|
||||
$nb_pics = count($calendar_months);
|
||||
}
|
||||
elseif (!isset($page['calendar_day']))
|
||||
{
|
||||
// creation of hash associating the number of the day in the month with
|
||||
// the number of picture for this day : $calendar_days
|
||||
$query = '
|
||||
SELECT DISTINCT(date_available) AS day, COUNT(id) AS count
|
||||
FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE.'
|
||||
'.$page['where'].'
|
||||
AND id = image_id
|
||||
AND YEAR(date_available) = '.$page['calendar_year'].'
|
||||
AND MONTH(date_available) = '.$page['calendar_month'].'
|
||||
GROUP BY day
|
||||
;';
|
||||
echo '<pre>'.$query.'</pre>';
|
||||
$result = mysql_query($query);
|
||||
$calendar_days = array();
|
||||
while ($row = mysql_fetch_array($result))
|
||||
{
|
||||
$calendar_days[$row['day']] = $row['count'];
|
||||
}
|
||||
$nb_pics = count($calendar_days);
|
||||
}
|
||||
elseif (isset($page['calendar_day']))
|
||||
{
|
||||
// $page['calendar_date'] is the concatenation of year-month-day. simplier
|
||||
// to use in SQ queries
|
||||
$page['calendar_date'] = $page['calendar_year'];
|
||||
$page['calendar_date'].= '-'.$page['calendar_month'];
|
||||
$page['calendar_date'].= '-'.$page['calendar_day'];
|
||||
|
||||
$query = '
|
||||
SELECT category_id AS category, COUNT(id) AS count
|
||||
FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE.'
|
||||
'.$page['where'].'
|
||||
AND date_available = \''.$page['calendar_date'].'\'
|
||||
AND id = image_id
|
||||
GROUP BY category_id
|
||||
;';
|
||||
// echo '<pre>'.$query.'</pre>';
|
||||
$result = mysql_query($query);
|
||||
$calendar_categories = array();
|
||||
// special category 0 : gathering all available categories (0 cannot be a
|
||||
// oregular category identifier)
|
||||
$calendar_categories[0] = 0;
|
||||
while ($row = mysql_fetch_array($result))
|
||||
{
|
||||
$calendar_categories[$row['category']] = $row['count'];
|
||||
}
|
||||
// update the total number of pictures for this day
|
||||
$calendar_categories[0] = array_sum($calendar_categories);
|
||||
|
||||
$nb_pics = count($calendar_categories);
|
||||
}
|
||||
|
||||
// template thumbnail initialization
|
||||
if ($nb_pics > 0)
|
||||
{
|
||||
$template->assign_block_vars('thumbnails', array());
|
||||
// first line
|
||||
$template->assign_block_vars('thumbnails.line', array());
|
||||
// current row displayed
|
||||
$row_number = 0;
|
||||
}
|
||||
|
||||
if (!isset($page['calendar_year']))
|
||||
{
|
||||
// for each month of this year, display a random picture
|
||||
foreach ($calendar_years as $calendar_year => $nb_pics)
|
||||
{
|
||||
$query = '
|
||||
SELECT file,tn_ext,date_available,storage_category_id
|
||||
FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE.'
|
||||
'.$page['where'].'
|
||||
AND YEAR(date_available) = '.$calendar_year.'
|
||||
AND id = image_id
|
||||
ORDER BY RAND()
|
||||
LIMIT 0,1
|
||||
;';
|
||||
$row = mysql_fetch_array(mysql_query($query));
|
||||
|
||||
$file = get_filename_wo_extension($row['file']);
|
||||
|
||||
// creating links for thumbnail and associated category
|
||||
$thumbnail_link = get_complete_dir($row['storage_category_id']);
|
||||
$thumbnail_link.= 'thumbnail/'.$conf['prefix_thumbnail'];
|
||||
$thumbnail_link.= $file.'.'.$row['tn_ext'];
|
||||
|
||||
$name = $calendar_year.' ('.$nb_pics.')';
|
||||
|
||||
$thumbnail_title = $lang['calendar_picture_hint'].$name;
|
||||
|
||||
$url_link = PHPWG_ROOT_PATH.'category.php?cat=calendar';
|
||||
$url_link.= '&year='.$calendar_year;
|
||||
|
||||
$template->assign_block_vars(
|
||||
'thumbnails.line.thumbnail',
|
||||
array(
|
||||
'IMAGE'=>$thumbnail_link,
|
||||
'IMAGE_ALT'=>$row['file'],
|
||||
'IMAGE_TITLE'=>$thumbnail_title,
|
||||
'IMAGE_NAME'=>$name,
|
||||
|
||||
'U_IMG_LINK'=>add_session_id($url_link)
|
||||
)
|
||||
);
|
||||
|
||||
// create a new line ?
|
||||
if (++$row_number == $user['nb_image_line'])
|
||||
{
|
||||
$template->assign_block_vars('thumbnails.line', array());
|
||||
$row_number = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (!isset($page['calendar_month']))
|
||||
{
|
||||
// for each month of this year, display a random picture
|
||||
foreach ($calendar_months as $calendar_month => $nb_pics)
|
||||
{
|
||||
$query = '
|
||||
SELECT file,tn_ext,date_available,storage_category_id
|
||||
FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE.'
|
||||
'.$page['where'].'
|
||||
AND YEAR(date_available) = '.$page['calendar_year'].'
|
||||
AND MONTH(date_available) = '.$calendar_month.'
|
||||
AND id = image_id
|
||||
ORDER BY RAND()
|
||||
LIMIT 0,1
|
||||
;';
|
||||
// echo '<pre>'.$query.'</pre>';
|
||||
$row = mysql_fetch_array(mysql_query($query));
|
||||
|
||||
$file = get_filename_wo_extension($row['file']);
|
||||
|
||||
// creating links for thumbnail and associated category
|
||||
$thumbnail_link = get_complete_dir($row['storage_category_id']);
|
||||
$thumbnail_link.= 'thumbnail/'.$conf['prefix_thumbnail'];
|
||||
$thumbnail_link.= $file.'.'.$row['tn_ext'];
|
||||
|
||||
$name = $lang['month'][$calendar_month];
|
||||
$name.= ' '.$page['calendar_year'];
|
||||
$name.= ' ('.$nb_pics.')';
|
||||
|
||||
$thumbnail_title = $lang['calendar_picture_hint'].$name;
|
||||
|
||||
$url_link = PHPWG_ROOT_PATH.'category.php?cat=calendar';
|
||||
$url_link.= '&month='.$page['calendar_year'].'.';
|
||||
if ($calendar_month < 10)
|
||||
{
|
||||
// adding leading zero
|
||||
$url_link.= '0';
|
||||
}
|
||||
$url_link.= $calendar_month;
|
||||
|
||||
$template->assign_block_vars(
|
||||
'thumbnails.line.thumbnail',
|
||||
array(
|
||||
'IMAGE'=>$thumbnail_link,
|
||||
'IMAGE_ALT'=>$row['file'],
|
||||
'IMAGE_TITLE'=>$thumbnail_title,
|
||||
'IMAGE_NAME'=>$name,
|
||||
|
||||
'U_IMG_LINK'=>add_session_id($url_link)
|
||||
)
|
||||
);
|
||||
|
||||
// create a new line ?
|
||||
if (++$row_number == $user['nb_image_line'])
|
||||
{
|
||||
$template->assign_block_vars('thumbnails.line', array());
|
||||
$row_number = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (!isset($page['calendar_day']))
|
||||
{
|
||||
// for each day of the requested month, display a random picture
|
||||
foreach ($calendar_days as $calendar_day => $nb_pics)
|
||||
{
|
||||
$query = '
|
||||
SELECT file,tn_ext,date_available,storage_category_id
|
||||
FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE.'
|
||||
'.$page['where'].'
|
||||
AND date_available = \''.$calendar_day.'\'
|
||||
AND id = image_id
|
||||
ORDER BY RAND()
|
||||
LIMIT 0,1
|
||||
;';
|
||||
$row = mysql_fetch_array(mysql_query($query));
|
||||
|
||||
$file = get_filename_wo_extension($row['file']);
|
||||
|
||||
// creating links for thumbnail and associated category
|
||||
$thumbnail_link = get_complete_dir($row['storage_category_id']);
|
||||
$thumbnail_link.= 'thumbnail/'.$conf['prefix_thumbnail'];
|
||||
$thumbnail_link.= $file.'.'.$row['tn_ext'];
|
||||
|
||||
list($year,$month,$day) = explode('-', $calendar_day);
|
||||
$unixdate = mktime(0,0,0,$month,$day,$year);
|
||||
$name = $lang['day'][date("w", $unixdate)];
|
||||
$name.= ' '.$day;
|
||||
$name.= ' ('.$nb_pics.')';
|
||||
|
||||
$thumbnail_title = $lang['calendar_picture_hint'].$name;
|
||||
|
||||
$url_link = PHPWG_ROOT_PATH.'category.php';
|
||||
$url_link.= '?cat=calendar&day='.str_replace('-', '.', $calendar_day);
|
||||
|
||||
$template->assign_block_vars(
|
||||
'thumbnails.line.thumbnail',
|
||||
array(
|
||||
'IMAGE'=>$thumbnail_link,
|
||||
'IMAGE_ALT'=>$row['file'],
|
||||
'IMAGE_TITLE'=>$thumbnail_title,
|
||||
'IMAGE_NAME'=>$name,
|
||||
|
||||
'U_IMG_LINK'=>add_session_id($url_link)
|
||||
)
|
||||
);
|
||||
|
||||
// create a new line ?
|
||||
if (++$row_number == $user['nb_image_line'])
|
||||
{
|
||||
$template->assign_block_vars('thumbnails.line', array());
|
||||
$row_number = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (isset($page['calendar_day']))
|
||||
{
|
||||
// for each category of this day, display a random picture
|
||||
foreach ($calendar_categories as $calendar_category => $nb_pics)
|
||||
{
|
||||
if ($calendar_category == 0)
|
||||
{
|
||||
$name = '[all]';
|
||||
}
|
||||
else
|
||||
{
|
||||
$cat_infos = get_cat_info( $calendar_category );
|
||||
$name = get_cat_display_name($cat_infos['name'],'<br />','',false);
|
||||
$name = '['.$name.']';
|
||||
}
|
||||
$name.= ' ('.$nb_pics.')';
|
||||
|
||||
$query = '
|
||||
SELECT file,tn_ext,date_available,storage_category_id
|
||||
FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE.'
|
||||
'.$page['where'].'
|
||||
AND date_available = \''.$page['calendar_date'].'\'';
|
||||
if ($calendar_category != 0)
|
||||
{
|
||||
$query.= '
|
||||
AND category_id = '.$calendar_category;
|
||||
}
|
||||
$query.= '
|
||||
AND id = image_id
|
||||
ORDER BY RAND()
|
||||
LIMIT 0,1
|
||||
;';
|
||||
$row = mysql_fetch_array(mysql_query($query));
|
||||
|
||||
$file = get_filename_wo_extension($row['file']);
|
||||
|
||||
// creating links for thumbnail and associated category
|
||||
$thumbnail_link = get_complete_dir($row['storage_category_id']);
|
||||
$thumbnail_link.= 'thumbnail/'.$conf['prefix_thumbnail'];
|
||||
$thumbnail_link.= $file.'.'.$row['tn_ext'];
|
||||
|
||||
$thumbnail_title = $lang['calendar_picture_hint'].$name;
|
||||
|
||||
$url_link = PHPWG_ROOT_PATH.'category.php?cat=search';
|
||||
$template->assign_block_vars(
|
||||
'thumbnails.line.thumbnail',
|
||||
array(
|
||||
'IMAGE'=>$thumbnail_link,
|
||||
'IMAGE_ALT'=>$row['file'],
|
||||
'IMAGE_TITLE'=>$thumbnail_title,
|
||||
'IMAGE_NAME'=>$name,
|
||||
|
||||
'U_IMG_LINK'=>add_session_id($url_link)
|
||||
)
|
||||
);
|
||||
$template->assign_block_vars('thumbnails.line.thumbnail.bullet',array());
|
||||
|
||||
// create a new line ?
|
||||
if (++$row_number == $user['nb_image_line'])
|
||||
{
|
||||
$template->assign_block_vars('thumbnails.line', array());
|
||||
$row_number = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | category_default.inc.php |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | application : PhpWebGallery <http://phpwebgallery.net> |
|
||||
// | branch : BSF (Best So Far) |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | 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 |
|
||||
// | 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. |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
/**
|
||||
* This file is included by category.php to show thumbnails for the default
|
||||
* case
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* $array_cat_directories is a cache hash associating category id with their
|
||||
* complete directory
|
||||
*/
|
||||
$array_cat_directories = array();
|
||||
|
||||
$query = '
|
||||
SELECT DISTINCT(id),file,date_available
|
||||
,tn_ext,name,filesize,storage_category_id
|
||||
FROM '.IMAGES_TABLE.' AS i
|
||||
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id=ic.image_id
|
||||
'.$page['where'].'
|
||||
'.$conf['order_by'].'
|
||||
LIMIT '.$page['start'].','.$page['nb_image_page'].'
|
||||
;';
|
||||
// echo '<pre>'.$query.'</pre>';
|
||||
$result = mysql_query($query);
|
||||
|
||||
// template thumbnail initialization
|
||||
if ( mysql_num_rows($result) > 0 )
|
||||
{
|
||||
$template->assign_block_vars('thumbnails', array());
|
||||
// first line
|
||||
$template->assign_block_vars('thumbnails.line', array());
|
||||
// current row displayed
|
||||
$row_number = 0;
|
||||
}
|
||||
|
||||
while ($row = mysql_fetch_array($result))
|
||||
{
|
||||
// retrieving the storage dir of the picture
|
||||
if (!isset($array_cat_directories[$row['storage_category_id']]))
|
||||
{
|
||||
$array_cat_directories[$row['storage_category_id']] =
|
||||
get_complete_dir($row['storage_category_id']);
|
||||
}
|
||||
$cat_directory = $array_cat_directories[$row['storage_category_id']];
|
||||
|
||||
$file = get_filename_wo_extension($row['file']);
|
||||
// name of the picture
|
||||
if (isset($row['name']) and $row['name'] != '')
|
||||
{
|
||||
$name = $row['name'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$name = str_replace('_', ' ', $file);
|
||||
}
|
||||
|
||||
if ($page['cat'] == 'search')
|
||||
{
|
||||
$name = replace_search($name, $_GET['search']);
|
||||
}
|
||||
// thumbnail url
|
||||
$thumbnail_url = $cat_directory;
|
||||
$thumbnail_url.= 'thumbnail/'.$conf['prefix_thumbnail'];
|
||||
$thumbnail_url.= $file.'.'.$row['tn_ext'];
|
||||
// message in title for the thumbnail
|
||||
$thumbnail_title = $row['file'];
|
||||
if ($row['filesize'] == '')
|
||||
{
|
||||
$filesize = floor(filesize($cat_directory.$row['file']) / 1024);
|
||||
}
|
||||
else
|
||||
{
|
||||
$filesize = $row['filesize'];
|
||||
}
|
||||
$thumbnail_title .= ' : '.$filesize.' KB';
|
||||
// url link on picture.php page
|
||||
$url_link = PHPWG_ROOT_PATH.'picture.php?cat='.$page['cat'];
|
||||
$url_link.= '&image_id='.$row['id'];
|
||||
if ($page['cat'] == 'search')
|
||||
{
|
||||
$url_link.= '&search='.$_GET['search'].'&mode='.$_GET['mode'];
|
||||
}
|
||||
|
||||
$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($row['date_available']),
|
||||
'IMAGE_STYLE' => 'thumb_picture',
|
||||
|
||||
'U_IMG_LINK' => add_session_id($url_link)
|
||||
)
|
||||
);
|
||||
|
||||
if ($conf['show_comments'] and $user['show_nb_comments'])
|
||||
{
|
||||
$query = '
|
||||
SELECT COUNT(*) AS nb_comments
|
||||
FROM '.COMMENTS_TABLE.'
|
||||
WHERE image_id = '.$row['id'].'
|
||||
AND validated = \'true\'
|
||||
;';
|
||||
$row = mysql_fetch_array(mysql_query($query));
|
||||
$template->assign_block_vars(
|
||||
'thumbnails.line.thumbnail.nb_comments',
|
||||
array('NB_COMMENTS'=>$row['nb_comments']));
|
||||
}
|
||||
|
||||
// create a new line ?
|
||||
if (++$row_number == $user['nb_image_line'])
|
||||
{
|
||||
$template->assign_block_vars('thumbnails.line', array());
|
||||
$row_number = 0;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | category_recent_cats.inc.php |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | application : PhpWebGallery <http://phpwebgallery.net> |
|
||||
// | branch : BSF (Best So Far) |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | 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 |
|
||||
// | 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. |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
/**
|
||||
* This file is included by category.php to show thumbnails for recent_cats
|
||||
* category
|
||||
*
|
||||
*/
|
||||
|
||||
// retrieving categories recently update, ie containing pictures added
|
||||
// recently. The calculated table field categories.date_last will be
|
||||
// easier to use
|
||||
$query = '
|
||||
SELECT id AS category_id
|
||||
FROM '.CATEGORIES_TABLE.'
|
||||
WHERE date_last > SUBDATE(CURRENT_DATE
|
||||
,INTERVAL '.$user['short_period'].' DAY)';
|
||||
if ( $user['forbidden_categories'] != '' )
|
||||
{
|
||||
$query.= '
|
||||
AND id NOT IN ('.$user['forbidden_categories'].')';
|
||||
}
|
||||
$query.= '
|
||||
;';
|
||||
$result = mysql_query( $query );
|
||||
|
||||
// template thumbnail initialization
|
||||
if (mysql_num_rows($result) > 0)
|
||||
{
|
||||
$template->assign_block_vars('thumbnails', array());
|
||||
// first line
|
||||
$template->assign_block_vars('thumbnails.line', array());
|
||||
// current row displayed
|
||||
$row_number = 0;
|
||||
}
|
||||
|
||||
// for each category, we have to search a recent picture to display and
|
||||
// the name to display
|
||||
while ( $row = mysql_fetch_array( $result ) )
|
||||
{
|
||||
$cat_infos = get_cat_info( $row['category_id'] );
|
||||
$name = get_cat_display_name($cat_infos['name'],'<br />','',false);
|
||||
|
||||
$query = '
|
||||
SELECT id,file,tn_ext,storage_category_id
|
||||
FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE.'
|
||||
WHERE category_id = '.$row['category_id'].'
|
||||
AND date_available > SUBDATE(CURRENT_DATE
|
||||
,INTERVAL '.$user['short_period'].' DAY)
|
||||
AND id = image_id
|
||||
ORDER BY RAND()
|
||||
LIMIT 0,1
|
||||
;';
|
||||
$subrow = mysql_fetch_array( mysql_query( $query ) );
|
||||
|
||||
$file = get_filename_wo_extension( $subrow['file'] );
|
||||
|
||||
// creating links for thumbnail and associated category
|
||||
$thumbnail_link = get_complete_dir( $subrow['storage_category_id'] );
|
||||
$thumbnail_link.= 'thumbnail/'.$conf['prefix_thumbnail'];
|
||||
$thumbnail_link.= $file.'.'.$subrow['tn_ext'];
|
||||
|
||||
$url_link = PHPWG_ROOT_PATH.'category.php?cat='.$row['category_id'];
|
||||
|
||||
$template->assign_block_vars(
|
||||
'thumbnails.line.thumbnail',
|
||||
array(
|
||||
'IMAGE' => $thumbnail_link,
|
||||
'IMAGE_ALT' => $subrow['file'],
|
||||
'IMAGE_TITLE' => $lang['hint_category'],
|
||||
'IMAGE_NAME' => '['.$name.']',
|
||||
'IMAGE_STYLE' => 'thumb_category',
|
||||
|
||||
'U_IMG_LINK' => add_session_id( $url_link )
|
||||
)
|
||||
);
|
||||
$template->assign_block_vars('thumbnails.line.thumbnail.bullet',array());
|
||||
|
||||
// create a new line ?
|
||||
if (++$row_number == $user['nb_image_line'])
|
||||
{
|
||||
$template->assign_block_vars('thumbnails.line', array());
|
||||
$row_number = 0;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | category_subcats.inc.php |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | application : PhpWebGallery <http://phpwebgallery.net> |
|
||||
// | branch : BSF (Best So Far) |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | 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 |
|
||||
// | 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. |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
/**
|
||||
* This file is included by category.php to show thumbnails for a category
|
||||
* that have only subcategories
|
||||
*
|
||||
*/
|
||||
|
||||
$subcats = array();
|
||||
if (isset($page['cat']))
|
||||
{
|
||||
$subcats = get_non_empty_subcat_ids($page['cat']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$subcats = get_non_empty_subcat_ids('');
|
||||
}
|
||||
|
||||
// template thumbnail initialization
|
||||
if (count($subcats) > 0)
|
||||
{
|
||||
$template->assign_block_vars('thumbnails', array());
|
||||
// first line
|
||||
$template->assign_block_vars('thumbnails.line', array());
|
||||
// current row displayed
|
||||
$row_number = 0;
|
||||
}
|
||||
|
||||
foreach ($subcats as $subcat_id => $non_empty_id)
|
||||
{
|
||||
$name = $page['plain_structure'][$subcat_id]['name'];
|
||||
|
||||
// searching the representative picture of the category
|
||||
$query = '
|
||||
SELECT representative_picture_id
|
||||
FROM '.CATEGORIES_TABLE.'
|
||||
WHERE id = '.$non_empty_id.'
|
||||
;';
|
||||
$row = mysql_fetch_array(mysql_query($query));
|
||||
|
||||
$query = '
|
||||
SELECT file,tn_ext,storage_category_id
|
||||
FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE.'
|
||||
WHERE category_id = '.$non_empty_id.'
|
||||
AND id = image_id';
|
||||
// if the category has a representative picture, this is its thumbnail
|
||||
// that will be displayed !
|
||||
if (isset($row['representative_picture_id']))
|
||||
{
|
||||
$query.= '
|
||||
AND id = '.$row['representative_picture_id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$query.= '
|
||||
ORDER BY RAND()
|
||||
LIMIT 0,1';
|
||||
}
|
||||
$query.= '
|
||||
;';
|
||||
$image_result = mysql_query($query);
|
||||
$image_row = mysql_fetch_array($image_result);
|
||||
|
||||
$file = get_filename_wo_extension($image_row['file']);
|
||||
|
||||
// creating links for thumbnail and associated category
|
||||
$thumbnail_link = get_complete_dir($image_row['storage_category_id']);
|
||||
$thumbnail_link.= 'thumbnail/'.$conf['prefix_thumbnail'];
|
||||
$thumbnail_link.= $file.'.'.$image_row['tn_ext'];
|
||||
|
||||
$thumbnail_title = $lang['hint_category'];
|
||||
|
||||
$url_link = PHPWG_ROOT_PATH.'category.php?cat='.$subcat_id;
|
||||
|
||||
$date = $page['plain_structure'][$subcat_id]['date_last'];
|
||||
|
||||
$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),
|
||||
'IMAGE_STYLE' => 'thumb_category',
|
||||
|
||||
'U_IMG_LINK' => add_session_id($url_link)
|
||||
)
|
||||
);
|
||||
$template->assign_block_vars('thumbnails.line.thumbnail.bullet',array());
|
||||
|
||||
// create a new line ?
|
||||
if (++$row_number == $user['nb_image_line'])
|
||||
{
|
||||
$template->assign_block_vars('thumbnails.line', array());
|
||||
$row_number = 0;
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user