Antworten auf deine Fragen:
Neues Thema erstellen

PHP Kalender feinschliff hilfe benötigt

AbbySu

Noch nicht viel geschrieben

Hi an alle,

aaaalso, ich habe die letzten Tage damit verbracht Google nach Kalender-Srkipten und Tutorials dazu zu durchwühlen.

Nach langem suchen habe ich endlich eines entdeckt, dass meinen Wünschen am ehesten gerecht zu werden schien. Als ich dann alles soweit in mein Dokument übertragen, farblich angepasst und die Feiertage geändert hatte, wollte ich mich daran machen die Ereignisse einzutragen, die man angeblich bequem unter dem Quelltext im Hauptdokument ändern können soll, aber offenbar mach ich noch etwas falsch oder so, zumindest erkennt er diese nicht.

Also das Original Skript habe ich von

Der Codeteil, der auf der Seite erklärt wird ist der, der mir Probleme macht und es bringt auch nichts von
PHP:
$calendar
auf
PHP:
$kalender
zu wechseln, denn das war schon so im Dokument vorgegeben. Ja hier dann mal meine Version, die nicht funktionieren will:
PHP:
$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');
Um nicht unnötig viele Informationen direkt einzustellen, bitte ich darum bei weiterem Informationsbedarf einfach danach zu fragen ;) danke

Ich hoffe irgendwer findet die Lösung :idee:
 

spenderorgan

Nicht mehr ganz neu hier

AW: PHP Kalender feinschliff hilfe benötigt

wenn du einen simplen kalender suchsts, versuchs doch mal mit dem jquery datepicker, der lässt sich relativ umfangreich konfigurieren und auch eindeutschen
 

Duddle

Posting-Frequenz: 14µHz

AW: PHP Kalender feinschliff hilfe benötigt

"Funktioniert nicht" ist keine Fehlermeldung.

Zeige bitte deinen gesamten Code und welche Fehler beim Ausführen angezeigt werden.


Duddle
 

blastermaster

Noch nicht viel geschrieben

AW: PHP Kalender feinschliff hilfe benötigt

Die Lösung ist ganz simpel - einstellige Monatszahlen ohne vorangestellter '0'
also
PHP:
$calendar->addHoliday('RosenstadtTriathlon', '24.6.2012');
 

AbbySu

Noch nicht viel geschrieben

AW: PHP Kalender feinschliff hilfe benötigt

Hi,

das habe ich auch schon versucht... leider ohne Erfolg.

Zudem habe ich es geschafft den aktuellen Monat nicht mehr angezeigt zu bekommen... vermutlich liegt es an dem nachträglich an der Seite eingefügten Kalenders, doch ich finde keine gemeinsamen Variablen, die mir das erklären würden... also zwei Probleme... mäh...
 

blastermaster

Noch nicht viel geschrieben

AW: PHP Kalender feinschliff hilfe benötigt

Ich habe testweise diesen Kalender auf meinem localen Server laufen ohne Veränderungen am eigentlichen Code und er funktioniert mit meiner angebotenen Lösung. Also muß das Problem an deinen vorgenommenen Änderungen liegen - du müsstest jetzt mal etwas zu deinen Änderungen und Einbindung in deine Webseite posten (gesamter Code)
 

AbbySu

Noch nicht viel geschrieben

AW: PHP Kalender feinschliff hilfe benötigt

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 &ndash; 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"); ?>
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' => '&laquo;', 'monthForward' => '&raquo;');
    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&ouml;nige [BW, BY, ST]', 'class' => 'holiday', 'url' => ''),
                                array('day' => '05.4.*', 'name' => 'Gr&uuml;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&auml; 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;
    }
}
?>
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; }
 
Zuletzt bearbeitet:

AbbySu

Noch nicht viel geschrieben

AW: PHP Kalender feinschliff hilfe benötigt

Ach ja und wie schon erwähnt habe ich nachträglich noch diesen Kalender:
PHP:
<?php
                    setlocale(LC_TIME, "de_DE");
                    $kal_datum = time();
                    $kal_tage_gesamt = date("t", $kal_datum);
                    $kal_start_timestamp = mktime(0,0,0,date("n",$kal_datum),1,date("Y",$kal_datum));
                    $kal_start_tag = date("N", $kal_start_timestamp);
                    $kal_ende_tag = date("N", mktime(0,0,0,date("n",$kal_datum),$kal_tage_gesamt,date("Y",$kal_datum)));
                ?>
                <table class="kalender">
                    <caption class="kal_titel"><a href="termine.php" target="_self" title="zum Kalender" id="kalender_a">&gt;&emsp;<?php echo strftime("%B %Y", $kal_datum); ?>&emsp;&lt;</a></caption>
                    <thead>
                        <tr class="kal_tr_wotag">
                        <th>Mo</th>
                        <th>Di</th>
                        <th>Mi</th>
                        <th>Do</th>
                        <th>Fr</th>
                        <th>Sa</th>
                        <th>So</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <?php
                                for($i = 1; $i <= $kal_tage_gesamt+($kal_start_tag-1)+(7-$kal_ende_tag); $i++) {
                                    $kal_anzeige_akt_tag = $i - $kal_start_tag;
                                    $kal_anzeige_heute_timestamp = strtotime($kal_anzeige_akt_tag." day", $kal_start_timestamp);
                                    $kal_anzeige_heute_tag = date("j", $kal_anzeige_heute_timestamp);
                                    if(date("dmY", $kal_datum) == date("dmY", $kal_anzeige_heute_timestamp))
                                    echo " <td class=\"kal_aktueller_tag\">",$kal_anzeige_heute_tag,"</td>\n";
                                    elseif($kal_anzeige_akt_tag >= 0 AND $kal_anzeige_akt_tag < $kal_tage_gesamt)
                                    echo " <td class=\"kal_standard_tag\">",$kal_anzeige_heute_tag,"</td>\n";
                                    else
                                    echo " <td class=\"kal_vormonat_tag\">",$kal_anzeige_heute_tag,"</td>\n";
                                    if(date("N",$kal_anzeige_heute_timestamp) == 7)
                                    echo " </tr>\n <tr>\n";
                                }
                            ?>
                        </tr>
                    </tbody>
                </table>
in meinen rechten Content eingefügt und jetzt beißt der sich mit dem anderen und klaut dem den aktuellen Monat. Ich seh nur nicht, wo genau das Problem liegt.
 

AbbySu

Noch nicht viel geschrieben

AW: PHP Kalender feinschliff hilfe benötigt

Oh je... fällt keinem mehr was ein?

Oder bin ich nur zu ungeduldig ^^
 

blastermaster

Noch nicht viel geschrieben

AW: PHP Kalender feinschliff hilfe benötigt

So dann will ich mal
1) der 'Mai' fehlt in dem Array - $deutscheDaten - 'monthsLong'
richtig wäre das dann so:
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', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember' ),
                       
                       'monthsShort' => array( 'Jan', 'Feb', 'März', 'Apr', 'Mai', 'Juni', 'Juli', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez' )
                       );
2) alle einzugebenen Tage und Monate müssen ohne vorangestellter '0' eingegeben werden
richtig wäre es diesem Beispiel so:
PHP:
$calendar->addHoliday('RosenstadtTriathlon', '24.6.2012');
3) bei Angabe von $url und $class bei $calendar->addVacation muß das folgendermaßen aussehen:
PHP:
$calendar->addVacation('22.6.2012', '23.6.2012', 'Globetrotter Harztriathlon', $url = 'http://www.oberharz.de/harz-triathlon.html', $class = 'gharztr');
4) und letztens ist ein Fehler vom Programmierer in der calendar.class.php
ersetze einfach den Inhalt der jetzigen mit dem:
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' => '&laquo;', 'monthForward' => '&raquo;');
    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&ouml;nige [BW, BY, ST]', 'class' => 'holiday', 'url' => ''),
                                array('day' => '05.4.*', 'name' => 'Gr&uuml;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&auml; 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.n.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;
    }
}
?>
 

AbbySu

Noch nicht viel geschrieben

AW: PHP Kalender feinschliff hilfe benötigt

Hey danke, du bist mein Held der Situation :D

Hab' ich das richtig gesehen, dass sich in der calendar.class.php lediglich das 'm' zum 'n' ändert?
PHP:
for($i = 0; $i <= $days; $i++) {
    $this->holidays[] = array('day' => date('d.n.Y', $fromTimestamp), 'name' => $name, 'url' => $url, 'class' => $class);
    $fromTimestamp = $this->addDay($fromTimestamp);
}
Also der erste Fehler, den du gefunden hast, das war mein Fehler... super doof. Aber genau für sowas braucht man den Blick anderer.

Ja danke dafür!

Ob ich dazu wohl noch was fragen kann? Weil ich hätte so gerne eine Auswahl über dem Kalender, in der man direkt den gewünschten Monat auswählen kann. Wobei immer die nächsten sechs Monate ausreichen würden. Zurück muss man nicht gucken.

Ich hab 'ne Idee, was man dann in den Links abfragen müsste, doch leider reicht mein Latein immer noch nur zum verstehen und umbasteln des Gegebenen, was ganz eigenes bekomm ich noch nicht hin... :'(

Jetzt ist mir grad noch aufgefallen, dass der die URLs _self öffnet... meinst da lässt sich was dran machen? Wobei das nicht zwingend sein muss, da ich irgendwie noch angeben wollte, was denn dort geleistet wird und da kann ich die Links auch einfach intern gestalten. Dennoch wäre es trotzdem nicht schlecht, wenn die sich _blank öffnen.

Also allmählich steh ich bei dir in der Schuld :)
 
Zuletzt bearbeitet:

blastermaster

Noch nicht viel geschrieben

AW: PHP Kalender feinschliff hilfe benötigt

Hab' ich das richtig gesehen, dass sich in der calendar.class.php lediglich das 'm' zum 'n' ändert?
ja - Monatszahl ohne vorangestelter '0'

zu Target_blank
suche in der calendar.class.php nach
Code:
<a href="' . $holiday['url'] . '" ' . $longdesc . ' title="' . $holiday['name'] . '" class="' . $holiday['class'] . '"
und füge dahinter (Achtung vor dem Code ist ein Leerzeichen einzufügen)
Code:
 onclick="this.target=\'_blank\'"

den Rest gibt es Morgen Nachmittag
 

AbbySu

Noch nicht viel geschrieben

AW: PHP Kalender feinschliff hilfe benötigt

Hey super, man ich beneide dein können!

Ich freue mich schon richtig auf den nächsten Input! :)
 

blastermaster

Noch nicht viel geschrieben

AW: PHP Kalender feinschliff hilfe benötigt

so wie versprochen - Monatsauswahl

PHP:
<ul class="monthsnavi">
<?php
//Anzahl anzuzeigender Monate
$number_of_months = 6;

//jetziger Monat
$present_month = date('n',time());
//jetziges Jahr
$present_year = date('Y',time());
//
for($i=0; $i < $number_of_months; $i++){
    $new_month = $i+$present_month;
    $year = $present_year;
    if($new_month > 12){
        $new_month = $new_month-12;
        $year = $present_year+1;
    }
    foreach($deutscheDaten['monthsLong'] as $key => $dD_months)
    if($new_month == $key+1) echo "<li><a href=\"".$_SERVER['PHP_SELF']."?m=".$new_month."&amp;y=".$year."\">".$dD_months."</a></li>";
}
?>
</ul>
Du müsstet das Array deutscheDaten verschieben - direkt unter dein
PHP:
include("head.php");
dann kannst du die Monatsauswahl auch über den Kalender einfügen.
Man kann hinter $number_of_months die anzuzeigenden Monate eingeben und mit CSS die Auswahl nach belieben gestalten, z.B.
Code:
ul.monthsnavi{
list-style-type:none;
margin-left:0;
padding-left:0;
}
ul.monthsnavi li{
float:left;
padding-right:2px;
}
ul.monthsnavi li a{
background-color:#cbcbcb;
padding:0.2em;
}
ul.monthsnavi li a:hover{
background-color:#ababab;
}
 

AbbySu

Noch nicht viel geschrieben

AW: PHP Kalender feinschliff hilfe benötigt

Also, damit ich das jetzt auch alles verstehe, was du da für mich gezaubert hast:

Den PHP-Code von dir füge ich in den Content ein bzw. habe ich bereits eingefügt. Dann hab ichs direkt mal ausprobiert und mich gefragt warum der andere PHP Teil direkt unter den Head wandern muss? Ergibt sich da sonst irgendein Fehler, der mir grad nicht aufgefallen ist? Und muss der gesamte Part da hoch, oder nur das $deutschedaten Arrey?

Also das #k - Div habe ich mit den eingegebenen Eventtagen unter deinem Code gelassen. Ich tipp mal drauf, wenn ich das gleich teste, wird mir schon auffallen, was sonst passiert... allerdings ist mir dein zweiter Hinweis ja auch noch nicht ganz klar :D

Bin mal gespannt

Dennoch funktioniert das schon mal und ich kann mich ans Design machen. Das ist so super! Als ich überlegt habe, was man da wohl programmieren müsste, kam ich auf wesentlich kompliziertere Gedanken, die aber auch kein Hand und Fuß hatten.
 

blastermaster

Noch nicht viel geschrieben

AW: PHP Kalender feinschliff hilfe benötigt

also nur diesen Teil
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', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember' ),
                       
                       'monthsShort' => array( 'Jan', 'Feb', 'März', 'Apr', 'Mai', 'Juni', 'Juli', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez' )
                       );
Der Grund ist, das mein Codeteil auf dieses Array zugreift. Wird dieser nach dem Array eingefügt gibt es keine Probleme, davor allerdings dürftest du nur die englischsprachigen Monatsnamen erhalten bzw. gar keine. Und so kannst du die Auswahlliste überall auf der Seite plazieren.

allerdings ist mir dein zweiter Hinweis ja auch noch nicht ganz klar
biggrin.png
erhöhe doch einfach mal die Zahl dahinter auf 10
PHP:
$number_of_months = 6;
 
Bilder bitte hier hochladen und danach über das Bild-Icon (Direktlink vorher kopieren) platzieren.
Antworten auf deine Fragen:
Neues Thema erstellen

Willkommen auf PSD-Tutorials.de

In unseren Foren vernetzt du dich mit anderen Personen, um dich rund um die Themen Fotografie, Grafik, Gestaltung, Bildbearbeitung und 3D auszutauschen. Außerdem schalten wir für dich regelmäßig kostenlose Inhalte frei. Liebe Grüße senden dir die PSD-Gründer Stefan und Matthias Petri aus Waren an der Müritz. Hier erfährst du mehr über uns.

Stefan und Matthias Petri von PSD-Tutorials.de

Nächster neuer Gratisinhalt

03
Stunden
:
:
25
Minuten
:
:
19
Sekunden

Neueste Themen & Antworten

Flatrate für Tutorials, Assets, Vorlagen

Zurzeit aktive Besucher

Statistik des Forums

Themen
118.565
Beiträge
1.538.066
Mitglieder
67.488
Neuestes Mitglied
Andrew56524
Oben