PSD-Tutorials.de
Forum für Design, Fotografie & Bildbearbeitung
Tutkit
Agentur
Hilfe
Kontakt
Start
Forum
Aktuelles
Besonderer Inhalt
Foren durchsuchen
Tutorials
News
Anmelden
Kostenlos registrieren
Aktuelles
Suche
Suche
Nur Titel durchsuchen
Von:
Menü
Anmelden
Kostenlos registrieren
App installieren
Installieren
JavaScript ist deaktiviert. Für eine bessere Darstellung aktiviere bitte JavaScript in deinem Browser, bevor du fortfährst.
Du verwendest einen veralteten Browser. Es ist möglich, dass diese oder andere Websites nicht korrekt angezeigt werden.
Du solltest ein Upgrade durchführen oder einen
alternativen Browser
verwenden.
Antworten auf deine Fragen:
Neues Thema erstellen
Start
Forum
Sonstiges
Webdesign, Webentwicklung & Programmierung
PHP, Javascript, jQuery, Ajax, nodeJS, MySQL...
PHP Kalender feinschliff hilfe benötigt
Beitrag
<blockquote data-quote="AbbySu" data-source="post: 1966570" data-attributes="member: 488764"><p><strong>AW: PHP Kalender feinschliff hilfe benötigt</strong></p><p></p><p>Nein, leider war meine Vermutung falsch, an Formaten dieser Art habe ich nicht gebastelt... ich poste dann mal wie gewünscht den gesamten Code, ich muss ja was übersehen...</p><p></p><p>termine.php</p><p>[PHP]<?php</p><p> $title = "Startseite &ndash; Triple Events";</p><p> $seite = "";</p><p> require_once 'calendar.class.php';</p><p> include ("head.php");</p><p>?></p><p><!-- ab hier der wechselnde Inhalt für den Haupt Content --></p><p> <div id="content"></p><p> <h1></p><p> Termine</h1></p><p> <div id="k"></p><p><?php</p><p>$deutscheDaten = array(</p><p> 'daysLong' => array('Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonntag' ),</p><p> </p><p> 'daysShort' => array('Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So', ),</p><p> </p><p> 'monthsLong' => array( 'Januar', 'Februar', 'März', 'April', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember' ),</p><p> </p><p> 'monthsShort' => array( 'Jan', 'Feb', 'März', 'Apr', 'Mai', 'Juni', 'Juli', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez' )</p><p> );</p><p></p><p>$calendar = new Punkt16_Calendar($deutscheDaten);</p><p>$calendar->addHoliday('Silvester', '31.12.*');</p><p>$calendar->addHoliday('RosenstadtTriathlon', '24.06.2012');</p><p>$calendar->addVacation('22.06.2012', '23.06.2012', 'Globetrotter Harztriathlon', 'http://www.oberharz.de/harz-triathlon.html', 'gharztr');</p><p>/*</p><p>addHolyday($name, $date, $url = '', $class = 'holiday') koennte damit vorlaufig entfernt werden:</p><p>$calendar->removeHoliday('06.1.*');</p><p> </p><p>so koennte man mit dem * auch alle Monate auswaehlen (ginge auch mit Tagen):</p><p>$calendar->addHoliday('Monats-Party', '05.*.*', 'http://xyz');</p><p></p><p>addVacation sorgt fuer die Makierung eines Zeitraums: [from, $to, $name, $url = '', $class = 'holiday'] </p><p>damit könnte man das dann wieder enfernen:</p><p>$calendar->removeVacation('eingetragener name');</p><p>*/</p><p></p><p>echo $calendar->getCalendar(); ?></p><p></div></p><p> </div></p><p><!-- Ende des Haupt Contents --></p><p> <?php include ("reco_footer.php"); ?>[/PHP]calendar.class.php</p><p>[PHP]<?php</p><p>/* </p><p> * @name: Punkt . 16 PHP Calendar </p><p> * @author: Florian Palme</p><p> * @date: 21.12.2009</p><p> * @class: Punkt16_Calendar</p><p> * @file: calendar.class.php</p><p> * @package: Punkt16</p><p> * @subpackage: Calendar</p><p> * @version: 1.1.1</p><p> */</p><p> </p><p>class Punkt16_Calendar</p><p>{</p><p> protected $now;</p><p> protected $temp;</p><p> protected $temp2;</p><p> protected $daysLong = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday');</p><p> protected $daysShort = array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun');</p><p> protected $monthsLong = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');</p><p> protected $monthsShort = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec');</p><p> protected $classes = array('table' => 'calendar', 'tableTitle' => 'title', 'monthBackwardA' => 'monthBackwardA', 'monthForwardA' => 'monthForwardA', 'monthYear' => 'monthYear', 'dayA' => 'dayA', 'dayTodayA' => 'dayTodayA', 'dayOther' => 'dayOther', 'dayName' => 'dayName');</p><p> protected $inserts = array('monthBackward' => '&laquo;', 'monthForward' => '&raquo;');</p><p> protected $n = "\n";</p><p> protected $getParams = array('month' => 'm', 'year' => 'y');</p><p> protected $holidays = array(</p><p> array('day' => '01.1.*', 'name' => 'Neujahrstag', 'class' => 'holiday', 'url' => ''), </p><p> array('day' => '06.1.*', 'name' => 'Heilige Drei K&ouml;nige [BW, BY, ST]', 'class' => 'holiday', 'url' => ''),</p><p> array('day' => '05.4.*', 'name' => 'Gr&uuml;ndonnerstag [BW]', 'class' => 'holiday', 'url' => ''),</p><p> array('day' => '06.4.*', 'name' => 'Karfreitag', 'class' => 'holiday', 'url' => ''),</p><p> array('day' => '09.4.*', 'name' => 'Ostermontag', 'class' => 'holiday', 'url' => ''),</p><p> array('day' => '01.5.*', 'name' => 'Tag der Arbeit', 'class' => 'holiday', 'url' => ''),</p><p> array('day' => '17.5.*', 'name' => 'Christi Himmelfahrt', 'class' => 'holiday', 'url' => ''),</p><p> array('day' => '28.5.*', 'name' => 'Pfingstmontag', 'class' => 'holiday', 'url' => ''),</p><p> array('day' => '07.6.*', 'name' => 'Fronleichnam [BW, BY, HE, NW, RP, SL]', 'class' => 'holiday', 'url' => ''),</p><p> array('day' => '15.8.*', 'name' => 'Mari&auml; Himmelfahrt [BY, SL]', 'class' => 'holiday', 'url' => ''),</p><p> array('day' => '03.10.*', 'name' => 'Tag der Deutschen Einheit', 'class' => 'holiday', 'url' => ''),</p><p> array('day' => '31.10.*', 'name' => 'Reformationstag [BW, BB, MV, SN, ST, TH]', 'class' => 'holiday', 'url' => ''),</p><p> array('day' => '01.11.*', 'name' => 'Allerheiligen [BW, BY, NW, RP, SL]', 'class' => 'holiday', 'url' => ''),</p><p> array('day' => '21.11.*', 'name' => 'Buß- und Bettag [BY, SN]', 'class' => 'holiday', 'url' => ''),</p><p> array('day' => '24.12.*', 'name' => 'Weihnachten', 'class' => 'christmas', 'url' => ''),</p><p> array('day' => '25.12.*', 'name' => '1. Weihnachtstag', 'class' => 'holiday', 'url' => ''),</p><p> array('day' => '26.12.*', 'name' => '2. Weihnachtstag', 'class' => 'holiday', 'url' => '')</p><p> );</p><p> protected $showHolidays = true;</p><p> protected $showAllUrls = true;</p><p> protected $timer = array('start' => 0, 'end' => 0, 'time' => 0);</p><p> protected $holiSep = ' - ';</p><p> </p><p> /*</p><p> * @access: public</p><p> * @param: array params</p><p> */</p><p> public function __construct($params = array())</p><p> {</p><p> $timerStart = explode(' ', microtime());</p><p> $this->timer['start'] = $timerStart[0] + $timerStart[1];</p><p> </p><p> $this->now = time();</p><p> </p><p> foreach($params as $param => $paramval)</p><p> { </p><p> if(is_array($paramval))</p><p> {</p><p> foreach($paramval as $paramvalparam => $paramvalparamval)</p><p> {</p><p> $theArray = $this->$param;</p><p> $theArray[$paramvalparam] = $paramvalparamval;</p><p> $this->$param = $theArray;</p><p> }</p><p> }</p><p> else</p><p> {</p><p> $this->$param = $paramval;</p><p> }</p><p> }</p><p></p><p> </p><p> if(isset($_GET[$this->getParams['month']]))</p><p> {</p><p> $month = intval($_GET[$this->getParams['month']]);</p><p> </p><p> if($month <= 12 && $month > 0)</p><p> {</p><p> $this->setCalendarMonth($month);</p><p> }</p><p> }</p><p> </p><p> </p><p> if(isset($_GET[$this->getParams['year']]))</p><p> {</p><p> $year = intval($_GET[$this->getParams['year']]);</p><p> </p><p> if($year >= 1970)</p><p> {</p><p> $this->setCalendarYear($year);</p><p> }</p><p> }</p><p> }</p><p> </p><p> </p><p> /*</p><p> * @access: public</p><p> */</p><p> public function getCalendar()</p><p> {</p><p> $this->temp = $this->createTempTimestamp($this->now);</p><p> $this->temp2 = $this->temp;</p><p> </p><p> $date = array();</p><p> </p><p> $date['month'] = $this->getMonth($this->now);</p><p> $date['monthName'] = $this->getMonthName($this->now);</p><p> $date['year'] = $this->getYear($this->now);</p><p> $date['firstDayNum'] = $this->getFirstDayNum($this->now);</p><p> </p><p> </p><p> $calendarOutput = $this->htmlTop($date['monthName'], $date['year']);</p><p> </p><p> $itsToday = date('d.n.Y', time());</p><p> </p><p> for($t = 0; $t < $date['firstDayNum']; $t++)</p><p> {</p><p> $this->temp2 = $this->removeDay($this->temp2);</p><p> }</p><p> </p><p> </p><p> $calendarOutput .= $this->htmlOpenRow();</p><p> </p><p> for($b = 0; $b < 7; $b++)</p><p> { </p><p> $calendarOutput .= $this->htmlDayName($this->daysShort[$b]);</p><p> }</p><p> </p><p> $calendarOutput .= $this->htmlCloseRow();</p><p> </p><p> </p><p> $isFirstRow = true;</p><p> </p><p> for($i = 0; $i < 6; $i++)</p><p> {</p><p> $calendarOutput .= $this->htmlOpenRow();</p><p> </p><p> for($b = 0; $b < 7; $b++)</p><p> {</p><p> /* Prüfen, ob dieser Tag ein Feiertag ist! */</p><p> $holiArray = array();</p><p></p><p> if($this->showHolidays == true)</p><p> {</p><p> $theDay = $this->getDay($this->temp2);</p><p> $theMonth = $this->getMonth($this->temp2);</p><p> $theYear = $this->getYear($this->temp2);</p><p> </p><p> $holidays = array();</p><p> $holidays['full'] = $theDay . '.' . $theMonth . '.' . $theYear;</p><p> $holidays['day'] = '*.' . $theMonth . '.' . $theYear;</p><p> $holidays['month'] = $theDay . '.*.' . $theYear;</p><p> $holidays['year'] = $theDay . '.' . $theMonth . '.*';</p><p> $holidays['dayMonth'] = '*.*.' . $theYear;</p><p> $holidays['dayYear'] = '*.' . $theMonth . '.*';</p><p> $holidays['monthYear'] = $theDay . '.*.*';</p><p> </p><p> foreach($this->holidays as $holiday)</p><p> {</p><p> if(in_array($holiday['day'], $holidays))</p><p> {</p><p> $holiArray[] = array('name' => $holiday['name'], 'class' => $holiday['class'], 'url' => $holiday['url']);</p><p> }</p><p> }</p><p> }</p><p> /* ENDE der Überprüfung */</p><p> </p><p> </p><p> </p><p> if($isFirstRow == true)</p><p> {</p><p> if($b < $date['firstDayNum'])</p><p> { </p><p> $calendarOutput .= $this->htmlDay($this->getDay($this->temp2), $this->classes['dayOther'], $holiArray);</p><p> $this->temp2 = $this->addDay($this->temp2);</p><p> }</p><p> else</p><p> { </p><p> $theDay = $this->getDay($this->temp);</p><p> $theMonth = $this->getMonth($this->temp);</p><p> </p><p> $cl = ($itsToday == $theDay . '.' . $theMonth . '.' . $date['year']) ? $this->classes['dayTodayA'] : '';</p><p> </p><p> $calendarOutput .= $this->htmlDay($theDay, $cl, $holiArray);</p><p> </p><p> $this->temp = $this->addDay($this->temp);</p><p> $this->temp2 = $this->addDay($this->temp2);</p><p> }</p><p> }</p><p> else</p><p> { </p><p> $theDay = $this->getDay($this->temp);</p><p> $theMonth = $this->getMonth($this->temp);</p><p> </p><p> $cl = ($itsToday == $theDay . '.' . $theMonth . '.' . $date['year']) ? $this->classes['dayTodayA'] : '';</p><p> $cl = ($date['month'] == $theMonth) ? $cl : $this->classes['dayOther'];</p><p> </p><p> $calendarOutput .= $this->htmlDay($theDay, $cl, $holiArray);</p><p> </p><p> $this->temp = $this->addDay($this->temp);</p><p> $this->temp2 = $this->addDay($this->temp2);</p><p> }</p><p> }</p><p> </p><p> $calendarOutput .= $this->htmlCloseRow();</p><p> </p><p> $isFirstRow = false;</p><p> }</p><p> </p><p> $calendarOutput .= $this->htmlBottom();</p><p> </p><p> return $calendarOutput;</p><p> }</p><p> </p><p> </p><p> /*</p><p> * @access: public</p><p> * @params: int month</p><p> */</p><p> public function setCalendarMonth($month)</p><p> {</p><p> $month = intval($month);</p><p> </p><p> $thisYear = date('Y', $this->now);</p><p> </p><p> $newTimestamp = mktime(0, 0, 0, $month, 1, $thisYear);</p><p> </p><p> $this->now = $newTimestamp;</p><p> }</p><p> </p><p> </p><p> /*</p><p> * @access: public</p><p> * @params: int year</p><p> */</p><p> public function setCalendarYear($year)</p><p> {</p><p> $year = intval($year);</p><p> </p><p> $thisMonth = date('n', $this->now);</p><p> </p><p> $newTimestamp = mktime(0, 0, 0, $thisMonth, 1, $year);</p><p> </p><p> $this->now = $newTimestamp;</p><p> }</p><p> </p><p> </p><p> /*</p><p> * @access: private</p><p> * @param: string dayname, string day, string month, string year</p><p> */</p><p> private function htmlTop($month, $year)</p><p> {</p><p> return '<table class="' . $this->classes['table'] . '" border="0" cellpadding="0" cellspacing="5">' . $this->n .</p><p> ' <tbody>' . $this->n .</p><p> ' <tr>' . $this->n .</p><p> ' <td colspan="7">' . $this->n .</p><p> ' <table class="' . $this->classes['tableTitle'] . '" border="0" cellpadding="0" cellspaing="0">' . $this->n .</p><p> ' <tbody>' . $this->n .</p><p> ' <tr>' . $this->n . </p><p> ' <td class="' . $this->classes['monthBackwardA'] . '">' . $this->n .</p><p> ' <a href="' . $this->createPrevMonthUrl($this->now) . '">' . $this->n .</p><p> ' ' . $this->inserts['monthBackward'] . $this->n .</p><p> ' </a>' . $this->n .</p><p> ' </td>' . $this->n .</p><p> ' <td class="' . $this->classes['monthYear'] . '">' . $this->n .</p><p> ' ' . $month . ' ' . $year . $this->n .</p><p> ' </td>' . $this->n .</p><p> ' <td class="' . $this->classes['monthForwardA'] . '">' . $this->n .</p><p> ' <a href="' . $this->createNextMonthUrl($this->now) . '">' . $this->n .</p><p> ' ' . $this->inserts['monthForward'] . $this->n .</p><p> ' </a>' . $this->n .</p><p> ' </td>' . $this->n .</p><p> ' </tr>' . $this->n .</p><p> ' </tbody>' . $this->n .</p><p> ' </table>' . $this->n .</p><p> ' </td>' . $this->n .</p><p> ' </tr>' . $this->n; </p><p> }</p><p> </p><p> </p><p> /*</p><p> * @access: private</p><p> */</p><p> private function htmlOpenRow()</p><p> {</p><p> return '<tr>' . $this->n;</p><p> }</p><p> </p><p> </p><p> /*</p><p> * @access: private</p><p> */</p><p> private function htmlCloseRow()</p><p> {</p><p> return '</tr>' . $this->n;</p><p> }</p><p> </p><p> </p><p> /*</p><p> * @access: private</p><p> * @param: string val (, string css, array holiday)</p><p> */</p><p> private function htmlDay($val, $css = '', $holidays = array())</p><p> {</p><p> $css = ($css == '') ? '' : ' ' . $css;</p><p> </p><p> $holiday = array('name' => '', 'class' => '', 'url' => '', 'url2' => '');</p><p> </p><p> foreach($holidays as $holi)</p><p> {</p><p> $holiday['name'] .= $holi['name'] . $this->holiSep;</p><p> $holiday['class'] .= $holi['class'] . ' ';</p><p> $holiday['url'] = $holi['url'];</p><p> $holiday['url2'] .= $holi['url'] . $this->holiSep;</p><p> }</p><p> </p><p> $holiday['name'] = substr($holiday['name'], 0, strlen($holiday['name']) - strlen($this->holiSep));</p><p> $holiday['class'] = substr($holiday['class'], 0, strlen($holiday['class']) - 1);</p><p> $holiday['url2'] = substr($holiday['url2'], 0, strlen($holiday['url2']) - strlen($this->holiSep));</p><p> </p><p> if($holiday['name'] != '')</p><p> {</p><p> $return = ' <td class="' . $this->classes['dayA'] . $css . '">' . $this->n;</p><p> </p><p> if($holiday['url'] != '')</p><p> {</p><p> $longdesc = 'longdesc="';</p><p> </p><p> if($this->showAllUrls == true)</p><p> {</p><p> $longdesc .= $holiday['url2'];</p><p> }</p><p> </p><p> $longdesc .= '"';</p><p> </p><p> $return .= ' <a href="' . $holiday['url'] . '" ' . $longdesc . ' title="' . $holiday['name'] . '" class="' . $holiday['class'] . '">' . $this->n .</p><p> ' ' . $val . $this->n .</p><p> ' </a>' . $this->n;</p><p> }</p><p> else</p><p> {</p><p> $return .= ' <span title="' . $holiday['name'] . '" class="' . $holiday['class'] . '">' . $this->n .</p><p> ' ' . $val . $this->n .</p><p> ' </span>'; </p><p> }</p><p> </p><p> $return .= '</td>'. $this->n;</p><p> </p><p> return $return;</p><p> }</p><p> else</p><p> {</p><p> return ' <td class="' . $this->classes['dayA'] . $css . '">' . $this->n .</p><p> ' ' . $val . $this->n .</p><p> ' </td>' . $this->n;</p><p> }</p><p> }</p><p> </p><p> </p><p> /*</p><p> * @access: private</p><p> * @param: string day</p><p> */</p><p> private function htmlDayName($day)</p><p> {</p><p> return ' <td class="' . $this->classes['dayName'] . '">' . $this->n .</p><p> ' ' . $day . $this->n .</p><p> ' </td>' . $this->n;</p><p> }</p><p> </p><p> </p><p> /*</p><p> * @access: private</p><p> */</p><p> private function htmlBottom()</p><p> {</p><p> $timerEnd = explode(' ', microtime());</p><p> $this->timer['end'] = $timerEnd[0] + $timerEnd[1];</p><p> </p><p> $this->timer['time'] = round($this->timer['end'] - $this->timer['start'], 6);</p><p> </p><p> return ' </tbody>' . $this->n .</p><p> '</table>' . $this->n .</p><p> '<!-- Punkt16 PHP Calendar www.punkt16.de // Time: ' . $this->timer['time'] . ' -->' . $this->n . $this->n;</p><p> }</p><p> </p><p> </p><p> /* </p><p> * @access: private</p><p> * @params: int timestamp</p><p> */</p><p> private function getRealDay($timestamp)</p><p> {</p><p> $day = intval(date('w', $timestamp)) - 1;</p><p> $day = ($day == -1) ? 6 : $day;</p><p> </p><p> return $day;</p><p> }</p><p> </p><p> </p><p> /*</p><p> * @access: private</p><p> * @params: int timestamp</p><p> */</p><p> private function getDayName($timestamp)</p><p> {</p><p> $day = $this->getRealDay($timestamp);</p><p> </p><p> return $this->daysLong[$day];</p><p> }</p><p> </p><p> </p><p> /*</p><p> * @access: private</p><p> * @params: int timestamp</p><p> */</p><p> private function getDay($timestamp)</p><p> {</p><p> return date('d', $timestamp);</p><p> }</p><p> </p><p> </p><p> /*</p><p> * @access: private</p><p> * @params: int timestamp</p><p> */</p><p> private function getMonth($timestamp)</p><p> {</p><p> return date('n', $timestamp);</p><p> }</p><p> </p><p> </p><p> /*</p><p> * @access: private</p><p> * @params: int timestamp</p><p> */</p><p> private function getMonthName($timestamp)</p><p> {</p><p> $month = date('n', $timestamp) - 1;</p><p> </p><p> return $this->monthsLong[$month];</p><p> }</p><p> </p><p> </p><p> /*</p><p> * @access: private</p><p> * @params: int timestamp</p><p> */</p><p> private function getYear($timestamp)</p><p> {</p><p> return date('Y', $timestamp);</p><p> }</p><p> </p><p> </p><p> /* </p><p> * @access: private</p><p> * @params: int timestamp</p><p> */</p><p> private function getFirstDayNum($timestamp)</p><p> {</p><p> $thisMonth = date('n', $timestamp);</p><p> $thisYear = date('Y', $timestamp);</p><p> </p><p> $realTime = mktime(0, 0, 0, $thisMonth, 1, $thisYear);</p><p> </p><p> $day = $this->getRealDay($realTime);</p><p> </p><p> return $day;</p><p> }</p><p> </p><p> </p><p> /*</p><p> * @access: private</p><p> * @params: int timestamp</p><p> */</p><p> private function addDay($timestamp)</p><p> {</p><p> /*</p><p> * 60 Seconds = 1 Minute</p><p> * 1 Hour = 60 Minutes @ 60 * 60</p><p> * 1 Day = 24 Hours @ 60 * 60 * 25</p><p> */</p><p> </p><p> return $timestamp + (60 * 60 * 24);</p><p> }</p><p> </p><p> </p><p> /*</p><p> * @access: private</p><p> * @params: int timestamp</p><p> */</p><p> private function removeDay($timestamp)</p><p> { </p><p> return $timestamp - (60 * 60 * 24);</p><p> }</p><p> </p><p> </p><p> /*</p><p> * @access: private</p><p> * @params: int timestamp</p><p> */</p><p> private function createTempTimestamp($timestamp)</p><p> {</p><p> $thisMonth = date('n', $timestamp);</p><p> $thisYear = date('Y', $timestamp);</p><p> </p><p> $realTime = mktime(0, 0, 0, $thisMonth, 1, $thisYear);</p><p> </p><p> return $realTime;</p><p> }</p><p> </p><p> </p><p> /*</p><p> * @access: private</p><p> * @params: int timestamp</p><p> */</p><p> private function createPrevMonthUrl($timestamp)</p><p> {</p><p> $thisMonth = date('n', $timestamp);</p><p> $thisYear = date('Y', $timestamp);</p><p> </p><p> $prevMonth = $thisMonth - 1;</p><p> $prevYear = $thisYear;</p><p> </p><p> if($prevMonth == 0)</p><p> {</p><p> $prevMonth = 12;</p><p> $prevYear = $thisYear - 1;</p><p> }</p><p> </p><p> $prevTimestamp = mktime(0, 0, 0, $prevMonth, 1, $prevYear);</p><p> </p><p> return '?' . $this->getParams['month'] . '=' . date('n', $prevTimestamp) . '&' . $this->getParams['year'] . '=' . date('Y', $prevTimestamp);</p><p> }</p><p> </p><p> </p><p> /*</p><p> * @access: private</p><p> * @params: int timestamp</p><p> */</p><p> private function createNextMonthUrl($timestamp)</p><p> {</p><p> $thisMonth = date('n', $timestamp);</p><p> $thisYear = date('Y', $timestamp);</p><p> </p><p> $nextMonth = $thisMonth + 1;</p><p> $nextYear = $thisYear;</p><p> </p><p> if($nextMonth == 13)</p><p> {</p><p> $nextMonth = 1;</p><p> $nextYear = $thisYear + 1;</p><p> }</p><p> </p><p> $nextTimestamp = mktime(0, 0, 0, $nextMonth, 1, $nextYear);</p><p> </p><p> return '?' . $this->getParams['month'] . '=' . date('n', $nextTimestamp) . '&' . $this->getParams['year'] . '=' . date('Y', $nextTimestamp);</p><p> }</p><p> </p><p> </p><p> /*</p><p> * @access: private</p><p> * @params: string var, array array</p><p> */</p><p> private function setArray($var, $array)</p><p> {</p><p> foreach($array as $param => $val)</p><p> {</p><p> $theArray = $this->$var;</p><p> $theArray[$param] = $val;</p><p> $this->$var = $theArray;</p><p> }</p><p> }</p><p> </p><p> </p><p> /* GET a SET */</p><p> public function getNow()</p><p> {</p><p> return $this->now;</p><p> }</p><p> </p><p> public function setNow($param)</p><p> {</p><p> $this->now = $param;</p><p> }</p><p> </p><p> public function getDaysLong()</p><p> {</p><p> return $this->daysLong;</p><p> }</p><p> </p><p> public function setDaysLong($param)</p><p> {</p><p> $this->daysLong = $param;</p><p> }</p><p> </p><p> public function getDaysShort()</p><p> {</p><p> return $this->daysShort;</p><p> }</p><p> </p><p> public function setDaysShort($param)</p><p> {</p><p> $this->daysShort = $param;</p><p> }</p><p> </p><p> public function getMonthLong()</p><p> {</p><p> return $this->monthLong;</p><p> }</p><p> </p><p> public function setMontzLong($param)</p><p> {</p><p> $this->monthLong = $param;</p><p> }</p><p> </p><p> public function getMonthShort()</p><p> {</p><p> return $this->monthShort;</p><p> }</p><p> </p><p> public function setMonthShort($param)</p><p> {</p><p> $this->monthShort = $param;</p><p> }</p><p> </p><p> public function getparams()</p><p> {</p><p> return $this->getParams;</p><p> }</p><p> </p><p> public function setparams($param)</p><p> {</p><p> $this->setArray('setparams', $param);</p><p> }</p><p> </p><p> public function getClasses()</p><p> {</p><p> return $this->getClasses;</p><p> }</p><p> </p><p> public function setClasses($param)</p><p> {</p><p> $this->setArray('classes', $param);</p><p> }</p><p> </p><p> public function getInserts()</p><p> {</p><p> return $this->inserts;</p><p> }</p><p> </p><p> public function setInserts($param)</p><p> {</p><p> $this->setArray('inserts', $param);</p><p> }</p><p> </p><p> public function getShowHolidays()</p><p> {</p><p> return $this->showHolidays; </p><p> }</p><p> </p><p> public function setShowHolidays($param)</p><p> {</p><p> $this->showHolidays = $param; </p><p> }</p><p> </p><p> public function getShowAllUrls()</p><p> {</p><p> return $this->showAllUrls; </p><p> }</p><p> </p><p> public function setShowAllUrls($param)</p><p> {</p><p> $this->showAllUrls = $param; </p><p> }</p><p> </p><p> public function getHoliSep()</p><p> {</p><p> return $this->holiSep();</p><p> }</p><p> </p><p> </p><p> /*</p><p> * @access: public</p><p> * @params: string name, string date (, string url, string class)</p><p> */</p><p> public function addHoliday($name, $date, $url = '', $class = 'holiday')</p><p> {</p><p> $this->holidays[] = array('name' => $name, 'day' => $date, 'class' => $class, 'url' => $url);</p><p> }</p><p> </p><p> </p><p> /*</p><p> * @access: public</p><p> * @params: string day</p><p> */</p><p> public function removeHoliday($day)</p><p> {</p><p> for($i = 0; $i < count($this->holidays); $i++)</p><p> {</p><p> if($this->holidays[$i]['day'] == $day)</p><p> {</p><p> unset($this->holidays[$i]);</p><p> }</p><p> }</p><p> </p><p> $this->holidays = $this->array_nindex($this->holidays);</p><p> }</p><p> </p><p> </p><p> /*</p><p> * @access: public</p><p> * @params: string from, string to</p><p> */</p><p> public function addVacation($from, $to, $name, $url = '', $class = '')</p><p> {</p><p> $fromArray = explode('.', $from);</p><p> $toArray = explode('.', $to);</p><p> </p><p> $fromTimestamp = mktime(0, 0, 0, $fromArray[1], $fromArray[0], $fromArray[2]);</p><p> $toTimestamp = mktime(0, 0, 0, $toArray[1], $toArray[0], $toArray[2]);</p><p> </p><p> $timestamp = $toTimestamp - $fromTimestamp;</p><p> $days = $timestamp / 60 / 60 / 24;</p><p> </p><p> for($i = 0; $i <= $days; $i++)</p><p> {</p><p> $this->holidays[] = array('day' => date('d.m.Y', $fromTimestamp), 'name' => $name, 'url' => $url, 'class' => $class);</p><p> </p><p> $fromTimestamp = $this->addDay($fromTimestamp);</p><p> }</p><p> }</p><p> </p><p> </p><p> /*</p><p> * @access: public</p><p> * @params: string name</p><p> */</p><p> public function removeVacation($name)</p><p> { </p><p> $count = count($this->holidays);</p><p> for($c = 0; $c < $count; $c++)</p><p> {</p><p> if($this->holidays[$c]['name'] == $name)</p><p> {</p><p> unset($this->holidays[$c]);</p><p> }</p><p> }</p><p> </p><p> $this->holidays = $this->array_nindex($this->holidays);</p><p> }</p><p> </p><p> </p><p> /*</p><p> * @access: private</p><p> * @params: array array</p><p> */</p><p> private function array_nindex($array)</p><p> { </p><p> $newArray = array();</p><p> </p><p> foreach($array as $elem)</p><p> {</p><p> $newArray[] = $elem; </p><p> }</p><p> </p><p> return $newArray;</p><p> }</p><p>}</p><p>?>[/PHP]css</p><p>[CODE]table.calendar {</p><p> width:570px; </p><p> margin:50px auto auto;</p><p>}</p><p>table.calendar table.title {</p><p> width:100%; </p><p> height:30px;</p><p> border:1px solid #673404; </p><p> background:#E77309;</p><p> text-align:center;</p><p>}</p><p>table.calendar table.title td.monthBackwardA {</p><p> width:30px;</p><p> color:#fff;</p><p>}</p><p>table.calendar table.title td.monthBackwardA a {</p><p> font-size:18px; </p><p> color:#fff;</p><p> width:30px;</p><p> height:30px;</p><p> line-height:30px;</p><p> display:block;</p><p> text-decoration:none;</p><p>}</p><p>table.calendar table.title td.monthYear {</p><p> font-size:14px; </p><p> line-height:30px;</p><p> color:#fff;</p><p>}</p><p>table.calendar table.title td.monthForwardA {</p><p> width:30px;</p><p> color:#fff;</p><p>}</p><p>table.calendar table.title td.monthForwardA a { </p><p> font-size:18px; </p><p> color:#fff;</p><p> width:30px; </p><p> height:30px; </p><p> line-height:30px; </p><p> display:block; </p><p> text-decoration:none;</p><p>}</p><p>table.calendar td.dayName { </p><p> text-align:center;</p><p> font-weight:bold; </p><p>}</p><p>table.calendar td.dayA {</p><p> border:1px solid #EB9A50;</p><p> background:#FFE4C4;</p><p> color:#E77309;</p><p> text-align:center;</p><p> height:30px;</p><p>}</p><p>table.calendar td.dayA.dayTodayA {</p><p> border:1px solid #fad42e;</p><p> background:#fbec88; </p><p> color:#522903;</p><p>}</p><p>table.calendar td.dayA.dayTodayA * {</p><p> background-color:#fbec88 !important;</p><p> color:#522903; </p><p>}</p><p>table.calendar td.dayA.dayOther {</p><p> border:1px solid #EEE9BF; </p><p> background:#FFFACD; </p><p> color:#BBAD66; </p><p>}</p><p>table.calendar td.dayA a, table.calendar td.dayA span {</p><p> display:block; </p><p> width:100%;</p><p> height:22px;</p><p>}</p><p></p><p>.holiday {</p><p> background:#FFD0A1;</p><p> color:#E78E3D;</p><p> padding-top:6px;</p><p>}</p><p>.christmas { </p><p> background:#3baae3 url(christmas.png) 50% 50% no-repeat;</p><p> color:#fff;</p><p>}</p><p>.gharztr {</p><p> background:#004494;</p><p>}</p><p></p><p>/************** GEHOEREN NICHT ZUM P16PHPKALENDER ********************/</p><p>#k { position:relative; top:0; left:0; display:block; }[/CODE]</p></blockquote><p></p>
[QUOTE="AbbySu, post: 1966570, member: 488764"] [b]AW: PHP Kalender feinschliff hilfe benötigt[/b] Nein, leider war meine Vermutung falsch, an Formaten dieser Art habe ich nicht gebastelt... ich poste dann mal wie gewünscht den gesamten Code, ich muss ja was übersehen... termine.php [PHP]<?php $title = "Startseite – Triple Events"; $seite = ""; require_once 'calendar.class.php'; include ("head.php"); ?> <!-- ab hier der wechselnde Inhalt für den Haupt Content --> <div id="content"> <h1> Termine</h1> <div id="k"> <?php $deutscheDaten = array( 'daysLong' => array('Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonntag' ), 'daysShort' => array('Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So', ), 'monthsLong' => array( 'Januar', 'Februar', 'März', 'April', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember' ), 'monthsShort' => array( 'Jan', 'Feb', 'März', 'Apr', 'Mai', 'Juni', 'Juli', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez' ) ); $calendar = new Punkt16_Calendar($deutscheDaten); $calendar->addHoliday('Silvester', '31.12.*'); $calendar->addHoliday('RosenstadtTriathlon', '24.06.2012'); $calendar->addVacation('22.06.2012', '23.06.2012', 'Globetrotter Harztriathlon', 'http://www.oberharz.de/harz-triathlon.html', 'gharztr'); /* addHolyday($name, $date, $url = '', $class = 'holiday') koennte damit vorlaufig entfernt werden: $calendar->removeHoliday('06.1.*'); so koennte man mit dem * auch alle Monate auswaehlen (ginge auch mit Tagen): $calendar->addHoliday('Monats-Party', '05.*.*', 'http://xyz'); addVacation sorgt fuer die Makierung eines Zeitraums: [from, $to, $name, $url = '', $class = 'holiday'] damit könnte man das dann wieder enfernen: $calendar->removeVacation('eingetragener name'); */ echo $calendar->getCalendar(); ?> </div> </div> <!-- Ende des Haupt Contents --> <?php include ("reco_footer.php"); ?>[/PHP]calendar.class.php [PHP]<?php /* * @name: Punkt . 16 PHP Calendar * @author: Florian Palme * @date: 21.12.2009 * @class: Punkt16_Calendar * @file: calendar.class.php * @package: Punkt16 * @subpackage: Calendar * @version: 1.1.1 */ class Punkt16_Calendar { protected $now; protected $temp; protected $temp2; protected $daysLong = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'); protected $daysShort = array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'); protected $monthsLong = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); protected $monthsShort = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec'); protected $classes = array('table' => 'calendar', 'tableTitle' => 'title', 'monthBackwardA' => 'monthBackwardA', 'monthForwardA' => 'monthForwardA', 'monthYear' => 'monthYear', 'dayA' => 'dayA', 'dayTodayA' => 'dayTodayA', 'dayOther' => 'dayOther', 'dayName' => 'dayName'); protected $inserts = array('monthBackward' => '«', 'monthForward' => '»'); protected $n = "\n"; protected $getParams = array('month' => 'm', 'year' => 'y'); protected $holidays = array( array('day' => '01.1.*', 'name' => 'Neujahrstag', 'class' => 'holiday', 'url' => ''), array('day' => '06.1.*', 'name' => 'Heilige Drei Könige [BW, BY, ST]', 'class' => 'holiday', 'url' => ''), array('day' => '05.4.*', 'name' => 'Gründonnerstag [BW]', 'class' => 'holiday', 'url' => ''), array('day' => '06.4.*', 'name' => 'Karfreitag', 'class' => 'holiday', 'url' => ''), array('day' => '09.4.*', 'name' => 'Ostermontag', 'class' => 'holiday', 'url' => ''), array('day' => '01.5.*', 'name' => 'Tag der Arbeit', 'class' => 'holiday', 'url' => ''), array('day' => '17.5.*', 'name' => 'Christi Himmelfahrt', 'class' => 'holiday', 'url' => ''), array('day' => '28.5.*', 'name' => 'Pfingstmontag', 'class' => 'holiday', 'url' => ''), array('day' => '07.6.*', 'name' => 'Fronleichnam [BW, BY, HE, NW, RP, SL]', 'class' => 'holiday', 'url' => ''), array('day' => '15.8.*', 'name' => 'Mariä Himmelfahrt [BY, SL]', 'class' => 'holiday', 'url' => ''), array('day' => '03.10.*', 'name' => 'Tag der Deutschen Einheit', 'class' => 'holiday', 'url' => ''), array('day' => '31.10.*', 'name' => 'Reformationstag [BW, BB, MV, SN, ST, TH]', 'class' => 'holiday', 'url' => ''), array('day' => '01.11.*', 'name' => 'Allerheiligen [BW, BY, NW, RP, SL]', 'class' => 'holiday', 'url' => ''), array('day' => '21.11.*', 'name' => 'Buß- und Bettag [BY, SN]', 'class' => 'holiday', 'url' => ''), array('day' => '24.12.*', 'name' => 'Weihnachten', 'class' => 'christmas', 'url' => ''), array('day' => '25.12.*', 'name' => '1. Weihnachtstag', 'class' => 'holiday', 'url' => ''), array('day' => '26.12.*', 'name' => '2. Weihnachtstag', 'class' => 'holiday', 'url' => '') ); protected $showHolidays = true; protected $showAllUrls = true; protected $timer = array('start' => 0, 'end' => 0, 'time' => 0); protected $holiSep = ' - '; /* * @access: public * @param: array params */ public function __construct($params = array()) { $timerStart = explode(' ', microtime()); $this->timer['start'] = $timerStart[0] + $timerStart[1]; $this->now = time(); foreach($params as $param => $paramval) { if(is_array($paramval)) { foreach($paramval as $paramvalparam => $paramvalparamval) { $theArray = $this->$param; $theArray[$paramvalparam] = $paramvalparamval; $this->$param = $theArray; } } else { $this->$param = $paramval; } } if(isset($_GET[$this->getParams['month']])) { $month = intval($_GET[$this->getParams['month']]); if($month <= 12 && $month > 0) { $this->setCalendarMonth($month); } } if(isset($_GET[$this->getParams['year']])) { $year = intval($_GET[$this->getParams['year']]); if($year >= 1970) { $this->setCalendarYear($year); } } } /* * @access: public */ public function getCalendar() { $this->temp = $this->createTempTimestamp($this->now); $this->temp2 = $this->temp; $date = array(); $date['month'] = $this->getMonth($this->now); $date['monthName'] = $this->getMonthName($this->now); $date['year'] = $this->getYear($this->now); $date['firstDayNum'] = $this->getFirstDayNum($this->now); $calendarOutput = $this->htmlTop($date['monthName'], $date['year']); $itsToday = date('d.n.Y', time()); for($t = 0; $t < $date['firstDayNum']; $t++) { $this->temp2 = $this->removeDay($this->temp2); } $calendarOutput .= $this->htmlOpenRow(); for($b = 0; $b < 7; $b++) { $calendarOutput .= $this->htmlDayName($this->daysShort[$b]); } $calendarOutput .= $this->htmlCloseRow(); $isFirstRow = true; for($i = 0; $i < 6; $i++) { $calendarOutput .= $this->htmlOpenRow(); for($b = 0; $b < 7; $b++) { /* Prüfen, ob dieser Tag ein Feiertag ist! */ $holiArray = array(); if($this->showHolidays == true) { $theDay = $this->getDay($this->temp2); $theMonth = $this->getMonth($this->temp2); $theYear = $this->getYear($this->temp2); $holidays = array(); $holidays['full'] = $theDay . '.' . $theMonth . '.' . $theYear; $holidays['day'] = '*.' . $theMonth . '.' . $theYear; $holidays['month'] = $theDay . '.*.' . $theYear; $holidays['year'] = $theDay . '.' . $theMonth . '.*'; $holidays['dayMonth'] = '*.*.' . $theYear; $holidays['dayYear'] = '*.' . $theMonth . '.*'; $holidays['monthYear'] = $theDay . '.*.*'; foreach($this->holidays as $holiday) { if(in_array($holiday['day'], $holidays)) { $holiArray[] = array('name' => $holiday['name'], 'class' => $holiday['class'], 'url' => $holiday['url']); } } } /* ENDE der Überprüfung */ if($isFirstRow == true) { if($b < $date['firstDayNum']) { $calendarOutput .= $this->htmlDay($this->getDay($this->temp2), $this->classes['dayOther'], $holiArray); $this->temp2 = $this->addDay($this->temp2); } else { $theDay = $this->getDay($this->temp); $theMonth = $this->getMonth($this->temp); $cl = ($itsToday == $theDay . '.' . $theMonth . '.' . $date['year']) ? $this->classes['dayTodayA'] : ''; $calendarOutput .= $this->htmlDay($theDay, $cl, $holiArray); $this->temp = $this->addDay($this->temp); $this->temp2 = $this->addDay($this->temp2); } } else { $theDay = $this->getDay($this->temp); $theMonth = $this->getMonth($this->temp); $cl = ($itsToday == $theDay . '.' . $theMonth . '.' . $date['year']) ? $this->classes['dayTodayA'] : ''; $cl = ($date['month'] == $theMonth) ? $cl : $this->classes['dayOther']; $calendarOutput .= $this->htmlDay($theDay, $cl, $holiArray); $this->temp = $this->addDay($this->temp); $this->temp2 = $this->addDay($this->temp2); } } $calendarOutput .= $this->htmlCloseRow(); $isFirstRow = false; } $calendarOutput .= $this->htmlBottom(); return $calendarOutput; } /* * @access: public * @params: int month */ public function setCalendarMonth($month) { $month = intval($month); $thisYear = date('Y', $this->now); $newTimestamp = mktime(0, 0, 0, $month, 1, $thisYear); $this->now = $newTimestamp; } /* * @access: public * @params: int year */ public function setCalendarYear($year) { $year = intval($year); $thisMonth = date('n', $this->now); $newTimestamp = mktime(0, 0, 0, $thisMonth, 1, $year); $this->now = $newTimestamp; } /* * @access: private * @param: string dayname, string day, string month, string year */ private function htmlTop($month, $year) { return '<table class="' . $this->classes['table'] . '" border="0" cellpadding="0" cellspacing="5">' . $this->n . ' <tbody>' . $this->n . ' <tr>' . $this->n . ' <td colspan="7">' . $this->n . ' <table class="' . $this->classes['tableTitle'] . '" border="0" cellpadding="0" cellspaing="0">' . $this->n . ' <tbody>' . $this->n . ' <tr>' . $this->n . ' <td class="' . $this->classes['monthBackwardA'] . '">' . $this->n . ' <a href="' . $this->createPrevMonthUrl($this->now) . '">' . $this->n . ' ' . $this->inserts['monthBackward'] . $this->n . ' </a>' . $this->n . ' </td>' . $this->n . ' <td class="' . $this->classes['monthYear'] . '">' . $this->n . ' ' . $month . ' ' . $year . $this->n . ' </td>' . $this->n . ' <td class="' . $this->classes['monthForwardA'] . '">' . $this->n . ' <a href="' . $this->createNextMonthUrl($this->now) . '">' . $this->n . ' ' . $this->inserts['monthForward'] . $this->n . ' </a>' . $this->n . ' </td>' . $this->n . ' </tr>' . $this->n . ' </tbody>' . $this->n . ' </table>' . $this->n . ' </td>' . $this->n . ' </tr>' . $this->n; } /* * @access: private */ private function htmlOpenRow() { return '<tr>' . $this->n; } /* * @access: private */ private function htmlCloseRow() { return '</tr>' . $this->n; } /* * @access: private * @param: string val (, string css, array holiday) */ private function htmlDay($val, $css = '', $holidays = array()) { $css = ($css == '') ? '' : ' ' . $css; $holiday = array('name' => '', 'class' => '', 'url' => '', 'url2' => ''); foreach($holidays as $holi) { $holiday['name'] .= $holi['name'] . $this->holiSep; $holiday['class'] .= $holi['class'] . ' '; $holiday['url'] = $holi['url']; $holiday['url2'] .= $holi['url'] . $this->holiSep; } $holiday['name'] = substr($holiday['name'], 0, strlen($holiday['name']) - strlen($this->holiSep)); $holiday['class'] = substr($holiday['class'], 0, strlen($holiday['class']) - 1); $holiday['url2'] = substr($holiday['url2'], 0, strlen($holiday['url2']) - strlen($this->holiSep)); if($holiday['name'] != '') { $return = ' <td class="' . $this->classes['dayA'] . $css . '">' . $this->n; if($holiday['url'] != '') { $longdesc = 'longdesc="'; if($this->showAllUrls == true) { $longdesc .= $holiday['url2']; } $longdesc .= '"'; $return .= ' <a href="' . $holiday['url'] . '" ' . $longdesc . ' title="' . $holiday['name'] . '" class="' . $holiday['class'] . '">' . $this->n . ' ' . $val . $this->n . ' </a>' . $this->n; } else { $return .= ' <span title="' . $holiday['name'] . '" class="' . $holiday['class'] . '">' . $this->n . ' ' . $val . $this->n . ' </span>'; } $return .= '</td>'. $this->n; return $return; } else { return ' <td class="' . $this->classes['dayA'] . $css . '">' . $this->n . ' ' . $val . $this->n . ' </td>' . $this->n; } } /* * @access: private * @param: string day */ private function htmlDayName($day) { return ' <td class="' . $this->classes['dayName'] . '">' . $this->n . ' ' . $day . $this->n . ' </td>' . $this->n; } /* * @access: private */ private function htmlBottom() { $timerEnd = explode(' ', microtime()); $this->timer['end'] = $timerEnd[0] + $timerEnd[1]; $this->timer['time'] = round($this->timer['end'] - $this->timer['start'], 6); return ' </tbody>' . $this->n . '</table>' . $this->n . '<!-- Punkt16 PHP Calendar www.punkt16.de // Time: ' . $this->timer['time'] . ' -->' . $this->n . $this->n; } /* * @access: private * @params: int timestamp */ private function getRealDay($timestamp) { $day = intval(date('w', $timestamp)) - 1; $day = ($day == -1) ? 6 : $day; return $day; } /* * @access: private * @params: int timestamp */ private function getDayName($timestamp) { $day = $this->getRealDay($timestamp); return $this->daysLong[$day]; } /* * @access: private * @params: int timestamp */ private function getDay($timestamp) { return date('d', $timestamp); } /* * @access: private * @params: int timestamp */ private function getMonth($timestamp) { return date('n', $timestamp); } /* * @access: private * @params: int timestamp */ private function getMonthName($timestamp) { $month = date('n', $timestamp) - 1; return $this->monthsLong[$month]; } /* * @access: private * @params: int timestamp */ private function getYear($timestamp) { return date('Y', $timestamp); } /* * @access: private * @params: int timestamp */ private function getFirstDayNum($timestamp) { $thisMonth = date('n', $timestamp); $thisYear = date('Y', $timestamp); $realTime = mktime(0, 0, 0, $thisMonth, 1, $thisYear); $day = $this->getRealDay($realTime); return $day; } /* * @access: private * @params: int timestamp */ private function addDay($timestamp) { /* * 60 Seconds = 1 Minute * 1 Hour = 60 Minutes @ 60 * 60 * 1 Day = 24 Hours @ 60 * 60 * 25 */ return $timestamp + (60 * 60 * 24); } /* * @access: private * @params: int timestamp */ private function removeDay($timestamp) { return $timestamp - (60 * 60 * 24); } /* * @access: private * @params: int timestamp */ private function createTempTimestamp($timestamp) { $thisMonth = date('n', $timestamp); $thisYear = date('Y', $timestamp); $realTime = mktime(0, 0, 0, $thisMonth, 1, $thisYear); return $realTime; } /* * @access: private * @params: int timestamp */ private function createPrevMonthUrl($timestamp) { $thisMonth = date('n', $timestamp); $thisYear = date('Y', $timestamp); $prevMonth = $thisMonth - 1; $prevYear = $thisYear; if($prevMonth == 0) { $prevMonth = 12; $prevYear = $thisYear - 1; } $prevTimestamp = mktime(0, 0, 0, $prevMonth, 1, $prevYear); return '?' . $this->getParams['month'] . '=' . date('n', $prevTimestamp) . '&' . $this->getParams['year'] . '=' . date('Y', $prevTimestamp); } /* * @access: private * @params: int timestamp */ private function createNextMonthUrl($timestamp) { $thisMonth = date('n', $timestamp); $thisYear = date('Y', $timestamp); $nextMonth = $thisMonth + 1; $nextYear = $thisYear; if($nextMonth == 13) { $nextMonth = 1; $nextYear = $thisYear + 1; } $nextTimestamp = mktime(0, 0, 0, $nextMonth, 1, $nextYear); return '?' . $this->getParams['month'] . '=' . date('n', $nextTimestamp) . '&' . $this->getParams['year'] . '=' . date('Y', $nextTimestamp); } /* * @access: private * @params: string var, array array */ private function setArray($var, $array) { foreach($array as $param => $val) { $theArray = $this->$var; $theArray[$param] = $val; $this->$var = $theArray; } } /* GET a SET */ public function getNow() { return $this->now; } public function setNow($param) { $this->now = $param; } public function getDaysLong() { return $this->daysLong; } public function setDaysLong($param) { $this->daysLong = $param; } public function getDaysShort() { return $this->daysShort; } public function setDaysShort($param) { $this->daysShort = $param; } public function getMonthLong() { return $this->monthLong; } public function setMontzLong($param) { $this->monthLong = $param; } public function getMonthShort() { return $this->monthShort; } public function setMonthShort($param) { $this->monthShort = $param; } public function getparams() { return $this->getParams; } public function setparams($param) { $this->setArray('setparams', $param); } public function getClasses() { return $this->getClasses; } public function setClasses($param) { $this->setArray('classes', $param); } public function getInserts() { return $this->inserts; } public function setInserts($param) { $this->setArray('inserts', $param); } public function getShowHolidays() { return $this->showHolidays; } public function setShowHolidays($param) { $this->showHolidays = $param; } public function getShowAllUrls() { return $this->showAllUrls; } public function setShowAllUrls($param) { $this->showAllUrls = $param; } public function getHoliSep() { return $this->holiSep(); } /* * @access: public * @params: string name, string date (, string url, string class) */ public function addHoliday($name, $date, $url = '', $class = 'holiday') { $this->holidays[] = array('name' => $name, 'day' => $date, 'class' => $class, 'url' => $url); } /* * @access: public * @params: string day */ public function removeHoliday($day) { for($i = 0; $i < count($this->holidays); $i++) { if($this->holidays[$i]['day'] == $day) { unset($this->holidays[$i]); } } $this->holidays = $this->array_nindex($this->holidays); } /* * @access: public * @params: string from, string to */ public function addVacation($from, $to, $name, $url = '', $class = '') { $fromArray = explode('.', $from); $toArray = explode('.', $to); $fromTimestamp = mktime(0, 0, 0, $fromArray[1], $fromArray[0], $fromArray[2]); $toTimestamp = mktime(0, 0, 0, $toArray[1], $toArray[0], $toArray[2]); $timestamp = $toTimestamp - $fromTimestamp; $days = $timestamp / 60 / 60 / 24; for($i = 0; $i <= $days; $i++) { $this->holidays[] = array('day' => date('d.m.Y', $fromTimestamp), 'name' => $name, 'url' => $url, 'class' => $class); $fromTimestamp = $this->addDay($fromTimestamp); } } /* * @access: public * @params: string name */ public function removeVacation($name) { $count = count($this->holidays); for($c = 0; $c < $count; $c++) { if($this->holidays[$c]['name'] == $name) { unset($this->holidays[$c]); } } $this->holidays = $this->array_nindex($this->holidays); } /* * @access: private * @params: array array */ private function array_nindex($array) { $newArray = array(); foreach($array as $elem) { $newArray[] = $elem; } return $newArray; } } ?>[/PHP]css [CODE]table.calendar { width:570px; margin:50px auto auto; } table.calendar table.title { width:100%; height:30px; border:1px solid #673404; background:#E77309; text-align:center; } table.calendar table.title td.monthBackwardA { width:30px; color:#fff; } table.calendar table.title td.monthBackwardA a { font-size:18px; color:#fff; width:30px; height:30px; line-height:30px; display:block; text-decoration:none; } table.calendar table.title td.monthYear { font-size:14px; line-height:30px; color:#fff; } table.calendar table.title td.monthForwardA { width:30px; color:#fff; } table.calendar table.title td.monthForwardA a { font-size:18px; color:#fff; width:30px; height:30px; line-height:30px; display:block; text-decoration:none; } table.calendar td.dayName { text-align:center; font-weight:bold; } table.calendar td.dayA { border:1px solid #EB9A50; background:#FFE4C4; color:#E77309; text-align:center; height:30px; } table.calendar td.dayA.dayTodayA { border:1px solid #fad42e; background:#fbec88; color:#522903; } table.calendar td.dayA.dayTodayA * { background-color:#fbec88 !important; color:#522903; } table.calendar td.dayA.dayOther { border:1px solid #EEE9BF; background:#FFFACD; color:#BBAD66; } table.calendar td.dayA a, table.calendar td.dayA span { display:block; width:100%; height:22px; } .holiday { background:#FFD0A1; color:#E78E3D; padding-top:6px; } .christmas { background:#3baae3 url(christmas.png) 50% 50% no-repeat; color:#fff; } .gharztr { background:#004494; } /************** GEHOEREN NICHT ZUM P16PHPKALENDER ********************/ #k { position:relative; top:0; left:0; display:block; }[/CODE] [/QUOTE]
Bilder bitte
hier hochladen
und danach über das Bild-Icon (Direktlink vorher kopieren) platzieren.
Zitate einfügen…
Authentifizierung
Wenn ★ = 12, ◇ = 4 und die Hälfte von ★ zu ◇ addiert wird, was ist das Ergebnis?
Antworten
Start
Forum
Sonstiges
Webdesign, Webentwicklung & Programmierung
PHP, Javascript, jQuery, Ajax, nodeJS, MySQL...
PHP Kalender feinschliff hilfe benötigt
Oben