[440] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[593] | 3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
| 4 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
| 5 | // | Copyright (C) 2003-2004 PhpWebGallery Team - http://phpwebgallery.net | |
---|
[440] | 6 | // +-----------------------------------------------------------------------+ |
---|
[593] | 7 | // | branch : BSF (Best So Far) |
---|
[440] | 8 | // | file : $RCSfile$ |
---|
| 9 | // | last update : $Date: 2004-11-06 21:12:59 +0000 (Sat, 06 Nov 2004) $ |
---|
| 10 | // | last modifier : $Author: z0rglub $ |
---|
| 11 | // | revision : $Revision: 593 $ |
---|
| 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 the default |
---|
| 30 | * case |
---|
| 31 | * |
---|
| 32 | */ |
---|
| 33 | |
---|
| 34 | /** |
---|
| 35 | * $array_cat_directories is a cache hash associating category id with their |
---|
| 36 | * complete directory |
---|
| 37 | */ |
---|
| 38 | $array_cat_directories = array(); |
---|
| 39 | |
---|
| 40 | $query = ' |
---|
[510] | 41 | SELECT DISTINCT(id),file,date_available,category_id |
---|
[508] | 42 | ,tn_ext,name,filesize,storage_category_id,average_rate |
---|
[440] | 43 | FROM '.IMAGES_TABLE.' AS i |
---|
| 44 | INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id=ic.image_id |
---|
| 45 | '.$page['where'].' |
---|
| 46 | '.$conf['order_by'].' |
---|
| 47 | LIMIT '.$page['start'].','.$page['nb_image_page'].' |
---|
| 48 | ;'; |
---|
| 49 | // echo '<pre>'.$query.'</pre>'; |
---|
[587] | 50 | $result = pwg_query($query); |
---|
[440] | 51 | |
---|
| 52 | // template thumbnail initialization |
---|
| 53 | if ( mysql_num_rows($result) > 0 ) |
---|
| 54 | { |
---|
| 55 | $template->assign_block_vars('thumbnails', array()); |
---|
| 56 | // first line |
---|
| 57 | $template->assign_block_vars('thumbnails.line', array()); |
---|
| 58 | // current row displayed |
---|
| 59 | $row_number = 0; |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | while ($row = mysql_fetch_array($result)) |
---|
| 63 | { |
---|
| 64 | // name of the picture |
---|
| 65 | if (isset($row['name']) and $row['name'] != '') |
---|
| 66 | { |
---|
| 67 | $name = $row['name']; |
---|
| 68 | } |
---|
| 69 | else |
---|
| 70 | { |
---|
[579] | 71 | $name = str_replace('_', ' ', get_filename_wo_extension($row['file'])); |
---|
[440] | 72 | } |
---|
[508] | 73 | if ($page['cat'] == 'best_rated') |
---|
| 74 | { |
---|
| 75 | $name = '('.$row['average_rate'].') '.$name; |
---|
| 76 | } |
---|
[440] | 77 | |
---|
| 78 | if ($page['cat'] == 'search') |
---|
| 79 | { |
---|
| 80 | $name = replace_search($name, $_GET['search']); |
---|
| 81 | } |
---|
[470] | 82 | |
---|
[579] | 83 | $thumbnail_url = get_thumbnail_src($row['file'], |
---|
| 84 | $row['storage_category_id'], |
---|
| 85 | @$row['tn_ext']); |
---|
| 86 | |
---|
[440] | 87 | // message in title for the thumbnail |
---|
| 88 | $thumbnail_title = $row['file']; |
---|
[526] | 89 | if (isset($row['filesize'])) |
---|
[440] | 90 | { |
---|
[526] | 91 | $thumbnail_title .= ' : '.$row['filesize'].' KB'; |
---|
[440] | 92 | } |
---|
| 93 | // url link on picture.php page |
---|
[510] | 94 | $url_link = PHPWG_ROOT_PATH.'picture.php?'; |
---|
| 95 | if ($page['cat'] == 'random') |
---|
| 96 | { |
---|
| 97 | $url_link.= 'cat='.$row['category_id']; |
---|
| 98 | } |
---|
| 99 | else |
---|
| 100 | { |
---|
| 101 | $url_link.= 'cat='.$page['cat']; |
---|
| 102 | } |
---|
[440] | 103 | $url_link.= '&image_id='.$row['id']; |
---|
| 104 | if ($page['cat'] == 'search') |
---|
| 105 | { |
---|
[456] | 106 | $url_link.= '&search='.$_GET['search']; |
---|
[440] | 107 | } |
---|
| 108 | |
---|
| 109 | $template->assign_block_vars( |
---|
| 110 | 'thumbnails.line.thumbnail', |
---|
| 111 | array( |
---|
| 112 | 'IMAGE' => $thumbnail_url, |
---|
| 113 | 'IMAGE_ALT' => $row['file'], |
---|
| 114 | 'IMAGE_TITLE' => $thumbnail_title, |
---|
| 115 | 'IMAGE_NAME' => $name, |
---|
| 116 | 'IMAGE_TS' => get_icon($row['date_available']), |
---|
| 117 | 'IMAGE_STYLE' => 'thumb_picture', |
---|
| 118 | |
---|
| 119 | 'U_IMG_LINK' => add_session_id($url_link) |
---|
| 120 | ) |
---|
| 121 | ); |
---|
| 122 | |
---|
| 123 | if ($conf['show_comments'] and $user['show_nb_comments']) |
---|
| 124 | { |
---|
| 125 | $query = ' |
---|
| 126 | SELECT COUNT(*) AS nb_comments |
---|
| 127 | FROM '.COMMENTS_TABLE.' |
---|
| 128 | WHERE image_id = '.$row['id'].' |
---|
| 129 | AND validated = \'true\' |
---|
| 130 | ;'; |
---|
[587] | 131 | $row = mysql_fetch_array(pwg_query($query)); |
---|
[440] | 132 | $template->assign_block_vars( |
---|
| 133 | 'thumbnails.line.thumbnail.nb_comments', |
---|
| 134 | array('NB_COMMENTS'=>$row['nb_comments'])); |
---|
| 135 | } |
---|
| 136 | |
---|
| 137 | // create a new line ? |
---|
| 138 | if (++$row_number == $user['nb_image_line']) |
---|
| 139 | { |
---|
| 140 | $template->assign_block_vars('thumbnails.line', array()); |
---|
| 141 | $row_number = 0; |
---|
| 142 | } |
---|
| 143 | } |
---|
| 144 | ?> |
---|