[440] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[593] | 3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
| 4 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
[1859] | 5 | // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | |
---|
[440] | 6 | // +-----------------------------------------------------------------------+ |
---|
[1859] | 7 | // | file : $Id: category_default.inc.php 2081 2007-08-27 19:08:54Z vdigital $ |
---|
[440] | 8 | // | last update : $Date: 2007-08-27 19:08:54 +0000 (Mon, 27 Aug 2007) $ |
---|
| 9 | // | last modifier : $Author: vdigital $ |
---|
| 10 | // | revision : $Revision: 2081 $ |
---|
| 11 | // +-----------------------------------------------------------------------+ |
---|
| 12 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 13 | // | it under the terms of the GNU General Public License as published by | |
---|
| 14 | // | the Free Software Foundation | |
---|
| 15 | // | | |
---|
| 16 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 17 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 18 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 19 | // | General Public License for more details. | |
---|
| 20 | // | | |
---|
| 21 | // | You should have received a copy of the GNU General Public License | |
---|
| 22 | // | along with this program; if not, write to the Free Software | |
---|
| 23 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 24 | // | USA. | |
---|
| 25 | // +-----------------------------------------------------------------------+ |
---|
| 26 | |
---|
| 27 | /** |
---|
[1082] | 28 | * This file is included by the main page to show thumbnails for the default |
---|
[440] | 29 | * case |
---|
[1090] | 30 | * |
---|
[440] | 31 | */ |
---|
| 32 | |
---|
[1036] | 33 | $page['rank_of'] = array_flip($page['items']); |
---|
| 34 | |
---|
| 35 | $pictures = array(); |
---|
| 36 | |
---|
| 37 | $selection = array_slice( |
---|
| 38 | $page['items'], |
---|
| 39 | $page['start'], |
---|
| 40 | $page['nb_image_page'] |
---|
| 41 | ); |
---|
| 42 | |
---|
| 43 | if (count($selection) > 0) |
---|
| 44 | { |
---|
| 45 | $query = ' |
---|
| 46 | SELECT * |
---|
| 47 | FROM '.IMAGES_TABLE.' |
---|
[1677] | 48 | WHERE id IN ('.implode(',', $selection).') |
---|
| 49 | ;'; |
---|
[1036] | 50 | $result = pwg_query($query); |
---|
[1596] | 51 | while ($row = mysql_fetch_assoc($result)) |
---|
[1036] | 52 | { |
---|
| 53 | $row['rank'] = $page['rank_of'][ $row['id'] ]; |
---|
[1090] | 54 | |
---|
[1036] | 55 | array_push($pictures, $row); |
---|
| 56 | } |
---|
[440] | 57 | |
---|
[1036] | 58 | usort($pictures, 'rank_compare'); |
---|
| 59 | } |
---|
| 60 | |
---|
[440] | 61 | // template thumbnail initialization |
---|
[1596] | 62 | $template->set_filenames( array( 'thumbnails' => 'thumbnails.tpl',)); |
---|
[1036] | 63 | if (count($pictures) > 0) |
---|
[440] | 64 | { |
---|
| 65 | // first line |
---|
| 66 | $template->assign_block_vars('thumbnails.line', array()); |
---|
| 67 | // current row displayed |
---|
| 68 | $row_number = 0; |
---|
| 69 | } |
---|
| 70 | |
---|
[1596] | 71 | trigger_action('loc_begin_index_thumbnails', $pictures); |
---|
| 72 | |
---|
[1036] | 73 | foreach ($pictures as $row) |
---|
[440] | 74 | { |
---|
[1596] | 75 | $thumbnail_url = get_thumbnail_url($row); |
---|
[1090] | 76 | |
---|
| 77 | // link on picture.php page |
---|
| 78 | $url = duplicate_picture_url( |
---|
| 79 | array( |
---|
| 80 | 'image_id' => $row['id'], |
---|
| 81 | 'image_file' => $row['file'] |
---|
[1094] | 82 | ), |
---|
| 83 | array('start') |
---|
[1090] | 84 | ); |
---|
| 85 | |
---|
[440] | 86 | $template->assign_block_vars( |
---|
| 87 | 'thumbnails.line.thumbnail', |
---|
| 88 | array( |
---|
| 89 | 'IMAGE' => $thumbnail_url, |
---|
| 90 | 'IMAGE_ALT' => $row['file'], |
---|
[1868] | 91 | 'IMAGE_TITLE' => get_thumbnail_title($row), |
---|
[440] | 92 | 'IMAGE_TS' => get_icon($row['date_available']), |
---|
[1090] | 93 | |
---|
[1098] | 94 | 'U_IMG_LINK' => $url, |
---|
| 95 | |
---|
| 96 | 'CLASS' => 'thumbElmt', |
---|
[440] | 97 | ) |
---|
| 98 | ); |
---|
[1864] | 99 | if ($user['show_nb_hits']) |
---|
[1763] | 100 | { |
---|
| 101 | $template->assign_block_vars( |
---|
| 102 | 'thumbnails.line.thumbnail.nb_hits', |
---|
[1769] | 103 | array( |
---|
| 104 | 'HITS'=> l10n_dec('%d hit', '%d hits', $row['hit']), |
---|
| 105 | 'CLASS'=> set_span_class($row['hit']) . ' nb-hits', |
---|
| 106 | ) |
---|
| 107 | ); |
---|
| 108 | |
---|
[1763] | 109 | } |
---|
[803] | 110 | |
---|
| 111 | if ($conf['show_thumbnail_caption']) |
---|
| 112 | { |
---|
| 113 | // name of the picture |
---|
| 114 | if (isset($row['name']) and $row['name'] != '') |
---|
| 115 | { |
---|
| 116 | $name = $row['name']; |
---|
| 117 | } |
---|
| 118 | else |
---|
| 119 | { |
---|
| 120 | $name = str_replace('_', ' ', get_filename_wo_extension($row['file'])); |
---|
| 121 | } |
---|
[1082] | 122 | |
---|
| 123 | switch ($page['section']) |
---|
[803] | 124 | { |
---|
[1082] | 125 | case 'best_rated' : |
---|
[1056] | 126 | { |
---|
| 127 | $name = '('.$row['average_rate'].') '.$name; |
---|
[1082] | 128 | break; |
---|
[1056] | 129 | } |
---|
[1082] | 130 | case 'most_visited' : |
---|
[1056] | 131 | { |
---|
[2081] | 132 | if ( !$user['show_nb_hits']) { |
---|
| 133 | $name = '('.$row['hit'].') '.$name; |
---|
| 134 | } |
---|
[1082] | 135 | break; |
---|
[1056] | 136 | } |
---|
[1082] | 137 | case 'search' : |
---|
[1056] | 138 | { |
---|
[1092] | 139 | $name = replace_search($name, $page['search']); |
---|
[1082] | 140 | break; |
---|
[1056] | 141 | } |
---|
[803] | 142 | } |
---|
[1090] | 143 | |
---|
[803] | 144 | $template->assign_block_vars( |
---|
| 145 | 'thumbnails.line.thumbnail.element_name', |
---|
| 146 | array( |
---|
| 147 | 'NAME' => $name |
---|
| 148 | ) |
---|
| 149 | ); |
---|
| 150 | } |
---|
[1090] | 151 | |
---|
[1864] | 152 | if ($user['show_nb_comments']) |
---|
[440] | 153 | { |
---|
| 154 | $query = ' |
---|
| 155 | SELECT COUNT(*) AS nb_comments |
---|
| 156 | FROM '.COMMENTS_TABLE.' |
---|
| 157 | WHERE image_id = '.$row['id'].' |
---|
| 158 | AND validated = \'true\' |
---|
| 159 | ;'; |
---|
[1882] | 160 | list($row['nb_comments']) = mysql_fetch_array(pwg_query($query)); |
---|
[440] | 161 | $template->assign_block_vars( |
---|
| 162 | 'thumbnails.line.thumbnail.nb_comments', |
---|
[1769] | 163 | array( |
---|
| 164 | 'NB_COMMENTS'=> l10n_dec('%d comment', '%d comments', |
---|
| 165 | $row['nb_comments']), |
---|
| 166 | 'CLASS'=> set_span_class($row['nb_comments']) . ' nb-comments', |
---|
| 167 | ) |
---|
| 168 | ); |
---|
[440] | 169 | } |
---|
| 170 | |
---|
[1596] | 171 | //plugins need to add/modify sth in this loop ? |
---|
| 172 | trigger_action('loc_index_thumbnail', $row, 'thumbnails.line.thumbnail' ); |
---|
| 173 | |
---|
[440] | 174 | // create a new line ? |
---|
| 175 | if (++$row_number == $user['nb_image_line']) |
---|
| 176 | { |
---|
| 177 | $template->assign_block_vars('thumbnails.line', array()); |
---|
| 178 | $row_number = 0; |
---|
| 179 | } |
---|
| 180 | } |
---|
[1596] | 181 | |
---|
| 182 | trigger_action('loc_end_index_thumbnails', $pictures); |
---|
[1384] | 183 | $template->assign_var_from_handle('THUMBNAILS', 'thumbnails'); |
---|
[1036] | 184 | |
---|
| 185 | pwg_debug('end include/category_default.inc.php'); |
---|
[1098] | 186 | ?> |
---|