Language: 
To browser these website, it's necessary to store cookies on your computer.
The cookies contain no personal information, they are required for program control.
  the storage of cookies while browsing this website, on Login and Register.
Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Select language:

Community



Donate

Donate for PortaMx !
Your donation is safe and helps support the issues and causes you care most about.

Stats

  • *Total Members: 4319
  • *Latest: thygrim

  • *Total Posts: 15779
  • *Total Topics: 2382
  • *Online Today: 4
  • *Most Online: 157
(27.08.09, 03:54:53)
  • *Users: 0
  • *Guests: 2
  • *Total: 2

Author Topic: Calendar PHP block  (Read 34605 times)

0 Members and 0 Guests are viewing this topic.

Offline mikeymx5

  • Jr. Member
  • **
  • Posts: 73
  • Gender: Male
    • Houston Miata Club
Re: Calendar PHP block
« Reply #60 on: 28.02.11, 21:14:26 »
I like the new block but you cannot turn off the calendar and it shows event spanning multiple days  multiple times.

But its a good block to have for the majority.

Offline feline

  • CO PortaMx corp.
  • Administrator
  • *
  • Posts: 5586
  • Gender: Female
Re: Calendar PHP block
« Reply #61 on: 28.02.11, 21:36:16 »
for what you need a calendar, if you will show only the events? This can be done with a simple php block  ;)
And spaning events .. will be add in the next release.
Many are stubborn in relation to the path, a few in relation to the target.

Offline mikeymx5

  • Jr. Member
  • **
  • Posts: 73
  • Gender: Male
    • Houston Miata Club
Re: Calendar PHP block
« Reply #62 on: 15.03.11, 22:04:59 »
Check out my Home page, this is what a calendar block should look and function like. ;D
http://houstonmiataclub.com/index.php

I used to have the calendar showing but why? It serves no purpose and waste space making it hard on users with low res screens.

But like i said most of the SMF websites I have seen, this block will work great for, and for the few others it would be nice to have a few more options.

Louis

Offline bluedevil

  • Newbie
  • *
  • Posts: 21
  • Gender: Male
    • ChevyAvalancheClub
Re: Calendar PHP block
« Reply #63 on: 26.03.11, 20:43:03 »
I already commented out the holidays and birthdays. I want to use this code for events only.

How do i also comment out the mini calendar?  I dont want to show that.

Offline feline

  • CO PortaMx corp.
  • Administrator
  • *
  • Posts: 5586
  • Gender: Female
Re: Calendar PHP block
« Reply #64 on: 26.03.11, 20:53:23 »
If you need only the events, you can done that with a php block.
Look at the source code of the mini-calendar how it's work...
Many are stubborn in relation to the path, a few in relation to the target.

Offline mikeymx5

  • Jr. Member
  • **
  • Posts: 73
  • Gender: Male
    • Houston Miata Club
Re: Calendar PHP block
« Reply #65 on: 06.04.11, 22:33:01 »
Code: [Select]
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( 'Events','Birthdays', 'Holidays');

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

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

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

// 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 = false;
$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 = false;
$show_hdays_to_guests = false;

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

// 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 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
// examples:
//$list_entry_class = 'table_grid';
$list_entry_class = array('windowbg','windowbg2');
//$list_entry_class = 'windowbg3';

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



// 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="none" cellspacing="0" cellpadding="0" style="margin:0 auto; width:100%;  text-align:center;"';
if ($bordercolor_gridlines)
   $table_bkgrd = 'class="bordercolor" cellspacing="'.$gridlines_thickness.'" cellpadding="1" style="margin:0 auto; width:100%; 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.'height: 20px; padding: 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>'));




echo '<table style="width: 100%;">';
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;



   // EVENTS SECTION
   if(($flag == 'E') && $show_events)
   {
      if($show_events_to_guests || !$user_info['is_guest'])
      {
         if (!empty($events))
         {
            $events_printed = array();

            $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="height: 8px; padding: 2px" 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>';
                     }
                  }
               }
            }
         }
      }
   }

   // 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="h4" 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="height: 8px; padding: 2px;" 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>';
                  }
               }
            }
         }
      }
   }

   // 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="h4" 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="height: 8px; padding: 2px" 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', 'calendar23', 'calendar23', 'align="middle"'), '</a>';
      echo '</td></tr>';
   }
}

echo '</table>';

Calendar Block with out calendar, Birthdays, and Holidays......in other words this will just give you a formatted list of events.  I probably could get rid of a bunch of extra code but Im lazy and dont want to mess with it.

Offline feline

  • CO PortaMx corp.
  • Administrator
  • *
  • Posts: 5586
  • Gender: Female
Re: Calendar PHP block
« Reply #66 on: 07.04.11, 09:46:01 »
PortaMx have a mini calendar block...
Many are stubborn in relation to the path, a few in relation to the target.

Offline mikeymx5

  • Jr. Member
  • **
  • Posts: 73
  • Gender: Male
    • Houston Miata Club
Re: Calendar PHP block
« Reply #67 on: 07.04.11, 21:17:15 »
PortaMx have a mini calendar block...

BlueDevil is looking for list of events only not the mini calendar block. My code above can do what he wants... Im sure SMF has a simple SSI that can also do this with less control but this is what I use.

Offline feline

  • CO PortaMx corp.
  • Administrator
  • *
  • Posts: 5586
  • Gender: Female
Re: Calendar PHP block
« Reply #68 on: 07.04.11, 21:32:51 »
That's simple .. try this:
Code: [Select]
global $smcFunc, $txt;

$daybefore = 1;
$dayafter = 2;

$start_data = date('Y-m-d', time() - (86400 * $daybefore));
$end_data = date('Y-m-d', time() + (86400 * $dayafter));
$calevents = getEventRange($start_data, $end_data);
ksort($calevents);

if(!empty($calevents))
{
foreach($calevents as $cdate => $data)
{
list($cdt['year'], $cdt['month'], $cdt['day']) = explode('-', $cdate);
foreach($data as $vals)
echo $smcFunc['substr']($txt['months'][intval($cdt['month'])], 0, 3) .' '. $cdt['day'] .': '. $vals['link'] .'<br />';
}
}
Many are stubborn in relation to the path, a few in relation to the target.

Offline Galedon

  • Newbie
  • *
  • Posts: 35
Re: Calendar PHP block
« Reply #69 on: 12.05.11, 08:14:36 »
Moin

- ich hänge mich mal einfach hier ran :D

Der MiniCalendar ist gut - ich suche bloß die Möglichkeit Events in der Kalender Übersicht hervorzuheben !

Der aktuelle Tag wird ja schon mit einem grünen Kasten inkl. Datum dargestellt

Gibt es diese Möglichkeit ?

gruss

Offline feline

  • CO PortaMx corp.
  • Administrator
  • *
  • Posts: 5586
  • Gender: Female
Re: Calendar PHP block
« Reply #70 on: 12.05.11, 13:54:46 »
Das ist nicht vorgesehen .. die Ereignisse werden ja mit Datum unterhalb des Kalenders dargestellt.
Das würde IMHO auch zu unübersichtlich .. zumal dann der nächste kommt und die Geburtstage und Feiertage haben will.
Und der Aufwand ist nicht gering .. für jeden Tag müsste das Event Array gescheckt werden und es kann auch Überlappungen geben.
Many are stubborn in relation to the path, a few in relation to the target.

Offline MiY4Gi

  • Innovator
  • Jr. Member
  • **
  • Posts: 64
  • Gender: Male
  • I bleed enthusiasm!
    • MyAnimeClub
Re: Calendar PHP block
« Reply #71 on: 26.07.11, 20:59:33 »
Code: [Select]
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( 'Events','Birthdays', 'Holidays');

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

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

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

// 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 = false;
$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 = false;
$show_hdays_to_guests = false;

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

// 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 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
// examples:
//$list_entry_class = 'table_grid';
$list_entry_class = array('windowbg','windowbg2');
//$list_entry_class = 'windowbg3';

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



// 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="none" cellspacing="0" cellpadding="0" style="margin:0 auto; width:100%;  text-align:center;"';
if ($bordercolor_gridlines)
   $table_bkgrd = 'class="bordercolor" cellspacing="'.$gridlines_thickness.'" cellpadding="1" style="margin:0 auto; width:100%; 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.'height: 20px; padding: 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>'));




echo '<table style="width: 100%;">';
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;



   // EVENTS SECTION
   if(($flag == 'E') && $show_events)
   {
      if($show_events_to_guests || !$user_info['is_guest'])
      {
         if (!empty($events))
         {
            $events_printed = array();

            $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="height: 8px; padding: 2px" 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>';
                     }
                  }
               }
            }
         }
      }
   }

   // 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="h4" 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="height: 8px; padding: 2px;" 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>';
                  }
               }
            }
         }
      }
   }

   // 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="h4" 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="height: 8px; padding: 2px" 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', 'calendar23', 'calendar23', 'align="middle"'), '</a>';
      echo '</td></tr>';
   }
}

echo '</table>';

Calendar Block with out calendar, Birthdays, and Holidays......in other words this will just give you a formatted list of events.  I probably could get rid of a bunch of extra code but Im lazy and dont want to mess with it.

How do I make it so that the modified block says "No Upcoming Events" whenever there are no events?
Check out my new anime club. Discuss and share anime, or just fool around with other forumites. Join us at MyAnimeClub.

Offline feline

  • CO PortaMx corp.
  • Administrator
  • *
  • Posts: 5586
  • Gender: Female
Re: Calendar PHP block
« Reply #72 on: 26.07.11, 21:04:44 »
For what you need this old code?  ???
We have a fantastic mini calendar block ....
Many are stubborn in relation to the path, a few in relation to the target.

Offline MiY4Gi

  • Innovator
  • Jr. Member
  • **
  • Posts: 64
  • Gender: Male
  • I bleed enthusiasm!
    • MyAnimeClub
Re: Calendar PHP block
« Reply #73 on: 27.07.11, 22:37:54 »
I don't want the full calendar, just the Events "notification" part of the calendar. The calendar takes up too much unnecessary space.

It would be nice if I could still use the same Mini Calendar block, and just disable the "calendar", but I don't think that's possible.

Should I use the code below?

That's simple .. try this:
Code: [Select]
global $smcFunc, $txt;

$daybefore = 1;
$dayafter = 2;

$start_data = date('Y-m-d', time() - (86400 * $daybefore));
$end_data = date('Y-m-d', time() + (86400 * $dayafter));
$calevents = getEventRange($start_data, $end_data);
ksort($calevents);

if(!empty($calevents))
{
foreach($calevents as $cdate => $data)
{
list($cdt['year'], $cdt['month'], $cdt['day']) = explode('-', $cdate);
foreach($data as $vals)
echo $smcFunc['substr']($txt['months'][intval($cdt['month'])], 0, 3) .' '. $cdt['day'] .': '. $vals['link'] .'<br />';
}
}
Check out my new anime club. Discuss and share anime, or just fool around with other forumites. Join us at MyAnimeClub.

Offline NIBOGO

  • Newbie
  • *
  • Posts: 7
  • Gender: Male
    • MUNDO-SE
Re: Calendar PHP block
« Reply #74 on: 29.07.11, 06:25:17 »
Nice