6 |
kaklik |
1 |
<?php
|
|
|
2 |
// +-----------------------------------------------------------------------+
|
|
|
3 |
// | PhpWebGallery - a PHP based picture gallery |
|
|
|
4 |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
|
|
5 |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
|
|
|
6 |
// +-----------------------------------------------------------------------+
|
|
|
7 |
// | branch : BSF (Best So Far)
|
|
|
8 |
// | file : $RCSfile: category_subcats.inc.php,v $
|
|
|
9 |
// | last update : $Date: 2005/01/07 23:10:51 $
|
|
|
10 |
// | last modifier : $Author: plg $
|
|
|
11 |
// | revision : $Revision: 1.9 $
|
|
|
12 |
// +-----------------------------------------------------------------------+
|
|
|
13 |
// | This program is free software; you can redistribute it and/or modify |
|
|
|
14 |
// | it under the terms of the GNU General Public License as published by |
|
|
|
15 |
// | the Free Software Foundation |
|
|
|
16 |
// | |
|
|
|
17 |
// | This program is distributed in the hope that it will be useful, but |
|
|
|
18 |
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
19 |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
|
|
20 |
// | General Public License for more details. |
|
|
|
21 |
// | |
|
|
|
22 |
// | You should have received a copy of the GNU General Public License |
|
|
|
23 |
// | along with this program; if not, write to the Free Software |
|
|
|
24 |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
|
|
25 |
// | USA. |
|
|
|
26 |
// +-----------------------------------------------------------------------+
|
|
|
27 |
|
|
|
28 |
/**
|
|
|
29 |
* This file is included by category.php to show thumbnails for a category
|
|
|
30 |
* that have only subcategories
|
|
|
31 |
*
|
|
|
32 |
*/
|
|
|
33 |
|
|
|
34 |
$query = '
|
|
|
35 |
SELECT id, name, date_last
|
|
|
36 |
FROM '.CATEGORIES_TABLE.'
|
|
|
37 |
WHERE id_uppercat ';
|
|
|
38 |
if (!isset($page['cat']) or !is_numeric($page['cat']))
|
|
|
39 |
{
|
|
|
40 |
$query.= 'is NULL';
|
|
|
41 |
}
|
|
|
42 |
else
|
|
|
43 |
{
|
|
|
44 |
$query.= '= '.$page['cat'];
|
|
|
45 |
}
|
|
|
46 |
// we must not show pictures of a forbidden category
|
|
|
47 |
if ($user['forbidden_categories'] != '')
|
|
|
48 |
{
|
|
|
49 |
$query.= ' AND id NOT IN ('.$user['forbidden_categories'].')';
|
|
|
50 |
}
|
|
|
51 |
$query.= '
|
|
|
52 |
ORDER BY rank
|
|
|
53 |
;';
|
|
|
54 |
$result = pwg_query($query);
|
|
|
55 |
|
|
|
56 |
// template thumbnail initialization
|
|
|
57 |
if (mysql_num_rows($result) > 0)
|
|
|
58 |
{
|
|
|
59 |
$template->assign_block_vars('thumbnails', array());
|
|
|
60 |
// first line
|
|
|
61 |
$template->assign_block_vars('thumbnails.line', array());
|
|
|
62 |
// current row displayed
|
|
|
63 |
$row_number = 0;
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
while ($row = mysql_fetch_array($result))
|
|
|
67 |
{
|
|
|
68 |
$query = '
|
|
|
69 |
SELECT path, tn_ext
|
|
|
70 |
FROM '.CATEGORIES_TABLE.' AS c INNER JOIN '.IMAGES_TABLE.' AS i
|
|
|
71 |
ON i.id = c.representative_picture_id
|
|
|
72 |
WHERE uppercats REGEXP \'(^|,)'.$row['id'].'(,|$)\'';
|
|
|
73 |
// we must not show pictures of a forbidden category
|
|
|
74 |
if ($user['forbidden_categories'] != '')
|
|
|
75 |
{
|
|
|
76 |
$query.= '
|
|
|
77 |
AND c.id NOT IN ('.$user['forbidden_categories'].')';
|
|
|
78 |
}
|
|
|
79 |
$query.= '
|
|
|
80 |
ORDER BY RAND()
|
|
|
81 |
LIMIT 0,1
|
|
|
82 |
;';
|
|
|
83 |
$element_result = pwg_query($query);
|
|
|
84 |
if (mysql_num_rows($element_result) == 0)
|
|
|
85 |
{
|
|
|
86 |
continue;
|
|
|
87 |
}
|
|
|
88 |
$element_row = mysql_fetch_array($element_result);
|
|
|
89 |
|
|
|
90 |
$thumbnail_link = get_thumbnail_src($element_row['path'],
|
|
|
91 |
@$element_row['tn_ext']);
|
|
|
92 |
|
|
|
93 |
$thumbnail_title = $lang['hint_category'];
|
|
|
94 |
|
|
|
95 |
$url_link = PHPWG_ROOT_PATH.'category.php?cat='.$row['id'];
|
|
|
96 |
|
|
|
97 |
$template->assign_block_vars(
|
|
|
98 |
'thumbnails.line.thumbnail',
|
|
|
99 |
array(
|
|
|
100 |
'IMAGE' => $thumbnail_link,
|
|
|
101 |
'IMAGE_ALT' => $row['name'],
|
|
|
102 |
'IMAGE_TITLE' => $thumbnail_title,
|
|
|
103 |
'IMAGE_NAME' => '['.$row['name'].']',
|
|
|
104 |
'IMAGE_TS' => get_icon(@$row['date_last']),
|
|
|
105 |
'IMAGE_STYLE' => 'thumb_category',
|
|
|
106 |
|
|
|
107 |
'U_IMG_LINK' => add_session_id($url_link)
|
|
|
108 |
)
|
|
|
109 |
);
|
|
|
110 |
$template->assign_block_vars('thumbnails.line.thumbnail.bullet',array());
|
|
|
111 |
|
|
|
112 |
// create a new line ?
|
|
|
113 |
if (++$row_number == $user['nb_image_line'])
|
|
|
114 |
{
|
|
|
115 |
$template->assign_block_vars('thumbnails.line', array());
|
|
|
116 |
$row_number = 0;
|
|
|
117 |
}
|
|
|
118 |
}
|
|
|
119 |
?>
|