TinyPortal

Development => Support => Topic started by: MoreBloodWine on April 05, 2011, 05:53:02 AM

Title: Left block calendar ??? - Updated 4/16/2011
Post by: MoreBloodWine on April 05, 2011, 05:53:02 AM
How can I get a calendar on my site exactly like the one in the left block here, I really like it.
Title: Re: Left block calendar ???
Post by: lurkalot on April 05, 2011, 07:56:10 AM
I believe the one used on this site is one ZarPrime mentions here,  http://www.tinyportal.net/index.php?topic=32717.msg262975#msg262975

Hope this helps.
Title: Re: Left block calendar ???
Post by: ZarPrime on April 05, 2011, 07:58:45 AM
Yeah, as Lurk said but, that one is only for SMF 2.0 and the latest TP.

ZarPrime
Title: Re: Left block calendar ???
Post by: MoreBloodWine on April 05, 2011, 08:36:13 AM
Quote from: ZarPrime on April 05, 2011, 07:58:45 AM
Yeah, as Lurk said but, that one is only for SMF 2.0 and the latest TP.

ZarPrime
I'm on RC5 right now for my live site and the latest TP so I should be good to go then.
Title: Re: Left block calendar ???
Post by: MoreBloodWine on April 05, 2011, 08:47:08 AM
http://www.eojmarket.com/index.php

I got this installed on my site but I'm a little less than thrilled with how it looks. What needs to be changed and where to get the EXACT same look as the mini calendar seen here and below BUT with events in the same layout as Birthdays & Holidays ?

(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fwww.eojmarket.com%2FNonForumStuff%2Fimages%2Ftpcalendar.png&hash=11d4bd8179a053a4a1c8623b2663f708526dcbfe)

Title: Re: Left block calendar ???
Post by: lurkalot on April 05, 2011, 09:07:55 AM
Just compared the block code I pointed you to, and the one we are using here.  They are different. 

Let's see if ZarPrime can point us both to the correct version.

Sorry if I mislead you.  ;)
Title: Re: Left block calendar ???
Post by: MoreBloodWine on April 05, 2011, 09:18:08 AM
Quote from: lurkalot on April 05, 2011, 09:07:55 AM
Just compared the block code I pointed you to, and the one we are using here.  They are different. 

Let's see if ZarPrime can point us both to the correct version.

Sorry if I mislead you.  ;)
Np, I dont mean to sound as if this version is crap because it's not, I just sort of fell in love with the way the one here looks. Only thing I would like to change is adding Events using the same layout as Holidays & Birthdays. Once thats done it will be the best TP calendar block ever.
Title: Re: Left block calendar ???
Post by: ZarPrime on April 05, 2011, 03:28:40 PM
MoreBloodWine,

I split the posts from the other topic you posted in and merged them to this topic.  Please don't cross post the same issue in two different topics.  It gets confusing.

The only difference between the one used here and the one in the topic that Lurkalot linked you to is that Guests are allowed to see Birthdays here.  That is changed in the parameters section of the code.  "$show_bdays_to_guests = false;" is changed to "$show_bdays_to_guests = true;" on this site.

Please bear in mind that this mini-calendar will look different on different themes.  The background cells may not show up as well on a dark theme as it does on a light theme.  Try it on the default SMF theme.  How does it look with Curve?  Are you using the latest version of Crip's BlackRain V2 theme (for RC5) on your site?  I can't change the theme on your site so I can't look at it.

I just setup another mini-calendar shown on at the bottom of the left panel (temporarily) of the Forum BoardIndex here (only) using the code from the topic Lurkalot linked you to.  I also added an event (USA Tax Day) to our calendar.  It looks exactly the same as the one on our FrontPage.

If you can't get it to look like the one we have here, post the code you are using in the block on your site using code tags so that I can look at it.

ZarPrime
Title: Re: Left block calendar ???
Post by: MoreBloodWine on April 05, 2011, 11:24:59 PM
The code I'm using is the code in the post you spit me from, and I only posted to that thread because the code I used from it.

Anyway, the code from that post is givin me the calendar seen in my pic that I would like to have modified for the exact same look as the one here but with the addition of Events.

Ps; I Know things look diff on diff themes but thats not what Im talking about.
Title: Re: Left block calendar ???
Post by: ZarPrime on April 06, 2011, 12:03:47 AM
Here is the block code for the mini-calendar in the left panel on the FrontPage here.  I setup another temporary instance of it (same code) to show only at the bottom of the left panel on the Forum BoardIndex here.


/******************************************************************************************
* '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, $options, $context, $user_info, $sourcedir, $txt;

// Program Paramters/Switches Section

// use forum's date/time
// 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';

// Use 'bordercolor' class for 'gridlines' (table background)
$bordercolor_gridlines = true; // Will 'show through' between table cells to act as 'grid lines'
$gridlines_thickness = 2;       // Pixel thickness for table "cellspacing" - only used w/ $bordercolor_gridlines = true;

// 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 = !empty($options['calendar_start_day']) ? $options['calendar_start_day'] : 0;

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

// 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 = true;

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

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

// Colors for saturday & sunday
$color_sunday = '#D00000';    // comment out to use default text colors -
$color_saturday = '#D00000';  //   can use hex codes with leading '#'

// Style to use for 'Today' highlight (color & background)
// example:
//  'color:#ff0000; background-color:#ffffff;';
$style_today = 'color:steelblue; font-weight:bold;';
// and / or
// Class to use for 'Today' highlight
$class_today = 'tborder';

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

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

// Class for 'cells' holding text labels on calendar entry lists
$list_label_class = 'bordercolor'; // 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
// examples:
//  $list_entry_class = 'windowbg';
//  $list_entry_class = array('windowbg2','windowbg3');
$list_entry_class = '';

// Highlight style (colors & backgrounds & font)
// example:
//  'font-weight:bold; color:#ff0000; background-color:#ffffff;';
// and / or
// Highlight class (a existing class name)
// example:
//  'myclassname';
$hilite_bday_style = 'font-weight:bold;';
$hilite_bday_class = 'birthday'; // default style

$hilite_hday_style = 'font-weight:bold;';
$hilite_hday_class = 'holiday'; // default style

$hilite_event_style = 'font-weight:bold;';
$hilite_event_class = 'event'; // default style

// Choose to show 'look-behind' for the various entry types
$show_bdays_past = false;
$show_events_past = false;
$show_hdays_past = false;

// For any of the above chosen, days prior to today to display -
//    use '0' (zero) to use beginning of current month
$past_look_behind_period = 0;

// 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';
// $list_label_bdays = 'Cumpleaños'; 
// $list_label_events = 'Fiestas';
// $list_label_hdays = 'Festivos';

// specify all the day names in desired language
// The Startday is set according the Firstday in the Member profile
$day_names = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
// $day_names = array('Domingo','Lunes','Martes','Miercoles','Jueves','Viernes','Sabado');

// setup the day_names array according the Memberprofile
$i = $first_day;
while(!empty($i))
{
$fd = array_shift($day_names);
array_push($day_names, $fd);
$i--;
}

// specify the month names in desired language
$month_nam = array();
$month_nam['01'] = 'January';       
$month_nam['02'] = 'February';
$month_nam['03'] = 'March';
$month_nam['04'] = 'April';
$month_nam['05'] = 'May';
$month_nam['06'] = 'June';
$month_nam['07'] = 'July';
$month_nam['08'] = 'August';
$month_nam['09'] = 'September';
$month_nam['10'] = 'October';
$month_nam['11'] = 'November';
$month_nam['12'] = 'December';

// $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)];
//NAMES (end)

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

if (empty($class_default))
$class_default = 'windowbg';

if (empty($hilite_bday_style))
$hilite_bday_class = $class_default;

if (empty($hilite_hday_class))
$hilite_hday_class = $class_default;

if (empty($hilite_event_class))
$hilite_event_class = $class_default;

$table_bkgrd = 'class="'.$class_default.'" cellspacing="1" cellpadding="1" style="margin:0 auto; text-align:center;"';
if ($bordercolor_gridlines)
$table_bkgrd = 'class="information" cellspacing="'.$gridlines_thickness.'" cellpadding="1" style="margin:0 auto; text-align:center;"';

$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 . '/Subs-Calendar.php');

$low_date_base = strftime('%Y-%m-%d', $now - 24 * 3600);
$high_date_base = strftime('%Y-%m-%d', $now + $modSettings['cal_days_for_index'] * 24 * 3600);

$low_date = ($show_bdays_past || $show_events_past || $show_hdays_past) ? ( ($past_look_behind_period == 0) ? date('Y',$now).'-'.date('m',$now).'-01' : strftime('%Y-%m-%d', $now - (($past_look_behind_period + 1) * 24 * 3600)) ) : $low_date_base;
$high_date = $high_date_base;
$low_date_ts = strtotime($low_date);

if ($show_bdays)
{
$bdays = $show_bdays_past ? getBirthdayRange($low_date, $high_date) : getBirthdayRange($low_date_base, $high_date);
ksort($bdays);
}

if ($show_events)
{
$events = $show_events_past ? getEventRange($low_date, $high_date, false) : getEventRange($low_date_base, $high_date, false);
ksort($events);
}

if ($show_hdays)
{
$holidays = $show_hdays_past ? getHolidayRange($low_date, $high_date) : getHolidayRange($low_date_base, $high_date);
ksort($holidays);
}

$stub = '<a class="smalltext" style="'.$style_today.'padding: 0px 2px 0px 2px;"';
// Highlighted 'Today' Box
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 || !$user_info['is_guest'])
{
$stub = '<a class="smalltext" style="'. $hilite_bday_style .'padding: 0px 2px 0px 2px;"';
foreach($bdays as $startdate => $value)
{
if(!isset($days[substr($startdate,8)]) || !is_array($days[substr($startdate,8)]))
{
if (substr($startdate,0,7) == substr($nowdate,0,7))
{
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"><span class="'.$hilite_bday_class.'">'.sprintf('%d',substr($startdate,8)).'</span></a>');
else
$days[substr($startdate,8)] = array(NULL, $hilite_bday_class, $stub.' href="'.htmlspecialchars($month_href).'" target="_self"><span class="'.$hilite_bday_class.'">'.sprintf('%d',substr($startdate,8)).'</span></a>');
}
}
}
}
}
}

// Event Highlighting
if ($flag == 'E')
{
if ($show_events)
{
if ($show_events_to_guests || !$user_info['is_guest'])
{
$stub = '<a class="smalltext" style="'. $hilite_event_style .'padding: 0px 2px 0px 2px;"';
foreach($events as $startdate => $value)
{
if(!isset($days[substr($startdate,8)]) || !is_array($days[substr($startdate,8)]))
{
if (substr($startdate,0,7) == substr($nowdate,0,7))
{
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"><span class="'.$hilite_event_class.'">'.sprintf('%d',substr($startdate,8)).'</span></a>');
else
$days[substr($startdate,8)] = array(NULL, $hilite_event_class, $stub.' href="'.htmlspecialchars($month_href).'" target="_self"><span class="'.$hilite_event_class.'">'.sprintf('%d',substr($startdate,8)).'</span></a>');
}
}
}
}
}
}

// Holiday Highlighting
if ($flag == 'H')
{
if ($show_hdays)
{
if ($show_hdays_to_guests || !$user_info['is_guest'])
{
$stub = '<a class="smalltext" style="'. $hilite_hday_style .'padding: 0px 2px 0px 2px;"';
foreach($holidays as $startdate => $value)
{
if (!isset($days[substr($startdate,8)]) || !is_array($days[substr($startdate,8)]))
{
if (substr($startdate,0,7) == substr($nowdate,0,7))
{
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"><span class="'.$hilite_hday_class.'">'.sprintf('%d',substr($startdate,8)).'</span></a>');
else
$days[substr($startdate,8)] = array(NULL, $hilite_hday_class, $stub.' href="'.htmlspecialchars($month_href).'" target="_self"><span class="'.$hilite_hday_class.'">'.sprintf('%d',substr($startdate,8)).'</span></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 '.$table_bkgrd.'>'.'<caption >'.($month_href ? '<a href="'.htmlspecialchars($month_href).'">'.$title.'</a>' : $title).'</caption><tr>';

if (empty($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.' smalltext" align="center" valign="middle" 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]) && 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';
elseif ($align_list_entries <> 'left')
$align_list_entries = 'center';

if (empty($list_label_class))
$list_label_class = $class_default;

if (empty($list_entry_class))
$list_entry_class = $class_default;

// BIRTHDAY SECTION
if(($flag == 'B') && $show_bdays)
{
if($show_bdays_to_guests || !$user_info['is_guest'])
{
if (!empty($bdays))
{
echo '<tr'. (isset($list_label_class) ? ' class="'.$list_label_class.'"' : '') .'><td colspan="7" class="smalltext" align="center" style="font-weight: bold;">'.$list_label_bdays.'</td></tr>';
$ctr = 0;

foreach($bdays as $startdate => $bday_date)
{
if (($startdate >= strftime('%Y-%m-%d', $low_date_ts)) && ($startdate <= strftime('%Y-%m-%d', $now + $modSettings['cal_days_for_index'] * 24 * 3600)))
{
foreach ($bday_date as $member)
{
$class_to_use = isset($list_entry_class) ? ( !is_array($list_entry_class) ? ' class="'.$list_entry_class.'"' : ' class="'.$list_entry_class[($ctr++) % count($list_entry_class)].'"') : '';
$birthdate = strtotime($startdate);
$text_start = !isset($month_nam['12']) ? date("M j",$birthdate) : substr($month_nam[strftime('%m', $birthdate)],0,3) . date(" j",$birthdate);

echo '<tr'.$class_to_use.'><td colspan="7" class="smalltext" style="padding: 0px 0px 0px 0px;" width="100%" align="'.$align_list_entries.'">';
echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . substr($startdate,5,2) . '"><strong>' . $text_start . ':</strong></a> ';
echo '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" title="' . $txt['profile_of'] . ' ' . $member['name'] . '">' . '<span class="'.$hilite_bday_class.'">' . ( ($nowdate == $startdate) ? '<b>' : '') . $member['name'] . (isset($member['age']) ? '(' . $member['age'] . ')' : '') . ( ($nowdate == $startdate) ? '</b>' : '') . '</span>' . '</a>';
echo '</td></tr>';
}
}
}
}
}
}

// EVENTS SECTION
if(($flag == 'E') && $show_events)
{
if($show_events_to_guests || !$user_info['is_guest'])
{
if (!empty($events))
{
$events_printed = array();
echo '<tr'. (isset($list_label_class) ? ' class="'.$list_label_class.'"' : '') .'><td colspan="7" class="smalltext" align="center" style="font-weight: bold;">'.$list_label_events.'</td></tr>';
$ctr = 0;

foreach ($events as $startdate => $evt_date)
{
if (($startdate >= strftime('%Y-%m-%d', $low_date_ts)) && ($startdate <= strftime('%Y-%m-%d', $now + $modSettings['cal_days_for_index'] * 24 * 3600)))
{
foreach ($evt_date as $event)
{
if (!in_array($event['id'],$events_printed))
{
$events_printed[] = $event['id'];
$class_to_use = isset($list_entry_class) ? ( !is_array($list_entry_class) ? ' class="'.$list_entry_class.'"' : ' class="'.$list_entry_class[($ctr++) % count($list_entry_class)].'"') : '';

$evt_start = strtotime($event['start_date']);
$evt_end = strtotime($event['end_date']);
$text_start = !isset($month_nam['12']) ? date("M j",$evt_start) : substr($month_nam[strftime('%m', $evt_start)],0,3) . date(" j",$evt_start);
$text_end = ($event['start_date'] == $event['end_date'] ? '' : '-'. (substr($event['start_date'],5,2) == substr($event['end_date'],5,2) ? date("j",$evt_end) : (!isset($month_nam['12']) ? date("M j",$evt_end) : substr($month_nam[strftime('%m', $evt_start)],0,3) . date(" j",$evt_start))));

$link = $event['topic'] == 0 ? '<span class="'.$hilite_event_class.'">'. $event['title'] .'</span>' : '<a href="' . $scripturl . '?topic=' . $event['topic'] . '.0' . '"><span class="'.$hilite_event_class.'">' . $event['title'] . '</span></a>';

echo '<tr'.$class_to_use.'><td colspan="7" class="smalltext" style="padding: 0px 0px 0px 0px;" width="100%" align="'.$align_list_entries.'">';
echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . substr($startdate,5,2) . '"><strong>' . $text_start . $text_end . ':</strong></a> ';
echo  ( ($nowdate >= $event['start_date']) && ($event['end_date'] >= $nowdate) ) ? '<b>'.$link.'</b>' : $link;
echo '</td></tr>';
}
}
}
}
}
}
}

// HOLIDAY SECTION
if(($flag == 'H') && $show_hdays)
{
if($show_hdays_to_guests || !$user_info['is_guest'])
{
if (!empty($holidays))
{
echo '<tr'. (isset($list_label_class) ? ' class="'.$list_label_class.'"' : '') .'><td colspan="7" class="smalltext" align="center" style="font-weight: bold;">'.$list_label_hdays.'</td></tr>';
$ctr = 0;

foreach ($holidays as $hDate => $hday)
{
if (($hDate >= strftime('%Y-%m-%d', $low_date_ts)) && ($hDate <= strftime('%Y-%m-%d', $now + $modSettings['cal_days_for_index'] * 24 * 3600)))
{
$eventdate = strtotime(date("Y").substr($hDate, 4));
foreach ($hday as $holiday)
{
$class_to_use = isset($list_entry_class) ? ( !is_array($list_entry_class) ? ' class="'.$list_entry_class.'"' : ' class="'.$list_entry_class[($ctr++) % count($list_entry_class)].'"') : '';
$text_start = !isset($month_nam['12']) ? date("M j",$eventdate) : substr($month_nam[strftime('%m', $eventdate)],0,3) . date(" j",$eventdate);

echo '<tr'.$class_to_use.'><td colspan="7" class="smalltext" style="padding: 0px 0px 0px 0px;" width="100%" align="'.$align_list_entries.'">';
echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . substr($startdate,5,2) . '"><strong>' . $text_start . ':</strong></a> ';
echo '<span class="'.$hilite_hday_class.'">'.$holiday.'</span>';
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', 'calendar_post_event', 'calendar_post_event', 'align="middle"'), '</a>';
echo '</td></tr>';
}
}

echo '</table>';



If it doesn't work for you, there is nothing I can do to fix it because it works without error here.

ZarPrime
Title: Re: Left block calendar ???
Post by: MoreBloodWine on April 06, 2011, 12:17:35 AM
I would like to suggest this as a sticky so people can choose between the calendar they like the best which for me is the code posted with Events.
Title: Re: Left block calendar ???
Post by: ZarPrime on April 06, 2011, 03:09:16 AM
Quote from: MoreBloodWine on April 06, 2011, 12:17:35 AM
1. What do I do to move Birthdays to the bottom so it reads Events, Holidays & then Biorthdays ?

Code (Find) Select

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


Code (Replace) Select

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


Quote from: MoreBloodWine on April 06, 2011, 12:17:35 AM
2. How do I underline the month name at the top ?

Actually, let me stop here.  I just looked at your site.  It looks like you have already figured all this out.  Good job. ;)

Quote from: MoreBloodWine on April 06, 2011, 12:17:35 AM
3. Same as two but for the day abbreviations.

Quote from: MoreBloodWine on April 06, 2011, 12:17:35 AM
4. Add a space between the users name and the () with their age in it for birthdays so MoreBloodWine(30) changes to MoreBloodWine (30)

Topic marked solved. O0

ZarPrime
Title: Re: Left block calendar ???
Post by: MoreBloodWine on April 06, 2011, 03:21:14 AM
Ya, I did figure it all out lol, I woulda replied way sooner but I keep seeming to have intermitten connection issues to this site. In any case, I would still like to recomend the code as a new sticky so people can choose to have which calendar they want.
Title: Re: Left block calendar ???
Post by: MoreBloodWine on April 06, 2011, 06:50:27 AM
Hey Zar, question, why do thigns from the previous day still stay listed in the block ?

I changed my d-day to yesterday to check it here and it's doin the same thing so it's not just me. Shouldnt items from the previous day fall off once the days passed ?
Title: Re: Left block calendar ??? - Updated 4/6/2011
Post by: ZarPrime on April 06, 2011, 03:52:31 PM
The look-behind will always show one day behind with the parameters set in the code I posted.  That is controlled with this code ...


// Choose to show 'look-behind' for the various entry types
$show_bdays_past = false;
$show_events_past = false;
$show_hdays_past = false;

// For any of the above chosen, days prior to today to display -
//    use '0' (zero) to use beginning of current month
$past_look_behind_period = 0;


If you haven't changed any of these parameters, the event listed for April 5th on you site will be visible today, the 6th, but will disappear tomorrow.  If you want to change it so that events show from the beginning of the month, you'd change "$show_events_past = false;" to true.

ZarPrime
Title: Re: Left block calendar ??? - Updated 4/6/2011
Post by: MoreBloodWine on April 06, 2011, 04:07:12 PM
I have those exact same settings...

// Choose to show 'look-behind' for the various entry types
$show_bdays_past = false;
$show_events_past = false;
$show_hdays_past = false;

// For any of the above chosen, days prior to today to display -
//    use '0' (zero) to use beginning of current month
$past_look_behind_period = 0;


Anyway, maybe I'm reading to much into this but shouldnt false mean no, don't do look behind ?

How I would like it to work is like the upcoming calendar on the board index where it starts with the current day then looks forward by however many days you have set for the advance in SMF calendar admin which for me is 7.
Title: Re: Left block calendar ??? - Updated 4/6/2011
Post by: ZarPrime on April 06, 2011, 04:52:01 PM
Quote from: MoreBloodWine on April 06, 2011, 04:07:12 PM
Anyway, maybe I'm reading to much into this but shouldnt false mean no, don't do look behind ?

How I would like it to work is like the upcoming calendar on the board index where it starts with the current day then looks forward by however many days you have set for the advance in SMF calendar admin which for me is 7.

Yeah, you're reading to much into it. :) As I said ...

Quote from: ZarPrime on April 06, 2011, 03:52:31 PM
The look-behind will always show one day behind with the parameters set in the code I posted.

The code is written in such a way as to make the look-behind feature available to the user, if they want to use it.  That's not available to the user through the SMF Calendar settings.  When you have all 3 settings in the block code set to false, the look-behind feature is disabled for the block code.  However, the mini-calendar will always look behind 1 day.  It has nothing to do with the look ahead features that are controlled by the SMF Calendar settings.  The code is written that way so that it will work the same for everyone.

As I said, the event for yesterday will drop off the mini-calendar tomorrow.  You can see this by looking at our calendar for April here --> http://www.tinyportal.net/index.php?action=calendar

As you can see, the the fake event that I put in for the 4th can no longer be seen in the mini-calendar.  Tomorrow, the event for the 5th will be gone as well.  I really fail to see what the big deal with this is.

ZarPrime
Title: Re: Left block calendar ??? - Updated 4/6/2011
Post by: MoreBloodWine on April 06, 2011, 04:55:39 PM
It's not a big deal, I'm just funny that way I guess.
Title: Re: Left block calendar ??? - Updated 4/6/2011
Post by: ZarPrime on April 06, 2011, 05:01:42 PM
Yeah, well some people are like that I guess. ;)

Anyway, if you are satisfied with the answer, please, once again, mark this topic solved as I did yesterday, by changing the message icon in the OP to the solved icon.

ZarPrime
Title: Re: Left block calendar ??? - Updated 4/6/2011
Post by: MoreBloodWine on April 06, 2011, 05:21:07 PM
I wouldnt say I;m satisfied but I try not to bother people more than I have to on a certian subject lol.

Anyway, I thought I found the line that controls the default -1 because it also shows a +1 which I guess is a look ahead. Anyway, everything I tried in regards to modifying it either didnt work or error'd on me.

$low_date = ($show_bdays_past || $show_events_past || $show_hdays_past) ? ( ($past_look_behind_period == 0) ? date('Y',$now).'-'.date('m',$now).'-01' : strftime('%Y-%m-%d', $now - (($past_look_behind_period + 1) * 24 * 3600)) ) : $low_date_base;
Title: Re: Left block calendar ??? - Updated 4/6/2011
Post by: ZarPrime on April 06, 2011, 05:32:57 PM
Code (Find) Select

$low_date_base = strftime('%Y-%m-%d', $now - 24 * 3600);


Code (Replace) Select

$low_date_base = strftime('%Y-%m-%d', $now - 1 * 3600);


If you do this, it should only look behind by 1 hour, instead of 24.  I can't guarantee that this won't cause the look-behind feature to malfunction though.  However, it seems like you aren't interested in that feature anyway.

ZarPrime
Title: Re: Left block calendar ??? - Updated 4/6/2011
Post by: MoreBloodWine on April 06, 2011, 05:42:20 PM
Quote from: ZarPrime on April 06, 2011, 05:32:57 PM
Code (Find) Select

$low_date_base = strftime('%Y-%m-%d', $now - 24 * 3600);


Code (Replace) Select

$low_date_base = strftime('%Y-%m-%d', $now - 1 * 3600);


If you do this, it should only look behind by 1 hour, instead of 24.  I can't guarantee that this won't cause the look-behind feature to malfunction though.  However, it seems like you aren't interested in that feature anyway.

ZarPrime
Not really, and I actually just changed it to $low_date_base = strftime('%Y-%m-%d', $now); to stop the whole function all together and so far everything seems ok without error.
Title: Re: Left block calendar ??? - Updated 4/6/2011
Post by: ZarPrime on April 06, 2011, 05:48:20 PM
Yeah, that would work too but, again, I don't know whether that will affect the look-behind feature, should you ever choose to use it.  Anyway, I'm glad it works for you. O0

ZarPrime
Title: Re: Left block calendar ??? - Updated 4/6/2011
Post by: MoreBloodWine on April 06, 2011, 05:55:21 PM
Well, if anything I could add $low_date_base = strftime('%Y-%m-%d', $now - 24 * 3600); back and just comment it out  so should I ever do want to use it I just uncomment it and comment out my version.

But ya it works and thx ;-)
Title: Re: Left block calendar ??? - Updated 4/16/2011
Post by: MoreBloodWine on April 16, 2011, 06:22:14 PM
Never bothered to think of this before but it's more of a curiosity thing than anything else, how can I decrease the line height of the displayed stuff so they dont look as far apart as they do now ?

My Code:
/******************************************************************************************
* '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, $options, $context, $user_info, $sourcedir, $txt;

// Program Paramters/Switches Section

// use forum's date/time
// 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('Events', 'Holidays', 'Birthdays');

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

// Use 'bordercolor' class for 'gridlines' (table background)
$bordercolor_gridlines = true; // Will 'show through' between table cells to act as 'grid lines'
$gridlines_thickness = 2;       // Pixel thickness for table "cellspacing" - only used w/ $bordercolor_gridlines = true;

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

// Selection for first day of the week: 0-Sunday; 1-Monday
$first_day = !empty($options['calendar_start_day']) ? $options['calendar_start_day'] : 0;

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

// 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 = true;

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

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

// Colors for saturday & sunday
$color_sunday = '#D00000';    // comment out to use default text colors -
$color_saturday = '#D00000';  //   can use hex codes with leading '#'

// Style to use for 'Today' highlight (color & background)
// example:
//  'color:#ff0000; background-color:#ffffff;';
$style_today = 'color:steelblue; font-weight:bold;';
// and / or
// Class to use for 'Today' highlight
$class_today = 'tborder';

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

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

// Class for 'cells' holding text labels on calendar entry lists
$list_label_class = 'bordercolor'; // 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
// examples:
//  $list_entry_class = 'windowbg';
//  $list_entry_class = array('windowbg2','windowbg3');
$list_entry_class = '';

// Highlight style (colors & backgrounds & font)
// example:
//  'font-weight:bold; color:#ff0000; background-color:#ffffff;';
// and / or
// Highlight class (a existing class name)
// example:
//  'myclassname';
$hilite_bday_style = 'font-weight:bold;';
$hilite_bday_class = 'birthday'; // default style

$hilite_hday_style = 'font-weight:bold;';
$hilite_hday_class = 'holiday'; // default style

$hilite_event_style = 'font-weight:bold;';
$hilite_event_class = 'event'; // default style

// Choose to show 'look-behind' for the various entry types
$show_bdays_past = false;
$show_events_past = false;
$show_hdays_past = false;

// For any of the above chosen, days prior to today to display -
//    use '0' (zero) to use beginning of current month
$past_look_behind_period = 0;

// 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';
// $list_label_bdays = 'Cumplea��ïÃ,¿Ã,½Ã�Ã,¯Ã�Ã,¿Ã�Ã,½Ã��ïÃ,¿Ã,½Ã��Ã�Ã,±os'; 
// $list_label_events = 'Fiestas';
// $list_label_hdays = 'Festivos';

// specify all the day names in desired language
// The Startday is set according the Firstday in the Member profile
$day_names = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
// $day_names = array('Domingo','Lunes','Martes','Miercoles','Jueves','Viernes','Sabado');

// setup the day_names array according the Memberprofile
$i = $first_day;
while(!empty($i))
{
$fd = array_shift($day_names);
array_push($day_names, $fd);
$i--;
}

// specify the month names in desired language
$month_nam = array();
$month_nam['01'] = 'January';       
$month_nam['02'] = 'February';
$month_nam['03'] = 'March';
$month_nam['04'] = 'April';
$month_nam['05'] = 'May';
$month_nam['06'] = 'June';
$month_nam['07'] = 'July';
$month_nam['08'] = 'August';
$month_nam['09'] = 'September';
$month_nam['10'] = 'October';
$month_nam['11'] = 'November';
$month_nam['12'] = 'December';

// $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)];
//NAMES (end)

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

if (empty($class_default))
$class_default = 'windowbg';

if (empty($hilite_bday_style))
$hilite_bday_class = $class_default;

if (empty($hilite_hday_class))
$hilite_hday_class = $class_default;

if (empty($hilite_event_class))
$hilite_event_class = $class_default;

$table_bkgrd = 'class="'.$class_default.'" cellspacing="1" cellpadding="1" style="margin:0 auto; text-align:center;"';
if ($bordercolor_gridlines)
$table_bkgrd = 'class="information" cellspacing="'.$gridlines_thickness.'" cellpadding="1" style="margin:0 auto; text-align:center;"';

$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 . '/Subs-Calendar.php');

// $low_date_base = strftime('%Y-%m-%d', $now - 24 * 3600);
$low_date_base = strftime('%Y-%m-%d', $now);
$high_date_base = strftime('%Y-%m-%d', $now + $modSettings['cal_days_for_index'] * 24 * 3600);

$low_date = ($show_bdays_past || $show_events_past || $show_hdays_past) ? ( ($past_look_behind_period == 0) ? date('Y',$now).'-'.date('m',$now).'-01' : strftime('%Y-%m-%d', $now - (($past_look_behind_period + 1) * 24 * 3600)) ) : $low_date_base;
$high_date = $high_date_base;
$low_date_ts = strtotime($low_date);

if ($show_bdays)
{
$bdays = $show_bdays_past ? getBirthdayRange($low_date, $high_date) : getBirthdayRange($low_date_base, $high_date);
ksort($bdays);
}

if ($show_events)
{
$events = $show_events_past ? getEventRange($low_date, $high_date, false) : getEventRange($low_date_base, $high_date, false);
ksort($events);
}

if ($show_hdays)
{
$holidays = $show_hdays_past ? getHolidayRange($low_date, $high_date) : getHolidayRange($low_date_base, $high_date);
ksort($holidays);
}

$stub = '<a class="smalltext" style="'.$style_today.'padding: 0px 2px 0px 2px;"';
// Highlighted 'Today' Box
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 || !$user_info['is_guest'])
{
$stub = '<a class="smalltext" style="'. $hilite_bday_style .'padding: 0px 2px 0px 2px;"';
foreach($bdays as $startdate => $value)
{
if(!isset($days[substr($startdate,8)]) || !is_array($days[substr($startdate,8)]))
{
if (substr($startdate,0,7) == substr($nowdate,0,7))
{
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"><span class="'.$hilite_bday_class.'">'.sprintf('%d',substr($startdate,8)).'</span></a>');
else
$days[substr($startdate,8)] = array(NULL, $hilite_bday_class, $stub.' href="'.htmlspecialchars($month_href).'" target="_self"><span class="'.$hilite_bday_class.'">'.sprintf('%d',substr($startdate,8)).'</span></a>');
}
}
}
}
}
}

// Event Highlighting
if ($flag == 'E')
{
if ($show_events)
{
if ($show_events_to_guests || !$user_info['is_guest'])
{
$stub = '<a class="smalltext" style="'. $hilite_event_style .'padding: 0px 2px 0px 2px;"';
foreach($events as $startdate => $value)
{
if(!isset($days[substr($startdate,8)]) || !is_array($days[substr($startdate,8)]))
{
if (substr($startdate,0,7) == substr($nowdate,0,7))
{
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"><span class="'.$hilite_event_class.'">'.sprintf('%d',substr($startdate,8)).'</span></a>');
else
$days[substr($startdate,8)] = array(NULL, $hilite_event_class, $stub.' href="'.htmlspecialchars($month_href).'" target="_self"><span class="'.$hilite_event_class.'">'.sprintf('%d',substr($startdate,8)).'</span></a>');
}
}
}
}
}
}

// Holiday Highlighting
if ($flag == 'H')
{
if ($show_hdays)
{
if ($show_hdays_to_guests || !$user_info['is_guest'])
{
$stub = '<a class="smalltext" style="'. $hilite_hday_style .'padding: 0px 2px 0px 2px;"';
foreach($holidays as $startdate => $value)
{
if (!isset($days[substr($startdate,8)]) || !is_array($days[substr($startdate,8)]))
{
if (substr($startdate,0,7) == substr($nowdate,0,7))
{
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"><span class="'.$hilite_hday_class.'">'.sprintf('%d',substr($startdate,8)).'</span></a>');
else
$days[substr($startdate,8)] = array(NULL, $hilite_hday_class, $stub.' href="'.htmlspecialchars($month_href).'" target="_self"><span class="'.$hilite_hday_class.'">'.sprintf('%d',substr($startdate,8)).'</span></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 '.$table_bkgrd.'>'.'<caption >'.($month_href ? '<a href="'.htmlspecialchars($month_href).'"><u>'.$title.'</u></a>' : $title).'</caption><tr>';

if (empty($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.' smalltext" align="center" valign="middle" abbr="'.htmlentities($d).'"><u>'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</u></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]) && 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';
elseif ($align_list_entries <> 'left')
$align_list_entries = 'center';

if (empty($list_label_class))
$list_label_class = $class_default;

if (empty($list_entry_class))
$list_entry_class = $class_default;

// BIRTHDAY SECTION
if(($flag == 'B') && $show_bdays)
{
if($show_bdays_to_guests || !$user_info['is_guest'])
{
if (!empty($bdays))
{
echo '<tr'. (isset($list_label_class) ? ' class="'.$list_label_class.'"' : '') .'><td colspan="7" class="smalltext" align="center" style="font-weight: bold;">'.$list_label_bdays.'</td></tr>';
$ctr = 0;

foreach($bdays as $startdate => $bday_date)
{
if (($startdate >= strftime('%Y-%m-%d', $low_date_ts)) && ($startdate <= strftime('%Y-%m-%d', $now + $modSettings['cal_days_for_index'] * 24 * 3600)))
{
foreach ($bday_date as $member)
{
$class_to_use = isset($list_entry_class) ? ( !is_array($list_entry_class) ? ' class="'.$list_entry_class.'"' : ' class="'.$list_entry_class[($ctr++) % count($list_entry_class)].'"') : '';
$birthdate = strtotime($startdate);
$text_start = !isset($month_nam['12']) ? date("M j",$birthdate) : substr($month_nam[strftime('%m', $birthdate)],0,3) . date(" j",$birthdate);

echo '<tr'.$class_to_use.'><td colspan="7" class="smalltext" style="padding: 0px 0px 0px 0px;" width="100%" align="'.$align_list_entries.'">';
echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . substr($startdate,5,2) . '"><strong>' . $text_start . ':</strong></a> ';
echo '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" title="' . $txt['profile_of'] . ' ' . $member['name'] . '">' . '<span class="'.$hilite_bday_class.'">' . ( ($nowdate == $startdate) ? '<b>' : '') . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . ( ($nowdate == $startdate) ? '</b>' : '') . '</span>' . '</a>';
echo '</td></tr>';
}
}
}
}
}
}

// EVENTS SECTION
if(($flag == 'E') && $show_events)
{
if($show_events_to_guests || !$user_info['is_guest'])
{
if (!empty($events))
{
$events_printed = array();
echo '<tr'. (isset($list_label_class) ? ' class="'.$list_label_class.'"' : '') .'><td colspan="7" class="smalltext" align="center" style="font-weight: bold;">'.$list_label_events.'</td></tr>';
$ctr = 0;

foreach ($events as $startdate => $evt_date)
{
if (($startdate >= strftime('%Y-%m-%d', $low_date_ts)) && ($startdate <= strftime('%Y-%m-%d', $now + $modSettings['cal_days_for_index'] * 24 * 3600)))
{
foreach ($evt_date as $event)
{
if (!in_array($event['id'],$events_printed))
{
$events_printed[] = $event['id'];
$class_to_use = isset($list_entry_class) ? ( !is_array($list_entry_class) ? ' class="'.$list_entry_class.'"' : ' class="'.$list_entry_class[($ctr++) % count($list_entry_class)].'"') : '';

$evt_start = strtotime($event['start_date']);
$evt_end = strtotime($event['end_date']);
$text_start = !isset($month_nam['12']) ? date("M j",$evt_start) : substr($month_nam[strftime('%m', $evt_start)],0,3) . date(" j",$evt_start);
$text_end = ($event['start_date'] == $event['end_date'] ? '' : '-'. (substr($event['start_date'],5,2) == substr($event['end_date'],5,2) ? date("j",$evt_end) : (!isset($month_nam['12']) ? date("M j",$evt_end) : substr($month_nam[strftime('%m', $evt_start)],0,3) . date(" j",$evt_start))));

$link = $event['topic'] == 0 ? '<span class="'.$hilite_event_class.'">'. $event['title'] .'</span>' : '<a href="' . $scripturl . '?topic=' . $event['topic'] . '.0' . '"><span class="'.$hilite_event_class.'">' . $event['title'] . '</span></a>';

echo '<tr'.$class_to_use.'><td colspan="7" class="smalltext" style="padding: 0px 0px 0px 0px;" width="100%" align="'.$align_list_entries.'">';
echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . substr($startdate,5,2) . '"><strong>' . $text_start . $text_end . ':</strong></a> ';
echo  ( ($nowdate >= $event['start_date']) && ($event['end_date'] >= $nowdate) ) ? '<b>'.$link.'</b>' : $link;
echo '</td></tr>';
}
}
}
}
}
}
}

// HOLIDAY SECTION
if(($flag == 'H') && $show_hdays)
{
if($show_hdays_to_guests || !$user_info['is_guest'])
{
if (!empty($holidays))
{
echo '<tr'. (isset($list_label_class) ? ' class="'.$list_label_class.'"' : '') .'><td colspan="7" class="smalltext" align="center" style="font-weight: bold;">'.$list_label_hdays.'</td></tr>';
$ctr = 0;

foreach ($holidays as $hDate => $hday)
{
if (($hDate >= strftime('%Y-%m-%d', $low_date_ts)) && ($hDate <= strftime('%Y-%m-%d', $now + $modSettings['cal_days_for_index'] * 24 * 3600)))
{
$eventdate = strtotime(date("Y").substr($hDate, 4));
foreach ($hday as $holiday)
{
$class_to_use = isset($list_entry_class) ? ( !is_array($list_entry_class) ? ' class="'.$list_entry_class.'"' : ' class="'.$list_entry_class[($ctr++) % count($list_entry_class)].'"') : '';
$text_start = !isset($month_nam['12']) ? date("M j",$eventdate) : substr($month_nam[strftime('%m', $eventdate)],0,3) . date(" j",$eventdate);

echo '<tr'.$class_to_use.'><td colspan="7" class="smalltext" style="padding: 0px 0px 0px 0px;" width="100%" align="'.$align_list_entries.'">';
echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . substr($startdate,5,2) . '"><strong>' . $text_start . ':</strong></a> ';
echo '<span class="'.$hilite_hday_class.'">'.$holiday.'</span>';
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'], '">','', create_button('calendarpe.gif', 'calendar_post_event', 'calendar_post_event', 'align="middle"'), '</a>';
echo '</td></tr>';
}
}

echo '</table>';
Title: Re: Left block calendar ??? - Updated 4/16/2011
Post by: ZarPrime on April 17, 2011, 12:12:12 PM
I really don't know what you mean when you say that you want to "decrease the line height of the displayed stuff" since there are different areas that are displayed.  I can't tell whether you are talking about the height between the cells in the calendar or the height between Birthdays, or what.  Also, please keep in mind something that I think I mentioned to you one other time, that being that the display will look different with different themes.  Maybe something at this link will help you to do what it is that you want to do.  Click here --> Let me google that for you! (http://letmegooglethatforyou.com/?q=decrease+line+height+in+html)

ZarPrime
Title: Re: Left block calendar ??? - Updated 4/16/2011
Post by: sangham.net on March 18, 2014, 11:33:14 AM
Dear ZarPrime,

I just came across your calender code and inquiring I have try it and it seems to work fine. So to speak "great!". How ever, I don't like to miss to ask for the use. I would change the layout a little if I am able to.

Thanks a lot in advanced!
Title: Re: Left block calendar ??? - Updated 4/16/2011
Post by: ZarPrime on March 22, 2014, 12:24:19 AM
How would you change the layout?  The code isn't too difficult to follow if you know a little bit about php and html.

ZarPrime
Title: Re: Left block calendar ??? - Updated 4/16/2011
Post by: sangham.net on March 22, 2014, 01:14:15 AM
Quote from: ZarPrime on March 22, 2014, 12:24:19 AM
How would you change the layout?  The code isn't too difficult to follow if you know a little bit about php and html.

ZarPrime

That is right ZarPrime,
I have to mention that it is well thought-out and canny delineate as well (so that even dummies like me understand the ways to change some things fast). I allowed myself to "hack" it in a fast style (so not so fine as the original), changed html parts here and there and pre-used it. Would honored and at peace of conscience to get you approve. If you like to take a look: here (http://sangham.net/index.php?action=forum)

(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fsangham.net%2FSmileys%2Fsangham%2Fsadhu_sangham_sw.gif&hash=fb1cc408d4e8c070a005620020203edeec2d4e75)
Title: Re: Left block calendar ??? - Updated 4/16/2011
Post by: sangham.net on March 22, 2014, 04:29:08 PM
Dear ZarPrime,

just came to see that there is an error created in the database:

8: Undefined index: align="middle"
Filter hinzufügen: Nur Fehler von dieser Datei zeigen
Datei: /var/www/vhosts/XXXX/httpdocs/Sources/Subs.php
Zeile: 3849

This is the line of the subs.php:
return '<img src="' . $settings['images_url'] . '/buttons/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . ' />' . ($label != '' ? '<strong>' . $txt[$label] . '</strong>' : '');
which is actually involved in bottoms creation.
   // Does the current loaded theme have this and we are not forcing the usage of this function?

Not very wise after that I searched around a little and I looked at the html source and found that be calender block creates a html including "middle" more times.

valign="middle"

Maybe its because HTML5 does not support valign? Not sure, but I remember something like that.

I have disabled the block and no more error in the error-log of this kind. Not sure if I did something wrong at this time. Just thought to tell you. Could be a general thing as well. Me do not know so much about this.

...no, no, no... I guess that looks more like the "problem" as even mixed with buttons:

echo '<a href="', $scripturl,  '?action=calendar;sa=post;month=', $month, ';year=', $year, ';sesc=', $context['session_id'], '">','<br />', create_button('calendar_post_event', 'calendar_post_event', 'align="middle"'), '</a>';

'calendar_post_event', 'calendar_post_event', 'align="middle"'

Will try to use "center" instead and tell you, if that was beginner luck.

Title: Re: Left block calendar ??? - Updated 4/16/2011
Post by: sangham.net on March 22, 2014, 04:35:00 PM
No beginner's luck...  :)

Seems that it doesn't like "center" either:

8: Undefined index: align="center"
Apply Filter: Only show the errors from this file
File: /var/www/vhosts/xxx/Sources/Subs.php
Line: 3849


Maybe give the align up totaly? It's seems that it is not specified in the subs.php maybe that is a possibility.
Title: Re: Left block calendar ??? - Updated 4/16/2011
Post by: sangham.net on March 22, 2014, 04:40:36 PM
Oki dok,

althrough I am not sure if I made the right thing, it seems to work when the align-part is gone and the layout (for our minimalistic style) seems to be ok as well.

echo '<a href="', $scripturl,  '?action=calendar;sa=post;month=', $month, ';year=', $year, ';sesc=', $context['session_id'], '">','<br />', create_button('calendar_post_event', 'calendar_post_event'), '</a>';

Let me trust that is maybe useful for others.
Title: Re: Left block calendar ??? - Updated 4/16/2011
Post by: ZarPrime on March 26, 2014, 12:50:00 PM
I looked at your site and the mini-calendar seems OK from what I can tell.  You could be right about issues with html 5 so I will take a look at that in the next week or so as I find time.  However, even if something in the code is deprecated in html 5, the code should still revert to showing everything OK.  As far as the button to post an event goes, you are aware that a non-admin who can't add events wouldn't even see the button, correct?

ZarPrime
Title: Re: Left block calendar ??? - Updated 4/16/2011
Post by: sangham.net on May 04, 2015, 06:38:26 AM
Quote from: ZarPrime on March 26, 2014, 12:50:00 PM
I looked at your site and the mini-calendar seems OK from what I can tell.  You could be right about issues with html 5 so I will take a look at that in the next week or so as I find time.  However, even if something in the code is deprecated in html 5, the code should still revert to showing everything OK.  As far as the button to post an event goes, you are aware that a non-admin who can't add events wouldn't even see the button, correct?

ZarPrime

Attma (me, Johann) guesses, he is now aware of what he sometimes just have been curious last time, Danke für all die Hilfe und Tipps ZarPrime.

Will forward your supports also to sangham.net's silent helpers, here (http://sangham.net/index.php/topic,1172.msg7433.html#msg7433).

Sadhu!
metta (goodwill/Wohlwollen) & mudita (sympathic joy/Mitfreunde an Geschicktem or appreciation/Anerkennung von Geschicktem)

May I turst that anything else if fine for all of you.
Title: Re: Left block calendar ??? - Updated 4/16/2011
Post by: sturmkatze on May 21, 2015, 10:23:52 PM
This is an old thread, but I wondered, will that code throw a calendar like in this pix he had posted? I really like that format.
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fwww.eojmarket.com%2FNonForumStuff%2Fimages%2Ftpcalendar.png&hash=11d4bd8179a053a4a1c8623b2663f708526dcbfe)
Title: Re: Left block calendar ??? - Updated 4/16/2011
Post by: ZarPrime on May 25, 2015, 07:53:17 PM
I believe the code we are using here is at the bottom of the first page of this topic but you are correct, this thread is old and was marked solved a long time ago. It works fine with SMF 2.X and the latest TP. Try it and see if it works for you but if it doesn't, please start a new topic rather than hijacking a long dead thread.
Title: Re: Left block calendar ??? - Updated 4/16/2011
Post by: sturmkatze on May 26, 2015, 03:52:07 PM
The intent was not to hijack a "dead thread" especially since it had recent activity, I just wanted to make sure the code would work, and it did. Thank you!! :-)