フール・ムーン

  • フールムーン
  • フールムーン
  • フールムーン
  • フールムーン
  • フールムーン
  • フールムーン

フールムーン

フールムーン

フールムーン

__construct(); } /** * カレンダー表示用に作成されたHTML結果を取得する * * @param int $year 年 * @param int $month 月 * @param int $week_start カレンダー左端の曜日(0:日曜日〜6:土曜日) * @param int $disp_flg 当月以外の日を表示するか(0:表示しない 1:表示する) * @param int $holiday_flg 祝日名を表示するか(0:表示しない 1:表示する) * */ function getCalendar($year, $month, $week_start = 0, $disp_flg = 0, $holiday_flag = 0){ // 年月のチェック if(checkdate($month, 1, $year) === false){ return false; } $bgcolor_weekname = array( $this->bgcolor_holiday, $this->bgcolor_weekname, $this->bgcolor_weekname, $this->bgcolor_weekname, $this->bgcolor_weekname, $this->bgcolor_weekname, $this->bgcolor_saturday, ); $bgcolor_body = array( $this->bgcolor_holiday, $this->bgcolor_body, $this->bgcolor_body, $this->bgcolor_body, $this->bgcolor_body, $this->bgcolor_body, $this->bgcolor_saturday, ); $holiday = $this->getHoliday($year, $month); // 曜日の開始位置を取得 $from = 1; while(date("w", mktime(0, 0, 0, $month, $from, $year)) != $week_start){ $from--; } $beforelast = date("t", mktime(0, 0, 0, $month - 1, 1, $year)); $thislast = date("t", mktime(0, 0, 0, $month, 1, $year)); $lpy = ceil(($thislast + abs($from) +1) / 7); $html = ""; $html .= "
\nstyle_table} bgcolor=\"#ffffff\" summary=\"カレンダー\">\n"; $html .= " \n"; $html .= " "; $html .= " \n"; $html .= " \n"; for($i = 0; $i < 7; $i++){ $id = ($week_start + $i) % 7; $html .= " \n"; } $html .= " \n"; for($i = 0; $i < $lpy; $i++) { $html .= " \n"; for($j = 0; $j < 7; $j++) { $day = $i * 7 + $j + $from; $id = ($week_start + $j) % 7; $bgcolor = $bgcolor_body[$id]; if($day < 1){ // 指定月の前月 $dd = $beforelast + $day; $data = $this->_getData($year, $month-1, $dd); $bgcolor = $this->bgcolor_other; }elseif($day > $thislast){ // 指定月の後月 $dd = $day - $thislast; $data = $this->_getData($year, $month+1, $dd); $bgcolor = $this->bgcolor_other; }else{ // 指定月 $dd = $day; $data = $this->_getData($year, $month, $dd); $link = $this->_getLink($year, $month, $dd); if($link != ""){ $tmonth = str_pad($month,2,"0",STR_PAD_LEFT); $tdate = str_pad($dd,2,"0",STR_PAD_LEFT); $tmp_time = substr($link,32); $length_time = strpos($tmp_time,";")-1; $time = substr($tmp_time,0,$length_time); //========================== $gweek = date("w", mktime(0, 0, 0, $month, $dd, $year)); if($gweek==0){$fweek = "日";} if($gweek==1){$fweek = "月";} if($gweek==2){$fweek = "火";} if($gweek==3){$fweek = "水";} if($gweek==4){$fweek = "木";} if($gweek==5){$fweek = "金";} if($gweek==6){$fweek = "土";} //$dd = "{$dd}"; $dd = "{$dd}"; } // 祝日の色変更処理 if($holiday[$day] != ""){ $bgcolor = $this->bgcolor_holiday; } } // 当月以外の日付を表示しない if($disp_flg != 1 && ($day < 1 || $day > $thislast)){ $dd = " "; $data = ""; } //$html .= " \n"; } $html .= " \n"; } $html .= "
style_title}>{$year}年{$month}月
style_weekname}>{$this->weekname[$id]}
style_body} bgcolor=\"{$bgcolor}\">\n"; $html .= " style_body}>\n"; //============================================= $tmp_link = strstr($dd,"【"); $tmp_link = ltrim($tmp_link,"【"); $n_end = strpos($tmp_link,"】"); $kindoff = substr($tmp_link,0,$n_end); $off1 = substr_count($kindoff,"余裕有り"); $off2 = substr_count($kindoff,"残りわずか"); $off3 = substr_count($kindoff,"予約不可"); //$input_today = date("mj"); $input_today = date("n/j"); $input_day = $month."/".$day; $month2 = date("m"); $today2 = date("d"); $today = date("n/j"); $s_today = substr_count($kindoff,$today); $off = substr_count($kindoff," "); if($s_today==1){ $html .= " \n"; }elseif($input_today==$input_day){ $html .= " \n"; }elseif($month2==$month && $dd<$today2){ $html .= " \n"; }elseif($off1==1){ //$html .= " \n"; $html .= "

style_day}>{$dd}

\n"; }elseif($off2==1){ $html .= " \n"; }elseif($off3==1){ $html .= " \n"; // }elseif($off1==0||$off2==0){ // $html .= "

style_day}>{$dd}

\n"; }else{ $html .= "

style_day}>{$dd}

\n"; } //============================================= // 休日名出力用追加処理 if($holiday_flag == 1 && $holiday[$day] != "") { $html .= "

{$holiday[$day]}

\n"; } if($data != "") { $html .= " {$data}\n"; } $html .= "
\n"; return $html; } /** * 指定日付にデータをセットする * * @param int $year * @param int $month * @param int $day * @param string $data */ function setData($year, $month, $day, $data){ $id = sprintf("%04d%02d%02d", $year, $month, $day); $this->_data[$id] = $data; } function setLink($year, $month, $day, $link){ $id = sprintf("%04d%02d%02d", $year, $month, $day); $this->_link[$id] = $link; } function _getData($year, $month, $day){ $id = sprintf("%04d%02d%02d", $year, $month, $day); if(isset($this->_data[$id])) { return $this->_data[$id]; } return; } /** * 指定日付にリンクをセットする * * @param int $year * @param int $month * @param int $day * @param string $link */ function _getLink($year, $month, $day){ $id = sprintf("%04d%02d%02d", $year, $month, $day); if(isset($this->_link[$id])) { return $this->_link[$id]; } return; } function getHoliday($year, $month) { $ret = array(); // その月の最初の月曜日が何日かを算出 $day = 1; while(date("w",mktime(0 ,0 ,0 , $month, $day, $year)) != 1) { $day++; } // 祝日をセット switch($month){ case 1: $ret[1] = "元旦"; if($year < 2000){ $ret[15] = "成人の日"; }else{ $ret[$day+7] = "成人の日"; } break; case 2: $ret[11] = "建国記念日"; break; case 3: if($year > 1979 && $year < 2100){ $tmp = floor(20.8431+($year-1980)*0.242194-floor(($year-1980)/4)); $ret[$tmp] = "春分の日"; } break; case 4: if($year < 1989){ $ret[29] = "天皇誕生日"; }elseif($year < 2007){ $ret[29] = "みどりの日"; }else{ $ret[29] = "昭和の日"; } break; case 5: $ret[3] = "憲法記念日"; if($year > 2006){ $ret[4] = "みどりの日"; } $ret[5] = "子供の日"; break; case 7: if($year > 2002){ $ret[$day+14] = "海の日"; }elseif($year > 1994){ $ret[21] = "海の日"; } break; case 9: if($year < 2003){ $ret[15] = "敬老の日"; }else{ $ret[$day+14] = "敬老の日"; } if($year > 1979 && $year < 2100) { $tmp = floor(23.2488+($year-1980)*0.242194-floor(($year-1980)/4)); $ret[$tmp] = "秋分の日"; } break; case 10; if($year < 2000){ $ret[10] = "体育の日"; }else{ $ret[$day+7] = "体育の日"; } break; case 11: $ret[3] = "文化の日"; $ret[23] = "勤労感謝の日"; break; case 12: if($year > 1988){ $ret[23] = "天皇誕生日"; } break; } if($year > 1985) { for($i = 1;$i < date("t",mktime(0, 0, 0, $month, 1, $year)); $i++) { if(isset($ret[$i]) && isset($ret[$i+2])) { $ret[$i+1] = "国民の休日"; $i = $i + 3; } } } $sday = $day - 1; if($sday == 0){ $sday = 7; } for($i = $sday;$i < date("t",mktime(0, 0, 0, $month, 1, $year));$i = $i + 7){ // 2008/2/27 変更 // if(isset($ret[$i])) { // $ret[$i+1] = "振替休日"; // } $j = $i; while(isset($ret[$j])){ $j++; } // 2008/3/20 修正 if(date("w",mktime(0, 0, 0, $month, $j, $year)) > 0){ $ret[$j] = "振替休日"; } } return $ret; } } ?>