source: trunk/include/category_subcats.inc.php @ 486

Last change on this file since 486 was 470, checked in by z0rglub, 20 years ago

non picture files management

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.5 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// |                        category_subcats.inc.php                       |
4// +-----------------------------------------------------------------------+
5// | application   : PhpWebGallery <http://phpwebgallery.net>              |
6// | branch        : BSF (Best So Far)                                     |
7// +-----------------------------------------------------------------------+
8// | file          : $RCSfile$
9// | last update   : $Date: 2004-08-05 17:38:14 +0000 (Thu, 05 Aug 2004) $
10// | last modifier : $Author: z0rglub $
11// | revision      : $Revision: 470 $
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$subcats = array();
35if (isset($page['cat']))
36{
37  $subcats = get_non_empty_subcat_ids($page['cat']);
38}
39else
40{
41  $subcats = get_non_empty_subcat_ids('');
42}
43
44// template thumbnail initialization
45if (count($subcats) > 0)
46{
47  $template->assign_block_vars('thumbnails', array());
48  // first line
49  $template->assign_block_vars('thumbnails.line', array());
50  // current row displayed
51  $row_number = 0;
52}
53 
54foreach ($subcats as $subcat_id => $non_empty_id) 
55{
56  $name = $page['plain_structure'][$subcat_id]['name'];
57
58  // searching the representative picture of the category
59  $query = '
60SELECT representative_picture_id
61  FROM '.CATEGORIES_TABLE.'
62  WHERE id = '.$non_empty_id.'
63;';
64  $row = mysql_fetch_array(mysql_query($query));
65   
66  $query = '
67SELECT file,tn_ext,storage_category_id
68  FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE.'
69  WHERE category_id = '.$non_empty_id.'
70    AND id = image_id';
71  // if the category has a representative picture, this is its thumbnail
72  // that will be displayed !
73  if (isset($row['representative_picture_id']))
74  {   
75    $query.= '
76    AND id = '.$row['representative_picture_id'];
77  }
78  else
79  {
80    $query.= '
81  ORDER BY RAND()
82  LIMIT 0,1';
83  }
84  $query.= '
85;';
86  $image_result = mysql_query($query);
87  $image_row    = mysql_fetch_array($image_result);
88
89  $file = get_filename_wo_extension($image_row['file']);
90
91  // creating links for thumbnail and associated category
92  if (isset($image_row['tn_ext']) and $image_row['tn_ext'] != '')
93  {
94    $thumbnail_link = get_complete_dir($image_row['storage_category_id']);
95    $thumbnail_link.= 'thumbnail/'.$conf['prefix_thumbnail'];
96    $thumbnail_link.= $file.'.'.$image_row['tn_ext'];
97  }
98  else
99  {
100    $thumbnail_link = './template/'.$user['template'].'/mimetypes/';
101    $thumbnail_link.= strtolower(get_extension($image_row['file'])).'.png';
102  }
103
104  $thumbnail_title = $lang['hint_category'];
105
106  $url_link = PHPWG_ROOT_PATH.'category.php?cat='.$subcat_id;
107
108  $date = $page['plain_structure'][$subcat_id]['date_last'];
109
110  $template->assign_block_vars(
111    'thumbnails.line.thumbnail',
112    array(
113      'IMAGE'                 => $thumbnail_link,
114      'IMAGE_ALT'             => $image_row['file'],
115      'IMAGE_TITLE'           => $thumbnail_title,
116      'IMAGE_NAME'            => '['.$name.']',
117      'IMAGE_TS'              => get_icon($date),
118      'IMAGE_STYLE'           => 'thumb_category',
119       
120      'U_IMG_LINK'            => add_session_id($url_link)
121     )
122   );
123  $template->assign_block_vars('thumbnails.line.thumbnail.bullet',array());
124
125  // create a new line ?
126  if (++$row_number == $user['nb_image_line'])
127  {
128    $template->assign_block_vars('thumbnails.line', array());
129    $row_number = 0;
130  }
131}
132?>
Note: See TracBrowser for help on using the repository browser.