Changeset 428 for trunk/category.php
- Timestamp:
- Jun 15, 2004, 10:00:40 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/category.php
r421 r428 151 151 152 152 //-------------------------------------------------------------- category title 153 $cat_title = $lang['no_category']; 154 if ( isset ( $page['cat'] ) ) 155 { 156 if ( is_numeric( $page['cat'] ) ) 157 { 158 $cat_title = get_cat_display_name( $page['cat_name'], ' - '); 159 } 160 else 161 { 162 if ( $page['cat'] == 'search' ) 163 { 164 $page['title'].= ' : <span style="font-style:italic;">'; 165 $page['title'].= $_GET['search']."</span>"; 166 } 167 $page['title'] = replace_space( $page['title'] ); 168 } 153 if ( !isset( $page['title'] ) ) 154 { 155 $page['title'] = $lang['no_category']; 156 } 157 $template_title = $page['title']; 158 if ( isset( $page['cat_nb_images'] ) and $page['cat_nb_images'] > 0 ) 159 { 160 $template_title.= ' ['.$page['cat_nb_images'].']'; 169 161 } 170 162 171 163 $template->assign_vars(array( 172 164 'NB_PICTURE' => count_user_total_images(), 173 'TITLE' => $ cat_title,165 'TITLE' => $template_title, 174 166 'USERNAME' => $user['username'], 175 167 'TOP_VISITED'=>$conf['top_number'], … … 182 174 'L_FAVORITE_HINT' => $lang['favorite_cat_hint'], 183 175 'L_FAVORITE' => $lang['favorite_cat'], 184 'L_S TATS' => $lang['stats'],176 'L_SPECIAL_CATEGORIES' => $lang['special_categories'], 185 177 'L_MOST_VISITED_HINT' => $lang['most_visited_cat_hint'], 186 178 'L_MOST_VISITED' => $lang['most_visited_cat'], 187 179 'L_RECENT_HINT' => $lang['recent_cat_hint'], 188 180 'L_RECENT' => $lang['recent_cat'], 181 'L_CALENDAR' => $lang['calendar'], 182 'L_CALENDAR_HINT' => $lang['calendar_hint'], 189 183 'L_SUMMARY' => $lang['title_menu'], 190 184 'L_UPLOAD' => $lang['upload_picture'], 191 185 'L_COMMENT' => $lang['comments'], 192 'L_NB_IMG' => $lang['nb_image_category'],193 186 'L_IDENTIFY' => $lang['ident_title'], 194 187 'L_SUBMIT' => $lang['menu_login'], … … 212 205 'U_MOST_VISITED'=>add_session_id( PHPWG_ROOT_PATH.'category.php?cat=most_visited' ), 213 206 'U_RECENT'=>add_session_id( PHPWG_ROOT_PATH.'category.php?cat=recent' ), 207 'U_CALENDAR'=>add_session_id( PHPWG_ROOT_PATH.'category.php?cat=calendar' ), 214 208 'U_LOGOUT' => PHPWG_ROOT_PATH.'category.php?act=logout', 215 209 'U_ADMIN'=>add_session_id( PHPWG_ROOT_PATH.'admin.php' ), … … 293 287 $line_number = 0; 294 288 289 $row_number = 1; 290 $line_opened = false; 291 $displayed_pics = 0; 292 295 293 while ( $row = mysql_fetch_array( $result ) ) 296 294 { … … 333 331 list( $year,$month,$day ) = explode( '-', $row['date_available'] ); 334 332 $date = mktime( 0, 0, 0, $month, $day, $year ); 333 334 // create a new line ? 335 if ( (!$line_opened or $row_number++ == $user['nb_image_line'] ) 336 and $displayed_pics++ < mysql_num_rows( $result ) ) 337 { 338 $template->assign_block_vars('thumbnails.line', array()); 339 $row_number = 1; 340 $line_opened = true; 341 } 335 342 336 // sending vars to display 337 if (!$cell_number && ( $line_number< $user['nb_line_page'])) 338 { 339 $template->assign_block_vars('thumbnails.line', array()); 340 $cell_number = 0; 341 $line_number++; 342 } 343 if ( $cell_number++ == $user['nb_image_line'] -1) $cell_number = 0; 344 345 $template->assign_block_vars('thumbnails.line.thumbnail', array( 346 'IMAGE'=>$thumbnail_url, 347 'IMAGE_ALT'=>$row['file'], 348 'IMAGE_TITLE'=>$thumbnail_title, 349 'IMAGE_NAME'=>$name, 350 'IMAGE_TS'=>get_icon( $date ), 351 352 'U_IMG_LINK'=>add_session_id( $url_link ) 353 )); 354 355 if ( $conf['show_comments'] && $user['show_nb_comments'] ) 343 $template->assign_block_vars( 344 'thumbnails.line.thumbnail', 345 array( 346 'IMAGE'=>$thumbnail_url, 347 'IMAGE_ALT'=>$row['file'], 348 'IMAGE_TITLE'=>$thumbnail_title, 349 'IMAGE_NAME'=>$name, 350 'IMAGE_TS'=>get_icon( $date ), 351 352 'U_IMG_LINK'=>add_session_id( $url_link ) 353 )); 354 355 if ( $conf['show_comments'] and $user['show_nb_comments'] ) 356 356 { 357 357 $query = 'SELECT COUNT(*) AS nb_comments'; … … 360 360 $query.= ';'; 361 361 $row = mysql_fetch_array( mysql_query( $query ) ); 362 $template->assign_block_vars( 'thumbnails.line.thumbnail.nb_comments', 363 array('NB_COMMENTS'=>$row['nb_comments']) ); 362 $template->assign_block_vars( 363 'thumbnails.line.thumbnail.nb_comments', 364 array('NB_COMMENTS'=>$row['nb_comments']) ); 365 } 366 } 367 } 368 //-------------------------------------------------------------------- calendar 369 elseif ( isset( $page['cat'] ) and $page['cat'] == 'calendar' ) 370 { 371 // years of image availability 372 $query = 'SELECT DISTINCT(YEAR(date_available)) AS year'; 373 $query.= ' FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE; 374 $query.= $page['where']; 375 $query.= ' AND id = image_id'; 376 $query.= ' ORDER BY year'; 377 $query.= ';'; 378 $result = mysql_query( $query ); 379 $calendar_years = array(); 380 while ( $row = mysql_fetch_array( $result ) ) 381 { 382 array_push( $calendar_years, $row['year'] ); 383 } 384 385 if ( !isset( $page['calendar_year'] ) 386 or !in_array( $page['calendar_year'], $calendar_years ) ) 387 { 388 $page['calendar_year'] = max( $calendar_years ); 389 } 390 391 // years navigation bar creation 392 $years_nav_bar = ''; 393 foreach ( $calendar_years as $calendar_year ) { 394 if ( $calendar_year == $page['calendar_year'] ) 395 { 396 $years_nav_bar.= ' <span class="selected">'; 397 $years_nav_bar.= $calendar_year; 398 $years_nav_bar.= '</span>'; 399 } 400 else 401 { 402 $url = PHPWG_ROOT_PATH.'category.php?cat=calendar'; 403 $url.= '&year='.$calendar_year; 404 $years_nav_bar.= ' '; 405 $years_nav_bar.= '<a href="'.add_session_id( $url ).'">'; 406 $years_nav_bar.= $calendar_year; 407 $years_nav_bar.= '</a>'; 408 } 409 } 410 $template->assign_block_vars( 411 'calendar', 412 array( 'YEARS_NAV_BAR' => $years_nav_bar ) 413 ); 414 415 $query = 'SELECT DISTINCT(MONTH(date_available)) AS month'; 416 $query.= ' FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE; 417 $query.= $page['where']; 418 $query.= ' AND id = image_id'; 419 $query.= ' AND YEAR(date_available) = '.$page['calendar_year']; 420 $query.= ' ORDER BY month'; 421 $query.= ';'; 422 $result = mysql_query( $query ); 423 $calendar_months = array(); 424 while ( $row = mysql_fetch_array( $result ) ) 425 { 426 array_push( $calendar_months, $row['month'] ); 427 } 428 429 // months navigation bar creation 430 $months_nav_bar = ''; 431 foreach ( $calendar_months as $calendar_month ) { 432 if ( isset( $page['calendar_month'] ) 433 and $calendar_month == $page['calendar_month'] ) 434 { 435 $months_nav_bar.= ' <span class="selected">'; 436 $months_nav_bar.= $lang['month'][(int)$calendar_month]; 437 $months_nav_bar.= '</span>'; 438 } 439 else 440 { 441 $url = PHPWG_ROOT_PATH.'category.php?cat=calendar&month='; 442 $url.= $page['calendar_year'].'.'; 443 if ( $calendar_month < 10 ) 444 { 445 // adding leading zero 446 $url.= '0'; 447 } 448 $url.= $calendar_month; 449 $months_nav_bar.= ' '; 450 $months_nav_bar.= '<a href="'.add_session_id( $url ).'">'; 451 $months_nav_bar.= $lang['month'][(int)$calendar_month]; 452 $months_nav_bar.= '</a>'; 453 } 454 } 455 $template->assign_block_vars( 456 'calendar', 457 array( 'MONTHS_NAV_BAR' => $months_nav_bar ) 458 ); 459 460 $row_number = 1; 461 $line_opened = false; 462 $displayed_pics = 0; 463 $template->assign_block_vars('thumbnails', array()); 464 465 if ( !isset( $page['calendar_month'] ) ) 466 { 467 // for each month of this year, display a random picture 468 foreach ( $calendar_months as $calendar_month ) { 469 $query = 'SELECT COUNT(id) AS nb_picture_month'; 470 $query.= ' FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE; 471 $query.= $page['where']; 472 $query.= ' AND YEAR(date_available) = '.$page['calendar_year']; 473 $query.= ' AND MONTH(date_available) = '.$calendar_month; 474 $query.= ' AND id = image_id'; 475 $query.= ';'; 476 $row = mysql_fetch_array( mysql_query( $query ) ); 477 $nb_picture_month = $row['nb_picture_month']; 478 479 $query = 'SELECT file,tn_ext,date_available,storage_category_id'; 480 $query.= ' FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE; 481 $query.= $page['where']; 482 $query.= ' AND YEAR(date_available) = '.$page['calendar_year']; 483 $query.= ' AND MONTH(date_available) = '.$calendar_month; 484 $query.= ' AND id = image_id'; 485 $query.= ' ORDER BY RAND()'; 486 $query.= ' LIMIT 0,1'; 487 $query.= ';'; 488 $row = mysql_fetch_array( mysql_query( $query ) ); 489 490 $file = get_filename_wo_extension( $row['file'] ); 491 492 // creating links for thumbnail and associated category 493 $thumbnail_link = get_complete_dir( $row['storage_category_id'] ); 494 $thumbnail_link.= 'thumbnail/'.$conf['prefix_thumbnail']; 495 $thumbnail_link.= $file.'.'.$row['tn_ext']; 496 497 $name = $lang['month'][$calendar_month]; 498 $name.= ' '.$page['calendar_year']; 499 $name.= ' ['.$nb_picture_month.']'; 500 501 $thumbnail_title = $lang['calendar_picture_hint'].$name; 502 503 $url_link = PHPWG_ROOT_PATH.'category.php?cat=calendar'; 504 $url_link.= '&month='.$page['calendar_year'].'.'; 505 if ( $calendar_month < 10 ) 506 { 507 // adding leading zero 508 $url_link.= '0'; 509 } 510 $url_link.= $calendar_month; 511 512 // create a new line ? 513 if ( ( !$line_opened or $row_number++ == $user['nb_image_line'] ) 514 and $displayed_pics++ < count( $calendar_months ) ) 515 { 516 $template->assign_block_vars('thumbnails.line', array()); 517 $row_number = 1; 518 $line_opened = true; 519 } 520 521 $template->assign_block_vars( 522 'thumbnails.line.thumbnail', 523 array( 524 'IMAGE'=>$thumbnail_link, 525 'IMAGE_ALT'=>$row['file'], 526 'IMAGE_TITLE'=>$thumbnail_title, 527 'IMAGE_NAME'=>$name, 528 529 'U_IMG_LINK'=>add_session_id( $url_link ) 530 ) 531 ); 532 } 533 } 534 else 535 { 536 $query = 'SELECT DISTINCT(date_available) AS day'; 537 $query.= ' FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE; 538 $query.= $page['where']; 539 $query.= ' AND id = image_id'; 540 $query.= ' AND YEAR(date_available) = '.$page['calendar_year']; 541 $query.= ' AND MONTH(date_available) = '.$page['calendar_month']; 542 $query.= ' ORDER BY day'; 543 $query.= ';'; 544 $result = mysql_query( $query ); 545 $calendar_days = array(); 546 while ( $row = mysql_fetch_array( $result ) ) 547 { 548 array_push( $calendar_days, $row['day'] ); 549 } 550 // for each month of this year, display a random picture 551 foreach ( $calendar_days as $calendar_day ) { 552 $query = 'SELECT COUNT(id) AS nb_picture_day'; 553 $query.= ' FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE; 554 $query.= $page['where']; 555 $query.= " AND date_available = '".$calendar_day."'"; 556 $query.= ' AND id = image_id'; 557 $query.= ';'; 558 $row = mysql_fetch_array( mysql_query( $query ) ); 559 $nb_picture_day = $row['nb_picture_day']; 560 561 $query = 'SELECT file,tn_ext,date_available,storage_category_id'; 562 $query.= ' FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE; 563 $query.= $page['where']; 564 $query.= " AND date_available = '".$calendar_day."'"; 565 $query.= ' AND id = image_id'; 566 $query.= ' ORDER BY RAND()'; 567 $query.= ' LIMIT 0,1'; 568 $query.= ';'; 569 $row = mysql_fetch_array( mysql_query( $query ) ); 570 571 $file = get_filename_wo_extension( $row['file'] ); 572 573 // creating links for thumbnail and associated category 574 $thumbnail_link = get_complete_dir( $row['storage_category_id'] ); 575 $thumbnail_link.= 'thumbnail/'.$conf['prefix_thumbnail']; 576 $thumbnail_link.= $file.'.'.$row['tn_ext']; 577 578 list($year,$month,$day) = explode( '-', $calendar_day ); 579 $unixdate = mktime(0,0,0,$month,$day,$year); 580 $name = $lang['day'][date( "w", $unixdate )]; 581 $name.= ' '.$day; 582 $name.= ' ['.$nb_picture_day.']'; 583 584 $thumbnail_title = $lang['calendar_picture_hint'].$name; 585 586 $url_link = PHPWG_ROOT_PATH.'category.php?cat=search'; 587 588 // create a new line ? 589 if ( ( !$line_opened or $row_number++ == $user['nb_image_line'] ) 590 and $displayed_pics++ < count( $calendar_months ) ) 591 { 592 $template->assign_block_vars('thumbnails.line', array()); 593 $row_number = 1; 594 $line_opened = true; 595 } 596 597 $template->assign_block_vars( 598 'thumbnails.line.thumbnail', 599 array( 600 'IMAGE'=>$thumbnail_link, 601 'IMAGE_ALT'=>$row['file'], 602 'IMAGE_TITLE'=>$thumbnail_title, 603 'IMAGE_NAME'=>$name, 604 605 'U_IMG_LINK'=>add_session_id( $url_link ) 606 ) 607 ); 364 608 } 365 609 } … … 419 663 420 664 // sending vars to display 421 665 if (!$cell_number && $i < count( $subcats )) 422 666 { 423 667 $template->assign_block_vars('thumbnails.line', array()); 424 668 $cell_number = 0; 425 $i++; 426 } 427 if ( $cell_number++ == $user['nb_image_line'] -1) $cell_number = 0; 428 429 $template->assign_block_vars('thumbnails.line.thumbnail', array( 430 'IMAGE'=>$thumbnail_link, 431 'IMAGE_ALT'=>$image_row['file'], 432 'IMAGE_TITLE'=>$thumbnail_title, 433 'IMAGE_NAME'=>$name, 434 'IMAGE_TS'=>get_icon( $date ), 435 436 'U_IMG_LINK'=>add_session_id( $url_link ) 437 )); 669 $i++; 670 } 671 if ( $cell_number++ == $user['nb_image_line'] -1 ) 672 { 673 $cell_number = 0; 674 } 675 676 $template->assign_block_vars( 677 'thumbnails.line.thumbnail', 678 array( 679 'IMAGE'=>$thumbnail_link, 680 'IMAGE_ALT'=>$image_row['file'], 681 'IMAGE_TITLE'=>$thumbnail_title, 682 'IMAGE_NAME'=>$name, 683 'IMAGE_TS'=>get_icon( $date ), 684 685 'U_IMG_LINK'=>add_session_id( $url_link ) 686 ) 687 ); 438 688 } 439 689 } … … 442 692 { 443 693 // upload a picture in the category 444 if ( is_numeric( $page['cat']) && $page['cat_site_id'] == 1 445 && $conf['upload_available'] && $page['cat_uploadable'] ) 694 if ( is_numeric( $page['cat'] ) 695 and $page['cat_site_id'] == 1 696 and $conf['upload_available'] 697 and $page['cat_uploadable'] ) 446 698 { 447 699 $url = PHPWG_ROOT_PATH.'upload.php?cat='.$page['cat']; 448 $template->assign_block_vars('upload',array('U_UPLOAD'=>add_session_id( $url ))); 449 } 450 451 $template->assign_block_vars('cat_infos',array('NB_IMG_CAT' => $page['cat_nb_images'])); 452 700 $template->assign_block_vars( 701 'upload', 702 array('U_UPLOAD'=>add_session_id( $url )) 703 ); 704 } 705 706 if ( $page['navigation_bar'] != '' 707 or ( isset( $page['comment'] ) and $page['comment'] != '' ) ) 708 { 709 $template->assign_block_vars('cat_infos',array()); 710 } 711 453 712 // navigation bar 454 713 if ( $page['navigation_bar'] != '' ) 455 714 { 456 $template->assign_block_vars('cat_infos.navigation',array('NAV_BAR' => $page['navigation_bar'])); 715 $template->assign_block_vars( 716 'cat_infos.navigation', 717 array('NAV_BAR' => $page['navigation_bar']) 718 ); 457 719 } 458 720 // category comment 459 721 if ( isset( $page['comment'] ) and $page['comment'] != '' ) 460 722 { 461 $template->assign_block_vars('cat_infos.comment',array('COMMENTS' => $page['comment'])); 723 $template->assign_block_vars( 724 'cat_infos.comment', 725 array('COMMENTS' => $page['comment']) 726 ); 462 727 } 463 728 }
Note: See TracChangeset
for help on using the changeset viewer.