Changeset 2231 for trunk/include/calendar_monthly.class.php
- Timestamp:
- Mar 1, 2008, 2:12:07 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/calendar_monthly.class.php
r2101 r2231 72 72 if ($view_type==CAL_VIEW_CALENDAR) 73 73 { 74 global $template; 75 $tpl_var = array(); 74 76 if ( count($page['chronology_date'])==0 ) 75 77 {//case A: no year given - display all years+months 76 if ($this->build_global_calendar()) 78 if ($this->build_global_calendar($tpl_var)) 79 { 80 $template->assign('chronology_calendar', $tpl_var); 77 81 return true; 82 } 78 83 } 79 84 80 85 if ( count($page['chronology_date'])==1 ) 81 86 {//case B: year given - display all days in given year 82 if ($this->build_year_calendar()) 83 { 87 if ($this->build_year_calendar($tpl_var)) 88 { 89 $template->assign('chronology_calendar', $tpl_var); 84 90 $this->build_nav_bar(CYEAR); // years 85 91 return true; … … 89 95 if ( count($page['chronology_date'])==2 ) 90 96 {//case C: year+month given - display a nice month calendar 91 $this->build_month_calendar(); 92 //$this->build_nav_bar(CYEAR); // years 93 //$this->build_nav_bar(CMONTH); // month 97 if ( $this->build_month_calendar($tpl_var) ) 98 { 99 $template->assign('chronology_calendar', $tpl_var); 100 } 94 101 $this->build_next_prev(); 95 102 return true; … … 99 106 if ($view_type==CAL_VIEW_LIST or count($page['chronology_date'])==3) 100 107 { 101 $has_nav_bar = false;102 108 if ( count($page['chronology_date'])==0 ) 103 109 { … … 214 220 } 215 221 216 function build_global_calendar( )222 function build_global_calendar(&$tpl_var) 217 223 { 218 224 global $page; … … 247 253 } 248 254 249 global $lang , $template;255 global $lang; 250 256 foreach ( $items as $year=>$year_data) 251 257 { … … 253 259 $url = duplicate_index_url( array('chronology_date'=>$chronology_date) ); 254 260 255 $nav_bar = '<span class="calCalHead"><a href="'.$url.'">'.$year.'</a>'; 256 $nav_bar .= ' ('.$year_data['nb_images'].')'; 257 $nav_bar .= '</span><br>'; 258 259 $nav_bar .= $this->get_nav_bar_from_items( $chronology_date, 261 $nav_bar = $this->get_nav_bar_from_items( $chronology_date, 260 262 $year_data['children'], 'calCal', false, false, $lang['month'] ); 261 263 262 $template->assign_block_vars( 'calendar.calbar', 263 array( 'BAR' => $nav_bar) 264 ); 264 $tpl_var['calendar_bars'][] = 265 array( 266 'U_HEAD' => $url, 267 'NB_IMAGES' => $year_data['nb_images'], 268 'HEAD_LABEL' => $year, 269 'NAV_BAR' => $nav_bar, 270 ); 265 271 } 266 272 return true; 267 273 } 268 274 269 function build_year_calendar( )275 function build_year_calendar(&$tpl_var) 270 276 { 271 277 global $page; … … 297 303 return false; 298 304 } 299 global $lang , $template;305 global $lang; 300 306 foreach ( $items as $month=>$month_data) 301 307 { … … 303 309 $url = duplicate_index_url( array('chronology_date'=>$chronology_date) ); 304 310 305 $nav_bar = '<span class="calCalHead"><a href="'.$url.'">'; 306 $nav_bar .= $lang['month'][$month].'</a>'; 307 $nav_bar .= ' ('.$month_data['nb_images'].')'; 308 $nav_bar .= '</span><br>'; 309 310 $nav_bar .= $this->get_nav_bar_from_items( $chronology_date, 311 $nav_bar = $this->get_nav_bar_from_items( $chronology_date, 311 312 $month_data['children'], 'calCal', false ); 312 313 313 $template->assign_block_vars( 'calendar.calbar', 314 array( 'BAR' => $nav_bar) 315 ); 314 $tpl_var['calendar_bars'][] = 315 array( 316 'U_HEAD' => $url, 317 'NB_IMAGES' => $month_data['nb_images'], 318 'HEAD_LABEL' => $lang['month'][$month], 319 'NAV_BAR' => $nav_bar, 320 ); 316 321 } 317 322 return true; … … 319 324 } 320 325 321 function build_month_calendar( )326 function build_month_calendar(&$tpl_var) 322 327 { 323 328 global $page; … … 359 364 } 360 365 361 global $lang, $ template, $conf;366 global $lang, $conf; 362 367 363 368 if ( !empty($items) … … 390 395 $cell_height = $conf['calendar_month_cell_height']; 391 396 392 $template->set_filenames( 393 array( 394 'month_calendar'=>'month_calendar.tpl', 395 ) 396 ); 397 398 $template->assign_block_vars('calendar.thumbnails', 399 array( 400 'WIDTH'=>$cell_width, 401 'HEIGHT'=>$cell_height, 402 ) 403 ); 404 405 //fill the heading with day names 406 $template->assign_block_vars('calendar.thumbnails.head', array()); 407 foreach( $wday_labels as $d => $label) 408 { 409 $template->assign_block_vars('calendar.thumbnails.head.col', 410 array('LABEL'=>$label) 411 ); 412 } 413 414 $template->assign_block_vars('calendar.thumbnails.row', array()); 397 $tpl_weeks = array(); 398 $tpl_crt_week = array(); 415 399 416 400 //fill the empty days in the week before first day of this month 417 401 for ($i=0; $i<$first_day_dow; $i++) 418 402 { 419 $t emplate->assign_block_vars('calendar.thumbnails.row.col', array());420 $template->assign_block_vars('calendar.thumbnails.row.col.blank', array());421 } 403 $tpl_crt_week[] = array(); 404 } 405 422 406 for ( $day = 1; 423 407 $day <= $this->get_all_days_in_month( … … 429 413 if ($dow==0 and $day!=1) 430 414 { 431 $template->assign_block_vars('calendar.thumbnails.row', array()); 432 } 433 $template->assign_block_vars('calendar.thumbnails.row.col', array()); 415 $tpl_weeks[] = $tpl_crt_week; // add finished week to week list 416 $tpl_crt_week = array(); // start new week 417 } 418 434 419 if ( !isset($items[$day]) ) 435 { 436 $template->assign_block_vars('calendar.thumbnails.row.col.empty', 437 array('LABEL'=>$day)); 420 {// empty day 421 $tpl_crt_week[] = 422 array( 423 'DAY' => $day 424 ); 438 425 } 439 426 else 440 427 { 441 /* // first try to guess thumbnail size 442 if ( !empty($items[$day]['width']) ) 443 { 444 $tn_size = get_picture_size( 445 $items[$day]['width'], $items[$day]['height'], 446 $conf['tn_width'], $conf['tn_height'] ); 447 } 448 else*/ 449 {// item not an image (tn is either mime type or an image) 450 $thumb = get_thumbnail_path($items[$day]); 451 $tn_size = @getimagesize($thumb); 452 } 428 $thumb = get_thumbnail_path($items[$day]); 429 $tn_size = @getimagesize($thumb); 430 453 431 $tn_width = $tn_size[0]; 454 432 $tn_height = $tn_size[1]; … … 460 438 $ratio_h = $tn_height/$cell_height; 461 439 462 463 440 $pos_top=$pos_left=0; 464 $img_width=$img_height=''; 441 $css_style = ''; 442 465 443 if ( $ratio_w>1 and $ratio_h>1) 466 444 {// cell completely smaller than the thumbnail so we will let the browser … … 468 446 if ($ratio_w > $ratio_h ) 469 447 {// thumbnail ratio compared to cell -> wide format 470 $ img_height = 'height="'.$cell_height.'"';448 $css_style = 'height:'.$cell_height.'px;'; 471 449 $browser_img_width = $cell_height*$tn_width/$tn_height; 472 450 $pos_left = ($browser_img_width-$cell_width)/2; … … 474 452 else 475 453 { 476 $ img_width = 'width="'.$cell_width.'"';454 $css_style = 'width:'.$cell_width.'px;'; 477 455 $browser_img_height = $cell_width*$tn_height/$tn_width; 478 456 $pos_top = ($browser_img_height-$cell_height)/2; … … 485 463 } 486 464 487 $css_style = '';488 465 if ( round($pos_left)!=0) 489 466 { … … 506 483 $alt = $wday_labels[$dow] . ' ' . $day. 507 484 ' ('.sprintf("%d ".l10n('pictures'), $items[$day]['nb_images']).')'; 508 $template->assign_block_vars('calendar.thumbnails.row.col.full', 509 array( 510 'LABEL' => $day, 511 'IMAGE' => $items[$day]['tn_url'], 512 'U_IMG_LINK'=> $url, 513 'STYLE' => $css_style, 514 'IMG_WIDTH' => $img_width, 515 'IMG_HEIGHT'=> $img_height, 516 'IMAGE_ALT' => $alt, 517 ) 485 486 $tpl_crt_week[] = 487 array( 488 'DAY' => $day, 489 'IMAGE' => $items[$day]['tn_url'], 490 'U_IMG_LINK'=> $url, 491 'IMAGE_STYLE' => $css_style, 492 'IMAGE_ALT' => $alt, 518 493 ); 519 494 } … … 522 497 while ( $dow<6 ) 523 498 { 524 $template->assign_block_vars('calendar.thumbnails.row.col', array()); 525 $template->assign_block_vars('calendar.thumbnails.row.col.blank', array()); 499 $tpl_crt_week[] = array(); 526 500 $dow++; 527 501 } 528 $template->assign_var_from_handle('MONTH_CALENDAR', 'month_calendar'); 529 } 530 else 531 { 532 $template->assign_block_vars('thumbnails', array()); 533 $template->assign_block_vars('thumbnails.line', array()); 534 foreach ( $items as $day=>$data) 535 { 536 $url = duplicate_index_url( 537 array( 538 'chronology_date' => 539 array( 540 $page['chronology_date'][CYEAR], 541 $page['chronology_date'][CMONTH], 542 $day 543 ) 544 ) 545 ); 546 547 $thumbnail_title = $lang['day'][$data['dow']] . ' ' . $day; 548 $name = $thumbnail_title .' ('.$data['nb_images'].')'; 549 550 $template->assign_block_vars( 551 'thumbnails.line.thumbnail', 552 array( 553 'IMAGE'=>$data['tn_url'], 554 'IMAGE_ALT'=>$data['file'], 555 'IMAGE_TITLE'=>$thumbnail_title, 556 'U_IMG_LINK'=>$url 557 ) 502 $tpl_weeks[] = $tpl_crt_week; 503 504 $tpl_var['month_view'] = 505 array( 506 'CELL_WIDTH' => $cell_width, 507 'CELL_HEIGHT' => $cell_height, 508 'wday_labels' => $wday_labels, 509 'weeks' => $tpl_weeks, 558 510 ); 559 $template->assign_block_vars(560 'thumbnails.line.thumbnail.category_name',561 array(562 'NAME' => $name563 )564 );565 }566 511 } 567 512
Note: See TracChangeset
for help on using the changeset viewer.