TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

April 19, 2024, 04:30:29 AM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,164
  • Total Topics: 21,219
  • Online today: 266
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 232
  • Total: 232

SMF Calendar Block

Started by Lesmond, September 03, 2005, 11:30:42 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

soMzE

This a great snippit, really cool!!

But one strange thing i see, valentines day is on Jan 1?  :D

jacortina

Find the section that lists holidays (the last section in the block), and find the line:
$eventdate = strtotime($row['eventDate']);

Change it to:
$eventdate = strtotime(date("Y").substr($row['eventDate'], 4));

soMzE

Thank you so much J.A.Cortina, that did the job! It's all perfect now  ;D



brianjw

Quote from: soMzE on February 08, 2007, 02:27:33 AM
Thank you so much J.A.Cortina, that did the job! It's all perfect now  ;D
I am interested in what code you are using ??? Does this calendar link in with the existing smf calendar that links the holidays/bdays/events/and days to? If not maybe someone can create something exactly like this but with links on holidays/bdays/events/and days !

Brianjw

soMzE

#244
Quote from: brianjw on February 08, 2007, 03:33:13 AM
Quote from: soMzE on February 08, 2007, 02:27:33 AM
Thank you so much J.A.Cortina, that did the job! It's all perfect nowÃ,  ;D
I am interested in what code you are using ??? Does this calendar link in with the existing smf calendar that links the holidays/bdays/events/and days to? If not maybe someone can create something exactly like this but with links on holidays/bdays/events/and days !

Brianjw

This is the code i'm using for the calendar snippet:

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 = 0;
$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 style="width:100%;">'.'<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']))
{
Ã,  Ã,  echo '<tr><td colspan="2"><hr></td><td colspan="3" class="smalltext" align="center" style="font-weight: bold; color: #' . $modSettings['cal_bdaycolor'] . ';">Birthdays</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'] . ';">Events</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
//
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'] . ';">Holidays</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>';


And yes it links to the existing calendar as far as i can seeÃ,  ::)
I can click the links on this block and it directs straightly to the calendar of smf :)

And if i change the colors in the admin section of the calendar it will change as well..


Hope this answers your question :)

jacortina

If you look at the picture given by soMzE, The numbers in the small calendar and the dates for the b-days/events/holdays ('Feb 14') are links which will bring up the SMF calandar to that date. The user names (which are membergroup colored) are links to the corresponding profiles.

brianjw

Thank you! :D I now use the code soMzE provided me :)
Code (Code soMzE provided me) Select

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 = 0;
$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 style="width:100%;">'.'<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']))
{
    echo '<tr><td colspan="2"><hr></td><td colspan="3" class="smalltext" align="center" style="font-weight: bold; color: #' . $modSettings['cal_bdaycolor'] . ';">Birthdays</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'] . ';">Events</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
//
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'] . ';">Holidays</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>';


;)
Brianjw

clarkkent93

Quote from: soMzE on February 08, 2007, 03:39:38 AM
Quote from: brianjw on February 08, 2007, 03:33:13 AM
Quote from: soMzE on February 08, 2007, 02:27:33 AM
Thank you so much J.A.Cortina, that did the job! It's all perfect now  ;D
I am interested in what code you are using ??? Does this calendar link in with the existing smf calendar that links the holidays/bdays/events/and days to? If not maybe someone can create something exactly like this but with links on holidays/bdays/events/and days !

Brianjw

This is the code i'm using for the calendar snippet:

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 = 0;
$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 style="width:100%;">'.'<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']))
{
    echo '<tr><td colspan="2"><hr></td><td colspan="3" class="smalltext" align="center" style="font-weight: bold; color: #' . $modSettings['cal_bdaycolor'] . ';">Birthdays</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'] . ';">Events</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
//
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'] . ';">Holidays</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>';


And yes it links to the existing calendar as far as i can see  ::)
I can click the links on this block and it directs straightly to the calendar of smf :)

And if i change the colors in the admin section of the calendar it will change as well..


Hope this answers your question :)

What kind of block is this?

Thanks

jacortina

Quote from: clarkkent93 on February 10, 2007, 08:50:35 AM
What kind of block is this?

Thanks

PHP block. Like the threed title says. ;)

clarkkent93

 :uglystupid2:  it's official.  i've lost it!

thanks for your help!

bernard