首頁  >  文章  >  後端開發  >  php 日曆類別 日曆控件

php 日曆類別 日曆控件

WBOY
WBOY原創
2016-07-25 08:46:071236瀏覽
";
  • }
  • public function getEndTR( ) {
  • $this->retunrhtml .= "
  • ";
  • }
  • protected function getDay() {
  • return $ 🎜> ->day;
  • }
  • protected function getMonth() { return $this->month; } protected function getYear() { protected function getYear() { $this->month; } protected function getYear() { return $this->month;年; }
  • protected function isWeekend() {
  • return $this->weekend;
  • }
  • protected function isCurrent() {
  • return $ $this>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 .= "" 。 ($year, $month) {
  • $this->makeWeeks($year, $month);
  • $this->getCalendarHeader();
  • for ($i = 0; $i week); $i ) {
  • $this->getBeginTR();
  • for ($j = 0; $j
  • if (!空($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->週末= 1;
  • $ this ->getTDWeekend();
  • }
  • else {
  • $this->weekend = 0;
  • $this->getTD();
  • }
  • }
  • else {
  • $this-> ;retunrhtml .= "
  • ";
  • }
  • }
  • $this->getEndTR();
  • }
  • $this-> ;getCalendarFooter();
  • }
  • public function getCodeMonth() {
  • $this->makeCodeMonth($this->年, $this->月) ;
  • return $this->retunrhtml;
  • }
  • public function showCodeMonth() {
  • echo $this->getCodeMonth();
  • }
  • echo $this->getCodeMonth();
  • }
  • }
  • class TechCalendarForm extends CalendarForm {
  • public function getTDHref() {
  • if ($this->isWeekend()) {
  • $font = "";
  • }
  • else {
  • $font = "";
  • }
  • return "」。 $字體。父級::getDay() 。 "
  • ";
  • }
  • }
  • 複製程式碼
  • php
    1. class CalendarForm {
    2. class CalendarForm {
    3. 受保護$year;
    4. 受保護$month;
    5. 受保護$day;
    6. 受保護$month;
    7. 受保護$day;
    8. 受保護 $週末;
    9. 受保護的$currentdate;
    10. 受保護的$dayofmonth;
    11. 受保護的$day_count;
    12. 受保護的$num;
    13. 受保護的$week = array();
    14. 受保護的$retunrhtml = " " ;
    15. function __construct($year, $month) {
    16. $this->makeWeeks($year, $month);
    17. }
    18. public function setYearMonth($年,$年, $月) {
    19. $this->year = $year;
    20. $this->month = $month;
    21. }
    22. 私有函數resetDayCount() {
    23. $this- >day_count = 1;
    24. }
    25. 創函數setFirstWeek() {
    26. $this->num = 00 ;
    27. }
    28. 公用函數getDayOfMonth($year, $月) {
    29. $this->resetDayCount();
    30. 回傳日期('t', mktime(0, 0, 0 , $month, $this->day_count, $年));
    31. }
    32. 陰道函數setDayOfMonth($year, $month) {
    33. $this->dayofmonth = $this->getDayOfMonth ($year, $month);
    34. }
    35. private function getDayOfWeek() {
    36. return date('w', mktime(0, 0, 0, $this->month, $this $ ->day_count, $this->year));
    37. }
    38. public function getNextMonth() {
    39. return date('m', mktime(0, 0, 0, $this-> month, 28, $今年->年) 432000);
    40. }
    41. public function getNextYear() {
    42. return date('Y', mktime(0, 0, 0, $this- >月, 28, $this->year) 432000);
    43. }
    44. public function getPrevMonth() {
    45. return date('m', mktime(0, 0, 0, $this -> ;月, 1, $今年->年) - 432000);
    46. }
    47. public function getPrevYear() {
    48. return date('Y', mktime(0, 0, 0 , $this->month, 1, $this->year) - 432000);
    49. }
    50. 私有函數makeWeeks($year, $month) {
    51. $this-> setYearMonth($year, $month);
    52. $this->setDayOfMonth($今年->年,$這個->月);
    53. $this->setFirstWeek();
    54. $this ->num = 0;
    55. for ($i = 0; $i $dayofweek = $this->getDayOfWeek();
    56. $dayofweek = $dayofweek - 1;
    57. if ($dayofweek == -1) {
    58. $dayofweek = 6 ;
    59. }
    60. if ($dayofweek == $i) {
    61. $this->week[$this->num][$i] = $this->day_count;
    62. $this->day_count ;
    63. }
    64. else {
    65. $this->week[$this->num][$i] = "";
    66. }
    67. }
    68. while (TRUE) {
    69. $this->num ;
    70. for ($i = 0; $i $this->week[$this->num][$ i] = $this->day_count;
    71. $this->day_count ;
    72. if ($this->day_count > $this->dayofmonth) {
    73. 中斷;
    74. }
    75. }
    76. if ($this->day_count > $this->dayofmonth) {
    77. ;
    78. }
    79. }
    80. }
    81. public function getCalendarHeader() {
    82. $this->retunrhtml =
    83. "" .
    84. ” .
    85. "
    86. "。$這個->月。“/”。$今年->今年。“”。
    87. ”。
    88. " .
    89. "
    90. " .
    91. "
    92. ";
    93. }
    94. public function getCalendarFooter() {
    95. $this-> retunrhtml .= "
    96. 星期一 星期二
      ";
    97. }
    98. public function getBeginTR() {
    99. $this->retunrhtml .= "
    陳述:
    本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn