使用範例: $cal = new CalendarForm(2012, 5); $cal->showCodeMonth();
-
class CalendarForm {
-
- protected $year;
- protected $month;
- protected day;
- protected $month;
- protectedday $ 受保護的$currentdate;
- 受保護的$dayofmonth;
- 受保護的$day_count;
- 受保護的$num;
- 受保護的$week = array() ;
- 受保護的$retunrhtml = " " ;
-
- function __construct($year, $month) {
- $this->makeWeeks($year, $month);
- }
-
- public function setYearMonth($年, $month) {
- $this->year = $year;
- $this->month = $month;
- }
-
- 內部函數resetDayCount() {
- $this- >day_count = 1;
- }
-
- 創函數setFirstWeek() {
- $this->num = 0;
- }
-
- 公用函數getDayOfMonth($year, $月) {
- $this->resetDayCount();
- 回傳日期('t', mktime(0, 0, 0, $month, $this- >day_count, $年));
- }
-
- 陰道函數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, $今年- >年) 432000);
- }
-
- public function getNextYear() {
- return date('Y', mktime(0, 0, 0, $this->月, 28, $this ->year) 432000);
- }
-
- public function getPrevMonth() {
- return date('m', mktime(0, 0, 0, $this-> ;月, 1, $今年->年) - 432000);
- }
-
- public function getPrevYear() {
- return date('Y', mktime(0, 0, 0, $this->月, 1, $this->年) - 432000);
- }
-
- 蒸發函數makeWeeks($year, $month) {
-
- $this->setYearMonth($year, $
-
- $this->setYearMonth($year, $
-
- $this->setYearMonth($year, $
-
- $this->setYearMonth($year, $
-
- $this->setYearMonth($year, $
-
- $this->setYearMonth($year, $ $this->setDayOfMonth($今年->年,$這個->月);
- $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) {
- 中斷;
- }
- }
- if ($this->day_count > $this->dayofmonth) {
- 線;
- }
- }
-
- }
-
- public function getCalendarHeader() {
-
- public function getCalendarHeader() {
- > 🎜> $this->retunrhtml =
- "
" .- 「」 .
- "
" 。 $this->month 。 ;">週一 | " .- "
星期二 | " .
- "
星期二 | " .
- "
星期三 | " .
- "
星期四 | " .
- "
星期五 | " .
- "星期六" .
- "
週日 | " .
- "
";
- }
-
- public function getCalendarFooter() {
- $this->retunrhtml .= "
";
- }
-
- public function getBeginTR() {
- $this-> retunrhtml .= "
";- }
-
- public function getEndTR( ) {
- $this->retunrhtml .= "
";
- } protected function getDay() { return $this->day; } protected function getMonth() { return $this->month; } } } } } } } } } } } } } } } } } } } } } } } } } } } } } }} > protected function getYear() { return $this->month; } protected function getYear() { return $this->month;。 ; }
-
- protected function isWeekend() {
- return $this->weekend;
- }
-
- protected function isCurrent() {
- return $> currentdate;
- }
-
- public function getTDHref() {
- return $this->getDay();
- }
-
- public function getTD() {
- $class = '';
- $td = "td";
- if ($this->isCurrent()) {
- $class = '今天';
- }
- $this-> ;retunrhtml .= "" 。 $class = '';
- $td = "td";
- if ($ this->isCurrent()) {
- $class = '今天';
- }
- $this- >retunrhtml .= "" 。 $month) {
- $this->makeWeeks($year, $month);
- $this->getCalendarHeader();
- for ($i = 0; $i 週); $i ) {
- $this->getBeginTR();
- for ($j = 0; $j
- if (!empty($this ->週[$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->目前日期= 1;
- }
- if ($j == 5 || $j == 6) {
- $this->weekend = 1;
- $this->getTDWeekend ( );
- }
- else {
- $this->weekend = 0;
- $this->getTD();
- }
-
- }
- else {
- $this-> ;retunrhtml .= "
| ";
- }
-
- }
- $this->getEndTR();
- }
- $ this ->getCalendarFooter();
- }
-
- public function getCodeMonth() {
- $this->makeCodeMonth($this->year, $this->month);
- return
- return
- return
- return
- return
- return
- return
- return
- return
- return
- return
- return
- return
- return
- return
- return
- return
- return
- return
- return retunrhtml;
- }
-
- public function showCodeMonth() {
- echo $this->getCodeMonth();
- }
-
- }
}
} } | > class TechCalendarForm extends CalendarForm {
public function getTDHref() {