[440] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[593] | 3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
| 4 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
[675] | 5 | // | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
---|
[440] | 6 | // +-----------------------------------------------------------------------+ |
---|
[593] | 7 | // | branch : BSF (Best So Far) |
---|
[440] | 8 | // | file : $RCSfile$ |
---|
| 9 | // | last update : $Date: 2006-06-24 08:56:59 +0000 (Sat, 24 Jun 2006) $ |
---|
| 10 | // | last modifier : $Author: chrisaga $ |
---|
| 11 | // | revision : $Revision: 1384 $ |
---|
| 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 | /** |
---|
[1082] | 29 | * This file is included by the main page to show thumbnails for the default |
---|
[440] | 30 | * case |
---|
[1090] | 31 | * |
---|
[440] | 32 | */ |
---|
| 33 | |
---|
[1036] | 34 | $page['rank_of'] = array_flip($page['items']); |
---|
| 35 | |
---|
| 36 | $pictures = array(); |
---|
| 37 | |
---|
| 38 | $selection = array_slice( |
---|
| 39 | $page['items'], |
---|
| 40 | $page['start'], |
---|
| 41 | $page['nb_image_page'] |
---|
| 42 | ); |
---|
| 43 | |
---|
| 44 | if (count($selection) > 0) |
---|
| 45 | { |
---|
| 46 | $query = ' |
---|
| 47 | SELECT * |
---|
| 48 | FROM '.IMAGES_TABLE.' |
---|
| 49 | WHERE id IN ('.implode(',', $selection).') |
---|
[440] | 50 | ;'; |
---|
[1036] | 51 | $result = pwg_query($query); |
---|
| 52 | while ($row = mysql_fetch_array($result)) |
---|
| 53 | { |
---|
| 54 | $row['rank'] = $page['rank_of'][ $row['id'] ]; |
---|
[1090] | 55 | |
---|
[1036] | 56 | array_push($pictures, $row); |
---|
| 57 | } |
---|
[440] | 58 | |
---|
[1036] | 59 | usort($pictures, 'rank_compare'); |
---|
| 60 | } |
---|
| 61 | |
---|
[440] | 62 | // template thumbnail initialization |
---|
[1384] | 63 | $template->set_filenames( array( 'thumbnails' => 'thumbnails.tpl',)); |
---|
[1036] | 64 | if (count($pictures) > 0) |
---|
[440] | 65 | { |
---|
| 66 | $template->assign_block_vars('thumbnails', array()); |
---|
| 67 | // first line |
---|
| 68 | $template->assign_block_vars('thumbnails.line', array()); |
---|
| 69 | // current row displayed |
---|
| 70 | $row_number = 0; |
---|
| 71 | } |
---|
| 72 | |
---|
[1036] | 73 | foreach ($pictures as $row) |
---|
[440] | 74 | { |
---|
[606] | 75 | $thumbnail_url = get_thumbnail_src($row['path'], @$row['tn_ext']); |
---|
[1090] | 76 | |
---|
[440] | 77 | // message in title for the thumbnail |
---|
| 78 | $thumbnail_title = $row['file']; |
---|
[526] | 79 | if (isset($row['filesize'])) |
---|
[440] | 80 | { |
---|
[526] | 81 | $thumbnail_title .= ' : '.$row['filesize'].' KB'; |
---|
[440] | 82 | } |
---|
[1119] | 83 | |
---|
[1090] | 84 | // link on picture.php page |
---|
| 85 | $url = duplicate_picture_url( |
---|
| 86 | array( |
---|
| 87 | 'image_id' => $row['id'], |
---|
| 88 | 'image_file' => $row['file'] |
---|
[1094] | 89 | ), |
---|
| 90 | array('start') |
---|
[1090] | 91 | ); |
---|
| 92 | |
---|
[440] | 93 | $template->assign_block_vars( |
---|
| 94 | 'thumbnails.line.thumbnail', |
---|
| 95 | array( |
---|
| 96 | 'IMAGE' => $thumbnail_url, |
---|
| 97 | 'IMAGE_ALT' => $row['file'], |
---|
| 98 | 'IMAGE_TITLE' => $thumbnail_title, |
---|
| 99 | 'IMAGE_TS' => get_icon($row['date_available']), |
---|
[1090] | 100 | |
---|
[1098] | 101 | 'U_IMG_LINK' => $url, |
---|
| 102 | |
---|
| 103 | 'CLASS' => 'thumbElmt', |
---|
[440] | 104 | ) |
---|
| 105 | ); |
---|
[803] | 106 | |
---|
| 107 | if ($conf['show_thumbnail_caption']) |
---|
| 108 | { |
---|
| 109 | // name of the picture |
---|
| 110 | if (isset($row['name']) and $row['name'] != '') |
---|
| 111 | { |
---|
| 112 | $name = $row['name']; |
---|
| 113 | } |
---|
| 114 | else |
---|
| 115 | { |
---|
| 116 | $name = str_replace('_', ' ', get_filename_wo_extension($row['file'])); |
---|
| 117 | } |
---|
[1082] | 118 | |
---|
| 119 | switch ($page['section']) |
---|
[803] | 120 | { |
---|
[1082] | 121 | case 'best_rated' : |
---|
[1056] | 122 | { |
---|
| 123 | $name = '('.$row['average_rate'].') '.$name; |
---|
[1082] | 124 | break; |
---|
[1056] | 125 | } |
---|
[1082] | 126 | case 'most_visited' : |
---|
[1056] | 127 | { |
---|
| 128 | $name = '('.$row['hit'].') '.$name; |
---|
[1082] | 129 | break; |
---|
[1056] | 130 | } |
---|
[1082] | 131 | case 'search' : |
---|
[1056] | 132 | { |
---|
[1092] | 133 | $name = replace_search($name, $page['search']); |
---|
[1082] | 134 | break; |
---|
[1056] | 135 | } |
---|
[803] | 136 | } |
---|
[1090] | 137 | |
---|
[803] | 138 | $template->assign_block_vars( |
---|
| 139 | 'thumbnails.line.thumbnail.element_name', |
---|
| 140 | array( |
---|
| 141 | 'NAME' => $name |
---|
| 142 | ) |
---|
| 143 | ); |
---|
| 144 | } |
---|
[1090] | 145 | |
---|
[602] | 146 | if ($user['show_nb_comments'] |
---|
[1082] | 147 | and isset($page['category']) |
---|
[602] | 148 | and $page['cat_commentable']) |
---|
[440] | 149 | { |
---|
| 150 | $query = ' |
---|
| 151 | SELECT COUNT(*) AS nb_comments |
---|
| 152 | FROM '.COMMENTS_TABLE.' |
---|
| 153 | WHERE image_id = '.$row['id'].' |
---|
| 154 | AND validated = \'true\' |
---|
| 155 | ;'; |
---|
[587] | 156 | $row = mysql_fetch_array(pwg_query($query)); |
---|
[440] | 157 | $template->assign_block_vars( |
---|
| 158 | 'thumbnails.line.thumbnail.nb_comments', |
---|
| 159 | array('NB_COMMENTS'=>$row['nb_comments'])); |
---|
| 160 | } |
---|
| 161 | |
---|
| 162 | // create a new line ? |
---|
| 163 | if (++$row_number == $user['nb_image_line']) |
---|
| 164 | { |
---|
| 165 | $template->assign_block_vars('thumbnails.line', array()); |
---|
| 166 | $row_number = 0; |
---|
| 167 | } |
---|
| 168 | } |
---|
[1384] | 169 | $template->assign_var_from_handle('THUMBNAILS', 'thumbnails'); |
---|
[1036] | 170 | |
---|
| 171 | pwg_debug('end include/category_default.inc.php'); |
---|
[1098] | 172 | ?> |
---|