00001 <?
00002 abstract class DateBox extends BaseBox
00003 {
00004 private $thisMonth;
00005 private $thisDay;
00006 private $thisYear;
00007 private $nextYear;
00008 public $month;
00009 public $maxCount = 5;
00010
00011 abstract public function drawDate($ob, $day);
00012 abstract public function getDates();
00013 abstract public function drawNoDates();
00014
00015 public function __construct($title, $month = null)
00016 {
00017 $this->month = $month;
00018 parent::__construct($title);
00019 }
00020
00021 public function initDates()
00022 {
00023 global $me;
00024
00025
00026 $this->thisMonth = (int)date("m");
00027 $this->thisDay = (int)date("d");
00028 $this->thisYear = (int)date("Y");
00029 $this->nextYear = (int)date("Y") + 1;
00030
00031
00032 $dates = $this->getDates();
00033
00034
00035 ksort($dates);
00036
00037 return $dates;
00038 }
00039
00040 public function getTime($date)
00041 {
00042 $ar = explode("-", $date);
00043 $month = (int)$ar[1];
00044 $day = (int)$ar[2];
00045
00046 if ($date != '0000-00-00')
00047 {
00048
00049 if ($this->month === null || $this->month == $month)
00050 {
00051
00052 if ($month < $this->thisMonth || ($month == $this->thisMonth && $day < $this->thisDay))
00053 $time = strtotime("$this->nextYear-$month-$day");
00054
00055 else
00056 $time = strtotime("$this->thisYear-$month-$day");
00057
00058 return $time;
00059 }
00060 }
00061
00062 return null;
00063 }
00064
00065 public function drawContent()
00066 {
00067 $dates = $this->initDates();
00068 $count = 0;
00069
00070
00071 if (count($dates))
00072 {
00073 foreach ($dates AS $key => $day)
00074 {
00075 foreach ($day AS $item)
00076 {
00077
00078 if ($count < $this->maxCount && $this->canDrawDate($key, $ob))
00079 {
00080 $this->drawDate($item, $key);
00081 $count++;
00082 }
00083 }
00084 }
00085 }
00086
00087 if (!$count)
00088 $this->drawNoDates();
00089 }
00090
00091 public function canDrawDate($key, $ob)
00092 {
00093 return true;
00094 }
00095 }