SMFPortal.de

Willkommen !

Autor Thema: Mini Kalender für TP  (Gelesen 11699 mal)

0 Mitglieder und 1 Gast betrachten dieses Thema.

Spawn

  • Gast
Mini Kalender für TP
« am: 22. März 2008, 18:48:40 »
Mini Kalender: Zeigt im TinyPortal einen Mini Kalender mit Ereignissen, Feiertage (falls aktiviert) und Geburtstage an (zu benutzen in einem php Block)
TinyPortal:0.9.8
Autor: nicht bekannt



Code
$now = mktime();
$today = date('j',$now);
$days = array($today=>array(NULL,NULL,'<span class="smalltext" style="color: blue; border: 1px solid black; background-color: yellow; padding:0px 2px 0px 2px;">'.$today.'</span>'));
$year = date("Y",$now);
$month = date("n",$now);

$day_name_length = 3;
$month_href = NULL;
$first_day = 1;
$pn = array();

$first_of_month = gmmktime(0,0,0,$month,1,$year);
#remember that mktime will automatically correct if invalid dates are entered
# for instance, mktime(0,0,0,12,32,1997) will be the date for Jan 1, 1998
# this provides a built in "rounding" feature to generate_calendar()

$day_names = array(); #generate all the day names according to the current locale
for($n=0,$t=(3+$first_day)*86400; $n<7; $n++,$t+=86400) #January 4, 1970 was a Sunday
$day_names[$n] = ucfirst(gmstrftime('%A',$t)); #%A means full textual day name

list($month, $year, $month_name, $weekday) = explode(',',gmstrftime('%m,%Y,%B,%w',$first_of_month));
$weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day
$title   = htmlentities(ucfirst($month_name)).' '.$year;  #note that some locales don't capitalize month and day names

#Begin calendar. Uses a real <caption>. See http://diveintomark.org/archives/2002/07/03
@list($p, $pl) = each($pn); @list($n, $nl) = each($pn); #previous and next links, if applicable
if($p) $p = '<span class="smalltext">'.($pl ? '<a href="'.htmlspecialchars($pl).'">'.$p.'</a>' : $p).'</span> ';
if($n) $n = ' <span class="smalltext">'.($nl ? '<a href="'.htmlspecialchars($nl).'">'.$n.'</a>' : $n).'</span>';
$calendar = '<table>'."\n".
'<caption >'.$p.($month_href ? '<a href="'.htmlspecialchars($month_href).'">'.$title.'</a>' : $title).$n."</caption>\n<tr>";

if($day_name_length){ #if the day names should be shown ($day_name_length > 0)
#if day_name_length is >3, the full name of the day will be printed
foreach($day_names as $d)
$calendar .= '<td class="smalltext" abbr="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</td>';
$calendar .= "</tr>\n<tr>";
}

if($weekday > 0) $calendar .= '<td class="smalltext" colspan="'.$weekday.'"> </td>'; #initial 'empty' days
for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){
if($weekday == 7){
$weekday   = 0; #start a new week
$calendar .= "</tr>\n<tr>";
}
if(isset($days[$day]) and is_array($days[$day])){
@list($link, $classes, $content) = $days[$day];
if(is_null($content))  $content  = $day;
$calendar .= '<td align=\"center\" valign=\"middle\" '.($classes ? ' class="'.htmlspecialchars($classes).'">' : '>').
($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).'</td>';
}
else $calendar .= "<td align=\"center\" valign=\"middle\" class=\"smalltext\">$day</td>";
}

if($weekday != 7) $calendar .= '<td class="smalltext" colspan="'.(7-$weekday).'"> </td>'; #remaining "empty" days
echo $calendar.'</tr>';

$todaysBirthdays = ssi_todaysBirthdays('array');
$todaysEvents = ssi_todaysEvents('array');
$todaysHolidays = ssi_todaysHolidays('array');

global $context, $scripturl, $modSettings;

if ($todaysEvents || $todaysHolidays || $todaysBirthdays)
{
echo '<tr><td colspan="2"><hr></td><td colspan="3" class="smalltext" align="center">Heutige Ereignisse</td><td colspan="2"><hr></td></tr><td colspan="7" class="smalltext">';
if ($todaysBirthdays)
{
echo '<span style="color: #' . $modSettings['cal_bdaycolor'] . ';">Geburstage: </span>';
foreach ($todaysBirthdays as $member)
echo '
<a href="', $scripturl, '?action=profile;u=', $member['id'], '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>' . (!$member['is_last'] ? ', ' : '');

if ($todaysEvents || $todaysHolidays)
echo '<br />';
}

if ($todaysHolidays)
{
echo '<span style="color: #' . $modSettings['cal_holidaycolor'] . ';">Feiertag: </span>';
echo implode(', ', $todaysHolidays);

if ($todaysEvents)
echo '<br />';
        }

if ($todaysEvents)
{
echo '<span style="color: #' . $modSettings['cal_eventcolor'] . ';">Events: </span>';
foreach ($todaysEvents as $event)
echo $event['link'] . (!$event['is_last'] ? ', ' : '');
}
echo '</td></tr>';
}

$today = ssi_todaysCalendar('array');
if ($today)
{
echo '<tr><td colspan="2"><hr></td><td colspan="3" class="smalltext" align="center">Zukünftige Ereignisse</td><td colspan="2"><hr></td></tr><td colspan="7" class="smalltext">';

if (!empty($today['birthdays']))
{
echo '<span style="color: #' . $modSettings['cal_bdaycolor'] . ';">Geburstage: </span>';
foreach ($today['birthdays'] as $member)
echo '
<a href="'. $scripturl .'?action=profile;u='. $member['id']. '">'. $member['name'] .'', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', !$member['is_last'] ? ', ' : '';

if (!empty($today['events']) || !empty($today['holidays']))
echo '<br />';
}

if (!empty($today['events']))
{
echo '<span style="color: #' . $modSettings['cal_eventcolor'] . ';">Events: </span>';
foreach ($today['events'] as $event)
{
echo '
' . $event['link'] . (!$event['is_last'] ? ', ' : '');
}
if (!empty($today['holidays']))
echo '<br />';
}

if (!empty($today['holidays']))
echo '<span style="color: #' . $modSettings['cal_holidaycolor'] . ';">Feiertage: </span>' . implode(', ', $today['holidays']);

echo '</td></tr>';
}

echo '</table>';
« Letzte Änderung: 22. März 2008, 20:18:22 von Spawn »

scott_68

  • Spezialist
  • ****
  • Beiträge: 79
  • Geschlecht: Männlich
Re: Mini Kalender für TP
« Antwort #1 am: 08. Juli 2008, 13:18:59 »
Hallo Helfer,
Kann hier für mich jemand den Code posten, wenn die zukünftigen Ereignisse nicht dargestellt werden sollen ?
Vielen Dank
TP 0.9.8 + SMF 1.1.x

ディン1031

  • Spezialist
  • ****
  • Beiträge: 1257
  • はるひ! :P
Re: Mini Kalender für TP
« Antwort #2 am: 08. Juli 2008, 17:48:10 »
Hallo Helfer,
Kann hier für mich jemand den Code posten, wenn die zukünftigen Ereignisse nicht dargestellt werden sollen ?
Vielen Dank
Dazu mußt du in deinen Einstellungen einfach die Tage für zukünftige erreichniss auf 0 stellen.

Findest du unter Admin -> Kalender -> Kalender Einstellungen -> Max. Anzahl der Kalendertage auf dem Board-Index im Voraus.

Weil diese funktion macht nichts anderes als wie die berreits geladenen daten auswerten ;).

Gruß
DIN1031
Bitte markiert das Thema als gelöst wenn ihr ein Lösung erhalten habt die euer problem gelöst hat. Da für ist dieser schöne Button "Thema gelöst" unten!
Mein Forum:ayu][kult
私のニクはディンです.
KEINE PMs ohne voherige erlaubniss... fragt im Fourm das ist besser.

Spawn

  • Gast
Re: Mini Kalender für TP
« Antwort #3 am: 08. Juli 2008, 17:50:26 »
Ich nehm aber mal an das er dies haben will, nur net im Kalender.  ;)

ディン1031

  • Spezialist
  • ****
  • Beiträge: 1257
  • はるひ! :P
Re: Mini Kalender für TP
« Antwort #4 am: 08. Juli 2008, 17:52:48 »
okay dann hast du wohl was zu tun *runs*
Bitte markiert das Thema als gelöst wenn ihr ein Lösung erhalten habt die euer problem gelöst hat. Da für ist dieser schöne Button "Thema gelöst" unten!
Mein Forum:ayu][kult
私のニクはディンです.
KEINE PMs ohne voherige erlaubniss... fragt im Fourm das ist besser.

Spawn

  • Gast
Re: Mini Kalender für TP
« Antwort #5 am: 08. Juli 2008, 17:55:34 »
Wieso ich?

Ich hab den Code nur eingestellt, modifizieren muss den jemand anderes.  ;D

scott_68

  • Spezialist
  • ****
  • Beiträge: 79
  • Geschlecht: Männlich
Re: Mini Kalender für TP
« Antwort #6 am: 08. Juli 2008, 19:32:27 »
Ich möchte in dem Kalenderblock KEINE Ansicht der in zukunft passierenden Ereignisse, finde , die verunstalten bei mir das Bild. Sprich also unter den Tagen nur das Ereignis des heutigen Tages.
Ich habe die Modifikationen selber schon ein paar mal Probiert, zerschiesse aber immer den Block.  ::)

Vielleicht erbarmt sich ja wer, kann ja für einen geübten Programmierer nicht so wild sein  ;D

Danke
TP 0.9.8 + SMF 1.1.x

Spawn

  • Gast
Re: Mini Kalender für TP
« Antwort #7 am: 08. Juli 2008, 19:37:39 »
Das geht ja nicht.

Entweder du lässt dir die Ereignisse anzeigen, oder eben nicht.

Der Block ruft die gleichen Daten der Datenbanken ab wie der normale Kalender auch, sprich, du kannst nicht hingehen und im normalen Kalender die Ereignisse der nächsten 4 Wochen anzeigen lassen und in dem Mini Kalender nur von heute.

EDIT:

Sorry, hab grad mal wieder auf dem Schlauch gestanden, weiß jetzt aber was du meinst.

Ich mach das bis später mal mit dem Kalender.
« Letzte Änderung: 08. Juli 2008, 19:41:52 von Spawn »

TE

  • Gast
Re: Mini Kalender für TP
« Antwort #8 am: 08. Juli 2008, 19:58:16 »
mhh, wenn ich das richtig sehe nutzt der Block die Funktionen aus der SSI.php

Code
$todaysBirthdays = ssi_todaysBirthdays('array');
$todaysEvents = ssi_todaysEvents('array');
$todaysHolidays = ssi_todaysHolidays('array');

man könnte die 3 Funktionen kopieren und dann in den kopien die SQL-Abfrage auf die Tage von heute reduzieren..

so nach dem Motto:
Code
ssi_todaysBirthdaysheute('array')

eventuell schaffst du es damit ja allein, bin leider im Moment ziemlich eingebunden. wenn gar nichts klappt dann schreib nochmal, dann schau ich später mal..

ディン1031

  • Spezialist
  • ****
  • Beiträge: 1257
  • はるひ! :P
Re: Mini Kalender für TP
« Antwort #9 am: 09. Juli 2008, 07:10:54 »
Was mich nun wundert ;)

Es gibt die Funktion ssi_todaysCalendar diese Zeigt nur die heutigen calendertage, was mich nun aber wundert ist das diest nicht gemacht wird da der Block eigentlich diese funktion nutzt um nur die heutigen calendertage anzuzeigen ;). (Und nun weiß ich auch warum, das scheint wohl nicht der fall zu sein...)

Hmmm so könnte es gehen (so ein muse hatte) kann es aber net testen ;P
Oben gibt es ein option zum an und ausschalten ;).
Code
<?php
$now = mktime();
$today = date('j',$now);
$days = array($today=>array(NULL,NULL,'<span class="smalltext" style="color: blue; border: 1px solid black; background-color: yellow; padding:0px 2px 0px 2px;">'.$today.'</span>'));
$year = date("Y",$now);
$month = date("n",$now);
# 1 = Enabel und 0 = Disable
$showTodayOnly = 1;

$day_name_length = 3;
$month_href = NULL;
$first_day = 1;
$pn = array();

$first_of_month = gmmktime(0,0,0,$month,1,$year);
#remember that mktime will automatically correct if invalid dates are entered
# for instance, mktime(0,0,0,12,32,1997) will be the date for Jan 1, 1998
# this provides a built in "rounding" feature to generate_calendar()

$day_names = array(); #generate all the day names according to the current locale
for($n=0,$t=(3+$first_day)*86400; $n<7; $n++,$t+=86400) #January 4, 1970 was a Sunday
$day_names[$n] = ucfirst(gmstrftime('%A',$t)); #%A means full textual day name

list($month, $year, $month_name, $weekday) = explode(',',gmstrftime('%m,%Y,%B,%w',$first_of_month));
$weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day
$title   = htmlentities(ucfirst($month_name)).' '.$year;  #note that some locales don't capitalize month and day names

#Begin calendar. Uses a real <caption>. See http://diveintomark.org/archives/2002/07/03
@list($p, $pl) = each($pn); @list($n, $nl) = each($pn); #previous and next links, if applicable
if($p) $p = '<span class="smalltext">'.($pl ? '<a href="'.htmlspecialchars($pl).'">'.$p.'</a>' : $p).'</span> ';
if($n) $n = ' <span class="smalltext">'.($nl ? '<a href="'.htmlspecialchars($nl).'">'.$n.'</a>' : $n).'</span>';
$calendar = '<table>'."\n".
'<caption >'.$p.($month_href ? '<a href="'.htmlspecialchars($month_href).'">'.$title.'</a>' : $title).$n."</caption>\n<tr>";

if($day_name_length){ #if the day names should be shown ($day_name_length > 0)
#if day_name_length is >3, the full name of the day will be printed
foreach($day_names as $d)
$calendar .= '<td class="smalltext" abbr="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</td>';
$calendar .= "</tr>\n<tr>";
}

if($weekday > 0) $calendar .= '<td class="smalltext" colspan="'.$weekday.'"> </td>'; #initial 'empty' days
for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){
if($weekday == 7){
$weekday   = 0; #start a new week
$calendar .= "</tr>\n<tr>";
}
if(isset($days[$day]) and is_array($days[$day])){
@list($link, $classes, $content) = $days[$day];
if(is_null($content))  $content  = $day;
$calendar .= '<td align=\"center\" valign=\"middle\" '.($classes ? ' class="'.htmlspecialchars($classes).'">' : '>').
($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).'</td>';
}
else $calendar .= "<td align=\"center\" valign=\"middle\" class=\"smalltext\">$day</td>";
}

if($weekday != 7) $calendar .= '<td class="smalltext" colspan="'.(7-$weekday).'"> </td>'; #remaining "empty" days
echo $calendar.'</tr>';

$todaysBirthdays = ssi_todaysBirthdays('array');
$todaysEvents = ssi_todaysEvents('array');
$todaysHolidays = ssi_todaysHolidays('array');

global $context, $scripturl, $modSettings;

if ($todaysEvents || $todaysHolidays || $todaysBirthdays)
{
echo '<tr><td colspan="2"><hr></td><td colspan="3" class="smalltext" align="center">Heutige Ereignisse</td><td colspan="2"><hr></td></tr><td colspan="7" class="smalltext">';
if ($todaysBirthdays)
{
echo '<span style="color: #' . $modSettings['cal_bdaycolor'] . ';">Geburstage: </span>';
foreach ($todaysBirthdays as $member) {
echo '
<a href="', $scripturl, '?action=profile;u=', $member['id'], '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>' . (!$member['is_last'] ? ', ' : '');
}
if ($todaysEvents || $todaysHolidays)
echo '<br />';
}

if ($todaysHolidays)
{
echo '<span style="color: #' . $modSettings['cal_holidaycolor'] . ';">Feiertag: </span>';
echo implode(', ', $todaysHolidays);

if ($todaysEvents)
echo '<br />';
}

if ($todaysEvents)
{
echo '<span style="color: #' . $modSettings['cal_eventcolor'] . ';">Events: </span>';
foreach ($todaysEvents as $event)
echo $event['link'] . (!$event['is_last'] ? ', ' : '');
}
echo '</td></tr>';
}

$today = ssi_todaysCalendar('array');
if (!empty($today))
{
echo '<tr><td colspan="2"><hr></td><td colspan="3" class="smalltext" align="center">Zukünftige Ereignisse</td><td colspan="2"><hr></td></tr><td colspan="7" class="smalltext">';

if (!empty($today['birthdays']))
{
$data = '<span style="color: #' . $modSettings['cal_bdaycolor'] . ';">Geburstage: </span>';
$i = 0;
foreach ($today['birthdays'] as $member) {
if(!empty($showOnlyToday) && !$member['is_today'])
continue;
else
$i++;
$data .= '
<a href="'. $scripturl .'?action=profile;u='. $member['id']. '">'. $member['name'] .'', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', !$member['is_last'] ? ', ' : '';
}
if (!empty($i) && (!empty($today['events']) || !empty($today['holidays'])))
echo $data.'<br />';
}

if (!empty($today['events']))
{
$data = '<span style="color: #' . $modSettings['cal_eventcolor'] . ';">Events: </span>';
$i = 0;
foreach ($today['events'] as $event)
{
if(!empty($showOnlyToday) && !$event['is_today'])
continue;
else
$i++;
$data .= '
' . $event['link'] . ', ';
}
if (!empty($i) && !empty($today['holidays']))
echo substr($data, 0, -2).'<br />'; #Lazyness is sometime needed!
}

if (!empty($today['holidays']))
echo '<span style="color: #' . $modSettings['cal_holidaycolor'] . ';">Feiertage: </span>' . implode(', ', $today['holidays']);

echo '</td></tr>';
}

echo '</table>';
?>

Gruß
DIN1031
« Letzte Änderung: 09. Juli 2008, 20:32:10 von din1031 »
Bitte markiert das Thema als gelöst wenn ihr ein Lösung erhalten habt die euer problem gelöst hat. Da für ist dieser schöne Button "Thema gelöst" unten!
Mein Forum:ayu][kult
私のニクはディンです.
KEINE PMs ohne voherige erlaubniss... fragt im Fourm das ist besser.

scott_68

  • Spezialist
  • ****
  • Beiträge: 79
  • Geschlecht: Männlich
Re: Mini Kalender für TP
« Antwort #10 am: 09. Juli 2008, 11:00:15 »
Eilt ja nicht  :D
Die Version von Din1032 habe ich mal in den php Block kopiert bekomme aber einen zerschossenen Block  8)
Zitat
Sources/Load.php(1740) : eval()'d code(35) : eval()'d code on line 1
TP 0.9.8 + SMF 1.1.x

ディン1031

  • Spezialist
  • ****
  • Beiträge: 1257
  • はるひ! :P
Re: Mini Kalender für TP
« Antwort #11 am: 09. Juli 2008, 20:25:10 »
Eilt ja nicht  :D
Die Version von Din1032 habe ich mal in den php Block kopiert bekomme aber einen zerschossenen Block  8)
Ich denke mal du mußt die <?php am anfang und das ?> am ende entfernen... macht der gewohnheit ;).

Uff war wirklich ein fehler drin ;D *verbssert*

Gruß
DIN1031
« Letzte Änderung: 09. Juli 2008, 20:33:00 von din1031 »
Bitte markiert das Thema als gelöst wenn ihr ein Lösung erhalten habt die euer problem gelöst hat. Da für ist dieser schöne Button "Thema gelöst" unten!
Mein Forum:ayu][kult
私のニクはディンです.
KEINE PMs ohne voherige erlaubniss... fragt im Fourm das ist besser.

Spawn

  • Gast
Re: Mini Kalender für TP
« Antwort #12 am: 10. Juli 2008, 01:59:12 »
Probier mal den hier.

Ist fast der gleiche wie der andere nur ohne zukünftige Geburtstage/Ereignisse/Ferien.

Code
global $scripturl, $modSettings, $context, $db_prefix, $user_profile;

smf_loadCalendarInfo();

$now = mktime() + $modSettings['time_offset'] * 3600;

$today = date('j',$now);
$year = date('Y',$now);
$month = date('n',$now);

$days = array($today=>array(NULL,NULL,'<a class="smalltext" style="color:steelblue; font-weight:bold; border:solid 1px black; background-color: white; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$today.'" target="_self">'.$today.'</a>'));

$day_name_length = 2;

$month_href = $scripturl . '?action=calendar&month=' . $month;
$first_day = 1;
$pn = array();

$first_of_month = gmmktime(0,0,0,$month,1,$year);

$day_names = array();                                      #generate all the day names according to the current locale
for($n=0,$t=(3+$first_day)*86400; $n<7; $n++,$t+=86400)    #January 4, 1970 was a Sunday
    $day_names[$n] = ucfirst(gmstrftime('%A',$t));         #%A means full textual day name

list($month, $year, $month_name, $weekday) = explode(',',gmstrftime('%m,%Y,%B,%w',$first_of_month));

$weekday = ($weekday + 7 - $first_day) % 7;                #adjust for $first_day
$title   = htmlentities(ucfirst($month_name)).' '.$year;   #note that some locales don't capitalize month and day names

@list($p, $pl) = each($pn); @list($n, $nl) = each($pn); #previous and next links, if applicable
if($p) $p = '<span class="smalltext">'.($pl ? '<a href="'.htmlspecialchars($pl).'">'.$p.'</a>' : $p).'</span> ';
if($n) $n = ' <span class="smalltext">'.($nl ? '<a href="'.htmlspecialchars($nl).'">'.$n.'</a>' : $n).'</span>';
$calendar = '<table align="center">'.'<caption >'.$p.($month_href ? '<a href="'.htmlspecialchars($month_href).'">'.$title.'</a>' : $title).$n.'</caption><tr>';

if($day_name_length){                                      #if the day names should be shown ($day_name_length > 0)
    foreach($day_names as $d)
    $calendar .= '<th class="smalltext" abbr="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</th>';
    $calendar .= '</tr><tr style="text-align:right;">';
    }

if($weekday > 0) $calendar .= '<td class="smalltext" colspan="'.$weekday.'"> </td>'; #initial 'empty' days

for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){
    if($weekday == 7){
        $weekday   = 0; #start a new week
        $calendar .= '</tr><tr style="text-align:right;">';
        }

    if(isset($days[$day]) and is_array($days[$day])){
        @list($link, $classes, $content) = $days[$day];
        if(is_null($content))  $content  = $day;
        $calendar .= '<td '.($classes ? ' class="'.htmlspecialchars($classes).'">' : '>').($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).'</td>';
        }
    else
        {
        $calendar .= '<td class="smalltext" style="padding-right:4px;"><a';
        if(((($weekday+$first_day) % 7)==0)||((($weekday+$first_day) % 7)==6))
            {
            $calendar .= ' style="color:#C00000;"';
            }
        $calendar .= ' href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$day.'" target="_self">'.$day.'</a></td>';
        }
    }

if($weekday != 7) $calendar .= '<td class="smalltext" colspan="'.(7-$weekday).'"> </td>'; #remaining "empty" days

echo $calendar.'</tr>';

/////////////////////////////////////////////////////////////////
//   BIRTHDAY SECTION
//
if (!empty($context['calendar_birthdays']) && ($context['user']['is_logged']))
{
    echo '<tr><td colspan="2"><hr></td><td colspan="3" class="smalltext" align="center" style="font-weight: bold; color: #' . $modSettings['cal_bdaycolor'] . ';">Geburtstage</td><td colspan="2"><hr></td></tr><td colspan="7" class="smalltext">';

    foreach ($context['calendar_birthdays'] as $member)
    {
        $query = db_query(
            "SELECT birthdate
            FROM {$db_prefix}members
            WHERE ID_MEMBER='".$member['id']."'", __FILE__, __LINE__);

        $row = mysql_fetch_assoc($query);
list ($uyear, $umonth, $uday) = explode('-', $row['birthdate']);
        $birthdate = strtotime(sprintf('%04d-%02d-%02d', date("Y"), $umonth, $uday));
        mysql_free_result($query);

        $dummy = array();
        $dummy[] = $member['id'];
        loadMemberData($dummy);
        $profile = &$user_profile[$member['id']];

        echo '<div align="center">';
        echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . date("n",$birthdate) . '"><strong>' . date("M j",$birthdate) . '</strong></a>';
        echo ' - ';
        echo '<a href="', $scripturl, '?action=profile;u=', $member['id'], '">';
        if (!empty($profile['member_group_color']))
        {
        echo '<font color="' . $profile['member_group_color'] . '">' . $member['name'] . (isset($member['age']) ? '(' . $member['age'] . ')' : '') . '</font>';
        }
        else
        {
        echo $member['name'] . (isset($member['age']) ? '(' . $member['age'] . ')' : '');
        }
        echo '</a>';
        echo '</div>';
    }
    echo '</td></tr>';
}

/////////////////////////////////////////////////////////////////
//   EVENTS SECTION
//
if (!empty($context['calendar_events']))
{
    echo '<tr><td colspan="2"><hr></td><td colspan="3" class="smalltext" align="center" style="font-weight: bold; color: #' . $modSettings['cal_eventcolor'] . ';">Ereignisse</td><td colspan="2"><hr></td></tr><td colspan="7" class="smalltext">';

    foreach ($context['calendar_events'] as $event)
    {
        $query = db_query(
            "SELECT startDate
            FROM {$db_prefix}calendar
            WHERE ID_EVENT='".$event['id']."'", __FILE__, __LINE__);

        $row = mysql_fetch_assoc($query);
        $startdate = strtotime($row['startDate']);

        mysql_free_result($query);

        echo '<div align="center">';
        echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . date("n",$startdate) . '"><strong>' . date("M j",$startdate) . '</strong></a>';
        echo ' - ';
        echo $event['link'] ;
        echo '</div>';
    }
    echo '</td></tr>';
}

/////////////////////////////////////////////////////////////////
//   HOLIDAY SECTION
// WHERE title='".str_replace("'","''",$holiday)."'
if (!empty($context['calendar_holidays']))
{
    echo '<tr><td colspan="2"><hr></td><td colspan="3" class="smalltext" align="center" style="font-weight: bold; color: #' . $modSettings['cal_holidaycolor'] . ';">Ferien</td><td colspan="2"><hr></td></tr><td colspan="7" class="smalltext">';

    foreach ($context['calendar_holidays'] as $holiday)
    {
        $query = db_query(
            "SELECT eventDate
            FROM {$db_prefix}calendar_holidays
            WHERE title='".str_replace("'","''",$holiday)."'
            AND (eventDate LIKE '".date("Y")."-%' OR eventDate LIKE '0004-%')", __FILE__, __LINE__);

        $row = mysql_fetch_assoc($query);
        $eventdate = strtotime(date("Y").substr($row['eventDate'], 4));

        mysql_free_result($query);

        echo '<div align="center">';
        echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . date("n",$eventdate) . '"><strong>' . date("M j",$eventdate) . '</strong></a>';
        echo ' - ';
        echo $holiday;
        echo '</div>';
    }
    echo '</td></tr>';
}

echo '</table>';

scott_68

  • Spezialist
  • ****
  • Beiträge: 79
  • Geschlecht: Männlich
Re: Mini Kalender für TP
« Antwort #13 am: 12. Juli 2008, 19:39:42 »
Vielen Dank Spawn !   :!.!:
Wer möchte kann den Kalender bei mir in Aktion sehen : www.zunft-hyboriens.de

Allerdings hat ein User von uns den Code nochmal winzig geändert, weiss jetzt aber nicht wo:

Code
global $scripturl, $modSettings, $context, $db_prefix, $user_profile;

smf_loadCalendarInfo();

$now = mktime() + $modSettings['time_offset'] * 3600;

$today = date('j',$now);
$year = date('Y',$now);
$month = date('n',$now);

$days = array($today=>array(NULL,NULL,'<a class="smalltext" style="color:steelblue; font-weight:bold; border:solid 1px black; background-color: white; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$today.'" target="_self">'.$today.'</a>'));

$day_name_length = 2;

$month_href = $scripturl . '?action=calendar&month=' . $month;
$first_day = 1;
$pn = array();

$first_of_month = gmmktime(0,0,0,$month,1,$year);

$day_names = array();                                      #generate all the day names according to the current locale
for($n=0,$t=(3+$first_day)*86400; $n<7; $n++,$t+=86400)    #January 4, 1970 was a Sunday
    $day_names[$n] = ucfirst(gmstrftime('%A',$t));         #%A means full textual day name

list($month, $year, $month_name, $weekday) = explode(',',gmstrftime('%m,%Y,%B,%w',$first_of_month));

$weekday = ($weekday + 7 - $first_day) % 7;                #adjust for $first_day
$title   = htmlentities(ucfirst($month_name)).' '.$year;   #note that some locales don't capitalize month and day names

@list($p, $pl) = each($pn); @list($n, $nl) = each($pn); #previous and next links, if applicable
if($p) $p = '<span class="smalltext">'.($pl ? '<a href="'.htmlspecialchars($pl).'">'.$p.'</a>' : $p).'</span> ';
if($n) $n = ' <span class="smalltext">'.($nl ? '<a href="'.htmlspecialchars($nl).'">'.$n.'</a>' : $n).'</span>';
$calendar = '<table align="center">'.'<caption >'.$p.($month_href ? '<a href="'.htmlspecialchars($month_href).'">'.$title.'</a>' : $title).$n.'</caption><tr>';

if($day_name_length){                                      #if the day names should be shown ($day_name_length > 0)
    foreach($day_names as $d)
    $calendar .= '<th class="smalltext" abbr="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</th>';
    $calendar .= '</tr><tr style="text-align:right;">';
    }

if($weekday > 0) $calendar .= '<td class="smalltext" colspan="'.$weekday.'"> </td>'; #initial 'empty' days

for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){
    if($weekday == 7){
        $weekday   = 0; #start a new week
        $calendar .= '</tr><tr style="text-align:right;">';
        }

    if(isset($days[$day]) and is_array($days[$day])){
        @list($link, $classes, $content) = $days[$day];
        if(is_null($content))  $content  = $day;
        $calendar .= '<td '.($classes ? ' class="'.htmlspecialchars($classes).'">' : '>').($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).'</td>';
        }
    else
        {
        $calendar .= '<td class="smalltext" style="padding-right:4px;"><a';
        if(((($weekday+$first_day) % 7)==0)||((($weekday+$first_day) % 7)==6))
            {
            $calendar .= ' style="color:#C00000;"';
            }
        $calendar .= ' href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$day.'" target="_self">'.$day.'</a></td>';
        }
    }

if($weekday != 7) $calendar .= '<td class="smalltext" colspan="'.(7-$weekday).'"> </td>'; #remaining "empty" days

echo $calendar.'</tr>';

/////////////////////////////////////////////////////////////////
//   BIRTHDAY SECTION
//
if (!empty($context['calendar_birthdays']) && ($context['user']['is_logged']))
{
    echo '<tr><td colspan="2"><hr></td><td colspan="3" class="smalltext" align="center" style="font-weight: bold; color: #' . $modSettings['cal_bdaycolor'] . ';">Geburtstage</td><td colspan="2"><hr></td></tr><td colspan="7" class="smalltext">';

    foreach ($context['calendar_birthdays'] as $member)
    {
        $query = db_query(
            "SELECT birthdate
            FROM {$db_prefix}members
            WHERE ID_MEMBER='".$member['id']."'", __FILE__, __LINE__);

        $row = mysql_fetch_assoc($query);
list ($uyear, $umonth, $uday) = explode('-', $row['birthdate']);
        $birthdate = strtotime(sprintf('%04d-%02d-%02d', date("Y"), $umonth, $uday));
        mysql_free_result($query);

        $dummy = array();
        $dummy[] = $member['id'];
        loadMemberData($dummy);
        $profile = &$user_profile[$member['id']];

        echo '<div align="center">';
        echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . date("n",$birthdate) . '"><strong>' . date("M j",$birthdate) . '</strong></a>';
        echo ' - ';
        echo '<a href="', $scripturl, '?action=profile;u=', $member['id'], '">';
        if (!empty($profile['member_group_color']))
        {
        echo '<font color="' . $profile['member_group_color'] . '">' . $member['name'] . (isset($member['age']) ? '(' . $member['age'] . ')' : '') . '</font>';
        }
        else
        {
        echo $member['name'] . (isset($member['age']) ? '(' . $member['age'] . ')' : '');
        }
        echo '</a>';
        echo '</div>';
    }
    echo '</td></tr>';
}

/////////////////////////////////////////////////////////////////
//   EVENTS SECTION
//
if (!empty($context['calendar_events']))
{
    echo '<tr><td colspan="2"><hr></td><td colspan="3" class="smalltext" align="center" style="font-weight: bold; color: #' . $modSettings['cal_eventcolor'] . ';">Ereignisse</td><td colspan="2"><hr></td></tr><td colspan="7" class="smalltext">';

    foreach ($context['calendar_events'] as $event)
    {
        $query = db_query(
            "SELECT startDate
            FROM {$db_prefix}calendar
            WHERE ID_EVENT='".$event['id']."'", __FILE__, __LINE__);

        $row = mysql_fetch_assoc($query);
        $startdate = strtotime($row['startDate']);

        mysql_free_result($query);

        echo '<div align="left">';
        echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . date("n",$startdate) . '"><strong>' . date("M j",$startdate) . '</strong></a>';
        echo ' - ';
        echo $event['link'] ;
        echo '</div>';
    }
    echo '</td></tr>';
}

/////////////////////////////////////////////////////////////////
//   HOLIDAY SECTION
// WHERE title='".str_replace("'","''",$holiday)."'
if (!empty($context['calendar_holidays']))
{
    echo '<tr><td colspan="2"><hr></td><td colspan="3" class="smalltext" align="center" style="font-weight: bold; color: #' . $modSettings['cal_holidaycolor'] . ';">Ferien</td><td colspan="2"><hr></td></tr><td colspan="7" class="smalltext">';

    foreach ($context['calendar_holidays'] as $holiday)
    {
        $query = db_query(
            "SELECT eventDate
            FROM {$db_prefix}calendar_holidays
            WHERE title='".str_replace("'","''",$holiday)."'
            AND (eventDate LIKE '".date("Y")."-%' OR eventDate LIKE '0004-%')", __FILE__, __LINE__);

        $row = mysql_fetch_assoc($query);
        $eventdate = strtotime(date("Y").substr($row['eventDate'], 4));

        mysql_free_result($query);

        echo '<div align="center">';
        echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . date("n",$eventdate) . '"><strong>' . date("M j",$eventdate) . '</strong></a>';
        echo ' - ';
        echo $holiday;
        echo '</div>';
    }
    echo '</td></tr>';
}

echo '</table>';
TP 0.9.8 + SMF 1.1.x

 

Internes

Nutzungsbedingungen Impressum

Wissenswertes

Hilfe Knowledge Base

Nützliches

Downloads Socialmedia