Changeset 26 for trunk/category.php
- Timestamp:
- Jul 21, 2003, 9:47:14 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/category.php
r20 r26 21 21 //----------------------------------------------------------- personnal include 22 22 include_once( './include/init.inc.php' ); 23 $output.= 'after init.inc.php : '.get_elapsed_time( $t2, get_moment() ).'<br />'; 23 24 //-------------------------------------------------- access authorization check 25 // creating the plain structure : array of all the available categories and 26 // their relative informations, see the definition of the function 27 // get_plain_structure for further details. 28 $page['plain_structure'] = get_plain_structure(); 29 24 30 check_cat_id( $_GET['cat'] ); 25 31 check_login_authorization(); … … 35 41 if ( isset ( $_GET['expand'] ) and $_GET['expand'] != 'all' ) 36 42 { 37 $j = 0; 38 $tab_expand = explode( ",", $_GET['expand'] ); 39 $size = sizeof( $tab_expand ); 40 for ( $i = 0; $i < $size; $i++ ) 41 { 42 if ( is_numeric( $tab_expand[$i] ) ) 43 { 44 $page['tab_expand'][$j++] = $tab_expand[$i]; 45 } 43 $tab_expand = explode( ',', $_GET['expand'] ); 44 foreach ( $tab_expand as $id ) { 45 if ( is_numeric( $id ) ) array_push( $page['tab_expand'], $id ); 46 46 } 47 47 $page['expand'] = implode( ',', $page['tab_expand'] ); … … 50 50 // The $page['expand'] equals 'all' and 51 51 // $page['tab_expand'] contains all the authorized cat ids 52 if ( $user['expand'] == 'true'or $_GET['expand'] == 'all' )52 if ( $user['expand'] or $_GET['expand'] == 'all' ) 53 53 { 54 54 $page['tab_expand'] = array(); 55 $query = 'SELECT id';56 $query.= ' FROM '.PREFIX_TABLE.'categories';57 $query.= ' WHERE id_uppercat IS NULL;';58 $result = mysql_query( $query );59 $i = 0;60 while ( $row = mysql_fetch_array( $result ) )61 {62 $page['tab_expand'][$i++] = $row['id'];63 }64 55 $page['expand'] = 'all'; 65 56 } … … 84 75 $page['start']*= $user['nb_image_page']; 85 76 } 77 // creating the structure of the categories (useful for displaying the menu) 78 $page['structure'] = create_structure( '', $user['restrictions'] ); 79 $page['structure'] = update_structure( $page['structure'] ); 86 80 initialize_category(); 81 $output.= 'before template init : '.get_elapsed_time( $t2, get_moment() ).'<br />'; 87 82 //----------------------------------------------------- template initialization 88 83 $vtp = new VTemplate; 89 84 $handle = $vtp->Open( './template/'.$user['template'].'/category.vtp' ); 90 85 initialize_template(); 91 92 $tpl = array( 'categories','hint_category','sub-cat','images_available', 93 'total','title_menu','nb_image_category','send_mail', 94 'title_send_mail','generation_time','upload_name', 95 'connected_user','recent_image','days','generation_time', 96 'favorite_cat_hint','favorite_cat','stats', 97 'most_visited_cat_hint','most_visited_cat','recent_cat', 98 'recent_cat_hint' ); 86 $output.= 'before lang array : '.get_elapsed_time( $t2, get_moment() ).'<br />'; 87 $tpl = array( 88 'categories','hint_category','sub-cat','images_available','total', 89 'title_menu','nb_image_category','send_mail','title_send_mail', 90 'generation_time','connected_user','recent_image','days','generation_time', 91 'favorite_cat_hint','favorite_cat','stats','most_visited_cat_hint', 92 'most_visited_cat','recent_cat','recent_cat_hint','upload_picture' ); 99 93 templatize_array( $tpl, 'lang', $handle ); 94 $output.= 'after lang array : '.get_elapsed_time( $t2, get_moment() ).'<br />'; 100 95 101 96 $tpl = array( 'mail_webmaster','webmaster','top_number','version','site_url' ); 102 97 templatize_array( $tpl, 'conf', $handle ); 98 $output.= 'after conf array : '.get_elapsed_time( $t2, get_moment() ).'<br />'; 103 99 104 100 $tpl = array( 'short_period','long_period','lien_collapsed', 'username' ); … … 112 108 $icon_long = get_icon( time() - ( $user['short_period'] * 24 * 60 * 60 + 1 ) ); 113 109 $vtp->setGlobalVar( $handle, 'icon_long', $icon_long ); 114 $nb_total_pictures = get_total_image( "", $user['restrictions'] );110 $nb_total_pictures = count_images( $page['structure'] ); 115 111 $vtp->setGlobalVar( $handle, 'nb_total_pictures',$nb_total_pictures ); 116 112 //------------------------------------------------------------- categories menu 113 $output.= 'before menu : '.get_elapsed_time( $t2, get_moment() ).'<br />'; 117 114 // normal categories 118 display_cat( '', ' ', $user['restrictions'], $page['tab_expand'] ); 115 foreach ( $page['structure'] as $category ) { 116 // display category is a function relative to the template 117 display_category( $category, ' ', $handle ); 118 } 119 $output.= 'after menu : '.get_elapsed_time( $t2, get_moment() ).'<br />'; 119 120 // favorites cat 120 121 if ( !$user['is_the_guest'] ) 121 122 { 122 123 $vtp->addSession( $handle, 'favorites' ); 123 $url = add_session_id('./category.php?cat=fav&expand='.$page['expand'] );124 $vtp->setVar( $handle, 'favorites.url', $url);124 $url = './category.php?cat=fav&expand='.$page['expand']; 125 $vtp->setVar( $handle, 'favorites.url', add_session_id( $url ) ); 125 126 // searching the number of favorite picture 126 127 $query = 'SELECT COUNT(*) AS count'; … … 133 134 } 134 135 // most visited pictures category 135 $url = add_session_id( './category.php?cat=most_visited'. 136 '&expand='.$page['expand'] ); 137 $vtp->setGlobalVar( $handle, 'most_visited_url', $url ); 136 $url = './category.php?cat=most_visited&expand='.$page['expand']; 137 $vtp->setGlobalVar( $handle, 'most_visited_url', add_session_id( $url ) ); 138 138 // recent pictures 139 $url = add_session_id( './category.php?cat=recent'. 140 '&expand='.$page['expand'] ); 141 $vtp->setGlobalVar( $handle, 'recent_url', $url ); 139 $url = './category.php?cat=recent&expand='.$page['expand']; 140 $vtp->setGlobalVar( $handle, 'recent_url', add_session_id( $url ) ); 142 141 //--------------------------------------------------------------------- summary 143 142 $vtp->addSession( $handle, 'summary' ); … … 146 145 { 147 146 $vtp->setVar( $handle, 'summary.title', '' ); 148 $vtp->setVar( $handle, 'summary.name', 149 replace_space( $lang['change_login'] ) ); 147 $vtp->setVar( $handle, 'summary.name',replace_space($lang['change_login'])); 150 148 } 151 149 else 152 150 { 153 151 $vtp->setVar( $handle, 'summary.title', $lang['hint_login'] ); 154 $vtp->setVar( $handle, 'summary.name', 155 replace_space( $lang['login'] ) ); 152 $vtp->setVar( $handle, 'summary.name', replace_space( $lang['login'] ) ); 156 153 } 157 154 $vtp->closeSession( $handle, 'summary' ); … … 186 183 // about link 187 184 $vtp->addSession( $handle, 'summary' ); 188 $vtp->setVar( $handle, 'summary.url', 189 add_session_id( './about.php?'.$_SERVER['QUERY_STRING'] ) );185 $vtp->setVar( $handle, 'summary.url', './about.php?'. 186 str_replace( '&', '&', $_SERVER['QUERY_STRING'] ) ); 190 187 $vtp->setVar( $handle, 'summary.title', $lang['hint_about'] ); 191 188 $vtp->setVar( $handle, 'summary.name', replace_space( $lang['about'] ) ); … … 227 224 } 228 225 //------------------------------------------------------------------ thumbnails 226 $output.= 'before thumbs : '.get_elapsed_time( $t2, get_moment() ).'<br />'; 229 227 if ( isset( $page['cat'] ) and $page['cat_nb_images'] != 0 ) 230 228 { … … 318 316 $query.= ' FROM '.PREFIX_TABLE.'comments'; 319 317 $query.= ' WHERE image_id = '.$row['id']; 318 $query.= " AND validated = 'true'"; 320 319 $query.= ';'; 321 320 $row = mysql_fetch_array( mysql_query( $query ) ); … … 342 341 $vtp->closeSession( $handle, 'thumbnails' ); 343 342 } 344 elseif ( isset( $page['cat'] ) 345 and is_numeric( $page['cat'] ) 346 and $page['cat_nb_images'] == 0 ) 343 //-------------------------------------------------------------- empty category 344 elseif ( ( isset( $page['cat'] ) 345 and is_numeric( $page['cat'] ) 346 and $page['cat_nb_images'] == 0 ) 347 or $_GET['cat'] == '' ) 347 348 { 348 349 $vtp->addSession( $handle, 'thumbnails' ); 349 350 $vtp->addSession( $handle, 'line' ); 350 351 351 $subcats = get_non_empty_sub _cat_ids( $page['cat'] );352 $subcats = get_non_empty_subcat_ids( $page['cat'] ); 352 353 $cell_number = 1; 353 foreach ( $subcats as $id => $subcat ) { 354 $result = get_cat_info( $subcat['non_empty_cat'] ); 355 $cat_directory = $result['dir']; 356 357 $name = '[ <span style="font-weight:bold;">'; 358 if ( $subcat['name'] != '' ) 359 { 360 $name.= $subcat['name']; 361 } 362 else 363 { 364 $name.= $subcat['dir']; 365 } 354 $i = 0; 355 foreach ( $subcats as $subcat_id => $non_empty_id ) { 356 $subcat_infos = get_cat_info( $subcat_id ); 357 $non_empty_infos = get_cat_info( $non_empty_id ); 358 359 $name ='[ <span style="font-weight:bold;">'; 360 $name.= $subcat_infos['name'][0]; 366 361 $name.= '</span> ]'; 367 $name = replace_space( $name );368 362 369 363 $query = 'SELECT file,tn_ext'; 370 364 $query.= ' FROM '.PREFIX_TABLE.'images'; 371 $query.= ' WHERE cat_id = '.$ subcat['non_empty_cat'];365 $query.= ' WHERE cat_id = '.$non_empty_id; 372 366 $query.= ' ORDER BY RAND()'; 373 367 $query.= ' LIMIT 0,1'; 374 368 $query.= ';'; 375 369 $image_result = mysql_query( $query ); 376 $image_row = mysql_fetch_array( $image_result );370 $image_row = mysql_fetch_array( $image_result ); 377 371 378 372 $file = get_filename_wo_extension( $image_row['file'] ); 379 373 380 374 // creating links for thumbnail and associated category 381 $lien_image = $cat_directory; 382 $lien_thumbnail = $lien_image; 383 $lien_thumbnail.= 'thumbnail/'.$conf['prefix_thumbnail']; 384 $lien_thumbnail.= $file.'.'.$image_row['tn_ext']; 385 $lien_image.= $image_row['file']; 375 $thumbnail_link = $non_empty_infos['dir']; 376 $thumbnail_link.= 'thumbnail/'.$conf['prefix_thumbnail']; 377 $thumbnail_link.= $file.'.'.$image_row['tn_ext']; 386 378 387 379 $thumbnail_title = $lang['hint_category']; 388 380 389 $url_link = './category.php?cat='.$subcat ['id'];381 $url_link = './category.php?cat='.$subcat_id; 390 382 if ( !in_array( $page['cat'], $page['tab_expand'] ) ) 391 383 { … … 394 386 } 395 387 $url_link.= '&expand='.$page['expand']; 396 list( $year,$month,$day ) = explode( '-', $subcat ['date_dernier'] );388 list( $year,$month,$day ) = explode( '-', $subcat_infos['date_last'] ); 397 389 $date = mktime( 0, 0, 0, $month, $day, $year ); 398 390 … … 400 392 $vtp->addSession( $handle, 'thumbnail' ); 401 393 $vtp->setVar( $handle, 'thumbnail.url', add_session_id( $url_link ) ); 402 $vtp->setVar( $handle, 'thumbnail.src', $ lien_thumbnail);394 $vtp->setVar( $handle, 'thumbnail.src', $thumbnail_link ); 403 395 $vtp->setVar( $handle, 'thumbnail.alt', $image_row['file'] ); 404 396 $vtp->setVar( $handle, 'thumbnail.title', $thumbnail_title ); … … 412 404 $cell_number = 1; 413 405 // we open a new line if the subcat was not the last one 414 if ( $i d< count( $subcats ) - 1 )406 if ( $i++ < count( $subcats ) - 1 ) 415 407 { 416 408 $vtp->addSession( $handle, 'line' ); … … 418 410 } 419 411 } 420 if ( $i d< count( $subcats ) - 1 )412 if ( $i < count( $subcats ) - 1 ) 421 413 { 422 414 $vtp->closeSession( $handle, 'line' ); … … 424 416 $vtp->closeSession( $handle, 'thumbnails' ); 425 417 } 418 $output.= 'after thumbs : '.get_elapsed_time( $t2, get_moment() ).'<br />'; 426 419 //------------------------------------------------------- category informations 427 420 if ( isset ( $page['cat'] ) ) … … 470 463 //----------------------------------------------------------- html code display 471 464 $code = $vtp->Display( $handle, 0 ); 465 echo $output; 472 466 echo $code; 473 467 ?>
Note: See TracChangeset
for help on using the changeset viewer.