hsfsf <html> <head> <link rel="stylesheet" type="text/css" href="style/style1.css" /> </head> <body> <h2>Calendar Sample</h2> <?php error_reporting(E_ALL); include_once 'calendarlib.php'; $mycal = new calendarlib(); $mycal->setLanguage(0); $mycal->setLinkTyp(4); $mycal->setGETVariableName('datum'); $mycal->setDateWithGET(); $mycal->addEvent('30-1-2008', 'http://www.tsql.de'); $mycal->addEvent('22-2-2008', 'http://myip.tsql.de'); $mycal->addEvent('25-2-2008'); $mycal->addEvent('01-3-2008'); $mycal->addEvent('2-3-2008'); $mycal->showCAL(); ?> <br /><br /> linktyp=0 - No link | keine Links<br /> linktyp=1 - Full linked | vollständige Links<br /> linktyp=2 - Only forward and back | nur weiter und zurck<br />
/** * @return bool */ public function createEvents() { // calculate the date of every events to create $dates = array(); $start = TikiLib::date_format2('Y/m/d', $this->getStartPeriod()); $start = explode("/", $start); if ($this->getNbRecurrences() > 0) { $nbRec = $this->getNbRecurrences(); if ($this->isWeekly()) { $startWeekday = TikiLib::date_format2('w', $this->getStartPeriod()); // 0->Sunday, 6->Saturday $firstEventDate = $this->getWeekday() - $startWeekday; if ($firstEventDate < 0) { $firstEventDate += 7; } for ($i = 0; $i < $nbRec; $i++) { $dates[] = TikiLib::make_time(0, 0, 0, $start[1], $start[2] + $firstEventDate + $i * 7, $start[0]); } } elseif ($this->isMonthly()) { $firstIsNextMonth = $this->getDayOfMonth() < $start[2]; $startMonth = $firstIsNextMonth ? $start[1] + 1 : $start[1]; $occurrences = 0; for ($i = 0; $occurrences < $nbRec; $i++) { $nbDaysInMonth = date('t', TikiLib::make_time(0, 0, 0, $startMonth + $i, 1, $start[0])); if ($this->getDayOfMonth() > $nbDaysInMonth) { continue; } $dates[] = TikiLib::make_time(0, 0, 0, $startMonth + $i, $this->getDayOfMonth(), $start[0]); $occurrences++; } } elseif ($this->isYearly()) { $yymm = TikiLib::date_format2('md', $this->getStartPeriod()); $isLeapDay = $this->getDateOfYear() == 229; // Feb 29th case. $offset = $this->getDateOfYear() < $yymm ? 1 : 0; $dt = str_pad($this->getDateOfYear(), 4, "0", STR_PAD_LEFT); $occurrences = 0; for ($i = 0; $occurrences < $nbRec; $i++) { if ($isLeapDay) { if (TikiLib::date_format2('L', TikiLib::make_time(0, 0, 0, 1, 1, $start[0] + $offset + $i)) == 0) { continue; } } $dates[] = TikiLib::make_time(0, 0, 0, substr($dt, 0, 2), substr($dt, -2), $start[0] + $offset + $i); $occurrences++; } } else { // there should be no other case return false; } } elseif ($this->getEndPeriod() > 0) { if ($this->isWeekly()) { $startWeekday = TikiLib::date_format2('w', $this->getStartPeriod()); // 0->Sunday, 6->Saturday $firstEventDate = $this->getWeekday() - $startWeekday; if ($firstEventDate < 0) { $firstEventDate += 7; } $currDate = TikiLib::make_time(0, 0, 0, $start[1], $start[2] + $firstEventDate, $start[0]); while ($currDate < $this->getEndPeriod()) { $dates[] = $currDate; $currDate += weekInSeconds; } } elseif ($this->isMonthly()) { $firstIsNextMonth = $this->getDayOfMonth() < $start[2]; $startMonth = $firstIsNextMonth ? $start[1] + 1 : $start[1]; $currDate = TikiLib::make_time(0, 0, 0, $startMonth, $this->getDayOfMonth(), $start[0]); $i = 0; while ($currDate < $this->getEndPeriod()) { $nbDaysInMonth = TikiLib::date_format2('t', TikiLib::make_time(0, 0, 0, $startMonth + $i, 1, $start[0])); if ($this->getDayOfMonth() > $nbDaysInMonth) { $i++; $currDate = TikiLib::make_time(0, 0, 0, substr($dt, 0, 2), substr($dt, -2), $start[0] + $offset + $i); continue; } $dates[] = $currDate; $i++; $currDate = TikiLib::make_time(0, 0, 0, $startMonth + $i, $this->getDayOfMonth(), $start[0]); } } elseif ($this->isYearly()) { $yymm = TikiLib::date_format2('md', $this->getStartPeriod()); $isLeapDay = $this->getDateOfYear() == 229; // Feb 29th case. $offset = $this->getDateOfYear() < $yymm ? 1 : 0; $dt = str_pad($this->getDateOfYear(), 4, "0", STR_PAD_LEFT); $currDate = TikiLib::make_time(0, 0, 0, substr($dt, 0, 2), substr($dt, -2), $start[0] + $offset); $i = 0; while ($currDate < $this->getEndPeriod()) { if ($isLeapDay) { if (TikiLib::date_format2('L', TikiLib::make_time(0, 0, 0, 1, 1, $start[0] + $offset + $i)) == 0) { $i++; $currDate = TikiLib::make_time(0, 0, 0, substr($dt, 0, 2), substr($dt, -2), $start[0] + $offset + $i); continue; } } $dates[] = $currDate; $i++; $currDate = TikiLib::make_time(0, 0, 0, substr($dt, 0, 2), substr($dt, -2), $start[0] + $offset + $i); } } else { // there should be no other case return false; } } else { // there should be no other case return false; } // create and store the events // get start and end hours in seconds from midnight, if event is not allday. $startOffset = 0; $endOffset = dayInSeconds - 1; if (!$this->isAllday()) { $tmp = str_pad($this->getStart(), 4, '0', STR_PAD_LEFT); $startOffset = substr($tmp, 0, 2) * 60 * 60 + substr($tmp, -2) * 60; $tmp = str_pad($this->getEnd(), 4, '0', STR_PAD_LEFT); $endOffset = substr($tmp, 0, 2) * 60 * 60 + substr($tmp, -2) * 60; } foreach ($dates as $aDate) { $data = array('calendarId' => $this->getCalendarId(), 'start' => $aDate + $startOffset, 'end' => $aDate + $endOffset, 'locationId' => $this->getLocationId(), 'categoryId' => $this->getCategoryId(), 'nlId' => $this->getNlId(), 'priority' => $this->getPriority(), 'status' => $this->getStatus(), 'url' => $this->getUrl(), 'lang' => $this->getLang(), 'name' => $this->getName(), 'description' => $this->getDescription(), 'user' => $this->getUser(), 'created' => $this->getCreated(), 'lastmodif' => $this->getCreated(), 'allday' => $this->isAllday(), 'recurrenceId' => $this->getId(), 'changed' => 0); $calendarlib = new calendarlib($this->db); global $user; $calendarlib->set_item($user, null, $data); } }