cal = $cal; $today = $GLOBALS['timedate']->getNow(true)->get_day_begin(); $this->today_ts = $today->format('U') + $today->getOffset(); $this->startday = $current_user->get_first_day_of_week(); $weekdays = array(); for($i = 0; $i < 7; $i++){ $j = $i + $this->startday; if($j >= 7) $j = $j - 7; $weekdays[$i] = $GLOBALS['app_list_strings']['dom_cal_day_short'][$j+1]; } $this->weekdays = $weekdays; $this->scrollable = false; if(in_array($this->cal->view,array('day','week'))){ $this->scrollable = true; if($this->cal->time_step < 30) $this->scroll_height = 480; else $this->scroll_height = $this->cal->celcount * 15 + 1; } $this->time_step = $this->cal->time_step; $this->time_format = $GLOBALS['timedate']->get_time_format(); $this->date_time_format = $GLOBALS['timedate']->get_date_time_format(); $this->style = $this->cal->style; } /** Get html of calendar grid * @return string */ public function display(){ $action = "display_".strtolower($this->cal->view); return $this->$action(); } /** Get html of time column * @param integer $start timestamp * @return string */ protected function get_time_column($start){ $str = ""; $head_content = " "; if($this->cal->view == 'month'){ if($this->startday == 0) $wf = 1; else $wf = 0; $head_content = "fromTimestamp($start)->format('j')."&month=".$GLOBALS['timedate']->fromTimestamp($start)->format('n')."&year=".$GLOBALS['timedate']->fromTimestamp($start)->format('Y'))."'>".$GLOBALS['timedate']->fromTimestamp($start + $wf*3600*24)->format('W').""; } $str .= "
"; //if(!$this->scrollable) // $str .= "
".$head_content."
"; for($i = 0; $i < 24; $i++){ for($j = 0; $j < 60; $j += $this->time_step){ if($j == 0){ $innerText = $GLOBALS['timedate']->fromTimestamp($start + $i * 3600)->format($this->time_format); }else{ $innerText = " "; } if($j == 60 - $this->time_step && $this->time_step < 60){ $class = " odd_border"; }else{ $class = ""; } $str .= "
".$innerText."
"; } } $str .= "
"; return $str; } /** * Get html of day slots column * @param integer $start timestamp * @param integer $day number of day in week * @param string $suffix suffix for id of time slot used in shared view * @return string */ protected function get_day_column($start,$day = 0,$suffix = ""){ $curr_time = $start; $str = ""; $str .= "
"; //$str .= $this->get_day_head($start,$day); for($i = 0; $i < 24; $i++){ for($j = 0; $j < 60; $j += $this->time_step){ $timestr = $GLOBALS['timedate']->fromTimestamp($curr_time)->format($this->time_format); if($j == 60 - $this->time_step && $this->time_step < 60){ $class = " odd_border"; }else{ $class = ""; } $str .= "
fromTimestamp($curr_time)->format($this->date_time_format)."'>
"; $curr_time += $this->time_step*60; } } $str .= "
"; return $str; } /** * Get html of basic cell * @param integer $start timestamp * @param integer $height slot height * @param string $prefix prefix for id of slot used in shared view * @return string */ protected function get_basic_cell($start,$height = 80,$suffix = ""){ $str = ""; $dt = $GLOBALS['timedate']->fromTimestamp($start)->get("+8 hours"); $str .= "
"; $str .= "
"; $str .= "
"; return $str; } /** * Get html of basic week grid * @param integer $start timestamp * @param string $prefix prefix for id of slot used in shared view * @return string */ protected function get_basic_row($start,$cols = 7,$suffix = ""){ $height = 20; $str = ""; $head_content = " "; if($this->cal->view == 'month' || $this->cal->style == "basic"){ $wf = 0; if($this->startday == 0) $wf = 1; $head_content = $GLOBALS['timedate']->fromTimestamp($start + $wf*3600*24)->format('W'); $head_content = "fromTimestamp($start)->format('j')."&month=".$GLOBALS['timedate']->fromTimestamp($start)->format('n')."&year=".$GLOBALS['timedate']->fromTimestamp($start)->format('Y'))."'>".$head_content.""; } $left_col = ($this->style != 'basic' || $this->cal->view == 'month'); $attr = ""; if($this->cal->style != "basic") $attr = " id='cal-multiday-bar'"; $str .= "
"; if($cols > 1){ $str .= "
"; if($left_col){ $str .= "
"; $str .= "
".$head_content."
"; $str .= "
"; } $str .= "
"; for($d = 0; $d < $cols; $d++){ $curr_time = $start + $d * 86400; $str .= "
"; $str .= $this->get_day_head($curr_time,$d,true); $str .= "
"; } $str .= "
"; $str .= "
"; $str .= "
"; } $str .= "
"; if($left_col){ $str .= "
"; $str .= "
 
"; $str .= "
"; } $str .= "
"; for($d = 0; $d < $cols; $d++){ $curr_time = $start + $d*86400; $str .= $this->get_basic_cell($curr_time,$height,$suffix); } $str .= "
"; $str .= "
"; $str .= "
"; $str .= "
"; return $str; } /** * Get html of day head * @param integer $start timestamp * @param integer $day number of day in week * @param bulean $force force display header * @return string */ protected function get_day_head($start,$day = 0,$force = false){ $str = ""; if($force){ $headstyle = ""; if($this->today_ts == $start) $headstyle = " today"; $str .= "
fromTimestamp($start)->format('j')."&month=".$GLOBALS['timedate']->fromTimestamp($start)->format('n')."&year=".$GLOBALS['timedate']->fromTimestamp($start)->format('Y'))."'>".$this->weekdays[$day]." ".$GLOBALS['timedate']->fromTimestamp($start)->format('d')."
"; } return $str; } /** * Get html of week calendar grid * @return string */ protected function display_week(){ $basic = $this->style == "basic"; $week_start_ts = $this->cal->grid_start_ts; $str = ""; $str .= ""; return $str; } /** * Get html of day calendar grid * @return string */ protected function display_day(){ $basic = $this->style == "basic"; $day_start_ts = $this->cal->grid_start_ts; $str = ""; $str .= ""; return $str; } /** * Get html of month calendar grid * @return string */ protected function display_month(){ $basic = $this->style == "basic"; $week_start_ts = $this->cal->grid_start_ts; $current_date = $this->cal->date_time; $month_start = $current_date->get_day_by_index_this_month(0); $month_end = $month_start->get("+".$month_start->format('t')." days"); $week_start = CalendarUtils::get_first_day_of_week($month_start); $month_end_ts = $month_end->format('U') + $month_end->getOffset(); $str = ""; $str .= ""; return $str; } /** * Get html of week shared grid * @return string */ protected function display_shared(){ $basic = $this->style == "basic"; $week_start_ts = $this->cal->grid_start_ts; $str = ""; $str .= ""; return $str; } /** * Get html of year calendar * @return string */ protected function display_year(){ $weekEnd1 = 0 - $this->startday; $weekEnd2 = -1 - $this->startday; if($weekEnd1 < 0) $weekEnd1 += 7; if($weekEnd2 < 0) $weekEnd2 += 7; $year_start = $GLOBALS['timedate']->fromString($this->cal->date_time->year.'-01-01'); $str = ""; $str .= ''; for($m = 0; $m < 12; $m++){ $month_start = $year_start->get("+".$m." months"); $month_start_ts = $month_start->format('U') + $month_start->getOffset(); $month_end = $month_start->get("+".$month_start->format('t')." days"); $week_start = CalendarUtils::get_first_day_of_week($month_start); $week_start_ts = $week_start->format('U') + $week_start->getOffset(); // convert to timestamp, ignore tz $month_end_ts = $month_end->format('U') + $month_end->getOffset(); $table_id = "daily_cal_table".$m; //bug 47471 if($m % 3 == 0) $str .= ""; $str .= ''; if(($m - 2) % 3 == 0) $str .= ""; } $str .= "
'; $str .= ''.$GLOBALS['app_list_strings']['dom_cal_month_long'][$m+1].''; $str .= ''; $str .= ''; for($d = 0; $d < 7; $d++) $str .= ''; $str .= ''; $curr_time_global = $week_start_ts; $w = 0; while($curr_time_global < $month_end_ts){ $str .= ''; for($d = 0; $d < 7; $d++){ $curr_time = $week_start_ts + $d*86400 + $w*60*60*24*7; if($curr_time < $month_start_ts || $curr_time >= $month_end_ts) $monC = ""; else $monC = ''.$GLOBALS['timedate']->fromTimestamp($curr_time)->format('j').''; if($d == $weekEnd1 || $d == $weekEnd2) $str .= ""; } $str .= ""; $curr_time_global += 60*60*24*7; $w++; } $str .= '
'.$this->weekdays[$d].'
"; else $str .= ""; $str .= $monC; $str .= "
'; $str .= '
"; return $str; } } ?>