57 $this->Security =
get_package(
'security' ,
'last' , __FILE__ );
88 $PageCSS =
get_package(
'page::page_css' ,
'last' , __FILE__ );
89 $PageCSS->add_stylesheet(
"{http_host}/$PackagePath/res/css/calendar.css" );
122 $this->CachedMultyFS->get_template( __FILE__ ,
'calendar_start.tpl' ) ,
123 $this->CachedMultyFS->get_template( __FILE__ ,
'calendar_end.tpl' ) ,
124 $this->CachedMultyFS->get_template( __FILE__ ,
'calendar_row_start.tpl' ) ,
125 $this->CachedMultyFS->get_template( __FILE__ ,
'calendar_row_end.tpl' ) ,
126 $this->CachedMultyFS->get_template( __FILE__ ,
'calendar_header_cell.tpl' ) ,
127 $this->CachedMultyFS->get_template( __FILE__ ,
'calendar_cell.tpl' )
131 catch( Exception $e )
171 private function compile_header_cell( $DisplayTime , $Template , $Text , $Day )
175 $Template = str_replace(
'{header_cell}' , $Text , $Template );
177 $FirstDay = mktime( 0 , 0 , 0 , date(
'n', $DisplayTime ) , 1 , date(
'Y' , $DisplayTime ) );
178 $w = date(
'w' , $FirstDay );
179 $w = $w == 0 ? 6 : $w - 1;
181 $Class = $w == $Day && date(
'd' ) < 7 - $w ?
' active_cell_bottom' :
'';
183 $Template = str_replace(
'{active_cell_bottom}' , $Class , $Template );
187 catch( Exception $e )
223 private function compile_header_cells( $DisplayTime , $HeaderCell , $HolidayHeaderCell )
228 $this->compile_header_cell( $DisplayTime , $HeaderCell ,
'{lang:mon}' , 1 ).
229 $this->compile_header_cell( $DisplayTime , $HeaderCell ,
'{lang:tue}' , 2 ).
230 $this->compile_header_cell( $DisplayTime , $HeaderCell ,
'{lang:wed}' , 3 ).
231 $this->compile_header_cell( $DisplayTime , $HeaderCell ,
'{lang:thr}' , 4 ).
232 $this->compile_header_cell( $DisplayTime , $HeaderCell ,
'{lang:fri}' , 5 ).
233 $this->compile_header_cell( $DisplayTime , $HolidayHeaderCell ,
'{lang:sat}' , 6 ).
234 $this->compile_header_cell( $DisplayTime , $HolidayHeaderCell ,
'{lang:sun}' , 0 )
237 catch( Exception $e )
269 list( $CalendarStart , $CalendarEnd , $RowStart , $RowEnd , $HeaderCell , $Cell ) =
272 $HolidayHeaderCell = str_replace(
'{holiday}' ,
' holiday' , $HeaderCell );
275 $RowStart.$this->compile_header_cells( $DisplayTime , $HeaderCell , $HolidayHeaderCell ).$RowEnd
278 catch( Exception $e )
310 $Code = $this->CachedMultyFS->get_template( __FILE__ ,
'calendar_toolbar.tpl' );
312 $MonthYear = date(
'm} Y' , $DisplayTime );
314 $MonthPrev = strtotime(
'-1 month' , $DisplayTime );
316 '{toolbar}' ,
"{href:page=?calendar_time[eq]$MonthPrev;text=month_prev}{toolbar}" , $Code
320 '{toolbar}' ,
" {lang:month_name_$MonthYear {toolbar}" , $Code
323 $MonthNext = strtotime(
'+1 month' , $DisplayTime );
324 $Code = str_replace(
'{toolbar}' ,
"{href:page=?calendar_time[eq]$MonthNext;text=month_next}" , $Code );
328 catch( Exception $e )
356 private function compile_cell_class( $CellDay )
360 $ThisDay = date(
'Y-m-d' ) == date(
'Y-m-d' , $CellDay );
361 $ThisMonth = date(
'Y-m' ) == date(
'Y-m' , $CellDay );
363 $Class = $ThisDay ?
' active_cell' :
'';
365 $NextWeekDay = date(
'j' ) == date(
'j' , $CellDay ) + 7;
366 $Class = $ThisMonth && $NextWeekDay ?
' active_cell_bottom' : $Class;
368 $NextDay = date(
'j' ) == date(
'j' , $CellDay ) + 1;
369 $Class = $ThisMonth && $NextDay ?
' active_cell_right' : $Class;
373 catch( Exception $e )
405 private function compile_cell( $Day , $CellDay )
409 list( $CalendarStart , $CalendarEnd , $RowStart , $RowEnd , $HeaderCell , $Cell ) =
414 $Code .= $Day % 7 === 1 ? $RowStart :
'';
415 $Code .= str_replace(
'{day}' , $CellDay , $Cell );
417 $DayOfWeek = date(
'w' , $CellDay );
419 $Code = $DayOfWeek == 0 || $DayOfWeek == 6 ? str_replace(
'{holiday}' ,
' holiday' , $Code ) : $Code;
420 $Class = $this->compile_cell_class( $CellDay );
421 $Code = str_replace(
'{active_cell}' , $Class , $Code );
422 $Code .= $Day % 7 === 0 ? $RowEnd :
'';
426 catch( Exception $e )
462 private function compile_rows( $DisplayTime , $DayOfWeek , $FirstDay , $DisplayTime )
466 list( $CalendarStart , $CalendarEnd , $RowStart , $RowEnd , $HeaderCell , $Cell ) =
471 for( $Day = 1 ; $Day <= 42 ; $Day++ )
473 $DayAdd = $Day - $DayOfWeek;
474 $CellDay = strtotime( $DayAdd < 0 ? $DayAdd.
' day' :
"+$DayAdd day" , $FirstDay );
475 $Code .= $this->compile_cell( $Day , $CellDay );
477 if( date(
'm' , $CellDay ) !== date(
'm' , $DisplayTime ) && $Day % 7 === 0 )
485 catch( Exception $e )
517 $DisplayTime = $this->Settings->get_setting(
'calendar_time' , time() );
518 $DisplayTime = $this->Security->get_gp(
'calendar_time' ,
'integer' , $DisplayTime );
520 list( $Start , $End , $RowStart , $RowEnd , $HeaderCell , $Cell ) =
523 $FirstDay = mktime( 0 , 0 , 0 , date(
'n', $DisplayTime ) , 1 , date(
'Y' , $DisplayTime ) );
525 $Code = $Start.$this->get_toolbar( $DisplayTime );
528 $DayOfWeek = date(
'w' , $FirstDay );
529 $Code .= $this->compile_rows( $DisplayTime , $DayOfWeek , $FirstDay , $DisplayTime );
531 return( $Code.$End );
533 catch( Exception $e )
565 if( $Options->get_setting(
'calendar' ,
false ) )
567 $CalendarTime = $this->Security->get_gp(
'calendar_time' ,
'integer' ,
false );
571 return( $this->Output );
573 catch( Exception $e )