collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 423
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

Blocks speak! Do you have an interest in getting more blocks - or even making your own? The Blocks Board is for you!

Author Topic: about calendar in SimplePortal 2 / SMF 1.1.X  (Read 71566 times)

0 Members and 1 Guest are viewing this topic.

Offline ???1031

  • ... feel not as a dev at the moment ...
  • Comrade
  • *
  • Posts: 789
  • Gender: Male
  • Overworked <<
  • SMF Version: None
  • SP Version: None
Re: about calendar in SimplePortal 1.1.5
« Reply #20 on: October 20, 2008, 01:05:44 AM »
Code: [Select]
Old one take the newest
I changed line 1, 3 and 42.

I'm not sure if the third error is solved... but the frist and the second should normal not appear any more :x.

Bye
DIN1031
« Last Edit: October 29, 2008, 07:39:06 AM by ???1031 »
Again... I'm having time problems...Normal Monday to Friday I'm at office from 6:00-16:00 (On my local time ;P).

Offline Manu

  • Translator
  • *
  • Posts: 203
  • Gender: Female
  • Angel by Day, Devil by Night
    • Arsenie Official Forum
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: about calendar in SimplePortal 1.1.5
« Reply #21 on: October 20, 2008, 05:31:27 AM »
Thanks ???1031!
I used the code you posted and I got the following entry in the error log

Quote
8: Undefined variable: event
File: /../.../.../.../.../Themes/default/SPortal1-1.template.php (main sub template - eval?)
Line: 99

This error I could find by myself, but I can't delete this entry in the error log

Quote
8: Undefined variable: start_date
File: /../.../.../.../.../Themes/default/SPortal1-1.template.php (main sub template - eval?)
Line: 99

This is the code I'm using now in the php block
Code: [Select]
global $scripturl, $modSettings, $sourcedir, $txt;

require_once(dirname(__FILE__) . '/../SSI.php');

$now = mktime() + $modSettings['time_offset'] * 3600;
         $today = date('j',$now);
         $year = date("Y",$now);
         $month = date("n",$now);
         $days = array();

         $day_name_length = 2;
         $month_href = $scripturl . '?action=calendar';
         $first_day = 0;
         $pn = array();

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

#retrieve this month events, holydays and birthdays
$days_in_month = gmdate('t',$first_of_month);
include_once($sourcedir . '/Calendar.php');
$low_date = $year.'-'.$month.'-01';
$high_date = $year.'-'.$month.'-'.$days_in_month;
$events = calendarEventArray($low_date, $high_date);
$birthdays = calendarBirthdayArray($low_date, $high_date);

#add important days to the days array
foreach($events as $startdate => $value)
$days[substr($startdate,8)] = array(NULL,NULL,'<a class="smalltext" style="color: white; font-weight: bold; background-color: '.(substr($startdate,8)<$today ? '#FF3366' : '#FFFF00').'; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.substr($events['start_date'],8).'" target="_self">'.substr($startdate,8).'</a>');

foreach($birthdays as $startdate => $value)
$days[substr($startdate,8)] = array(NULL,NULL,'<a class="smalltext" style="color: white; font-weight: bold; background-color: '.(substr($startdate,8)<$today ? '#FF3366' : '#FFFF00').'; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.substr($birthdays['start_date'],8).'" target="_self">'.substr($startdate,8).'</a>');

$today_date = $year.'-'.($month<10 ? '0'.$month : $month).'-'.$today;

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


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

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

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

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

if($weekday > 0) $calendar .= '<td class="smalltext" colspan="'.$weekday.'"> </td>'; #initial 'empty' days
for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){
if($weekday == 7){
$weekday   = 0; #start a new week
$calendar .= "</tr>\n<tr style=\"text-align:right;\">";
}
if(isset($days[$day]) and is_array($days[$day])){
@list($link, $classes, $content) = $days[$day];
if(is_null($content))  $content  = $day;
$calendar .= '<td "'.($classes ? ' class="'.htmlspecialchars($classes).'">' : '>').
($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).'</td>';
}
else
{
$calendar .= "<td class=\"smalltext\" style=\"padding-right:4px;\"><a";
if(((($weekday+$first_day) % 7)==0))
{
$calendar .= ' style="color:#C00000;"';
}
$calendar .= " href=\"".$scripturl."?action=calendar;sa=post;month=".$month.";year=".$year.";day=".$day."\" target=\"_self\">$day</a></td>";
}
}
if($weekday != 7) $calendar .= '<td class="smalltext" colspan="'.(7-$weekday).'"> </td>'; #remaining "empty" days

echo $calendar.'</tr>';

#crate notice for the next N days events. N is set in Settings.
if (ssi_todaysCalendar('')) {
$result = ssi_todaysCalendar('');
if(!empty($result['birthdays'])){
echo '<tr><td><hr></td><td colspan="5" class="smalltext" align="center"><b>Birthdays</b></td><td><hr></td></tr><td colspan="7" class="smalltext">';
$birthdays = $result['birthdays'];
echo '
<span style="color: #FF3366">' . $txt['calendar3b'] . '</span><br />';
foreach( $birthdays as $member )
echo '
<a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['name'], isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', '<br />';
echo '</td></tr>';
}
if(!empty($result['events']))
{
echo '<tr><td><hr></td><td colspan="5" class="smalltext" align="center"><b>Upcomings</b></td><td><hr></td></tr><td colspan="7" class="smalltext">';
echo '
<span style="color: #FFFF00">' . $txt['calendar4b'] . '</span><br /> ';
$events = $result['events'];
foreach ($events as $event)
{
echo '
'.substr($events['start_date'],8).'/'.substr($events['start_date'],5 , 2).':';
if ($event['can_edit'])
echo '
<a href="' . $event['modify_href'] . '" style="color: #FF0000;">*</a> ';
echo '
' . $event['link'] . '<br />';
}
}
  echo '</td></tr>';
}

echo '</table>';
Sometimes I'm an angel, sometimes I'm a devil, but I am always 100% woman and if you have a problem with me, learn to deal with it!

Offline Kosedragen

  • Jr. Member
  • **
  • Posts: 87
  • Soft
Re: about calendar in SimplePortal 1.1.5
« Reply #22 on: October 20, 2008, 09:33:37 AM »
What exactly was it you did, ディン1031. What is different now? ^^; Functionally I mean.

Offline ???1031

  • ... feel not as a dev at the moment ...
  • Comrade
  • *
  • Posts: 789
  • Gender: Male
  • Overworked <<
  • SMF Version: None
  • SP Version: None
Re: about calendar in SimplePortal 1.1.5
« Reply #23 on: October 21, 2008, 12:28:38 AM »
Sorry yesterday i was to tiered in the morning... now i post the fix correct...
Old Code, take the new one

What are the exact changes:
First i changed:

Line 1:
Code: [Select]
global $scripturl, $modSettings, $sourcedir;
to
Code: [Select]
global $scripturl, $modSettings, $sourcedir, $txt;
Add the global txt vars, normal the index lang file is loaded on SPortal. And they hold the missing txt string datas of this calendar.

Line 3:
Code: [Select]
require("/your/path/to/SSI.php");
to
Code: [Select]
require_once(dirname(__FILE__) . '/../SSI.php');
This is an unimportend change, it make it only more compatible ;)

Line 42:
Code: [Select]
foreach($events as $startdate => $value)
$days[substr($startdate,8)] = array(NULL,NULL,'<a class="smalltext" style="color: steelblue; font-weight: bold; background-color: '.(substr($startdate,8)<$today ? 'lightblue' : 'yellow').'; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.substr($event['start_date'],8).'" target="_self">'.substr($startdate,8).'</a>');

foreach($birthdays as $startdate => $value)
$days[substr($startdate,8)] = array(NULL,NULL,'<a class="smalltext" style="color: steelblue; font-weight: bold; background-color: '.(substr($startdate,8)<$today ? 'lightblue' : 'yellow').'; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.substr($birth['start_date'],8).'" target="_self">'.substr($startdate,8).'</a>');
to
Code: [Select]
foreach($events as $startdate => $event)
$days[substr($startdate,8)] = array(NULL,NULL,'<a class="smalltext" style="color: steelblue; font-weight: bold; background-color: '.(substr($startdate,8)<$today ? 'lightblue' : 'yellow').'; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.substr($event['start_date'],8).'" target="_self">'.substr($startdate,8).'</a>');

foreach($birthdays as $startdate => $birth)
$days[substr($startdate,8)] = array(NULL,NULL,'<a class="smalltext" style="color: steelblue; font-weight: bold; background-color: '.(substr($startdate,8)<$today ? 'lightblue' : 'yellow').'; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.substr($birth['start_date'],8).'" target="_self">'.substr($startdate,8).'</a>');
There i changed the $startdate => $birth and the same on the events...

So i hope this work now ;).

Bye
DIN1031

« Last Edit: October 29, 2008, 07:35:48 AM by ???1031 »
Again... I'm having time problems...Normal Monday to Friday I'm at office from 6:00-16:00 (On my local time ;P).

Offline Manu

  • Translator
  • *
  • Posts: 203
  • Gender: Female
  • Angel by Day, Devil by Night
    • Arsenie Official Forum
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: about calendar in SimplePortal 1.1.5
« Reply #24 on: October 28, 2008, 11:00:03 AM »
@???1031

I still get the error messages with the "start_date"   :'(

Here are the parts I found "start_date" in the code, but I have no clue what to do.  :'(

Code: [Select]
#add important days to the days array
foreach($events as $startdate => $event)
$days[substr($startdate,8)] = array(NULL,NULL,'<a class="smalltext" style="color: steelblue; font-weight: bold; background-color: '.(substr($startdate,8)<$today ? 'lightblue' : 'yellow').'; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.substr($event['start_date'],8).'" target="_self">'.substr($startdate,8).'</a>');

foreach($birthdays as $startdate => $birth)
$days[substr($startdate,8)] = array(NULL,NULL,'<a class="smalltext" style="color: steelblue; font-weight: bold; background-color: '.(substr($startdate,8)<$today ? 'lightblue' : 'yellow').'; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.substr($birth['start_date'],8).'" target="_self">'.substr($startdate,8).'</a>');

Code: [Select]
$events = $result['events'];
foreach ($events as $event)
{
echo '
'.substr($event['start_date'],8).'/'.substr($event['start_date'],5 , 2).':';
if ($event['can_edit'])
echo '
<a href="' . $event['modify_href'] . '" style="color: #FF0000;">*</a> ';
echo '
' . $event['link'] . '<br />';
}

I really love to use this calendar in our forum. :)
Sometimes I'm an angel, sometimes I'm a devil, but I am always 100% woman and if you have a problem with me, learn to deal with it!

Offline ???1031

  • ... feel not as a dev at the moment ...
  • Comrade
  • *
  • Posts: 789
  • Gender: Male
  • Overworked <<
  • SMF Version: None
  • SP Version: None
Re: about calendar in SimplePortal 1.1.5
« Reply #25 on: October 29, 2008, 07:38:27 AM »
Code: [Select]
Old Version
Code last time Changed: 31.10.2008

So i tried now the block myself to see how it work ;). And now this Version has no eval errors, in my log :).

The change to the last code is:

Code: [Select]
foreach($events as $startdate => $event)
$days[substr($startdate,8)] = array(NULL,NULL,'<a class="smalltext" style="color: steelblue; font-weight: bold; background-color: '.(substr($startdate,8)<$today ? 'lightblue' : 'yellow').'; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.substr($event['start_date'],8).'" target="_self">'.substr($startdate,8).'</a>');

foreach($birthdays as $startdate => $birth)
$days[substr($startdate,8)] = array(NULL,NULL,'<a class="smalltext" style="color: steelblue; font-weight: bold; background-color: '.(substr($startdate,8)<$today ? 'lightblue' : 'yellow').'; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.substr($birth['start_date'],8).'" target="_self">'.substr($startdate,8).'</a>');

to

Code: [Select]
#add important days to the days array
foreach($events as $startdate => $event) {
$cday = substr($startdate,8,2);
$days[$cday] = array(NULL,NULL,'<a class="smalltext" style="color: steelblue; font-weight: bold; background-color: '.($cday < $today ? 'lightblue' : 'yellow').'; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$cday.'" target="_self">'.$cday.'</a>');
}
foreach($birthdays as $startdate => $birth) {
$cday = substr($startdate,8,2);
$days[$cday] = array(NULL,NULL,'<a class="smalltext" style="color: steelblue; font-weight: bold; background-color: '.($cday < $today ? 'lightblue' : 'yellow').'; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$cday.'" target="_self">'.$cday.'</a>');
}

« Last Edit: October 31, 2008, 03:02:06 AM by ???1031 »
Again... I'm having time problems...Normal Monday to Friday I'm at office from 6:00-16:00 (On my local time ;P).

Offline AdreasGr

  • Newbie
  • Posts: 3
Re: about calendar in SimplePortal 1.1.5
« Reply #26 on: October 30, 2008, 05:30:23 AM »
Hi i am a new member, and i have one problem.

In my site i use 2 language : English ang Greek.

If i use English i have picture 1

if i use Greek i have picture 2

How i can fix this problem ??

I use the folloing code :

Code: [Select]
global $scripturl, $modSettings, $sourcedir, $txt;

require_once(dirname(__FILE__) . '/../SSI.php');

$now = mktime() + $modSettings['time_offset'] * 3600;
         $today = date('j',$now);
         $year = date("Y",$now);
         $month = date("n",$now);
         $days = array();

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

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

#retrieve this month events, holydays and birthdays
$days_in_month = gmdate('t',$first_of_month);
include_once($sourcedir . '/Calendar.php');
$low_date = $year.'-'.$month.'-01';
$high_date = $year.'-'.$month.'-'.$days_in_month;
$events = calendarEventArray($low_date, $high_date);
$birthdays = calendarBirthdayArray($low_date, $high_date);

#add important days to the days array
foreach($events as $startdate => $event) {
$cday = substr($startdate,8,2);
$days[$cday] = array(NULL,NULL,'<a class="smalltext" style="color: steelblue; font-weight: bold; background-color: '.($cday < $today ? 'lightblue' : 'yellow').'; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$cday.'" target="_self">'.$cday.'</a>');
}
foreach($birthdays as $startdate => $birth) {
$cday = substr($startdate,8,2);
$days[$cday] = array(NULL,NULL,'<a class="smalltext" style="color: steelblue; font-weight: bold; background-color: '.($cday < $today ? 'lightblue' : 'yellow').'; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$cday.'" target="_self">'.$cday.'</a>');
}

$today_date = $year.'-'.($month<10 ? '0'.$month : $month).'-'.$today;

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


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

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

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

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

if($weekday > 0) $calendar .= '<td class="smalltext" colspan="'.$weekday.'"> </td>'; #initial 'empty' days
for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){
if($weekday == 7){
$weekday   = 0; #start a new week
$calendar .= "</tr>\n<tr style=\"text-align:right;\">";
}
if(isset($days[$day]) and is_array($days[$day])){
@list($link, $classes, $content) = $days[$day];
if(is_null($content))  $content  = $day;
$calendar .= '<td "'.($classes ? ' class="'.htmlspecialchars($classes).'">' : '>').
($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).'</td>';
}
else
{
$calendar .= "<td class=\"smalltext\" style=\"padding-right:4px;\"><a";
if(((($weekday+$first_day) % 7)==0))
{
$calendar .= ' style="color:#C00000;"';
}
$calendar .= " href=\"".$scripturl."?action=calendar;sa=post;month=".$month.";year=".$year.";day=".$day."\" target=\"_self\">$day</a></td>";
}
}
if($weekday != 7) $calendar .= '<td class="smalltext" colspan="'.(7-$weekday).'"> </td>'; #remaining "empty" days

echo $calendar.'</tr>';

#crate notice for the next N days events. N is set in Settings.
if (ssi_todaysCalendar('')) {
$result = ssi_todaysCalendar('');
if(!empty($result['birthdays'])){
echo '<tr><td><hr></td><td colspan="5" class="smalltext" align="center"><b>Birthdays</b></td><td><hr></td></tr><td colspan="7" class="smalltext">';
$birthdays = $result['birthdays'];
echo '
<span style="color: #' . $modSettings['cal_bdaycolor'] . ';">' . $txt['calendar3b'] . '</span><br />';
foreach( $birthdays as $member )
echo '
<a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['name'], isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', '<br />';
echo '</td></tr>';
}
if(!empty($result['events']))
{
echo '<tr><td><hr></td><td colspan="5" class="smalltext" align="center"><b>Events</b></td><td><hr></td></tr><td colspan="7" class="smalltext">';
echo '
<span style="color: #' . $modSettings['cal_eventcolor'] . ';">' . $txt['calendar4b'] . '</span><br /> ';
$events = $result['events'];
foreach ($events as $event)
{
echo '
'.substr($event['start_date'],8).'/'.substr($event['start_date'],5 , 2).':';
if ($event['can_edit'])
echo '
<a href="' . $event['modify_href'] . '" style="color: #FF0000;">*</a> ';
echo '
' . $event['link'] . '<br />';
}
}
  echo '</td></tr>';
}

echo '</table>';

Sorry for bad English
« Last Edit: October 30, 2008, 05:41:54 AM by AdreasGr »

Offline ???1031

  • ... feel not as a dev at the moment ...
  • Comrade
  • *
  • Posts: 789
  • Gender: Male
  • Overworked <<
  • SMF Version: None
  • SP Version: None
Re: about calendar in SimplePortal 1.1.5
« Reply #27 on: October 31, 2008, 03:01:40 AM »
Code: [Select]
//Calender Elina Copy, Version 31-10-2008-1
//The script take the Days from the SMF txt strings, so that normal the correct day and month name will be used :)
//This skript show a small calender with Birthdays and Events on it.

global $scripturl, $modSettings, $sourcedir, $txt;

//Chanche this oly if it not work =D
require_once(dirname(__FILE__) . '/../SSI.php');

//With that you can start the calander on a other day
//-1 = Start on Saturaday, 0 = Start on Sunday, 1 = Start on Monday, 2 = Start on Thusday...
$first_day = 0;
//How long should the day, if the number higher 3 than the complete dayname will be shown
$day_name_length = 2;
//The Color of the background of days with Events or birthdays, you can use css colors
$color_items = 'lightblue';

//The Color of the background of days with Events or birthdays, you can use css colors
$color_today = 'yellow';

//The Textcolor for the days
$color_text = 'steelblue';

//If you have a diffrent calender you can change the link to it here
$month_href = $scripturl . '?action=calendar';


//Okay please don't do anything here if you not now what you do
/**************************************************************/
$now = mktime() + $modSettings['time_offset'] * 3600;
$today = date('j',$now);
$year = date("Y",$now);
$month = date("n",$now);
$days = array();
$pn = array();

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

#retrieve this month events, holydays and birthdays
$days_in_month = gmdate('t',$first_of_month);
include_once($sourcedir . '/Calendar.php');
$low_date = $year.'-'.$month.'-01';
$high_date = $year.'-'.$month.'-'.$days_in_month;
$events = calendarEventArray($low_date, $high_date);
$birthdays = calendarBirthdayArray($low_date, $high_date);

#add important days to the days array
foreach($events as $startdate => $event) {
$cday = substr($startdate,8,2);
$days[$cday] = array(NULL,NULL,'<a class="smalltext" style="color: '.$color_text.'; font-weight: bold; background-color: '.($cday < $today ? $color_items : $color_today).'; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$cday.'" target="_self">'.$cday.'</a>');
}
foreach($birthdays as $startdate => $birth) {
$cday = substr($startdate,8,2);
$days[$cday] = array(NULL,NULL,'<a class="smalltext" style="color: '.$color_text.'; font-weight: bold; background-color: '.($cday < $today ? $color_items : $color_today).'; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$cday.'" target="_self">'.$cday.'</a>');
}

$today_date = $year.'-'.($month<10 ? '0'.$month : $month).'-'.$today;

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

//Wellcome to the smf way of Day building with existing Language strings :D
$day_names = array(); #generate all the day names according to the current locale
$day_names = $txt['days'];
//So lets see $firstday = 0 means sunday this is the first day :)
//if there is a higher number than i need to resort them
//negativ values can also be used :)
if(!empty($first_day)) {
if($first_day < 0)
$first_day = 7-(abs($first_day)%7);
else
$first_day = ($first_day%7);
}
if(!empty($first_day)) {
$old = $day_names;
$day_names = array();
//Create the new day order :)
for($n=0; $n<7; $n++) {
$c = (($first_day+$n)%7);
$day_names[$n] = $old[$c];
}
}

list($month, $year, $weekday) = explode(',',gmstrftime('%m,%Y,%w',$first_of_month));
$weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day
$title = $txt['months_titles'][$month].' '.$year;  #This is the SMF Text string, so it should be corrected for ut8 or iso

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

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

if($weekday > 0) $calendar .= '<td class="smalltext" colspan="'.$weekday.'"> </td>'; #initial 'empty' days
for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){
if($weekday == 7){
$weekday   = 0; #start a new week
$calendar .= "</tr>\n<tr style=\"text-align:right;\">";
}
if(isset($days[$day]) and is_array($days[$day])){
@list($link, $classes, $content) = $days[$day];
if(is_null($content))  $content  = $day;
$calendar .= '<td "'.($classes ? ' class="'.htmlspecialchars($classes).'">' : '>').
($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).'</td>';
}
else
{
$calendar .= "<td class=\"smalltext\" style=\"padding-right:4px;\"><a";
if(((($weekday+$first_day) % 7)==0))
{
$calendar .= ' style="color:#C00000;"';
}
$calendar .= " href=\"".$scripturl."?action=calendar;sa=post;month=".$month.";year=".$year.";day=".$day."\" target=\"_self\">$day</a></td>";
}
}
if($weekday != 7) $calendar .= '<td class="smalltext" colspan="'.(7-$weekday).'"> </td>'; #remaining "empty" days

echo $calendar.'</tr>';

#crate notice for the next N days events. N is set in Settings.
if (ssi_todaysCalendar('')) {
$result = ssi_todaysCalendar('');
if(!empty($result['birthdays'])){
echo '<tr><td><hr></td><td colspan="5" class="smalltext" align="center"><b>Birthdays</b></td><td><hr></td></tr><td colspan="7" class="smalltext">';
$birthdays = $result['birthdays'];
echo '
<span style="color: #' . $modSettings['cal_bdaycolor'] . ';">' . $txt['calendar3b'] . '</span><br />';
foreach( $birthdays as $member )
echo '
<a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['name'], isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', '<br />';
echo '</td></tr>';
}
if(!empty($result['events']))
{
echo '<tr><td><hr></td><td colspan="5" class="smalltext" align="center"><b>Upcomings</b></td><td><hr></td></tr><td colspan="7" class="smalltext">';
echo '
<span style="color: #' . $modSettings['cal_eventcolor'] . ';">' . $txt['calendar4b'] . '</span><br /> ';
$events = $result['events'];
foreach ($events as $event)
{
echo '
'.substr($event['start_date'],8).'/'.substr($event['start_date'],5 , 2).':';
if ($event['can_edit'])
echo '
<a href="' . $event['modify_href'] . '" style="color: #FF0000;">*</a> ';
echo '
' . $event['link'] . '<br />';
}
}
  echo '</td></tr>';
}

echo '</table>';

So now event the days and month will be use the smf text strings for building this.

Bye
DIN1031
Again... I'm having time problems...Normal Monday to Friday I'm at office from 6:00-16:00 (On my local time ;P).

Offline AdreasGr

  • Newbie
  • Posts: 3
Re: about calendar in SimplePortal 1.1.5
« Reply #28 on: October 31, 2008, 04:01:22 AM »
Code: [Select]
//Calender Elina Copy, Version 31-10-2008-1
//The script take the Days from the SMF txt strings, so that normal the correct day and month name will be used :)
//This skript show a small calender with Birthdays and Events on it.

global $scripturl, $modSettings, $sourcedir, $txt;

//Chanche this oly if it not work =D
require_once(dirname(__FILE__) . '/../SSI.php');

//With that you can start the calander on a other day
//-1 = Start on Saturaday, 0 = Start on Sunday, 1 = Start on Monday, 2 = Start on Thusday...
$first_day = 0;
//How long should the day, if the number higher 3 than the complete dayname will be shown
$day_name_length = 2;
//The Color of the background of days with Events or birthdays, you can use css colors
$color_items = 'lightblue';

//The Color of the background of days with Events or birthdays, you can use css colors
$color_today = 'yellow';

//The Textcolor for the days
$color_text = 'steelblue';

//If you have a diffrent calender you can change the link to it here
$month_href = $scripturl . '?action=calendar';


//Okay please don't do anything here if you not now what you do
/**************************************************************/
$now = mktime() + $modSettings['time_offset'] * 3600;
$today = date('j',$now);
$year = date("Y",$now);
$month = date("n",$now);
$days = array();
$pn = array();

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

#retrieve this month events, holydays and birthdays
$days_in_month = gmdate('t',$first_of_month);
include_once($sourcedir . '/Calendar.php');
$low_date = $year.'-'.$month.'-01';
$high_date = $year.'-'.$month.'-'.$days_in_month;
$events = calendarEventArray($low_date, $high_date);
$birthdays = calendarBirthdayArray($low_date, $high_date);

#add important days to the days array
foreach($events as $startdate => $event) {
$cday = substr($startdate,8,2);
$days[$cday] = array(NULL,NULL,'<a class="smalltext" style="color: '.$color_text.'; font-weight: bold; background-color: '.($cday < $today ? $color_items : $color_today).'; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$cday.'" target="_self">'.$cday.'</a>');
}
foreach($birthdays as $startdate => $birth) {
$cday = substr($startdate,8,2);
$days[$cday] = array(NULL,NULL,'<a class="smalltext" style="color: '.$color_text.'; font-weight: bold; background-color: '.($cday < $today ? $color_items : $color_today).'; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$cday.'" target="_self">'.$cday.'</a>');
}

$today_date = $year.'-'.($month<10 ? '0'.$month : $month).'-'.$today;

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

//Wellcome to the smf way of Day building with existing Language strings :D
$day_names = array(); #generate all the day names according to the current locale
$day_names = $txt['days'];
//So lets see $firstday = 0 means sunday this is the first day :)
//if there is a higher number than i need to resort them
//negativ values can also be used :)
if(!empty($first_day)) {
if($first_day < 0)
$first_day = 7-(abs($first_day)%7);
else
$first_day = ($first_day%7);
}
if(!empty($first_day)) {
$old = $day_names;
$day_names = array();
//Create the new day order :)
for($n=0; $n<7; $n++) {
$c = (($first_day+$n)%7);
$day_names[$n] = $old[$c];
}
}

list($month, $year, $weekday) = explode(',',gmstrftime('%m,%Y,%w',$first_of_month));
$weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day
$title = $txt['months_titles'][$month].' '.$year;  #This is the SMF Text string, so it should be corrected for ut8 or iso

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

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

if($weekday > 0) $calendar .= '<td class="smalltext" colspan="'.$weekday.'"> </td>'; #initial 'empty' days
for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){
if($weekday == 7){
$weekday   = 0; #start a new week
$calendar .= "</tr>\n<tr style=\"text-align:right;\">";
}
if(isset($days[$day]) and is_array($days[$day])){
@list($link, $classes, $content) = $days[$day];
if(is_null($content))  $content  = $day;
$calendar .= '<td "'.($classes ? ' class="'.htmlspecialchars($classes).'">' : '>').
($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).'</td>';
}
else
{
$calendar .= "<td class=\"smalltext\" style=\"padding-right:4px;\"><a";
if(((($weekday+$first_day) % 7)==0))
{
$calendar .= ' style="color:#C00000;"';
}
$calendar .= " href=\"".$scripturl."?action=calendar;sa=post;month=".$month.";year=".$year.";day=".$day."\" target=\"_self\">$day</a></td>";
}
}
if($weekday != 7) $calendar .= '<td class="smalltext" colspan="'.(7-$weekday).'"> </td>'; #remaining "empty" days

echo $calendar.'</tr>';

#crate notice for the next N days events. N is set in Settings.
if (ssi_todaysCalendar('')) {
$result = ssi_todaysCalendar('');
if(!empty($result['birthdays'])){
echo '<tr><td><hr></td><td colspan="5" class="smalltext" align="center"><b>Birthdays</b></td><td><hr></td></tr><td colspan="7" class="smalltext">';
$birthdays = $result['birthdays'];
echo '
<span style="color: #' . $modSettings['cal_bdaycolor'] . ';">' . $txt['calendar3b'] . '</span><br />';
foreach( $birthdays as $member )
echo '
<a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['name'], isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', '<br />';
echo '</td></tr>';
}
if(!empty($result['events']))
{
echo '<tr><td><hr></td><td colspan="5" class="smalltext" align="center"><b>Upcomings</b></td><td><hr></td></tr><td colspan="7" class="smalltext">';
echo '
<span style="color: #' . $modSettings['cal_eventcolor'] . ';">' . $txt['calendar4b'] . '</span><br /> ';
$events = $result['events'];
foreach ($events as $event)
{
echo '
'.substr($event['start_date'],8).'/'.substr($event['start_date'],5 , 2).':';
if ($event['can_edit'])
echo '
<a href="' . $event['modify_href'] . '" style="color: #FF0000;">*</a> ';
echo '
' . $event['link'] . '<br />';
}
}
  echo '</td></tr>';
}

echo '</table>';

So now event the days and month will be use the smf text strings for building this.

Bye
DIN1031


I try your code and problem still only in days....
Any other ideas ??

Offline ???1031

  • ... feel not as a dev at the moment ...
  • Comrade
  • *
  • Posts: 789
  • Gender: Male
  • Overworked <<
  • SMF Version: None
  • SP Version: None
Re: about calendar in SimplePortal 1.1.5
« Reply #29 on: October 31, 2008, 07:41:53 AM »
Code: [Select]
//Calender Elina Copy, Version 31-10-2008-2
//The script take the Days from the SMF txt strings, so that normal the correct day and month name will be used :)
//This skript show a small calender with Birthdays and Events on it.

global $scripturl, $modSettings, $sourcedir, $txt;

//Chanche this oly if it not work =D
require_once(dirname(__FILE__) . '/../SSI.php');

//With that you can start the calander on a other day
//-1 = Start on Saturaday, 0 = Start on Sunday, 1 = Start on Monday, 2 = Start on Thusday...
$first_day = 0;
//How long should the day, if the number higher 3 than the complete dayname will be shown
//0 is short 1 is full name :)
$day_name_length = 0;

//The Color of the background of days with Events or birthdays, you can use css colors
$color_items = 'lightblue';

//The Color of the background of days with Events or birthdays, you can use css colors
$color_today = 'yellow';

//The Textcolor for the days
$color_text = 'steelblue';

//If you have a diffrent calender you can change the link to it here
$month_href = $scripturl . '?action=calendar';


//Okay please don't do anything here if you not now what you do
/**************************************************************/
$now = mktime() + $modSettings['time_offset'] * 3600;
$today = date('j',$now);
$year = date("Y",$now);
$month = date("n",$now);
$days = array();
$pn = array();

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

#retrieve this month events, holydays and birthdays
$days_in_month = gmdate('t',$first_of_month);
include_once($sourcedir . '/Calendar.php');
$low_date = $year.'-'.$month.'-01';
$high_date = $year.'-'.$month.'-'.$days_in_month;
$events = calendarEventArray($low_date, $high_date);
$birthdays = calendarBirthdayArray($low_date, $high_date);

#add important days to the days array
foreach($events as $startdate => $event) {
$cday = substr($startdate,8,2);
$days[$cday] = array(NULL,NULL,'<a class="smalltext" style="color: '.$color_text.'; font-weight: bold; background-color: '.($cday < $today ? $color_items : $color_today).'; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$cday.'" target="_self">'.$cday.'</a>');
}
foreach($birthdays as $startdate => $birth) {
$cday = substr($startdate,8,2);
$days[$cday] = array(NULL,NULL,'<a class="smalltext" style="color: '.$color_text.'; font-weight: bold; background-color: '.($cday < $today ? $color_items : $color_today).'; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$cday.'" target="_self">'.$cday.'</a>');
}

$today_date = $year.'-'.($month<10 ? '0'.$month : $month).'-'.$today;

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

//Wellcome to the smf way of Day building with existing Language strings :D
$day_names = $txt['days'];
$day_names_short = $txt['days_short'];
//So lets see $firstday = 0 means sunday this is the first day :)
//if there is a higher number than i need to resort them
//negativ values can also be used :)
if(!empty($first_day)) {
if($first_day < 0)
$first_day = 7-(abs($first_day)%7);
else
$first_day = ($first_day%7);
}
if(!empty($first_day)) {
$old = $day_names;
$old_s = $day_names_short;
$day_names = array();
$day_names_short = array();
//Create the new day order :)
for($n=0; $n<7; $n++) {
$c = (($first_day+$n)%7);
$day_names[$n] = $old[$c];
$day_names_short[$n] = $old_s[$c];
}
}

list($month, $year, $weekday) = explode(',',gmstrftime('%m,%Y,%w',$first_of_month));
$weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day
$title = $txt['months_titles'][$month].' '.$year;  #This is the SMF Text string, so it should be corrected for ut8 or iso

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

//Put out the Daynames :)
foreach($day_names as $k => $d)
$calendar .= '<th class="smalltext" abbr="'.$d.'">'.(!empty($day_name_length) ? $d : $day_names_short[$k]).'</th>';
$calendar .= "</tr>\n<tr style=\"text-align:right;\">";

if($weekday > 0) $calendar .= '<td class="smalltext" colspan="'.$weekday.'"> </td>'; #initial 'empty' days
for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){
if($weekday == 7){
$weekday   = 0; #start a new week
$calendar .= "</tr>\n<tr style=\"text-align:right;\">";
}
if(isset($days[$day]) and is_array($days[$day])){
@list($link, $classes, $content) = $days[$day];
if(is_null($content))  $content  = $day;
$calendar .= '<td "'.($classes ? ' class="'.htmlspecialchars($classes).'">' : '>').
($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).'</td>';
}
else
{
$calendar .= "<td class=\"smalltext\" style=\"padding-right:4px;\"><a";
if(((($weekday+$first_day) % 7)==0))
{
$calendar .= ' style="color:#C00000;"';
}
$calendar .= " href=\"".$scripturl."?action=calendar;sa=post;month=".$month.";year=".$year.";day=".$day."\" target=\"_self\">$day</a></td>";
}
}
if($weekday != 7) $calendar .= '<td class="smalltext" colspan="'.(7-$weekday).'"> </td>'; #remaining "empty" days

echo $calendar.'</tr>';

#crate notice for the next N days events. N is set in Settings.
if (ssi_todaysCalendar('')) {
$result = ssi_todaysCalendar('');
if(!empty($result['birthdays'])){
echo '<tr><td><hr></td><td colspan="5" class="smalltext" align="center"><b>Birthdays</b></td><td><hr></td></tr><td colspan="7" class="smalltext">';
$birthdays = $result['birthdays'];
echo '
<span style="color: #' . $modSettings['cal_bdaycolor'] . ';">' . $txt['calendar3b'] . '</span><br />';
foreach( $birthdays as $member )
echo '
<a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['name'], isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', '<br />';
echo '</td></tr>';
}
if(!empty($result['events']))
{
echo '<tr><td><hr></td><td colspan="5" class="smalltext" align="center"><b>Upcomings</b></td><td><hr></td></tr><td colspan="7" class="smalltext">';
echo '
<span style="color: #' . $modSettings['cal_eventcolor'] . ';">' . $txt['calendar4b'] . '</span><br /> ';
$events = $result['events'];
foreach ($events as $event)
{
echo '
'.substr($event['start_date'],8).'/'.substr($event['start_date'],5 , 2).':';
if ($event['can_edit'])
echo '
<a href="' . $event['modify_href'] . '" style="color: #FF0000;">*</a> ';
echo '
' . $event['link'] . '<br />';
}
}
  echo '</td></tr>';
}

echo '</table>';
So now even the short tags are taken by smf ;).
So you can only choice short or full name :).

Bye
DIN1031
Again... I'm having time problems...Normal Monday to Friday I'm at office from 6:00-16:00 (On my local time ;P).

Offline AdreasGr

  • Newbie
  • Posts: 3
Re: about calendar in SimplePortal 1.1.5
« Reply #30 on: October 31, 2008, 11:49:16 AM »
Ok now works fine  :applause: :applause: :applause:

Thank you.!

 :thumbsup: :thumbsup: :thumbsup:

Offline Aw06

  • Full Member
  • ***
  • Posts: 238
  • Gender: Male
    • www.ShopinJA.com
  • SMF Version: 1.1.13
  • SP Version: 2.3.2
Re: about calendar in SimplePortal 1.1.5
« Reply #31 on: November 04, 2008, 01:15:44 PM »
Code: [Select]
//Calender Elina Copy, Version 31-10-2008-2
//The script take the Days from the SMF txt strings, so that normal the correct day and month name will be used :)
//This skript show a small calender with Birthdays and Events on it.

global $scripturl, $modSettings, $sourcedir, $txt;

//Chanche this oly if it not work =D
require_once(dirname(__FILE__) . '/../SSI.php');

//With that you can start the calander on a other day
//-1 = Start on Saturaday, 0 = Start on Sunday, 1 = Start on Monday, 2 = Start on Thusday...
$first_day = 0;
//How long should the day, if the number higher 3 than the complete dayname will be shown
//0 is short 1 is full name :)
$day_name_length = 0;

//The Color of the background of days with Events or birthdays, you can use css colors
$color_items = 'lightblue';

//The Color of the background of days with Events or birthdays, you can use css colors
$color_today = 'yellow';

//The Textcolor for the days
$color_text = 'steelblue';

//If you have a diffrent calender you can change the link to it here
$month_href = $scripturl . '?action=calendar';


//Okay please don't do anything here if you not now what you do
/**************************************************************/
$now = mktime() + $modSettings['time_offset'] * 3600;
$today = date('j',$now);
$year = date("Y",$now);
$month = date("n",$now);
$days = array();
$pn = array();

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

#retrieve this month events, holydays and birthdays
$days_in_month = gmdate('t',$first_of_month);
include_once($sourcedir . '/Calendar.php');
$low_date = $year.'-'.$month.'-01';
$high_date = $year.'-'.$month.'-'.$days_in_month;
$events = calendarEventArray($low_date, $high_date);
$birthdays = calendarBirthdayArray($low_date, $high_date);

#add important days to the days array
foreach($events as $startdate => $event) {
$cday = substr($startdate,8,2);
$days[$cday] = array(NULL,NULL,'<a class="smalltext" style="color: '.$color_text.'; font-weight: bold; background-color: '.($cday < $today ? $color_items : $color_today).'; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$cday.'" target="_self">'.$cday.'</a>');
}
foreach($birthdays as $startdate => $birth) {
$cday = substr($startdate,8,2);
$days[$cday] = array(NULL,NULL,'<a class="smalltext" style="color: '.$color_text.'; font-weight: bold; background-color: '.($cday < $today ? $color_items : $color_today).'; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$cday.'" target="_self">'.$cday.'</a>');
}

$today_date = $year.'-'.($month<10 ? '0'.$month : $month).'-'.$today;

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

//Wellcome to the smf way of Day building with existing Language strings :D
$day_names = $txt['days'];
$day_names_short = $txt['days_short'];
//So lets see $firstday = 0 means sunday this is the first day :)
//if there is a higher number than i need to resort them
//negativ values can also be used :)
if(!empty($first_day)) {
if($first_day < 0)
$first_day = 7-(abs($first_day)%7);
else
$first_day = ($first_day%7);
}
if(!empty($first_day)) {
$old = $day_names;
$old_s = $day_names_short;
$day_names = array();
$day_names_short = array();
//Create the new day order :)
for($n=0; $n<7; $n++) {
$c = (($first_day+$n)%7);
$day_names[$n] = $old[$c];
$day_names_short[$n] = $old_s[$c];
}
}

list($month, $year, $weekday) = explode(',',gmstrftime('%m,%Y,%w',$first_of_month));
$weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day
$title = $txt['months_titles'][$month].' '.$year;  #This is the SMF Text string, so it should be corrected for ut8 or iso

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

//Put out the Daynames :)
foreach($day_names as $k => $d)
$calendar .= '<th class="smalltext" abbr="'.$d.'">'.(!empty($day_name_length) ? $d : $day_names_short[$k]).'</th>';
$calendar .= "</tr>\n<tr style=\"text-align:right;\">";

if($weekday > 0) $calendar .= '<td class="smalltext" colspan="'.$weekday.'"> </td>'; #initial 'empty' days
for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){
if($weekday == 7){
$weekday   = 0; #start a new week
$calendar .= "</tr>\n<tr style=\"text-align:right;\">";
}
if(isset($days[$day]) and is_array($days[$day])){
@list($link, $classes, $content) = $days[$day];
if(is_null($content))  $content  = $day;
$calendar .= '<td "'.($classes ? ' class="'.htmlspecialchars($classes).'">' : '>').
($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).'</td>';
}
else
{
$calendar .= "<td class=\"smalltext\" style=\"padding-right:4px;\"><a";
if(((($weekday+$first_day) % 7)==0))
{
$calendar .= ' style="color:#C00000;"';
}
$calendar .= " href=\"".$scripturl."?action=calendar;sa=post;month=".$month.";year=".$year.";day=".$day."\" target=\"_self\">$day</a></td>";
}
}
if($weekday != 7) $calendar .= '<td class="smalltext" colspan="'.(7-$weekday).'"> </td>'; #remaining "empty" days

echo $calendar.'</tr>';

#crate notice for the next N days events. N is set in Settings.
if (ssi_todaysCalendar('')) {
$result = ssi_todaysCalendar('');
if(!empty($result['birthdays'])){
echo '<tr><td><hr></td><td colspan="5" class="smalltext" align="center"><b>Birthdays</b></td><td><hr></td></tr><td colspan="7" class="smalltext">';
$birthdays = $result['birthdays'];
echo '
<span style="color: #' . $modSettings['cal_bdaycolor'] . ';">' . $txt['calendar3b'] . '</span><br />';
foreach( $birthdays as $member )
echo '
<a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['name'], isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', '<br />';
echo '</td></tr>';
}
if(!empty($result['events']))
{
echo '<tr><td><hr></td><td colspan="5" class="smalltext" align="center"><b>Upcomings</b></td><td><hr></td></tr><td colspan="7" class="smalltext">';
echo '
<span style="color: #' . $modSettings['cal_eventcolor'] . ';">' . $txt['calendar4b'] . '</span><br /> ';
$events = $result['events'];
foreach ($events as $event)
{
echo '
'.substr($event['start_date'],8).'/'.substr($event['start_date'],5 , 2).':';
if ($event['can_edit'])
echo '
<a href="' . $event['modify_href'] . '" style="color: #FF0000;">*</a> ';
echo '
' . $event['link'] . '<br />';
}
}
  echo '</td></tr>';
}

echo '</table>';
So now even the short tags are taken by smf ;).
So you can only choice short or full name :).

Bye
DIN1031

Nice code .. but it doesnt seem to be displaying Holidays ... can you look into that ...

Also .. instead of it reading 'upcomings' can you edit it to say 'Events'

also can you make us the see day of the persons birthday .. example
Code: [Select]
____Birthdays____
Upcoming Birthdays:
Nov 10 - test user (27)
Nov 12 - test user2 (19)
Nov 14 - test user3 (20)

thanks in advance..  8)
« Last Edit: November 04, 2008, 01:28:54 PM by Aw06 »

Offline ???1031

  • ... feel not as a dev at the moment ...
  • Comrade
  • *
  • Posts: 789
  • Gender: Male
  • Overworked <<
  • SMF Version: None
  • SP Version: None
Re: about calendar in SimplePortal 1.1.5
« Reply #32 on: November 04, 2008, 03:57:24 PM »
Yes your right ;) there are no holidays in it.
It was never in the original code, but i think it will be no problem to add them, too ;).
Again... I'm having time problems...Normal Monday to Friday I'm at office from 6:00-16:00 (On my local time ;P).

Offline Aw06

  • Full Member
  • ***
  • Posts: 238
  • Gender: Male
    • www.ShopinJA.com
  • SMF Version: 1.1.13
  • SP Version: 2.3.2
Re: about calendar in SimplePortal 1.1.5
« Reply #33 on: November 04, 2008, 04:04:04 PM »
Yes your right ;) there are no holidays in it.
It was never in the original code, but i think it will be no problem to add them, too ;).

ok kool, i await your edits  :pirate:

Offline ???1031

  • ... feel not as a dev at the moment ...
  • Comrade
  • *
  • Posts: 789
  • Gender: Male
  • Overworked <<
  • SMF Version: None
  • SP Version: None
Re: about calendar in SimplePortal 2 / SMF 1.1.X
« Reply #34 on: November 08, 2008, 10:20:58 AM »
Okay now i overworked the block :X

What the changes
! Fixed the today color bug ;)
! Check if the user is allowed to post a calendar information.
+ Add options for enable and disable the block
* Remove the SSI.php require (I think we don't need the already loaded informations twice) ;)
* Only Today informations are shown under the Calendar (No Future, only todays!)
+ Add a easy way to change the colors
+ Add Holidays
* Change the name to DIN1031 Version (I think e rewrote to much xD).
+... rewrite a lot ;).

So Here is the Code
Code: [Select]
/*
Calender DIN1031 Version 08-11-2008-1
This is a costumizable calendar php block
It will show a calendar, and add the Today Events, Holidays and Birthdays.
Normal it's programmed and tested for SMF 1.1.X
I don't use any SSI.php, because all data that needed is loaded.
*/
global $scripturl, $modSettings, $sourcedir, $txt;

//With that you can start the calander on a other day
//-1 = Start on Saturaday, 0 = Start on Sunday, 1 = Start on Monday, 2 = Start on Thusday...
$first_day = 1;

//How long should the day, if the number higher 3 than the complete dayname will be shown
$day_name_length = 0; //0 is short day name 1 is full day name :)

//The background color of days with Events, birthdays or holidays, you can use css colors
$color_background_items_mixed = 'lightblue';
$color_background_items_event = 'lightblue';
$color_background_items_birthday = 'lightblue';
$color_background_items_holiday = 'lightblue';

//The textcolor of days with Events, birthdays or holidays, you can use css colors
$color_text_items_mixed = 'steelblue';
$color_text_items_event = 'steelblue';
$color_text_items_birthday = 'steelblue';
$color_text_items_holiday = 'steelblue';

//The Color of the todays background / text
$color_background_today = 'white';
$color_text_today = 'green';

//The Textcolor for the standard days
$color_text = 'steelblue';

//The Textcolor for the Sundays
$color_text_sunday = '#C00000';

//If you have a diffrent calender you can change the link to it here
$month_href = $scripturl . '?action=calendar';

//What should the callendar show?
$show_events = 1; //0 No, 1 Yes
$show_birthdays = 1; //0 No, 1 Yes
$show_holidays = 1; //0 No, 1 Yes
//Show the single events and items of the day :)
$show_today = 1; //0 No, 1 Yes

//Okay please don't do anything here if you not now what you do
/**************************************************************/
// You can't do anything if the calendar is off!
if (empty($modSettings['cal_enabled']))
fatal_lang_error('calendar_off', false);

$now = mktime() + $modSettings['time_offset'] * 3600;
$today = date('j',$now);
$year = date("Y",$now);
$month = date("n",$now);
$days = array();
$pn = array();

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

//retrieve this month events, holydays and birthdays
$days_in_month = gmdate('t',$first_of_month);
include_once($sourcedir . '/Calendar.php');
$low_date = $year.'-'.$month.'-01';
$high_date = $year.'-'.$month.'-'.$days_in_month;
$can_post_calendar = allowedTo('calendar_post');
$calendarDataToday = array('events' => array(), 'birthdays' => array(), 'holidays' => array());
$todayDate = date("Y-m-d", time());

//add important days to the days array
if(!empty($show_events)) {
$events = calendarEventArray($low_date, $high_date);
foreach($events as $startdate => $event) {
//This insert the today events if they exist
if($todayDate == $startdate)
$calendarDataToday['events'] = $event;
$cday = (int) substr($startdate,8,2);
//We must select between create or only show!
$href_calendar = $can_post_calendar && $cday >= $today ? $scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$cday : $scripturl.'?action=calendar';
$days[$cday] = '<a class="smalltext" style="color: '.$color_text_items_event.'; font-weight: bold; background-color: '.$color_background_items_event.'; padding: 0px 4px 0px 4px;" href="'.$href_calendar.'" target="_self">'.$cday.'</a>';
}
}
//Add holidays into the day array?
if(!empty($show_birthdays)) {
$birthdays = calendarBirthdayArray($low_date, $high_date);
foreach($birthdays as $startdate => $birth) {
//This insert the today events if they exist
if($todayDate == $startdate)
$calendarDataToday['birthdays'] = $birth;
$cday = (int) substr($startdate,8,2);
//We must select between create or only show!
$href_calendar = $can_post_calendar && $cday >= $today ? $scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$cday : $scripturl.'?action=calendar';
//Mixed color?
$text_color = !empty($days[$cday]) ? $color_text_items_mixed : $color_text_items_birthday;
$background_color = !empty($days[$cday]) ? $color_background_items_mixed : $color_background_items_birthday;
$days[$cday] = '<a class="smalltext" style="color: '.$text_color.'; font-weight: bold; background-color: '.$background_color.'; padding: 0px 4px 0px 4px;" href="'.$href_calendar.'" target="_self">'.$cday.'</a>';
}
}
//Add holidays into the day array?
if(!empty($show_holidays)) {
$holidays = calendarHolidayArray($low_date, $high_date);
foreach($holidays as $startdate => $holiday) {
//This insert the today events if they exist
if($todayDate == $startdate)
$calendarDataToday['holidays'] = $holiday;
$cday = (int) substr($startdate,8,2);
//We must select between create or only show!
$text_color = !empty($days[$cday]) ? $color_text_items_mixed : $color_text_items_holiday;
$background_color = !empty($days[$cday]) ? $color_background_items_mixed : $color_background_items_holiday;
$href_calendar = $can_post_calendar && $cday >= $today ? $scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$cday : $scripturl.'?action=calendar';
$days[$cday] = '<a class="smalltext" style="color: '.$text_color.'; font-weight: bold; background-color: '.$background_color.'; padding: 0px 4px 0px 4px;" href="'.$href_calendar.'" target="_self">'.$cday.'</a>';
}
}

//So Todays it's an diffrent color :D
$href_calendar = $can_post_calendar ? $scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$today : $scripturl.'?action=calendar';
$days[$today] = '<a class="smalltext" style="color: '.$color_text_today.'; font-weight: bold; border: solid 1px black; background-color: '.$color_background_today.'; padding: 0px 4px 0px 4px;" href="'.$href_calendar.'" target="_self">'.$today.'</a>';

//Wellcome to the smf way of Day building with existing Language strings :D
$day_names = $txt['days'];
$day_names_short = $txt['days_short'];
//So lets see $firstday = 0 means sunday this is the first day :)
//if there is a higher number than i need to resort them
//negativ values can also be used :)
if(!empty($first_day)) {
if($first_day < 0)
$first_day = 7-(abs($first_day)%7);
else
$first_day = ($first_day%7);
}
if(!empty($first_day)) {
$old = $day_names;
$old_s = $day_names_short;
$day_names = array();
$day_names_short = array();
//Create the new day order :)
for($n=0; $n<7; $n++) {
$c = (($first_day+$n)%7);
$day_names[$n] = $old[$c];
$day_names_short[$n] = $old_s[$c];
}
}

list($month, $year, $weekday) = explode(',',gmstrftime('%m,%Y,%w',$first_of_month));
$weekday = ($weekday + 7 - $first_day) % 7; //adjust for $first_day
$title = $txt['months_titles'][$month].' '.$year;  //This is the SMF Text string, so it should be corrected for ut8 or iso

/* Begin calendar. Uses a real <caption>. See http://diveintomark.org/archives/2002/07/03 */
$calendar = '
<table>
<caption>'.($month_href ? '<a href="'.htmlspecialchars($month_href).'">'.$title.'</a>' : $title)."</caption>
<tr>";

//Put out the Daynames :)
foreach($day_names as $k => $d)
$calendar .= '
<th class="smalltext" abbr="'.$d.'">'.(!empty($day_name_length) ? $d : $day_names_short[$k]).'</th>';
$calendar .= "
</tr>
<tr style=\"text-align:right;\">";

if($weekday > 0) $calendar .= '
<td class="smalltext" colspan="'.$weekday.'"> </td>'; //initial 'empty' days
for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){
if($weekday == 7){
$weekday   = 0; //start a new week
$calendar .= "
</tr>
<tr style=\"text-align:right;\">";
}
if(isset($days[$day])){
$calendar .= '
<td>'.$days[$day].'</td>';
}
else
{
$href_calendar = $can_post_calendar && $day >= $today ? $scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$day : $scripturl.'?action=calendar';
$calendar .= "
<td class=\"smalltext\" style=\"padding-right:4px;\"><a";
if(((($weekday+$first_day) % 7)==0))
{
$calendar .= ' style="color:'.$color_text_sunday.';"';
}
$calendar .= " href=\"".$href_calendar."\" target=\"_self\">$day</a></td>";
}
}
if($weekday != 7) $calendar .= '
<td class="smalltext" colspan="'.(7-$weekday).'"> </td>'; //remaining "empty" days

echo $calendar.'
</tr>';


if (!empty($show_today) && (!empty($calendarDataToday['events']) || !empty($calendarDataToday['birthdays']) || !empty($calendarDataToday['holidays']))) {

if(!empty($calendarDataToday['holidays'])){
echo '
<tr><td>
<hr />
</td>
<td colspan="5" class="smalltext" align="center" style="color: ' . $color_text_items_holiday . ';">
<b>Holidays</b>
</td><td>
<hr />
</td>
</tr>
<td colspan="7" class="smalltext">';
foreach( $calendarDataToday['holidays'] as $holiday )
echo '
', $holiday['name'], '<br />';
echo '
</td></tr>';
}

if(!empty($calendarDataToday['birthdays'])){
echo '
<tr><td>
<hr />
</td>
<td colspan="5" class="smalltext" align="center" style="color: ' . $color_text_items_birthday . ';">
<b>Birthdays</b>
</td><td>
<hr />
</td></tr>
<td colspan="7" class="smalltext">';
foreach( $calendarDataToday['birthdays'] as $member )
echo '
<a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['name'], isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', '<br />';
echo '
</td></tr>';
}

if(!empty($calendarDataToday['events']))
{
echo '
<tr><td>
<hr />
</td>
<td colspan="5" class="smalltext" align="center" style="color: ' . $color_text_items_event . ';">
<b>Events</b>
</td><td>
<hr />
</td></tr>
<td colspan="7" class="smalltext">';
foreach ($calendarDataToday['events'] as $event)
{
if ($event['can_edit'])
echo '
<a href="' . $event['modify_href'] . '" style="color: #FF0000;">*</a> ';
echo '
' . $event['link'] . '<br />';
}
}
  echo '
  </td></tr>';
}

echo '
</table>';
« Last Edit: November 08, 2008, 10:24:04 AM by ???1031 »
Again... I'm having time problems...Normal Monday to Friday I'm at office from 6:00-16:00 (On my local time ;P).

Offline Aw06

  • Full Member
  • ***
  • Posts: 238
  • Gender: Male
    • www.ShopinJA.com
  • SMF Version: 1.1.13
  • SP Version: 2.3.2
Re: about calendar in SimplePortal 2 / SMF 1.1.X
« Reply #35 on: November 09, 2008, 03:10:23 AM »
thats magic... thanks allot  ;D

one thing .. what do i edit to let it show events in advance .. because for important events it will be good to give some amount of notice .. no notice is needed for holidays and birthdays as you have set it .

Offline Kosedragen

  • Jr. Member
  • **
  • Posts: 87
  • Soft
Re: about calendar in SimplePortal 2 / SMF 1.1.X
« Reply #36 on: November 09, 2008, 06:19:44 AM »
Yes, that was exactly what bugged me too >< Usually it gave a notice one week or so in advance. You think you can fix that? =/

Offline ???1031

  • ... feel not as a dev at the moment ...
  • Comrade
  • *
  • Posts: 789
  • Gender: Male
  • Overworked <<
  • SMF Version: None
  • SP Version: None
Re: about calendar in SimplePortal 2 / SMF 1.1.X
« Reply #37 on: November 10, 2008, 01:12:14 AM »
thats magic... thanks allot  ;D

one thing .. what do i edit to let it show events in advance .. because for important events it will be good to give some amount of notice .. no notice is needed for holidays and birthdays as you have set it .
Yes, that was exactly what bugged me too >< Usually it gave a notice one week or so in advance. You think you can fix that? =/
I changed this... because i thought it's not usfull to show information about the future...
Quote
* Only Today informations are shown under the Calendar (No Future, only todays!)
You want select how many day in future it should show entries?

I can try to make a java script version out of it, so that you can click on the day and it show the informations for that day, because the data is allready loaded and so i think i can use it without problem to create a calender with that feature ;).

Bye
DIN1031
Again... I'm having time problems...Normal Monday to Friday I'm at office from 6:00-16:00 (On my local time ;P).

Offline [SiNaN]

  • Mr. SimplePortal
  • Developer
  • *
  • Posts: 6782
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
Re: about calendar in SimplePortal 2 / SMF 1.1.X
« Reply #38 on: November 10, 2008, 06:05:50 AM »
Maybe move this one to blocks board.
And slowly, you come to realize... It's all as it should be...

Offline Aw06

  • Full Member
  • ***
  • Posts: 238
  • Gender: Male
    • www.ShopinJA.com
  • SMF Version: 1.1.13
  • SP Version: 2.3.2
Re: about calendar in SimplePortal 2 / SMF 1.1.X
« Reply #39 on: November 10, 2008, 10:03:41 AM »
I changed this... because i thought it's not usfull to show information about the future...You want select how many day in future it should show entries?

I can try to make a java script version out of it, so that you can click on the day and it show the informations for that day, because the data is allready loaded and so i think i can use it without problem to create a calender with that feature ;).

Bye
DIN1031

As is its fine, but only events need some notice days in advance .. holidays and birthdays dont need it