[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-27 00:38:19 +0000 (Tue, 27 Jun 2006) $ |
---|
| 10 | // | last modifier : $Author: rvelices $ |
---|
| 11 | // | revision : $Revision: 1407 $ |
---|
| 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 recent_cats |
---|
[440] | 30 | * category |
---|
[1092] | 31 | * |
---|
[440] | 32 | */ |
---|
| 33 | |
---|
[1130] | 34 | // FIXME: categories having no representant |
---|
| 35 | // ($conf['allow_random_representative'] = true) are not displayed :-/ |
---|
| 36 | |
---|
[440] | 37 | // retrieving categories recently update, ie containing pictures added |
---|
| 38 | // recently. The calculated table field categories.date_last will be |
---|
| 39 | // easier to use |
---|
| 40 | $query = ' |
---|
[1130] | 41 | SELECT c.id AS category_id |
---|
| 42 | , uppercats |
---|
| 43 | , representative_picture_id |
---|
| 44 | , path |
---|
| 45 | , file |
---|
| 46 | , c.comment |
---|
| 47 | , tn_ext |
---|
| 48 | , nb_images |
---|
[1145] | 49 | , c.name AS cat_name |
---|
[1130] | 50 | FROM '.CATEGORIES_TABLE.' AS c |
---|
| 51 | INNER JOIN '.IMAGES_TABLE.' AS i ON i.id = c.representative_picture_id |
---|
| 52 | WHERE date_last > SUBDATE( |
---|
| 53 | CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY |
---|
| 54 | )'; |
---|
[440] | 55 | if ( $user['forbidden_categories'] != '' ) |
---|
| 56 | { |
---|
| 57 | $query.= ' |
---|
[664] | 58 | AND c.id NOT IN ('.$user['forbidden_categories'].')'; |
---|
[440] | 59 | } |
---|
| 60 | $query.= ' |
---|
| 61 | ;'; |
---|
[587] | 62 | $result = pwg_query( $query ); |
---|
[440] | 63 | |
---|
[1132] | 64 | if ($conf['subcatify']) |
---|
[440] | 65 | { |
---|
[1132] | 66 | $template->set_filenames( |
---|
[440] | 67 | array( |
---|
[1132] | 68 | 'mainpage_categories' => 'mainpage_categories.tpl', |
---|
[760] | 69 | ) |
---|
| 70 | ); |
---|
[1145] | 71 | |
---|
[1132] | 72 | // template thumbnail initialization |
---|
| 73 | if (mysql_num_rows($result) > 0) |
---|
| 74 | { |
---|
| 75 | $template->assign_block_vars('categories', array()); |
---|
| 76 | } |
---|
| 77 | |
---|
[1145] | 78 | $comment = null; |
---|
| 79 | if (isset($row['comment'])) |
---|
| 80 | { |
---|
[1354] | 81 | $comment = strip_tags($row['comment'], '<a><br><p><b><i><small><strong><font>'); |
---|
[1145] | 82 | } |
---|
| 83 | |
---|
[1132] | 84 | // for each category, we have to search a recent picture to display and |
---|
| 85 | // the name to display |
---|
| 86 | while ( $row = mysql_fetch_array( $result ) ) |
---|
| 87 | { |
---|
| 88 | $template->assign_block_vars( |
---|
| 89 | 'categories.category', |
---|
| 90 | array( |
---|
| 91 | 'SRC' => get_thumbnail_src($row['path'], @$row['tn_ext']), |
---|
| 92 | 'ALT' => $row['file'], |
---|
| 93 | 'TITLE' => $lang['hint_category'], |
---|
[1145] | 94 | |
---|
[1132] | 95 | 'URL' => make_index_url( |
---|
| 96 | array( |
---|
| 97 | 'category' => $row['category_id'], |
---|
[1145] | 98 | 'cat_name' => $row['cat_name'], |
---|
[1132] | 99 | ) |
---|
| 100 | ), |
---|
| 101 | 'NAME' => get_cat_display_name_cache($row['uppercats'], null, false), |
---|
[1172] | 102 | 'CAPTION_NB_IMAGES' => (($row['nb_images'] == 0) ? '' : sprintf("%d ".l10n('pictures'), $row['nb_images'])), |
---|
[1145] | 103 | 'DESCRIPTION' => $comment, |
---|
[1132] | 104 | ) |
---|
| 105 | ); |
---|
| 106 | } |
---|
| 107 | |
---|
| 108 | $template->assign_var_from_handle('CATEGORIES', 'mainpage_categories'); |
---|
[440] | 109 | } |
---|
[1132] | 110 | else |
---|
| 111 | { |
---|
[1407] | 112 | $template->set_filenames( array( 'thumbnails' => 'thumbnails.tpl',)); |
---|
[1132] | 113 | // template thumbnail initialization |
---|
| 114 | if (mysql_num_rows($result) > 0) |
---|
| 115 | { |
---|
| 116 | $template->assign_block_vars('thumbnails', array()); |
---|
| 117 | // first line |
---|
| 118 | $template->assign_block_vars('thumbnails.line', array()); |
---|
| 119 | // current row displayed |
---|
| 120 | $row_number = 0; |
---|
| 121 | } |
---|
[1145] | 122 | |
---|
[1132] | 123 | $old_level_separator = $conf['level_separator']; |
---|
| 124 | $conf['level_separator'] = '<br />'; |
---|
| 125 | // for each category, we have to search a recent picture to display and |
---|
| 126 | // the name to display |
---|
| 127 | while ( $row = mysql_fetch_array( $result ) ) |
---|
| 128 | { |
---|
| 129 | $template->assign_block_vars( |
---|
| 130 | 'thumbnails.line.thumbnail', |
---|
| 131 | array( |
---|
| 132 | 'IMAGE' => get_thumbnail_src($row['path'], @$row['tn_ext']), |
---|
| 133 | 'IMAGE_ALT' => $row['file'], |
---|
| 134 | 'IMAGE_TITLE' => $lang['hint_category'], |
---|
[1145] | 135 | |
---|
[1132] | 136 | 'U_IMG_LINK' => make_index_url( |
---|
| 137 | array( |
---|
| 138 | 'category' => $row['category_id'], |
---|
[1145] | 139 | 'cat_name' => $row['cat_name'], |
---|
[1132] | 140 | ) |
---|
| 141 | ), |
---|
| 142 | ) |
---|
| 143 | ); |
---|
| 144 | |
---|
| 145 | $template->assign_block_vars( |
---|
| 146 | 'thumbnails.line.thumbnail.category_name', |
---|
| 147 | array( |
---|
| 148 | 'NAME' => get_cat_display_name_cache($row['uppercats'], null, false), |
---|
| 149 | ) |
---|
| 150 | ); |
---|
| 151 | |
---|
| 152 | // create a new line ? |
---|
| 153 | if (++$row_number == $user['nb_image_line']) |
---|
| 154 | { |
---|
| 155 | $template->assign_block_vars('thumbnails.line', array()); |
---|
| 156 | $row_number = 0; |
---|
| 157 | } |
---|
| 158 | } |
---|
| 159 | $conf['level_separator'] = $old_level_separator; |
---|
[1407] | 160 | $template->assign_var_from_handle('THUMBNAILS', 'thumbnails'); |
---|
[1132] | 161 | } |
---|
[440] | 162 | ?> |
---|