[2] | 1 | <?php |
---|
| 2 | /*************************************************************************** |
---|
| 3 | * category.php * |
---|
| 4 | * ------------------- * |
---|
[57] | 5 | * application : PhpWebGallery 1.3 <http://phpwebgallery.net> * |
---|
| 6 | * author : Pierrick LE GALL <pierrick@z0rglub.com> * |
---|
[2] | 7 | * * |
---|
[57] | 8 | * $Id: category.php 376 2004-02-27 17:36:55Z z0rglub $ |
---|
| 9 | * * |
---|
[2] | 10 | ***************************************************************************/ |
---|
| 11 | |
---|
| 12 | /*************************************************************************** |
---|
| 13 | * * |
---|
| 14 | * This program is free software; you can redistribute it and/or modify * |
---|
| 15 | * it under the terms of the GNU General Public License as published by * |
---|
| 16 | * the Free Software Foundation; * |
---|
| 17 | * * |
---|
| 18 | ***************************************************************************/ |
---|
| 19 | //----------------------------------------------------------- personnal include |
---|
| 20 | include_once( './include/init.inc.php' ); |
---|
[45] | 21 | //---------------------------------------------------------------------- logout |
---|
[286] | 22 | if ( isset( $_GET['act'] ) |
---|
| 23 | and $_GET['act'] == 'logout' |
---|
| 24 | and isset( $_COOKIE['id'] ) ) |
---|
[45] | 25 | { |
---|
| 26 | // cookie deletion if exists |
---|
| 27 | setcookie( 'id', '', 0, cookie_path() ); |
---|
| 28 | $url = 'category.php'; |
---|
| 29 | header( 'Request-URI: '.$url ); |
---|
| 30 | header( 'Content-Location: '.$url ); |
---|
| 31 | header( 'Location: '.$url ); |
---|
| 32 | exit(); |
---|
| 33 | } |
---|
[2] | 34 | //-------------------------------------------------- access authorization check |
---|
[286] | 35 | if ( isset( $_GET['cat'] ) ) check_cat_id( $_GET['cat'] ); |
---|
[2] | 36 | check_login_authorization(); |
---|
[286] | 37 | if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) ) |
---|
[2] | 38 | { |
---|
| 39 | check_restrictions( $page['cat'] ); |
---|
| 40 | } |
---|
| 41 | //-------------------------------------------------------------- initialization |
---|
[252] | 42 | // detection of the start picture to display |
---|
| 43 | if ( !isset( $_GET['start'] ) |
---|
| 44 | or !is_numeric( $_GET['start'] ) |
---|
| 45 | or ( is_numeric( $_GET['start'] ) and $_GET['start'] < 0 ) ) |
---|
| 46 | $page['start'] = 0; |
---|
| 47 | else |
---|
| 48 | $page['start'] = $_GET['start']; |
---|
[376] | 49 | // Sometimes, a "num" is provided in the URL. It is the number |
---|
| 50 | // of the picture to show. This picture must be in the thumbnails page. |
---|
| 51 | // We have to find the right $page['start'] that show the num picture |
---|
| 52 | // in this category |
---|
| 53 | if ( isset( $_GET['num'] ) |
---|
| 54 | and is_numeric( $_GET['num'] ) |
---|
| 55 | and $_GET['num'] >= 0 ) |
---|
| 56 | { |
---|
| 57 | $page['start'] = floor( $_GET['num'] / $user['nb_image_page'] ); |
---|
| 58 | $page['start']*= $user['nb_image_page']; |
---|
| 59 | } |
---|
[252] | 60 | |
---|
| 61 | initialize_category(); |
---|
| 62 | |
---|
[2] | 63 | // creation of the array containing the cat ids to expand in the menu |
---|
| 64 | // $page['tab_expand'] contains an array with the category ids |
---|
| 65 | // $page['expand'] contains the string to display in URL with comma |
---|
| 66 | $page['tab_expand'] = array(); |
---|
| 67 | if ( isset ( $_GET['expand'] ) and $_GET['expand'] != 'all' ) |
---|
| 68 | { |
---|
[26] | 69 | $tab_expand = explode( ',', $_GET['expand'] ); |
---|
| 70 | foreach ( $tab_expand as $id ) { |
---|
| 71 | if ( is_numeric( $id ) ) array_push( $page['tab_expand'], $id ); |
---|
[2] | 72 | } |
---|
[252] | 73 | } |
---|
[274] | 74 | if ( isset($page['cat']) && is_numeric( $page['cat'] ) ) |
---|
[252] | 75 | { |
---|
| 76 | // the category displayed (in the URL cat=23) must be seen in the menu -> |
---|
| 77 | // parent categories must be expanded |
---|
| 78 | $uppercats = explode( ',', $page['uppercats'] ); |
---|
| 79 | foreach ( $uppercats as $uppercat ) { |
---|
| 80 | array_push( $page['tab_expand'], $uppercat ); |
---|
[193] | 81 | } |
---|
[2] | 82 | } |
---|
[252] | 83 | $page['tab_expand'] = array_unique( $page['tab_expand'] ); |
---|
| 84 | $page['expand'] = implode( ',', $page['tab_expand'] ); |
---|
[2] | 85 | // in case of expanding all authorized cats |
---|
| 86 | // The $page['expand'] equals 'all' and |
---|
| 87 | // $page['tab_expand'] contains all the authorized cat ids |
---|
[286] | 88 | if ( $user['expand'] |
---|
| 89 | or ( isset( $_GET['expand'] ) and $_GET['expand'] == 'all' ) ) |
---|
[2] | 90 | { |
---|
| 91 | $page['tab_expand'] = array(); |
---|
| 92 | $page['expand'] = 'all'; |
---|
| 93 | } |
---|
[26] | 94 | // creating the structure of the categories (useful for displaying the menu) |
---|
[252] | 95 | // creating the plain structure : array of all the available categories and |
---|
| 96 | // their relative informations, see the definition of the function |
---|
| 97 | // get_user_plain_structure for further details. |
---|
| 98 | $page['plain_structure'] = get_user_plain_structure(); |
---|
| 99 | $page['structure'] = create_user_structure( '' ); |
---|
[26] | 100 | $page['structure'] = update_structure( $page['structure'] ); |
---|
[290] | 101 | |
---|
[2] | 102 | //----------------------------------------------------- template initialization |
---|
[290] | 103 | |
---|
| 104 | // |
---|
| 105 | // Start output of page |
---|
| 106 | // |
---|
| 107 | $title = $page['title']; |
---|
| 108 | include('include/page_header.php'); |
---|
| 109 | |
---|
[2] | 110 | $handle = $vtp->Open( './template/'.$user['template'].'/category.vtp' ); |
---|
| 111 | initialize_template(); |
---|
[26] | 112 | $tpl = array( |
---|
| 113 | 'categories','hint_category','sub-cat','images_available','total', |
---|
| 114 | 'title_menu','nb_image_category','send_mail','title_send_mail', |
---|
[290] | 115 | 'connected_user','recent_image','days', |
---|
[26] | 116 | 'favorite_cat_hint','favorite_cat','stats','most_visited_cat_hint', |
---|
[128] | 117 | 'most_visited_cat','recent_cat','recent_cat_hint','upload_picture', |
---|
| 118 | 'comments' ); |
---|
[9] | 119 | templatize_array( $tpl, 'lang', $handle ); |
---|
[2] | 120 | |
---|
[290] | 121 | $tpl = array( 'mail_webmaster','webmaster','top_number'); |
---|
[9] | 122 | templatize_array( $tpl, 'conf', $handle ); |
---|
[2] | 123 | |
---|
[14] | 124 | $tpl = array( 'short_period','long_period','lien_collapsed', 'username' ); |
---|
[9] | 125 | templatize_array( $tpl, 'user', $handle ); |
---|
[2] | 126 | |
---|
[290] | 127 | $tpl = array( 'navigation_bar','cat_comment','cat_nb_images' ); |
---|
[9] | 128 | templatize_array( $tpl, 'page', $handle ); |
---|
[2] | 129 | |
---|
| 130 | // special global template vars |
---|
| 131 | $vtp->setGlobalVar( $handle, 'icon_short', get_icon( time() ) ); |
---|
| 132 | $icon_long = get_icon( time() - ( $user['short_period'] * 24 * 60 * 60 + 1 ) ); |
---|
| 133 | $vtp->setGlobalVar( $handle, 'icon_long', $icon_long ); |
---|
[252] | 134 | $nb_total_pictures = count_user_total_images(); |
---|
[2] | 135 | $vtp->setGlobalVar( $handle, 'nb_total_pictures',$nb_total_pictures ); |
---|
[252] | 136 | |
---|
[2] | 137 | //------------------------------------------------------------- categories menu |
---|
[314] | 138 | $vtp->setVar( $handle, 'home_url', add_session_id( 'category.php' ) ); |
---|
[2] | 139 | // normal categories |
---|
[26] | 140 | foreach ( $page['structure'] as $category ) { |
---|
| 141 | // display category is a function relative to the template |
---|
| 142 | display_category( $category, ' ', $handle ); |
---|
| 143 | } |
---|
[2] | 144 | // favorites cat |
---|
| 145 | if ( !$user['is_the_guest'] ) |
---|
| 146 | { |
---|
| 147 | $vtp->addSession( $handle, 'favorites' ); |
---|
[26] | 148 | $url = './category.php?cat=fav&expand='.$page['expand']; |
---|
| 149 | $vtp->setVar( $handle, 'favorites.url', add_session_id( $url ) ); |
---|
[2] | 150 | // searching the number of favorite picture |
---|
[16] | 151 | $query = 'SELECT COUNT(*) AS count'; |
---|
| 152 | $query.= ' FROM '.PREFIX_TABLE.'favorites'; |
---|
| 153 | $query.= ' WHERE user_id = '.$user['id'].';'; |
---|
[2] | 154 | $result = mysql_query( $query ); |
---|
| 155 | $row = mysql_fetch_array( $result ); |
---|
| 156 | $vtp->setVar( $handle, 'favorites.nb_favorites', $row['count'] ); |
---|
| 157 | $vtp->closeSession( $handle, 'favorites' ); |
---|
| 158 | } |
---|
| 159 | // most visited pictures category |
---|
[26] | 160 | $url = './category.php?cat=most_visited&expand='.$page['expand']; |
---|
| 161 | $vtp->setGlobalVar( $handle, 'most_visited_url', add_session_id( $url ) ); |
---|
[2] | 162 | // recent pictures |
---|
[26] | 163 | $url = './category.php?cat=recent&expand='.$page['expand']; |
---|
| 164 | $vtp->setGlobalVar( $handle, 'recent_url', add_session_id( $url ) ); |
---|
[2] | 165 | //--------------------------------------------------------------------- summary |
---|
| 166 | $vtp->addSession( $handle, 'summary' ); |
---|
| 167 | $vtp->setVar( $handle, 'summary.url', './identification.php' ); |
---|
| 168 | if ( !$user['is_the_guest'] ) |
---|
| 169 | { |
---|
| 170 | $vtp->setVar( $handle, 'summary.title', '' ); |
---|
[26] | 171 | $vtp->setVar( $handle, 'summary.name',replace_space($lang['change_login'])); |
---|
[2] | 172 | } |
---|
| 173 | else |
---|
| 174 | { |
---|
| 175 | $vtp->setVar( $handle, 'summary.title', $lang['hint_login'] ); |
---|
[175] | 176 | $vtp->setVar( $handle, 'summary.name', replace_space( $lang['menu_login'])); |
---|
[2] | 177 | } |
---|
| 178 | $vtp->closeSession( $handle, 'summary' ); |
---|
| 179 | // links for registered users |
---|
| 180 | if ( !$user['is_the_guest'] ) |
---|
| 181 | { |
---|
| 182 | // logout link |
---|
| 183 | $vtp->addSession( $handle, 'summary' ); |
---|
[45] | 184 | $vtp->setVar( $handle, 'summary.url', './category.php?act=logout' ); |
---|
[2] | 185 | $vtp->setVar( $handle, 'summary.title', '' ); |
---|
| 186 | $vtp->setVar( $handle, 'summary.name', replace_space( $lang['logout'] ) ); |
---|
| 187 | $vtp->closeSession( $handle, 'summary' ); |
---|
| 188 | // customization link |
---|
| 189 | $vtp->addSession( $handle, 'summary' ); |
---|
[274] | 190 | $url = './profile.php'; |
---|
| 191 | if (isset($page['cat']) && isset($page['expand'])) |
---|
| 192 | $url.='?cat='.$page['cat'].'&expand='.$page['expand']; |
---|
| 193 | if ( isset($page['cat']) && $page['cat'] == 'search' ) |
---|
[2] | 194 | { |
---|
[17] | 195 | $url.= '&search='.$_GET['search'].'&mode='.$_GET['mode']; |
---|
[2] | 196 | } |
---|
| 197 | $vtp->setVar( $handle, 'summary.url', add_session_id( $url ) ); |
---|
| 198 | $vtp->setVar( $handle, 'summary.title', $lang['hint_customize'] ); |
---|
| 199 | $vtp->setVar( $handle, 'summary.name', replace_space( $lang['customize'] ) ); |
---|
| 200 | $vtp->closeSession( $handle, 'summary' ); |
---|
| 201 | } |
---|
| 202 | // search link |
---|
| 203 | $vtp->addSession( $handle, 'summary' ); |
---|
| 204 | $vtp->setVar( $handle, 'summary.url', add_session_id( './search.php' ) ); |
---|
| 205 | $vtp->setVar( $handle, 'summary.title', $lang['hint_search'] ); |
---|
| 206 | $vtp->setVar( $handle, 'summary.name', replace_space( $lang['search'] ) ); |
---|
| 207 | $vtp->closeSession( $handle, 'summary' ); |
---|
[166] | 208 | // comments link |
---|
| 209 | $vtp->addSession( $handle, 'summary' ); |
---|
| 210 | $vtp->setVar( $handle, 'summary.url', add_session_id( './comments.php' ) ); |
---|
| 211 | $vtp->setVar( $handle, 'summary.title', $lang['hint_comments'] ); |
---|
| 212 | $vtp->setVar( $handle, 'summary.name', replace_space( $lang['comments'] ) ); |
---|
| 213 | $vtp->closeSession( $handle, 'summary' ); |
---|
[2] | 214 | // about link |
---|
| 215 | $vtp->addSession( $handle, 'summary' ); |
---|
[26] | 216 | $vtp->setVar( $handle, 'summary.url', './about.php?'. |
---|
| 217 | str_replace( '&', '&', $_SERVER['QUERY_STRING'] ) ); |
---|
[2] | 218 | $vtp->setVar( $handle, 'summary.title', $lang['hint_about'] ); |
---|
| 219 | $vtp->setVar( $handle, 'summary.name', replace_space( $lang['about'] ) ); |
---|
| 220 | $vtp->closeSession( $handle, 'summary' ); |
---|
| 221 | // administration link |
---|
| 222 | if ( $user['status'] == 'admin' ) |
---|
| 223 | { |
---|
| 224 | $vtp->addSession( $handle, 'summary' ); |
---|
| 225 | $vtp->setVar( $handle, 'summary.url', |
---|
| 226 | add_session_id( './admin/admin.php' ) ); |
---|
| 227 | $vtp->setVar( $handle, 'summary.title', $lang['hint_admin'] ); |
---|
| 228 | $vtp->setVar( $handle, 'summary.name', replace_space( $lang['admin'] ) ); |
---|
| 229 | $vtp->closeSession( $handle, 'summary' ); |
---|
| 230 | } |
---|
| 231 | //-------------------------------------------------------------- category title |
---|
| 232 | if ( isset ( $page['cat'] ) ) |
---|
| 233 | { |
---|
| 234 | if ( is_numeric( $page['cat'] ) ) |
---|
| 235 | { |
---|
| 236 | $cat_title = get_cat_display_name( $page['cat_name'], '<br />', |
---|
| 237 | 'font-style:italic;' ); |
---|
| 238 | $vtp->setGlobalVar( $handle, "cat_title", $cat_title ); |
---|
| 239 | } |
---|
| 240 | else |
---|
| 241 | { |
---|
| 242 | if ( $page['cat'] == 'search' ) |
---|
| 243 | { |
---|
| 244 | $page['title'].= ' : <span style="font-style:italic;">'; |
---|
| 245 | $page['title'].= $_GET['search']."</span>"; |
---|
| 246 | } |
---|
| 247 | $page['title'] = replace_space( $page['title'] ); |
---|
| 248 | $vtp->setGlobalVar( $handle, "cat_title", $page['title'] ); |
---|
| 249 | } |
---|
| 250 | } |
---|
| 251 | else |
---|
| 252 | { |
---|
| 253 | $vtp->setGlobalVar( $handle, "cat_title", |
---|
| 254 | replace_space( $lang['no_category'] ) ); |
---|
| 255 | } |
---|
| 256 | //------------------------------------------------------------------ thumbnails |
---|
| 257 | if ( isset( $page['cat'] ) and $page['cat_nb_images'] != 0 ) |
---|
| 258 | { |
---|
[61] | 259 | $array_cat_directories = array(); |
---|
[2] | 260 | |
---|
[64] | 261 | $query = 'SELECT distinct(id),file,date_available,tn_ext,name,filesize'; |
---|
| 262 | $query.= ',storage_category_id'; |
---|
| 263 | $query.= ' FROM '.PREFIX_TABLE.'images AS i'; |
---|
[252] | 264 | $query.=' INNER JOIN '.PREFIX_TABLE.'image_category AS ic ON id=ic.image_id'; |
---|
[2] | 265 | $query.= $page['where']; |
---|
| 266 | $query.= $conf['order_by']; |
---|
[16] | 267 | $query.= ' LIMIT '.$page['start'].','.$page['nb_image_page']; |
---|
[2] | 268 | $query.= ';'; |
---|
| 269 | $result = mysql_query( $query ); |
---|
| 270 | |
---|
| 271 | $vtp->addSession( $handle, 'thumbnails' ); |
---|
| 272 | $vtp->addSession( $handle, 'line' ); |
---|
[16] | 273 | // iteration counter to use a new <tr> every "$nb_image_line" pictures |
---|
[17] | 274 | $cell_number = 1; |
---|
| 275 | // iteration counter to be sure not to create too much lines in the table |
---|
| 276 | $line_number = 1; |
---|
[2] | 277 | while ( $row = mysql_fetch_array( $result ) ) |
---|
| 278 | { |
---|
[64] | 279 | // retrieving the storage dir of the picture |
---|
[276] | 280 | if ( !isset($array_cat_directories[$row['storage_category_id']])) |
---|
[2] | 281 | { |
---|
[61] | 282 | $array_cat_directories[$row['storage_category_id']] = |
---|
| 283 | get_complete_dir( $row['storage_category_id'] ); |
---|
[2] | 284 | } |
---|
[61] | 285 | $cat_directory = $array_cat_directories[$row['storage_category_id']]; |
---|
| 286 | |
---|
[16] | 287 | $file = get_filename_wo_extension( $row['file'] ); |
---|
[2] | 288 | // name of the picture |
---|
[311] | 289 | if ( isset( $row['name'] ) and $row['name'] != '' ) $name = $row['name']; |
---|
| 290 | else $name = str_replace( '_', ' ', $file ); |
---|
[61] | 291 | |
---|
[2] | 292 | if ( $page['cat'] == 'search' ) |
---|
| 293 | { |
---|
| 294 | $name = replace_search( $name, $_GET['search'] ); |
---|
| 295 | } |
---|
| 296 | // thumbnail url |
---|
| 297 | $thumbnail_url = $cat_directory; |
---|
[20] | 298 | $thumbnail_url.= 'thumbnail/'.$conf['prefix_thumbnail']; |
---|
[2] | 299 | $thumbnail_url.= $file.'.'.$row['tn_ext']; |
---|
| 300 | // message in title for the thumbnail |
---|
[16] | 301 | $thumbnail_title = $row['file']; |
---|
[2] | 302 | if ( $row['filesize'] == '' ) |
---|
[148] | 303 | $poids = floor( filesize( $cat_directory.$row['file'] ) / 1024 ); |
---|
[2] | 304 | else |
---|
| 305 | $poids = $row['filesize']; |
---|
[16] | 306 | $thumbnail_title .= ' : '.$poids.' KB'; |
---|
[2] | 307 | // url link on picture.php page |
---|
| 308 | $url_link = './picture.php?cat='.$page['cat']; |
---|
| 309 | $url_link.= '&image_id='.$row['id'].'&expand='.$page['expand']; |
---|
| 310 | if ( $page['cat'] == 'search' ) |
---|
| 311 | { |
---|
[17] | 312 | $url_link.= '&search='.$_GET['search'].'&mode='.$_GET['mode']; |
---|
[2] | 313 | } |
---|
| 314 | // date of availability for creation icon |
---|
[17] | 315 | list( $year,$month,$day ) = explode( '-', $row['date_available'] ); |
---|
| 316 | $date = mktime( 0, 0, 0, $month, $day, $year ); |
---|
[2] | 317 | // sending vars to display |
---|
| 318 | $vtp->addSession( $handle, 'thumbnail' ); |
---|
| 319 | $vtp->setVar( $handle, 'thumbnail.url', add_session_id( $url_link ) ); |
---|
| 320 | $vtp->setVar( $handle, 'thumbnail.src', $thumbnail_url ); |
---|
| 321 | $vtp->setVar( $handle, 'thumbnail.alt', $row['file'] ); |
---|
| 322 | $vtp->setVar( $handle, 'thumbnail.title', $thumbnail_title ); |
---|
| 323 | $vtp->setVar( $handle, 'thumbnail.name', $name ); |
---|
| 324 | $vtp->setVar( $handle, 'thumbnail.icon', get_icon( $date ) ); |
---|
| 325 | |
---|
| 326 | if ( $conf['show_comments'] and $user['show_nb_comments'] ) |
---|
| 327 | { |
---|
| 328 | $vtp->addSession( $handle, 'nb_comments' ); |
---|
[16] | 329 | $query = 'SELECT COUNT(*) AS nb_comments'; |
---|
| 330 | $query.= ' FROM '.PREFIX_TABLE.'comments'; |
---|
| 331 | $query.= ' WHERE image_id = '.$row['id']; |
---|
[26] | 332 | $query.= " AND validated = 'true'"; |
---|
[2] | 333 | $query.= ';'; |
---|
| 334 | $row = mysql_fetch_array( mysql_query( $query ) ); |
---|
| 335 | $vtp->setVar( $handle, 'nb_comments.nb', $row['nb_comments'] ); |
---|
| 336 | $vtp->closeSession( $handle, 'nb_comments' ); |
---|
| 337 | } |
---|
| 338 | |
---|
| 339 | $vtp->closeSession( $handle, 'thumbnail' ); |
---|
| 340 | |
---|
[17] | 341 | if ( $cell_number++ == $user['nb_image_line'] ) |
---|
[2] | 342 | { |
---|
[17] | 343 | // creating a new line |
---|
[2] | 344 | $vtp->closeSession( $handle, 'line' ); |
---|
[17] | 345 | // the number of the next cell is 1 |
---|
| 346 | $cell_number = 1; |
---|
| 347 | // we only create a new line if it does not exceed the maximum line |
---|
| 348 | // per page for the logged user |
---|
| 349 | if ( $line_number++ < $user['nb_line_page'] ) |
---|
| 350 | { |
---|
| 351 | $vtp->addSession( $handle, 'line' ); |
---|
| 352 | } |
---|
[2] | 353 | } |
---|
| 354 | } |
---|
| 355 | $vtp->closeSession( $handle, 'thumbnails' ); |
---|
| 356 | } |
---|
[26] | 357 | //-------------------------------------------------------------- empty category |
---|
| 358 | elseif ( ( isset( $page['cat'] ) |
---|
| 359 | and is_numeric( $page['cat'] ) |
---|
[252] | 360 | and $page['cat_nb_images'] == 0 |
---|
| 361 | and $page['plain_structure'][$page['cat']]['nb_sub_categories'] > 0) |
---|
[274] | 362 | or (!isset($_GET['cat']))) |
---|
[2] | 363 | { |
---|
| 364 | $vtp->addSession( $handle, 'thumbnails' ); |
---|
[16] | 365 | $vtp->addSession( $handle, 'line' ); |
---|
| 366 | |
---|
[274] | 367 | $subcats=array(); |
---|
[286] | 368 | if (isset($page['cat'])) $subcats = get_non_empty_subcat_ids( $page['cat'] ); |
---|
| 369 | else $subcats = get_non_empty_subcat_ids( '' ); |
---|
[17] | 370 | $cell_number = 1; |
---|
[26] | 371 | $i = 0; |
---|
| 372 | foreach ( $subcats as $subcat_id => $non_empty_id ) { |
---|
[134] | 373 | $name = '<img src="'.$user['lien_collapsed'].'" style="border:none;"'; |
---|
| 374 | $name.= ' alt=">"/> '; |
---|
| 375 | $name.= '[ <span style="font-weight:bold;">'; |
---|
| 376 | $name.= $page['plain_structure'][$subcat_id]['name']; |
---|
[7] | 377 | $name.= '</span> ]'; |
---|
[61] | 378 | |
---|
[134] | 379 | // searching the representative picture of the category |
---|
| 380 | $query = 'SELECT representative_picture_id'; |
---|
| 381 | $query.= ' FROM '.PREFIX_TABLE.'categories'; |
---|
| 382 | $query.= ' WHERE id = '.$non_empty_id; |
---|
[252] | 383 | $query.= ';'; |
---|
[134] | 384 | $row = mysql_fetch_array( mysql_query( $query ) ); |
---|
| 385 | |
---|
[61] | 386 | $query = 'SELECT file,tn_ext,storage_category_id'; |
---|
[252] | 387 | $query.= ' FROM '.PREFIX_TABLE.'images, '.PREFIX_TABLE.'image_category'; |
---|
[61] | 388 | $query.= ' WHERE category_id = '.$non_empty_id; |
---|
[252] | 389 | $query.= ' AND id = image_id'; |
---|
[134] | 390 | // if the category has a representative picture, this is its thumbnail |
---|
[292] | 391 | // that will be displayed ! |
---|
| 392 | if ( isset( $row['representative_picture_id'] ) ) |
---|
[134] | 393 | $query.= ' AND id = '.$row['representative_picture_id']; |
---|
| 394 | else |
---|
| 395 | $query.= ' ORDER BY RAND()'; |
---|
[16] | 396 | $query.= ' LIMIT 0,1'; |
---|
[2] | 397 | $query.= ';'; |
---|
| 398 | $image_result = mysql_query( $query ); |
---|
[26] | 399 | $image_row = mysql_fetch_array( $image_result ); |
---|
[2] | 400 | |
---|
[17] | 401 | $file = get_filename_wo_extension( $image_row['file'] ); |
---|
[2] | 402 | |
---|
| 403 | // creating links for thumbnail and associated category |
---|
[61] | 404 | $thumbnail_link = get_complete_dir( $image_row['storage_category_id'] ); |
---|
[26] | 405 | $thumbnail_link.= 'thumbnail/'.$conf['prefix_thumbnail']; |
---|
| 406 | $thumbnail_link.= $file.'.'.$image_row['tn_ext']; |
---|
[2] | 407 | |
---|
[17] | 408 | $thumbnail_title = $lang['hint_category']; |
---|
[2] | 409 | |
---|
[26] | 410 | $url_link = './category.php?cat='.$subcat_id; |
---|
[290] | 411 | if ( isset($page['cat'])&& !in_array( $page['cat'], $page['tab_expand'] ) ) |
---|
[2] | 412 | { |
---|
[17] | 413 | array_push( $page['tab_expand'], $page['cat'] ); |
---|
[2] | 414 | $page['expand'] = implode( ',', $page['tab_expand'] ); |
---|
| 415 | } |
---|
| 416 | $url_link.= '&expand='.$page['expand']; |
---|
[120] | 417 | // we add the category to explore in the expand list |
---|
| 418 | if ( $page['expand'] != '' ) $url_link.= ','; |
---|
| 419 | $url_link.= $subcat_id; |
---|
| 420 | |
---|
[134] | 421 | $date = $page['plain_structure'][$subcat_id]['date_last']; |
---|
[2] | 422 | |
---|
| 423 | // sending vars to display |
---|
| 424 | $vtp->addSession( $handle, 'thumbnail' ); |
---|
| 425 | $vtp->setVar( $handle, 'thumbnail.url', add_session_id( $url_link ) ); |
---|
[26] | 426 | $vtp->setVar( $handle, 'thumbnail.src', $thumbnail_link ); |
---|
[2] | 427 | $vtp->setVar( $handle, 'thumbnail.alt', $image_row['file'] ); |
---|
| 428 | $vtp->setVar( $handle, 'thumbnail.title', $thumbnail_title ); |
---|
| 429 | $vtp->setVar( $handle, 'thumbnail.name', $name ); |
---|
| 430 | $vtp->setVar( $handle, 'thumbnail.icon', get_icon( $date ) ); |
---|
| 431 | $vtp->closeSession( $handle, 'thumbnail' ); |
---|
| 432 | |
---|
[17] | 433 | if ( $cell_number++ == $user['nb_image_line'] ) |
---|
[2] | 434 | { |
---|
| 435 | $vtp->closeSession( $handle, 'line' ); |
---|
[17] | 436 | $cell_number = 1; |
---|
| 437 | // we open a new line if the subcat was not the last one |
---|
[26] | 438 | if ( $i++ < count( $subcats ) - 1 ) |
---|
[17] | 439 | { |
---|
| 440 | $vtp->addSession( $handle, 'line' ); |
---|
| 441 | } |
---|
[2] | 442 | } |
---|
| 443 | } |
---|
[26] | 444 | if ( $i < count( $subcats ) - 1 ) |
---|
[17] | 445 | { |
---|
| 446 | $vtp->closeSession( $handle, 'line' ); |
---|
| 447 | } |
---|
[2] | 448 | $vtp->closeSession( $handle, 'thumbnails' ); |
---|
| 449 | } |
---|
| 450 | //------------------------------------------------------- category informations |
---|
| 451 | if ( isset ( $page['cat'] ) ) |
---|
| 452 | { |
---|
| 453 | $vtp->addSession( $handle, 'cat_infos' ); |
---|
| 454 | // navigation bar |
---|
| 455 | if ( $page['navigation_bar'] != '' ) |
---|
| 456 | { |
---|
| 457 | $vtp->addSession( $handle, 'navigation' ); |
---|
| 458 | $vtp->closeSession( $handle, 'navigation' ); |
---|
| 459 | } |
---|
| 460 | // category comment |
---|
| 461 | if ( isset( $page['comment'] ) and $page['comment'] != '' ) |
---|
| 462 | { |
---|
[14] | 463 | $vtp->addSession( $handle, 'comment' ); |
---|
| 464 | $vtp->setVar( $handle, 'comment.cat_comment', $page['comment'] ); |
---|
| 465 | $vtp->closeSession( $handle, 'comment' ); |
---|
[2] | 466 | } |
---|
| 467 | // total number of pictures in the category |
---|
| 468 | if ( is_numeric( $page['cat'] ) ) |
---|
| 469 | { |
---|
| 470 | $vtp->setVar( $handle, 'cat_infos.cat_name', |
---|
| 471 | get_cat_display_name( $page['cat_name'], ' - ', |
---|
| 472 | 'font-style:italic;' ) ); |
---|
[286] | 473 | // upload a picture in the category |
---|
| 474 | if ( $page['cat_site_id'] == 1 |
---|
| 475 | and $conf['upload_available'] |
---|
| 476 | and $page['cat_uploadable'] ) |
---|
| 477 | { |
---|
| 478 | $vtp->addSession( $handle, 'upload' ); |
---|
| 479 | $url = './upload.php?cat='.$page['cat'].'&expand='.$page['expand']; |
---|
| 480 | $vtp->setVar( $handle, 'upload.url', add_session_id( $url ) ); |
---|
| 481 | $vtp->closeSession( $handle, 'upload' ); |
---|
| 482 | } |
---|
[2] | 483 | } |
---|
| 484 | else |
---|
| 485 | { |
---|
| 486 | $vtp->setVar( $handle, 'cat_infos.cat_name', $page['title'] ); |
---|
| 487 | } |
---|
[279] | 488 | |
---|
[2] | 489 | $vtp->closeSession( $handle, 'cat_infos' ); |
---|
| 490 | } |
---|
| 491 | //------------------------------------------------------------ log informations |
---|
| 492 | pwg_log( 'category', $page['title'] ); |
---|
| 493 | mysql_close(); |
---|
| 494 | //----------------------------------------------------------- html code display |
---|
[350] | 495 | $output.= $vtp->Display( $handle, 0 ); |
---|
[290] | 496 | |
---|
| 497 | include('include/page_tail.php'); |
---|
[350] | 498 | ?> |
---|