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

Last change on this file since 579 was 579, checked in by z0rglub, 20 years ago
  • refactoring of comments.php
  • creation of function get_thumbnail_src used everywhere a thumbnail must be displayed
  • creation of function parse_comment_content (used in comments.php and picture.php)
  • concerning undefined index on arrays retrieved in database, instead of testing possibly unset values, use of @ operator (smarter...)
  • add pre tag in default.css stylesheet for debugging purpose (need to have left aligned text)
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.1 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-10-23 17:56:46 +0000 (Sat, 23 Oct 2004) $
10// | last modifier : $Author: z0rglub $
11// | revision      : $Revision: 579 $
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  $thumbnail_link = get_thumbnail_src($image_row['file'],
90                                      $image_row['storage_category_id'],
91                                      @$image_row['tn_ext']);
92
93  $thumbnail_title = $lang['hint_category'];
94
95  $url_link = PHPWG_ROOT_PATH.'category.php?cat='.$subcat_id;
96
97  $date = $page['plain_structure'][$subcat_id]['date_last'];
98
99  $template->assign_block_vars(
100    'thumbnails.line.thumbnail',
101    array(
102      'IMAGE'                 => $thumbnail_link,
103      'IMAGE_ALT'             => $image_row['file'],
104      'IMAGE_TITLE'           => $thumbnail_title,
105      'IMAGE_NAME'            => '['.$name.']',
106      'IMAGE_TS'              => get_icon($date),
107      'IMAGE_STYLE'           => 'thumb_category',
108       
109      'U_IMG_LINK'            => add_session_id($url_link)
110     )
111   );
112  $template->assign_block_vars('thumbnails.line.thumbnail.bullet',array());
113
114  // create a new line ?
115  if (++$row_number == $user['nb_image_line'])
116  {
117    $template->assign_block_vars('thumbnails.line', array());
118    $row_number = 0;
119  }
120}
121?>
Note: See TracBrowser for help on using the repository browser.