[440] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 3 | // | Piwigo - a PHP based photo gallery | |
---|
[2297] | 4 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 5 | // | Copyright(C) 2008-2011 Piwigo Team http://piwigo.org | |
---|
[2297] | 6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
| 7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
| 8 | // +-----------------------------------------------------------------------+ |
---|
| 9 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 10 | // | it under the terms of the GNU General Public License as published by | |
---|
| 11 | // | the Free Software Foundation | |
---|
| 12 | // | | |
---|
| 13 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 16 | // | General Public License for more details. | |
---|
| 17 | // | | |
---|
| 18 | // | You should have received a copy of the GNU General Public License | |
---|
| 19 | // | along with this program; if not, write to the Free Software | |
---|
| 20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 21 | // | USA. | |
---|
| 22 | // +-----------------------------------------------------------------------+ |
---|
[440] | 23 | |
---|
| 24 | /** |
---|
[1082] | 25 | * This file is included by the main page to show thumbnails for the default |
---|
[440] | 26 | * case |
---|
[1090] | 27 | * |
---|
[440] | 28 | */ |
---|
| 29 | |
---|
[1036] | 30 | $pictures = array(); |
---|
| 31 | |
---|
| 32 | $selection = array_slice( |
---|
| 33 | $page['items'], |
---|
| 34 | $page['start'], |
---|
| 35 | $page['nb_image_page'] |
---|
| 36 | ); |
---|
| 37 | |
---|
| 38 | if (count($selection) > 0) |
---|
| 39 | { |
---|
[3126] | 40 | $rank_of = array_flip($page['items']); |
---|
| 41 | |
---|
[1036] | 42 | $query = ' |
---|
| 43 | SELECT * |
---|
| 44 | FROM '.IMAGES_TABLE.' |
---|
[1677] | 45 | WHERE id IN ('.implode(',', $selection).') |
---|
| 46 | ;'; |
---|
[1036] | 47 | $result = pwg_query($query); |
---|
[4325] | 48 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[1036] | 49 | { |
---|
[3128] | 50 | $row['rank'] = $rank_of[ $row['id'] ]; |
---|
[1090] | 51 | |
---|
[1036] | 52 | array_push($pictures, $row); |
---|
| 53 | } |
---|
[440] | 54 | |
---|
[1036] | 55 | usort($pictures, 'rank_compare'); |
---|
[3126] | 56 | unset($rank_of); |
---|
[1036] | 57 | } |
---|
| 58 | |
---|
| 59 | if (count($pictures) > 0) |
---|
[440] | 60 | { |
---|
[2218] | 61 | // define category slideshow url |
---|
| 62 | $row = reset($pictures); |
---|
| 63 | $page['cat_slideshow_url'] = |
---|
| 64 | add_url_params( |
---|
| 65 | duplicate_picture_url( |
---|
| 66 | array( |
---|
| 67 | 'image_id' => $row['id'], |
---|
| 68 | 'image_file' => $row['file'] |
---|
| 69 | ), |
---|
| 70 | array('start') |
---|
| 71 | ), |
---|
| 72 | array('slideshow' => |
---|
| 73 | (isset($_GET['slideshow']) ? $_GET['slideshow'] |
---|
| 74 | : '' )) |
---|
| 75 | ); |
---|
[2234] | 76 | |
---|
[2274] | 77 | if ($user['show_nb_comments']) |
---|
| 78 | { |
---|
| 79 | $query = ' |
---|
| 80 | SELECT image_id, COUNT(*) AS nb_comments |
---|
| 81 | FROM '.COMMENTS_TABLE.' |
---|
| 82 | WHERE validated = \'true\' |
---|
| 83 | AND image_id IN ('.implode(',', $selection).') |
---|
| 84 | GROUP BY image_id |
---|
| 85 | ;'; |
---|
| 86 | $nb_comments_of = simple_hash_from_query($query, 'image_id', 'nb_comments'); |
---|
| 87 | } |
---|
[440] | 88 | } |
---|
| 89 | |
---|
[2274] | 90 | // template thumbnail initialization |
---|
| 91 | $template->set_filenames( array( 'index_thumbnails' => 'thumbnails.tpl',)); |
---|
| 92 | |
---|
[1596] | 93 | trigger_action('loc_begin_index_thumbnails', $pictures); |
---|
[3124] | 94 | $tpl_thumbnails_var = array(); |
---|
[1596] | 95 | |
---|
[1036] | 96 | foreach ($pictures as $row) |
---|
[440] | 97 | { |
---|
[1090] | 98 | // link on picture.php page |
---|
| 99 | $url = duplicate_picture_url( |
---|
| 100 | array( |
---|
| 101 | 'image_id' => $row['id'], |
---|
| 102 | 'image_file' => $row['file'] |
---|
[1094] | 103 | ), |
---|
| 104 | array('start') |
---|
[1090] | 105 | ); |
---|
[3491] | 106 | |
---|
[11996] | 107 | if (isset($nb_comments_of) ) |
---|
| 108 | { |
---|
| 109 | $row['nb_comments'] = (int)@$nb_comments_of[$row['id']]; |
---|
| 110 | } |
---|
| 111 | |
---|
[12451] | 112 | $name = get_picture_title($row); |
---|
| 113 | |
---|
[12546] | 114 | $tpl_var = array( |
---|
| 115 | 'ID' => $row['id'], |
---|
| 116 | 'TN_SRC' => get_thumbnail_url($row), |
---|
| 117 | 'TN_ALT' => htmlspecialchars(strip_tags($name)), |
---|
| 118 | 'TN_TITLE' => get_thumbnail_title($row), |
---|
| 119 | 'URL' => $url, |
---|
[2841] | 120 | |
---|
[12546] | 121 | // Extra fields for usage in extra themes |
---|
| 122 | 'FILE_PATH' => $row['path'], |
---|
| 123 | 'FILE_POSTED' => $row['date_available'], |
---|
| 124 | 'FILE_CREATED' => $row['date_creation'], |
---|
| 125 | 'FILE_DESC' => $row['comment'], |
---|
| 126 | 'FILE_AUTHOR' => $row['author'], |
---|
| 127 | 'FILE_HIT' => $row['hit'], |
---|
| 128 | 'FILE_SIZE' => $row['filesize'], |
---|
| 129 | 'FILE_WIDTH' => $row['width'], |
---|
| 130 | 'FILE_HEIGHT' => $row['height'], |
---|
| 131 | 'FILE_METADATE' => $row['date_metadata_update'], |
---|
| 132 | 'FILE_HAS_HD' => $row['has_high'], |
---|
| 133 | 'FILE_HD_WIDTH' => $row['high_width'], |
---|
| 134 | 'FILE_HD_HEIGHT' => $row['high_height'], |
---|
| 135 | 'FILE_HD_FILESIZE' => $row['high_filesize'], |
---|
| 136 | 'FILE_RATING_SCORE' => $row['rating_score'], |
---|
[440] | 137 | ); |
---|
[12546] | 138 | |
---|
[11285] | 139 | if ($conf['index_new_icon']) |
---|
| 140 | { |
---|
[11591] | 141 | $tpl_var['icon_ts'] = get_icon($row['date_available']); |
---|
[11285] | 142 | } |
---|
[2234] | 143 | |
---|
[1864] | 144 | if ($user['show_nb_hits']) |
---|
[1763] | 145 | { |
---|
[2274] | 146 | $tpl_var['NB_HITS'] = $row['hit']; |
---|
[1763] | 147 | } |
---|
[11981] | 148 | |
---|
| 149 | switch ($page['section']) |
---|
| 150 | { |
---|
| 151 | case 'best_rated' : |
---|
| 152 | { |
---|
| 153 | $name = '('.$row['rating_score'].') '.$name; |
---|
| 154 | break; |
---|
| 155 | } |
---|
| 156 | case 'most_visited' : |
---|
| 157 | { |
---|
| 158 | if ( !$user['show_nb_hits']) |
---|
| 159 | { |
---|
| 160 | $name = '('.$row['hit'].') '.$name; |
---|
| 161 | } |
---|
| 162 | break; |
---|
| 163 | } |
---|
| 164 | } |
---|
| 165 | |
---|
| 166 | $tpl_var['NAME'] = $name; |
---|
[1082] | 167 | |
---|
[11996] | 168 | if (isset($row['nb_comments'])) |
---|
[440] | 169 | { |
---|
[11996] | 170 | $tpl_var['NB_COMMENTS'] = $row['nb_comments']; |
---|
[440] | 171 | } |
---|
| 172 | |
---|
[3124] | 173 | $tpl_thumbnails_var[] = $tpl_var; |
---|
[440] | 174 | } |
---|
[1596] | 175 | |
---|
[12391] | 176 | $template->assign('SHOW_THUMBNAIL_CAPTION', $conf['show_thumbnail_caption']); |
---|
[3124] | 177 | $tpl_thumbnails_var = trigger_event('loc_end_index_thumbnails', $tpl_thumbnails_var, $pictures); |
---|
| 178 | $template->assign('thumbnails', $tpl_thumbnails_var); |
---|
[12391] | 179 | |
---|
[2274] | 180 | $template->assign_var_from_handle('THUMBNAILS', 'index_thumbnails'); |
---|
[1036] | 181 | |
---|
| 182 | pwg_debug('end include/category_default.inc.php'); |
---|
[3120] | 183 | ?> |
---|