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

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 629
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 396
  • Total: 396

SMF Calendar Block

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

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Rus

DOH!

I made a couple changes myself.  Would you be able to let me know what you changed?

I changed the alignment to left for the results of all the searches

Rus

Never mind, thanks for the great code.  This time I was able to remember which centers to change and didnt screw it up like I did the first time.  :)

Rus

Thanks again for such a great calendar block.  I have it in 3 forums I run now.

I would like to mention that today is the 9th and in Holidays I still have Canadian Thanksgiving which falls on the 8th this year showing up in the block.

jacortina

Quote from: Rus on October 10, 2007, 06:07:36 AM
Thanks again for such a great calendar block.  I have it in 3 forums I run now.

I would like to mention that today is the 9th and in Holidays I still have Canadian Thanksgiving which falls on the 8th this year showing up in the block.

Yep. I see that the computation for lowdate for highlighting (the processing for which I made use of to eliminate redundant SQL call) actually went back one day from current forum date. Fixed this in latest code in post to follow.


jacortina

One more time.

Tracked down dannbass' problem with days when using the Non-Enblish.
Added an alignment parameter for the list entries (hope that helps, Rus).

Biggest enhancement was to allow specification of class to use for just about every element/element type

And again:

Plenty of comments in the code and notes about use, but here's a summary.

Numerous options selectable by parameters including:

  • Individual selections to choose to show Birthday, Event, Holiday Lists.
  • Separate individual selections to choose to show same to guests.
  • Separate text colors for each of Saturdays, Sundays.
  • Parameterized foreground and background colors for 'Today' highlight.
  • Choice to have day numbers link to 'Post Event' form or Calendar page display (with SMF 'post event' permission check).
  • Option to show a 'Post Event' button on bottom of block (with SMF 'post event' permission check).
  • Variables for text of list section labels ('Birthdays', 'Events', 'Holidays').
  • Option to highlight day numbers for days with Birthdays, Events, Holidays.
  • Variables for foreground, backround, bolding to use for highlights.
  • Ability to specify sequence of the list sections shown.
  • Ability to specify 'priority' of highlighting.
  • Can allow for user's time offset for determination of 'today'.
  • Still able to choose Sunday or Monday as start of week.
  • Still able to choose how many letters of day names to show.

Latest:

  • Fix Non-English days alignment.
  • Parameterized alignment for list entries.
  • Allow class specification for nearly all elements.
  • Entry list class can be none (use overall default w/smalltext), single, or two alternating classes.
  • Allowed specification of color for entry list lables so can use other than the admin specified colors for entry type (which might not show up on background of desired class).


Highlighting does NOT highlight past days, only days going forward.

Additionally, there's an example section, currently commented out, to show
how to use Non-English Labels, Month and Day names in place.

Also modified to avoid all SQL queries in the block itself (and optimized
usage of SMF functions likely to perform queries).

I've done what testing I can, but no board I admin makes much use of events,
so apart from a couple of dummy entries for the purpose of testing, that part
of the code isn't as well 'shaken down'.

Go to it, guys. Find the bugs and I'll fix them.


/******************************************************************************************
*                                                                                         *
* 'Mini' Calendar in phpblock -                                                           *
*                                                                                         *
* Program Parameters/Switches can be specified to change what is displayed and how.       *
*   If highlighting is turned on, only the types of entries which are selected to         *
*   be shown will be highlighted (and have to be shown to guests for guests to see        *
*   highlights). If option of linking the day numbers to calendar event posting form      *
*   is chosen ($date_links_to_posting = true), SMF permissions are in effect and only     *
*   those allowed to post events to the calendar will have this link in effect. For       *
*   $date_links_to_posting = false, and for those not permitted to post events, day       *
*   numbers will link to the full SMF Calendar page. Additionally, if option to show      *
*   a separate 'Post Event' button is chosen ($show_post_event_button = true), it will    *
*   only show for those permitted to post events to the calendar.                         *
*                                                                                         *
* Look for 'NON-ENGLISH' to see section for changing language. This is actually more      *
*   correctly referred to as 'language other than server default' as this Calendar will   *
*   use the server's default LOCALE language for Month and Day names unless overides      *
*   are specified in the code section labeled 'NON-ENGLISH  LABELS, MONTH & DAY NAMES',   *
*   below.                                                                                *
*                                                                                         *
* Once a given day is highlighted, the highlight will not be supplanted. That means       *
*   you may want to modify the order in which highlights are applied in order to set      *
*   desired 'precedence' (i.e. if b-days highlights are applied first, once a given       *
*   day is highlighted with b-day color, it will not be changed to be highlighted         *
*   with event color if an event occurs on the same day; you need to choose an order      *
*   of precedence and sequence the highlighting accordingly by changing the sequence      *
*   of sections in the $order_hilites array. Highlighting will be done in the given       *
*   order.                                                                                *
*                                                                                         *
* Also, if you want the individual B-day/Event/Holiday sections to be ordered in a        *
*   different sequence, you need to change the sequence of entries in the $order_lists    *
*   array.                                                                                *
*                                                                                         *
* Examples of highlighting can be seen in the section 'Highlight colors & backgrounds'    *
*   below. As given, highlighting is done by applying the admin specified calendar        *
*   entry color to the date, bolded, on the default background. Commented example given   *
*   of using bold white on a background box of the admin specified calendar entry color.  *
*                                                                                         *
******************************************************************************************/
global $scripturl, $modSettings, $context, $db_prefix, $user_profile, $user_info, $sourcedir;

/////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  Program Paramters/Switches Section
//

// use forum's date/time
//$now = mktime() + $modSettings['time_offset'] * 3600;                                 
// include user's time offset to forum date/time
$now = mktime() + (($user_info['time_offset'] + $modSettings['time_offset']) * 3600);

// Order to do highlightling - earlier have precedence
$order_hilites = array('Birthdays', 'Events', 'Holidays');

// Order to show calendar entry lists
$order_lists = array('Birthdays', 'Events', 'Holidays');

// Alignment of calendar entry lists
// $align_list_entries = 'left';
$align_list_entries = 'center';

// Letters to show on calendar for names of each of the days
$day_name_length = 2;

// Selection for first day of the week: 0-Sunday; 1-Monday
$first_day = 0;

// Show B-Day list at all / to guests
$show_bdays = true;
$show_bdays_to_guests = false;

// Show Event list at all / to guests
$show_events = true;
$show_events_to_guests = true;

// Show Holiday list at all / to guests
$show_hdays = true;
$show_hdays_to_guests = true;

// If true, calendar date numbers link to calendar event posting form
//    if not, links to full calendar page
$date_links_to_posting = false;

// Adds 'Post Event' button to bottom of block
$show_post_event_button = false; 

// Highlight events, b-days, holidays (only if they're selected to show at all)
$show_hilites = true;         

$color_sunday = '#D00000';    // comment out to use default text colors -
$color_saturday = '#D00000';  //   can use hex codes with leading '#'
$color_today = 'steelblue';   //   or color names
$bkgrd_today = 'white';

// Default class to use when no other class specified
$class_default = '';
// $class_default = 'smalltext';
// $class_default = 'windowbg2';

// Class to use for column top day names
// $class_day_names = 'titlebg';  // Ex.: titlebg, catbg, catbg2, catbg3, windowbg, windowbg2, windowbg3

// Class to use for 'Today' highlight
$class_today = 'windowbg2';

// Text Labels to use for calendar entry lists
$list_label_bdays = '-------  Birthdays  -------';
$list_label_events = '----------  Events  ----------';
$list_label_hdays = '-------  Holidays  -------';

// Colors for text labels on calendar entry lists
$list_label_bdays_color = '#'.$modSettings['cal_bdaycolor'];
$list_label_events_color = '#'.$modSettings['cal_eventcolor'];
$list_label_hdays_color = '#'.$modSettings['cal_holidaycolor'];

// Class for 'cells' holding text labels on calendar entry lists
// $list_label_class = 'titlebg'; // Ex.: titlebg, catbg, catbg2, catbg3, windowbg, windowbg2, windowbg3

// Class for 'cells' holding calendar entry lists
//   use regular variable for all same class
//   use two-member array to alternate between the two
$list_entry_class = '';
// $list_entry_class = 'windowbg';
// $list_entry_class = array('windowbg2','windowbg3');

///////////////////////////////
//   Highlight colors & backgrounds
//
//   Admin-specified birthday color: $modSettings['cal_bdaycolor']
//   Admin-specified event color:    $modSettings['cal_eventcolor']
//   Admin-specified holiday color:  $modSettings['cal_holidaycolor']

// Highlight bold white on backgound of forum's defined color for date entry type
//
// $hilite_bday_color = 'white';
// $hilite_bday_bkgrd = '#'.$modSettings['cal_bdaycolor'];
// $hilite_bday_bold = true;
// $hilite_bday_class = '';
//
// $hilite_event_color = 'white';
// $hilite_event_bkgrd = '#'.$modSettings['cal_eventcolor'];
// $hilite_event_bold = true;
// $hilite_event_class = '';
//
// $hilite_hday_color = 'white';
// $hilite_hday_bkgrd = '#'.$modSettings['cal_holidaycolor'];
// $hilite_hday_bold = true;
// $hilite_hday_class = '';
////////////////////////////////

// Highlight bolded color for date entry type on default backgound
//
$hilite_bday_color = '#'.$modSettings['cal_bdaycolor'];
// $hilite_bday_bkgrd = '';
$hilite_bday_bold = true;
// $hilite_bday_class = 'windowbg3';
//
$hilite_event_color = '#'.$modSettings['cal_eventcolor'];
// $hilite_event_bkgrd = '';
$hilite_event_bold = true;
// $hilite_event_class = 'windowbg3';
//
$hilite_hday_color = '#'.$modSettings['cal_holidaycolor'];
// $hilite_hday_bkgrd = '';
$hilite_hday_bold = true;
// $hilite_hday_class = 'windowbg3';
////////////////////////////////

/////////////////////////////////////////////// NON-ENGLISH  LABELS, MONTH & DAY NAMES (start)
//
// Non-English Labels, Month and Day Names
//
// To use Month and Day names other than the default on your server,
//   remove the two asterisk '*******' lines (the first starts with '/***'
//   and the second ends '***/') and supply the List Section Labels and the
//   Month and Day names to use per instructions below.
//

/**********************************************************
$list_label_bdays = 'Birthdays';  // Change to labels in language of choice
$list_label_events = 'Events';
$list_label_hdays = 'Holidays';

//
// specify all the day names in desired language
//   if you specify "$first_day = 1;" above, first entry below must be for Monday; e.g:
//      when $first_day = 0;  then $day_names = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
//      when $first_day = 1;  then $day_names = array('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday');
//   
$day_names = array('Lunes','Martes','Miercoles','Jueves','Viernes','Sabado','Domingo');

//
// specify the month names in desired language
//   
$month_nam = array();
$month_nam['01'] = 'Enero';       
$month_nam['02'] = 'Febrero';
$month_nam['03'] = 'Marzo';
$month_nam['04'] = 'Abril';
$month_nam['05'] = 'Mayo';
$month_nam['06'] = 'Junio';
$month_nam['07'] = 'Julio';
$month_nam['08'] = 'Agosto';
$month_nam['09'] = 'Septiembre';
$month_nam['10'] = 'Octubre';
$month_nam['11'] = 'Noviembre';
$month_nam['12'] = 'Diciembre';
$month_name = $month_nam[date('m',$now)];
//
**********************************************************/
/////////////////////////////////////////////// NON-ENGLISH  LABELS, MONTH & DAY NAMES (end)

//
//  Program Paramters/Switches Section - End
//    (modify below at your own risk!!!)
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////

$hi_bday_color = '';
if (isset($hilite_bday_color)) $hi_bday_color = 'color:'.$hilite_bday_color.'; ';
$hi_bday_bkgrd = '';
if (isset($hilite_bday_bkgrd)) $hi_bday_bkgrd = 'background-color: '.$hilite_bday_bkgrd.'; ';
$hi_bday_fontwt = '';
if (isset($hilite_bday_bold) && $hilite_bday_bold) $hi_bday_fontwt = 'font-weight:bold; ';

$hi_event_color = '';
if (isset($hilite_event_color)) $hi_event_color = 'color:'.$hilite_event_color.'; ';
$hi_event_bkgrd = '';
if (isset($hilite_event_bkgrd)) $hi_event_bkgrd = 'background-color: '.$hilite_event_bkgrd.'; ';
$hi_event_fontwt = '';
if (isset($hilite_event_bold) && $hilite_event_bold) $hi_event_fontwt = 'font-weight:bold; ';

$hi_hday_color = '';
if (isset($hilite_hday_color)) $hi_hday_color = 'color:'.$hilite_hday_color.'; ';
$hi_hday_bkgrd = '';
if (isset($hilite_hday_bkgrd)) $hi_hday_bkgrd = 'background-color: '.$hilite_hday_bkgrd.'; ';
$hi_hday_fontwt = '';
if (isset($hilite_hday_bold) && $hilite_hday_bold) $hi_hday_fontwt = 'font-weight:bold; ';

// --------------------------------------

if (!isset($class_default)) $class_default = 'smalltext';
if ($class_default == '') $class_default = 'smalltext';

smf_loadCalendarInfo();

//$today = date('j',$now);
$today = strftime('%d', $now);
$year = date('Y',$now);
$month = date('n',$now);

$nowdate = strftime('%Y-%m-%d', $now);

$month_href = $scripturl . '?action=calendar;year='.$year.';month='.$month;

require_once($sourcedir . '/Calendar.php');
$low_date = strftime('%Y-%m-%d', $now);
$high_date = strftime('%Y-%m-%d', $now + max(($modSettings['cal_days_for_index'] - 1),0) * 24 * 3600);

$bdays = calendarBirthdayArray($low_date, $high_date);
ksort($bdays);
$events = calendarEventArray($low_date, $high_date, false);
ksort($events);
$holidays = calendarHolidayArray($low_date, $high_date);
ksort($holidays);

$todays_color = '';
if (isset($color_today)) $todays_color = 'color:'.$color_today.'; ';
$todays_bkgrd = '';
if (isset($bkgrd_today)) $todays_bkgrd = 'background-color: '.$bkgrd_today.'; ';

$stub = '<a class="smalltext" style="'.$todays_color.'font-weight:bold; border:solid 1px black; '.$todays_bkgrd.'padding: 0px 2px 0px 2px;"';
if ($date_links_to_posting && allowedTo('calendar_post')) {
    $days = array($today=>array(NULL,$class_today,$stub.' href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$today.'" target="_self">'.date('j',$now).'</a>'));}
else {
    $days = array($today=>array(NULL,$class_today,$stub.' href="'.htmlspecialchars($month_href).'" target="_self">'.date('j',$now).'</a>'));}

////////////////////////////////////////////////////////////////////////////// HIGHLIGHTING (start)
//
if ($show_hilites) {
    foreach($order_hilites as $hilite_to_do){
        $flag = strtoupper(substr($hilite_to_do,0,1));

///////////////////////////////////////////////// B-Day Highlighting
        if ($flag == 'B') {
            if ($show_bdays) {
                if ($show_bdays_to_guests or !$user_info['is_guest']) {
                    $stub = '<a class="smalltext" style="'. $hi_bday_color . $hi_bday_bkgrd . $hi_bday_fontwt .'padding: 0px 2px 0px 2px;"';
                    if (!isset($hilite_bday_class)) $hilite_bday_class = $class_default;
                    if ($hilite_bday_class == '') $hilite_bday_class = $class_default;
                    foreach($bdays as $startdate => $value)
                        if(!isset($days[substr($startdate,8)]) or !is_array($days[substr($startdate,8)])) {
                            if (($startdate > $nowdate) && (substr($startdate,5,2) == substr($nowdate,5,2))) {
                                if ($date_links_to_posting && allowedTo('calendar_post')) {
                                    $days[substr($startdate,8)] = array(NULL,$hilite_bday_class,$stub.' href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.substr($startdate,8).'" target="_self">'.sprintf('%d',substr($startdate,8)).'</a>');}
                                else {
                                    $days[substr($startdate,8)] = array(NULL,$hilite_bday_class,$stub.' href="'.htmlspecialchars($month_href).'" target="_self">'.sprintf('%d',substr($startdate,8)).'</a>');}
                            }
                        }
                }
            }
        }
////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////// Event Highlighting
        if ($flag == 'E') {
            if ($show_events) {
                if ($show_events_to_guests or !$user_info['is_guest']) {
                    $stub = '<a class="smalltext" style="'. $hi_event_color . $hi_event_bkgrd . $hi_event_fontwt .'padding: 0px 2px 0px 2px;"';
                    if (!isset($hilite_event_class)) $hilite_event_class = $class_default;
                    if ($hilite_event_class == '') $hilite_event_class = $class_default;
                    foreach($events as $startdate => $value)
                        if(!isset($days[substr($startdate,8)]) or !is_array($days[substr($startdate,8)])) {
                            if (($startdate > $nowdate) && (substr($startdate,5,2) == substr($nowdate,5,2))) {
                                if ($date_links_to_posting && allowedTo('calendar_post')) {
                                    $days[substr($startdate,8)] = array(NULL,$hilite_event_class,$stub.' href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.substr($startdate,8).'" target="_self">'.sprintf('%d',substr($startdate,8)).'</a>');}
                                else {
                                    $days[substr($startdate,8)] = array(NULL,$hilite_event_class,$stub.' href="'.htmlspecialchars($month_href).'" target="_self">'.sprintf('%d',substr($startdate,8)).'</a>');}
                            }
                        }
                }
            }
        }
////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////// Holiday Highlighting
        if ($flag == 'H') {
            if ($show_hdays) {
                if ($show_hdays_to_guests or !$user_info['is_guest']) {
                    $stub = '<a class="smalltext" style="'. $hi_hday_color . $hi_hday_bkgrd . $hi_hday_fontwt .'padding: 0px 2px 0px 2px;"';
                    if (!isset($hilite_hday_class)) $hilite_hday_class = $class_default;
                    if ($hilite_hday_class == '') $hilite_hday_class = $class_default;
                    foreach($holidays as $startdate => $value)
                        if (!isset($days[substr($startdate,8)]) or !is_array($days[substr($startdate,8)])) {
                            if (($startdate > $nowdate) && (substr($startdate,5,2) == substr($nowdate,5,2))) {
                                if ($date_links_to_posting && allowedTo('calendar_post')) {
                                    $days[substr($startdate,8)] = array(NULL,$hilite_hday_class,$stub.' href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.substr($startdate,8).'" target="_self">'.sprintf('%d',substr($startdate,8)).'</a>');}
                                else {
                                    $days[substr($startdate,8)] = array(NULL,$hilite_hday_class,$stub.' href="'.htmlspecialchars($month_href).'" target="_self">'.sprintf('%d',substr($startdate,8)).'</a>');}
                            }
                        }
                }
            }
        }
////////////////////////////////////////////////////////////////////
    }
}

////////////////////////////////////////////////////////////////////////////// HIGHLIGHTING (end)

$first_of_month = gmmktime(0,0,0,$month,1,$year);
list($month, $year, $weekday) = explode(',',gmstrftime('%m,%Y,%w',$first_of_month));

if (!isset($month_nam['12'])) {
    $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

$calendar = '<table align="center">'.'<caption >'.($month_href ? '<a href="'.htmlspecialchars($month_href).'">'.$title.'</a>' : $title).'</caption><tr>';

if (!isset($class_day_names)) $class_day_names = $class_default;
if ($class_day_names == '') $class_day_names = $class_default;
if($day_name_length){                                      #if the day names should be shown ($day_name_length > 0)
    foreach($day_names as $d)
    $calendar .= '<th class="'.$class_day_names.'" align="center" valign="middle" style="padding-left: 0px; padding-right: 0px;font-size: x-small;" 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="'.$class_default.'" 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;">';
        }

    $daynow = sprintf('%02d',$day);
    $col_width = ' width="14%"';
    if ( ((($weekday+$first_day) % 7) == 0) || ((($weekday+$first_day) % 7) == 0) ) $col_width = ' width="15%"';

    if(isset($days[$daynow]) and is_array($days[$daynow])){
        @list($link, $classes, $content) = $days[$daynow];
        if(is_null($content))  $content  = $daynow;
        $calendar .= '<td'.$col_width.' align="center" valign="middle" '.($classes ? ' class="'.htmlspecialchars($classes).'" style="padding: 0px 0px 0px 0px;font-size: x-small;">' : '>').($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).'</td>';
        }
    else
        {
        $calendar .= '<td'.$col_width.' class="'.$class_default.'" align="center" valign="middle" style="padding: 0px 0px 0px 0px;font-size: x-small;"><a class="smalltext"';
        if (((($weekday+$first_day) % 7) == 0) && isset($color_sunday))
            $calendar .= ' style="color:'.$color_sunday.';"';
        if (((($weekday+$first_day) % 7) == 6) && isset($color_saturday))
            $calendar .= ' style="color:'.$color_saturday.';"';
        if ($date_links_to_posting && allowedTo('calendar_post')) {
            $calendar .= ' href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$day.'" target="_self">'.$day.'</a></td>';}
        else {
            $calendar .= ' href="'.htmlspecialchars($month_href).'" target="_self">'.$day.'</a></td>';}
        }
    }

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

echo $calendar.'</tr>';

foreach($order_lists as $list_to_do){
    $flag = strtoupper(substr($list_to_do,0,1));

if (!isset($align_list_entries)) $align_list_entries = 'center';
if (isset($align_list_entries))
    if ($align_list_entries <> 'left') $align_list_entries = 'center';

/////////////////////////////////////////////////////////////////
//   BIRTHDAY SECTION
//
if(($flag == 'B') and $show_bdays) {
    if($show_bdays_to_guests or !$user_info['is_guest']) {

        if (!empty($context['calendar_birthdays']))
        {
            $class_to_use = '';
            if (isset($list_label_class)) $class_to_use = ' class="'.$list_label_class.'"';
            echo '<tr'.$class_to_use.'><td colspan="7" class="smalltext" align="center" style="font-weight: bold; color: ' . $list_label_bdays_color . ';">'.$list_label_bdays.'</td></tr><tr><td colspan="7" class="smalltext">';

            $dummy = array();
            foreach ($context['calendar_birthdays'] as $member)
                $dummy[] = $member['id'];

            loadMemberData($dummy);

            $ctr = 0;

            foreach ($context['calendar_birthdays'] as $member)
            {
                $class_to_use = '';
                if (isset($list_entry_class))
                    if (!is_array($list_entry_class)) {
                        $class_to_use = ' class="'.$list_entry_class.'"';
                    }
                    else {
                        $class_to_use = ' class="'.$list_entry_class[($ctr++) % 2].'"';
                    }
                $profile = &$user_profile[$member['id']];
                $birthdate = empty($profile['birthdate']) || $profile['birthdate'] === '0001-01-01' ? '0000-00-00' : (substr($profile['birthdate'], 0, 4) === '0004' ? '0000' . substr($profile['birthdate'], 4) : $profile['birthdate']);

                list ($uyear, $umonth, $uday) = explode('-', $birthdate);
                $birthdate = strtotime(sprintf('%04d-%02d-%02d', date("Y"), $umonth, $uday));

                echo '<div'.$class_to_use.' align="'.$align_list_entries.'">';
                if (!isset($month_nam['12'])) {
                    echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . date("n",$birthdate) . '"><strong>' . date("M j",$birthdate) . '</strong></a>';}
                else {   
                    echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . date("n",$birthdate) . '"><strong>' . substr($month_nam[strftime('%m', $birthdate)],0,3) . date(" j",$birthdate) . '</strong></a>';}
                echo ' - ';
                echo '<a href="', $scripturl, '?action=profile;u=', $member['id'], '">';

                if ((date('Y',$now).date('m',$now).date('d',$now)) == (date('Y',$birthdate).date('m',$birthdate).date('d',$birthdate)))
                    $member['name'] = '<b>'.$member['name'].'</b>';

                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(($flag == 'E') and $show_events) {
    if($show_events_to_guests or !$user_info['is_guest']) {

        if (!empty($context['calendar_events']))
        {
            $class_to_use = '';
            if (isset($list_label_class)) $class_to_use = ' class="'.$list_label_class.'"';
            echo '<tr'.$class_to_use.'><td colspan="7" class="smalltext" align="center" style="font-weight: bold; color: ' . $list_label_events_color . ';">'.$list_label_events.'</td></tr><tr><td colspan="7" class="smalltext">';

            $ctr = 0;

            foreach ($context['calendar_events'] as $event)
            {
                $class_to_use = '';
                if (isset($list_entry_class))
                    if (!is_array($list_entry_class)) {
                        $class_to_use = ' class="'.$list_entry_class.'"';
                    }
                    else {
                        $class_to_use = ' class="'.$list_entry_class[($ctr++) % 2].'"';
                    }
                $startdate = strtotime($event['start_date']);

                $cal_date = date("Y", $now) . date("m", $now) .date("d", $now);
                $evt_date = date("Y", $startdate) . date("m", $startdate) .date("d", $startdate);
                if($cal_date > $evt_date)
                    $startdate = $now;

                echo '<div'.$class_to_use.' align="'.$align_list_entries.'">';
                if (!isset($month_nam['12'])) {
                    echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . date("n",$startdate) . '"><strong>' . date("M j",$startdate) . '</strong></a>';}
                else {   
                    echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . date("n",$startdate) . '"><strong>' . substr($month_nam[strftime('%m', $startdate)],0,3) . date(" j",$startdate) . '</strong></a>';}
                echo ' - ';
                if ((date('Y',$now).date('m',$now).date('d',$now)) >= (date('Y',$startdate).date('m',$startdate).date('d',$startdate))) {
                    echo '<b>',$event['link'], '</b>';}
                else {
                    echo $event['link'] ;}
                echo '</div>';
            }
            echo '</td></tr>';
        }
    }
}

/////////////////////////////////////////////////////////////////
//   HOLIDAY SECTION
//
if(($flag == 'H') and $show_hdays) {
    if($show_hdays_to_guests or !$user_info['is_guest']) {

        if (!empty($holidays))
        {
            $class_to_use = '';
            if (isset($list_label_class)) $class_to_use = ' class="'.$list_label_class.'"';
            echo '<tr'.$class_to_use.'><td colspan="7" class="smalltext" align="center" style="font-weight: bold; color: ' . $list_label_hdays_color . ';">'.$list_label_hdays.'</td></tr><tr><td colspan="7" class="smalltext">';

            $ctr = 0;

            foreach ($holidays as $hDate => $hday)
            {
                $eventdate = strtotime(date("Y").substr($hDate, 4));

                foreach ($hday as $holiday)
                {
                    $class_to_use = '';
                    if (isset($list_entry_class))
                       if (!is_array($list_entry_class)) {
                            $class_to_use = ' class="'.$list_entry_class.'"';
                        }
                        else {
                            $class_to_use = ' class="'.$list_entry_class[($ctr++) % 2].'"';
                        }
                    echo '<div'.$class_to_use.' align="'.$align_list_entries.'">';
                    if (!isset($month_nam['12'])) {
                        echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . date("n",$eventdate) . '"><strong>' . date("M j",$eventdate) . '</strong></a>';}
                    else {   
                        echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . date("n",$eventdate) . '"><strong>' . substr($month_nam[strftime('%m', $eventdate)],0,3) . date(" j",$eventdate) . '</strong></a>';}
                    echo ' - ';
                    echo $holiday;
                    echo '</div>';
                }
            }
            echo '</td></tr>';
        }
    }
}
}

if ($show_post_event_button) {
        if (allowedTo('calendar_post')) {
            echo '<tr><td colspan="7" class="'.$class_default.'" align="center" valign="middle">';
            echo '<hr/ >';
            echo '<a href="', $scripturl,  '?action=calendar;sa=post;month=', $month, ';year=', $year, ';sesc=', $context['session_id'], '">','<br />', create_button('calendarpe.gif', 'calendar23', 'calendar23', 'align="middle"'), '</a>';
            echo '</td></tr>';
    }
}

echo '</table>';

Rus

I dont know if it was in there before and you just added the alignment thing now because I mentioned it but if you did, thanks for listening.  That is a marvelous feature.  :)

jacortina

Quote from: Rus on October 10, 2007, 04:54:14 PM
I dont know if it was in there before and you just added the alignment thing now because I mentioned it but if you did, thanks for listening.  That is a marvelous feature.  :)

No problem. ;)

Fairly easy to add (considering I was tweaking all the places it was used anyway).

And going forward, when providing support for the block, the more people that can use it AS-IS (changing only some variable values rather than the code further down), the easier it'll be on me.  ;D

dannbass

THANK YOU!!!!!!!

The language bug is gone, it works perfect!!!! I don't know what to tell you, only that I'm the most grateful and happy TP user ever!!! you are my heroe!!!!

If I have a silly question about the looks I'll ask, and when I have it done I'll post a picture.

Thank you very much!!!

dannbass

Ok, I have one question... I included in the <table> a class="bordercolor" just to have the boxes with a division line, but it didn't apply to the listing in the birthdays, events and holidays.  Is there a way to include them in the table so they will have the bordercolor line as well?

Here is how it looks now, which is terrific BTW!!

Thanks a lot again!

This website is proudly hosted on Crocweb Cloud Website Hosting.