- class CalendarForm {
-
- protected $year;
- protected $month;
- protected $day;
- protected $weekend;
- protected $currentdate;
- protected $dayofmonth;
- protected $day_count;
- protected $num;
- protected $week = array();
- protected $retunrhtml = "";
-
- function __construct($year, $month) {
- $this->makeWeeks($year, $month);
- }
-
- パブリック関数 set YearMonth($year, $month) {
- $this->year = $year;
- $this->month = $month;
- }
-
- プライベート関数 replaceDayCount() {
- $this-> day_count = 1;
- }
-
- プライベート関数 setFirstWeek() {
- $this->num = 0;
- }
-
- パブリック関数 getDayOfMonth($year, $month) {
- $this->resetDayCount();
- return date('t', mktime(0, 0, 0, $month, $this->day_count, $year));
- }
-
- プライベート関数 setDayOfMonth($year, $month) {
- $this-> ;dayofmonth = $this->getDayOfMonth($year, $month);
- }
-
- private function getDayOfWeek() {
- return date('w', mktime(0, 0, 0, $this->month, $this->day_count, $this->year));
- }
-
- public function getNextMonth() {
- return date('m', mktime(0, 0, 0, $this->month, 28) , $this->year) + 432000);
- }
-
- public function getNext Year() {
- return date('Y', mktime(0, 0, 0, $this->month, 28, $this- >年) + 432000);
- }
-
- public function getPrevMonth() {
- return date('m', mktime(0, 0, 0, $this->month, 1, $this->year) - 432000);
- }
-
- public function getPrev Year() {
- return date('Y', mktime(0, 0, 0, $this->month, 1, $this->year) - 432000);
- }
-
- プライベート関数 makeWeeks($year, $month) {
-
- $this->set YearMonth($year, $month);
- $this->setDayOfMonth($this->year, $this-> ;month);
- $this->setFirstWeek();
-
- $this->num = 0;
- for ($i = 0; $i $dayofweek = $this->getDayOfWeek();
- $dayofweek = $dayofweek - 1;
- if ($dayofweek == -1) {
- $dayofweek = 6;
- }
- if ($dayofweek == $i) {
- $this->week[$this->num][$i] = $this->day_count;
- $this->day_count++;
- }
- else {
- $this- >week[$this->num][$i] = "";
- }
- }
- while (TRUE) {
- $this->num++;
- for ($i = 0; $i $this->week[$this->num][$i] = $this->day_count;
- $this->day_count++;
- if ($this->day_count > ; $this->dayofmonth) {
- Break;
- }
- }
- if ($this->day_count > $this->dayofmonth) {
- Break;
- }
- }
-
- }
-
- public function getCalendarHeader () {
- $this->retunrhtml =
- "
" .
- 「」 .
- "
" 。 $this->month 。 「/」。 $this->今年 。 "" .
- "
" .- "
月曜日 | " .
- "
火曜日 | " .
- "
水曜日 | " .
- "
木曜日 | " .
- "
金曜日 | " .
- "
土曜日 | " .
- "
日曜日 | " .
- "
";
- }
-
- public function getCalendarFooter() {
- $this->retunrhtml .= "
";
- }
-
- public function getBeginTR( ) {
- $this->retunrhtml .= "
";
- }
-
- public function getEndTR() {
- $this->retunrhtml .= "
";
- }
-
- protected function getDay() {
- return $this->day;
- }
-
- protected 関数 getMonth() {
- return $this->month;
- }
-
- protected function get Year() {
- return $this->gt;年;
- }
-
- 保護された関数 isWeekend() {
- return $this->weekend;
- }
-
- 保護された関数 isCurrent() {
- return $this->currentdate;
- }
-
- public function getTDHref() {
- return $this ->getDay();
- }
-
- public function getTD() {
- $class = '';
- $td = "td";
- if ($this->isCurrent()) {
- $class = '今日';
- }
- $this->retunrhtml .= "<$td class=\"$class\">" 。 $this->getTDHref() 。 "$td>";
- }
-
- public function getTDWeekend() {
- $class = '';
- $td = "td";
- if ($this->isCurrent()) {
- $class = '今日';
- }
- $this->retunrhtml .= "<$td class=\"$class\">" 。 $this->getTDHref() 。 "$td>";
- }
-
- 保護関数 makeCodeMonth($year, $month) {
- $this->makeWeeks($year, $month);
- $this->getCalendarHeader();
- for ($i = 0; $i week); $i++) {
- $this->getBeginTR();
- for ($j = 0; $j
- if (!empty($this->week[$i][$j])) {
- $this->day = $this->week[$i][$j];
- $this->currentdate = 0;
- if ($this->year == date('Y') && $this->month == date('m') && $this->day = = date('j')) {
- $this->currentdate = 1;
- }
- if ($j == 5 || $j == 6) {
- $this->weekend = 1;
- $ this->getTDWeekend();
- }
- else {
- $this->weekend = 0;
- $this->getTD();
- }
-
- }
- else {
- $this->returnrhtml .= "
| ";
- }
-
- }
- $this->getEndTR();
- }
- $this->getCalendarFooter();
- }
-
- public function getCodeMonth() {
- $this->makeCodeMonth($this->year, $this->month);
- return $this->retunrhtml;
- }
-
- public function showCodeMonth() {
- echo $this->getCodeMonth( );
- }
-
- }
-
- class TechCalendarForm extends CalendarForm {
- public function getTDHref() {
- if ($this->isWeekend()) {
- $font = "";
- }
- else {
- $font = "";
- }
- return "gt;" . $font .parent::getDay() . "";
- }
- }复制代码
|