SimplePortal

Customization => Custom Coding => Topic started by: evan_go_mad on August 22, 2008, 11:43:15 AM

Title: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: evan_go_mad on August 22, 2008, 11:43:15 AM
how to create.. like a..shortcut Calendar (small Calendar) in SimplePortal and it will connect to Calendar...? So the member can see and click the small calendar in SimplePortal..and then the member will see all events in Calendar...(by the way i'm using SimplePortal 1.1.5)Thanx BeforeEvan
The Third and latest Version can be found -> http://simpleportal.net/index.php?topic=89.msg5205#msg5205 It's attached to the post as php file.Last Edit: 11.11.08Edited By DIN1031
This is the oldest Version :P
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 =Drequire_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 arrayforeach($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 applicableif($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' daysfor($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" daysecho $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>';Last Change 31.10.08
Title: Re: about calendar in SimplePortal 1.1.5
Post by: ccbtimewiz on August 22, 2008, 01:26:10 PM
One possible method is using SMF's ssi_recentcalendar anotation. However I'm not certain if that displays the way you want to.
Title: Re: about calendar in SimplePortal 1.1.5
Post by: [n3rve] on August 23, 2008, 09:53:21 AM
Welcome to SimplePortal, evan_go_mad.
Do you require additional assistance?

-[n3rve]
Title: Re: about calendar in SimplePortal 1.1.5
Post by: Eliana Tamerin on August 23, 2008, 10:21:59 AM
Something like this should work. This code was originally by http://keithdevens.com/software/php_calendar, modified by Bloc and various others on TinyPortal.net. Here's the post I grabbed this code from: http://www.tinyportal.net/index.php?topic=700.msg30584#msg30584
Quote
http://simpleportal.net/index.php?topic=89.msg4322#msg4322 <- Take the latest Version
Just stick that in a php block. Then go to http://yoursite.com/forum/ssi_examples.php and copy the line that looks like this: require("/home/spadmin/public_html/SSI.php"); and replace that one with the second line in this code. If you have any errors or problems, let me know.
Title: Re: about calendar in SimplePortal 1.1.5
Post by: evan_go_mad on August 26, 2008, 11:49:16 AM
Thanx for supporting me...After many times....but its still got an error
like this..


PHP Error Message

Fatal error: require() [function.require]: Failed opening required '/home/a9716649/spadmin/public_html/SSI.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/a9716649/public_html/Sources/SPortal.php(1586) : eval()'d code on line 3
Title: Re: about calendar in SimplePortal 1.1.5
Post by: ccbtimewiz on August 26, 2008, 12:16:23 PM
Try using the require_once() function instead.

If that doesn't way, attempt using include(), or leave out the inclusion entirely.
Title: Re: about calendar in SimplePortal 1.1.5
Post by: Eliana Tamerin on August 26, 2008, 12:43:59 PM
It won't work unless you include SSI.
Title: Re: about calendar in SimplePortal 1.1.5
Post by: evan_go_mad on August 27, 2008, 12:06:03 PM
hahaha.....finally make it..

my step is :

1.copy and paste the code from Ms Eliana Tamerin to content in PHP Block
2.open smf folder our web hosting ...looking for our  ssi_examples.php
3.open ssi_examples.php using wordpad and find

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

4.find code like this from Ms Eliana Tamerin

require("/your/path/to/SSI.php");

5. cut and edit with

require(dirname(Calendar) . '/SSI.php');

That's it....Thanx before

Evan
Title: Re: about calendar in SimplePortal 1.1.5
Post by: Eliana Tamerin on August 27, 2008, 12:15:06 PM
Don't use WordPad for editing php files. It includes its own markup, and makes things VERY bad.

Use notepad, notepad2 (http://www.flos-freeware.ch/notepad2.html) or notepad++ (http://notepad-plus.sourceforge.net/uk/site.htm) instead.
Title: Re: about calendar in SimplePortal 1.1.5
Post by: evan_go_mad on August 27, 2008, 12:22:20 PM
ooo i see...because i'm just using wordpad for only copy the code but not for editing....(so..i have to install notepad++ first right... )

Many thanks for the advice...(because i'm still newbie in programing...hahaha..)

Evan
Title: Re: about calendar in SimplePortal 1.1.5
Post by: Eliana Tamerin on August 27, 2008, 12:32:10 PM
I'd suggest Notepad2, no installation necessary, just download, extract and use. Of course, you'd probably want it on your desktop, so it doesn't get lost. ;)
Title: Re: about calendar in SimplePortal 1.1.5
Post by: Sudhakar on August 27, 2008, 01:04:09 PM
I have downloaded notepad2.

Will look in to it.

And the Calendar idea is good Will try it . :)
Title: Re: about calendar in SimplePortal 1.1.5
Post by: Jakki on August 27, 2008, 05:08:26 PM
I got it to work thanks for good instructions

Hint take out the <?php>
Title: Re: about calendar in SimplePortal 1.1.5
Post by: Flip on August 29, 2008, 09:38:00 AM
Hey All,

  Quick question, what do I need to change to make the days show full, e.g. from "Mo" to "Monday", or can that even be done?

    Flip - KE4OBT
     The Blind Ham
Title: Re: about calendar in SimplePortal 1.1.5
Post by: Eliana Tamerin on August 29, 2008, 10:36:52 AM
It'll stretch it, so I suggest adding it as a center block. But yes.

Found this comment in the code:
Code: [Select]
#if day_name_length is >3, the full name of the day will be printed
So just find this part:

Code: [Select]
$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();

And change $day_name_length to 4 or greater. That'll display the whole day name.
Title: Re: about calendar in SimplePortal 1.1.5
Post by: Flip on August 29, 2008, 01:21:13 PM
That worked great, now to figure out why I see something about prev. and next but nothing is displayed, actually I only need the next link displayed down at the bottom.

     Flip - KE4OBT
     The Blind Ham
Title: Re: about calendar in SimplePortal 1.1.5
Post by: ???1031 on August 29, 2008, 02:48:00 PM
Only a small suggest ;)

Please use require_once("/your/path/to/SSI.php"); instead of require("/your/path/to/SSI.php"); it's better because if you use 2 blocks with a ssi include it will output a error ;). Only a small thing to make the script better.

Bye
DIN1031
Title: Re: about calendar in SimplePortal 1.1.5
Post by: ccbtimewiz on September 02, 2008, 01:50:30 AM
Is this issue solved or do you still require assistance? If this is solved feel free to mark it as solved otherwise reply with some details of what isn't working.
Title: Re: about calendar in SimplePortal 1.1.5
Post by: Kosedragen on October 07, 2008, 05:07:07 AM
Uhm, I'm having a problem with the calendar. Up until now it has worked absolutely perfectly, but now it's beginning to cough and trip. Take a look at the attachment. Where there should be yellow spots for the events, and a link to edit the events of that day, the spots have disappeared and the link is gone. Instead they are just plain numbers. Also the square indicating what day it is today is gone. I don't know if I have done something to upset it, but I could really use some help ^^;

Oh right; forgot to mention this: I use the last version of SP and SMF 1.1.6

EDIT: Aha, I found out this problem only exists in IE. Opera is still fine.

EDIT again!: Okay, is it possible to add something to the code in order to remove the links for other, regular members and other who do not have the permission to edit events? ^^; Everyone on my forum are able to enter the edit page (and then get the error message "you can't edit events", of course), and they see it as a glitch. So do I. Or, a mere code slip.

And EDIT for the last time: Is it possible to add links to dates with events linking to the appropriate topic of the event? =o That was also requested..
Title: Re: about calendar in SimplePortal 1.1.5
Post by: Manu on October 17, 2008, 06:52:05 PM
EDIT again!: Okay, is it possible to add something to the code in order to remove the links for other, regular members and other who do not have the permission to edit events? ^^; Everyone on my forum are able to enter the edit page (and then get the error message "you can't edit events", of course), and they see it as a glitch. So do I. Or, a mere code slip.

That's what I want to know too. Is there a way to solve this?  :)



Since the last night we're using the code for the calendar in our portal. It looks great and I like it, but the error log doesn't look great.  :(

In the morning I checked the the forum including the error log and was shocked more than 300 pages I found there :O

There errors are this:
Quote
8: Undefined variable: birth
File: /../.../.../.../.../Themes/default/SPortal1-1.template.php (main sub template - eval?)
Line: 34
Quote
8: Undefined variable: txt
File: /../.../.../.../.../Themes/default/SPortal1-1.template.php (main sub template - eval?)
Line: 99
Quote
8: Use of undefined constant Calendar - assumed 'Calendar'
File: /../.../.../.../.../Themes/default/SPortal1-1.template.php (main sub template - eval?)
Line: 3
Title: Re: about calendar in SimplePortal 1.1.5
Post by: ???1031 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
Title: Re: about calendar in SimplePortal 1.1.5
Post by: Manu 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>';
Title: Re: about calendar in SimplePortal 1.1.5
Post by: Kosedragen on October 20, 2008, 09:33:37 AM
What exactly was it you did, ディン1031. What is different now? ^^; Functionally I mean.
Title: Re: about calendar in SimplePortal 1.1.5
Post by: ???1031 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

Title: Re: about calendar in SimplePortal 1.1.5
Post by: Manu 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. :)
Title: Re: about calendar in SimplePortal 1.1.5
Post by: ???1031 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>');
}

Title: Re: about calendar in SimplePortal 1.1.5
Post by: AdreasGr 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
Title: Re: about calendar in SimplePortal 1.1.5
Post by: ???1031 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
Title: Re: about calendar in SimplePortal 1.1.5
Post by: AdreasGr 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 ??
Title: Re: about calendar in SimplePortal 1.1.5
Post by: ???1031 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
Title: Re: about calendar in SimplePortal 1.1.5
Post by: AdreasGr on October 31, 2008, 11:49:16 AM
Ok now works fine  :applause: :applause: :applause:

Thank you.!

 :thumbsup: :thumbsup: :thumbsup:
Title: Re: about calendar in SimplePortal 1.1.5
Post by: Aw06 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)
Title: Re: about calendar in SimplePortal 1.1.5
Post by: ???1031 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 ;).
Title: Re: about calendar in SimplePortal 1.1.5
Post by: Aw06 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:
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: ???1031 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>';
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: Aw06 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 .
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: Kosedragen 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? =/
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: ???1031 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
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: [SiNaN] on November 10, 2008, 06:05:50 AM
Maybe move this one to blocks board.
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: Aw06 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
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: ???1031 on November 11, 2008, 12:50:04 AM
Maybe move this one to blocks board.
Thanks for mention this... i really did not see that it was in english support *drop*.

Quote from: AW06
but only events need some notice days in advance
I don't understand this...
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: Aw06 on November 11, 2008, 09:00:25 AM
Thanks for mention this... i really did not see that it was in english support *drop*.
I don't understand this...

ok, as you have it now .. events/birthdays/holidays only show up on the day it happens ..

But for events it would be good to give a few days notice, like if im having an auto show, id want it to be showing a few days before so people can plan for it, if it shows up on the actual day of the event allot of people may miss it ..
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: ???1031 on November 11, 2008, 09:31:41 AM
Yes i understand it now, i made allready a version where you can select how many day in the future the script should look for events :). (Not official at the moment).
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: Aw06 on November 11, 2008, 09:59:18 AM
Yes i understand it now, i made allready a version where you can select how many day in the future the script should look for events :). (Not official at the moment).

ok, awaiting that release  ;D

Also, today is veterans day, and in the calender it just shows as V
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: ???1031 on November 11, 2008, 01:03:41 PM
So this is V3 the most advanced Version

Here are the changes
Code: [Select]
! Error on today detection fix (not easy to understand xD)
! Fixed the bug on holidays
+ Add Javascript Changer, click on the day and the events, birthdays and holidays will be shown for that day
+ Add future events to the today output (you can set how many day in future it should look ;D, 0 = only today)
+ Add Weeks to the calendar
+ You can disable each of the new option
* Removed the edit link, i think this is not needed on such calendar

I've a display bug that i don't understand... i hope someone can help me with that. It looks good now, but it's not the way i wished for <<. (Remove the <?php and ?> before you insert it as php block (not needed for Version 2.1.1 and higher)) ;)

The code is attached to the post, i extend the post limit with the code ;P.

Sorry that the day order is not correct on the pic, but that is fixed xD.
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: Aw06 on November 11, 2008, 02:55:14 PM
Whats the display Bug ?

looks good for me
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: Aw06 on November 11, 2008, 03:09:17 PM
also .. we are asking much .. but when displaying event date .. could you make it show for example (Nov 11/08) instead of (11/11)

and i wish i could get the block just a little smaller .. its abit wide now, but i can live with it

 ;D
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: Manu on November 11, 2008, 07:14:00 PM
@???1031

It works perfect and it looks perfect!!!  :applause:

Example of the calendar you can find here: http://forum.arseniums.com
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: ???1031 on November 12, 2008, 02:01:11 AM
also .. we are asking much .. but when displaying event date .. could you make it show for example (Nov 11/08) instead of (11/11)

and i wish i could get the block just a little smaller .. its abit wide now, but i can live with it

 ;D
You can disable the weeks ;). Than it will be smaller.
Hmmm i think i can insert the "Nov" item, it should be no problem :).
I will do that later if i have time.

Bye
DIN1031
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: Aw06 on November 12, 2008, 09:53:46 AM
maybe another bug .. i have no birthdays/holidays/events .. and the calender is showing 'no entries' would rather it be blank..  :in-love:
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: amlucent on November 18, 2008, 04:00:26 PM
I really love your calendar block! Great work! I am eagerly awaiting a release for SMF 2.0 
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: hot rides on December 05, 2008, 11:24:28 AM
@???1031

It works perfect and it looks perfect!!!  :applause:

Example of the calendar you can find here: http://forum.arseniums.com
Nice site Manu! I can't wait to put this calendar up on my site
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: b-machinery on January 01, 2009, 08:17:46 AM
Hi there!

Happy new year to all!

I use this calendar block in my forum (http://www.forum500.de) too, but since today I miss something. First, the monthname does not appear anymore in the headline, just "2009" is displayed. This could be corrected by changing the line 229
Code: [Select]
$title = $txt['months_titles'][$month].' '.$year;  //This is the SMF Text string, so it should be corrected for ut8 or iso
to
Code: [Select]
$title = $txt['months_titles'][(int)$month].' '.$year;  //This is the SMF Text string, so it should be corrected for ut8 or iso

But, birthdays are not shown too. I did not have the time to investigate why this is happening, but maybe someone of you has an idea on this.

BTW, checked this on some other sites using this great calendar block, they all have these problems!

@DIN1031: Pretty good work, thanks a lot!
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: b-machinery on January 04, 2009, 05:30:45 AM
I checked for myself and found what causes the problem:

Search for
Code: [Select]
//Built Month low and high date :)
$low_date = $year.'-'.$month.'-01';
$high_date = $year.'-'.$month.'-'.$days_in_month;

and replace with
Code: [Select]
//Built Month low and high date :)
$low_date = $year.'-'.sprintf('%02d', $month).'-01';
$high_date = $year.'-'.sprintf('%02d', $month).'-'.$days_in_month;

Problem was that the month is needed in 2 digits.
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: hot rides on January 06, 2009, 08:19:33 AM
thanks for the fix b-m, I noticed the month not showing the other day but it didnt even click, lol
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: ???1031 on January 08, 2009, 02:33:06 AM
Drop i allready fixed it, but forget to update my version... sorry for the problems :).

Thanks for the help b-machinery.
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: gyrene2083 on February 06, 2009, 11:18:22 PM
*Solved

I copied an older code. I updated with the new code, and it looks sweet!!!!

Quick question though, I copied both of the files in post, where do I, if I need it, paste the Calendar3block.php?

-Semper Fi
gyrene2083
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: yield on February 22, 2009, 11:58:26 AM
Hi! Thanks DIN1031 for your great work!

I would like to make a simple question: what I have to change to sort the upcoming events starting from with the "lower date"?

Example: There are two events, dated 23/Fev and 28/Fev. They show up like this:
Upcoming Events
28/02 event2
23/02 event1

and I would like this way:
Upcoming Events
23/02 event1
28/02 event2

Thank you!
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: Smirnoff on March 02, 2009, 04:49:08 PM
The calendar in my site is align to the left... how can i align the calendar to the center of the block?

Using Simple Portal 2.1.1 SMF 1.1.8
Title: Re: about calendar in SimplePortal 1.1.5
Post by: Neith on March 13, 2009, 01:35:26 PM
I finished step 3, but could not find the path on step 4....

Code: [Select]
<?php

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

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title> << :: SMF SSI.php 1.1 :: >> </title><?php

echo 
'
<meta http-equiv="Content-Type" content="text/html; charset='
$context['character_set'], '" />
<link rel="stylesheet" type="text/css" href="'
$settings['default_theme_url'], '/style.css" />
<script language="JavaScript" type="text/javascript" src="'
$settings['default_theme_url'], '/script.js"></script>
<style type="text/css">
body
{
margin: 1ex;
}'
;

if ($context['browser']['needs_size_fix'])
echo '
@import('
$settings['default_theme_url'], '/fonts-compat.css);';

echo '
</style>'
;

?>

</head>
<body>
<h1>SMF SSI.php Functions</h1>
Current Version: 1.1<br />
<br />
This file is used to demonstrate the capabilities of SSI.php using PHP include functions.<br />
The examples show the include tag, then the results of it. Examples are separated by horizontal rules.<br />

<hr />

<br />
To use SSI.php in your page add at the very top of your page before the &lt;html&gt; tag on line 1:<br />
<div style="font-family: monospace;">
&lt;?php require(&quot;<?php echo addslashes($user_info['is_admin'] ? realpath($boarddir '/SSI.php') : 'SSI.php'); ?>&quot;); ?&gt;
</div>
<br />

<hr />

<h3>Recent Topics Function: &lt;?php ssi_recentTopics(); ?&gt;</h3>
<?php ssi_recentTopics(); flush(); ?>

<hr />

<h3>Recent Posts Function: &lt;?php ssi_recentPosts(); ?&gt;</h3>
<?php ssi_recentPosts(); flush(); ?>

<hr />

<h3>Recent Poll Function: &lt;?php ssi_recentPoll(); ?&gt;</h3>
<?php ssi_recentPoll(); flush(); ?>

<hr />

<h3>Top Boards Function: &lt;?php ssi_topBoards(); ?&gt;</h3>
<?php ssi_topBoards(); flush(); ?>

<hr />

<h3>Top Topics by View Function: &lt;?php ssi_topTopicsViews(); ?&gt;</h3>
<?php ssi_topTopicsViews(); flush(); ?>

<hr />

<h3>Top Topics by Replies Function: &lt;?php ssi_topTopicsReplies(); ?&gt;</h3>
<?php ssi_topTopicsReplies(); flush(); ?>

<hr />

<h3>Top Poll Function: &lt;?php ssi_topPoll(); ?&gt;</h3>
<?php ssi_topPoll(); flush(); ?>

<hr />

<h3>Top Poster Function: &lt;?php ssi_topPoster(); ?&gt;</h3>
<?php ssi_topPoster(); flush(); ?>

<hr />

<h3>Topic's Poll Function: &lt;?php ssi_showPoll($topic); ?&gt;</h3>
<?php ssi_showPoll(); flush(); ?>

<hr />

<h3>Latest Member Function: &lt;?php ssi_latestMember(); ?&gt;</h3>
<?php ssi_latestMember(); flush(); ?>

<hr />

<h3>Board Stats: &lt;?php ssi_boardStats(); ?&gt;</h3>
<?php ssi_boardStats(); flush(); ?>

<hr />

<h3>Who's Online Function: &lt;?php ssi_whosOnline(); ?&gt;</h3>
<?php ssi_whosOnline(); flush(); ?>

<hr />

<h3>Log Online Presence + Who's Online Function: &lt;?php ssi_logOnline(); ?&gt;</h3>
<?php ssi_logOnline(); flush(); ?>

<hr />

<h3>Welcome Function: &lt;?php ssi_welcome(); ?&gt;</h3>
<?php ssi_welcome(); flush(); ?>

<hr />

<h3>News Function: &lt;?php ssi_news(); ?&gt;</h3>
<?php ssi_news(); flush(); ?>

<hr />

<h3>Board News Function: &lt;?php ssi_boardNews(); ?&gt;</h3>
<?php ssi_boardNews(); flush(); ?>

<hr />

<h3>Menubar Function: &lt;?php ssi_menubar(); ?&gt;</h3>
<?php ssi_menubar(); flush(); ?>

<hr />

<h3>Quick Search Function: &lt;?php ssi_quickSearch(); ?&gt;</h3>
<?php ssi_quickSearch(); flush(); ?>

<hr />

<h3>Login Function: &lt;?php ssi_login(); ?&gt;</h3>
<?php ssi_login(); flush(); ?>

<hr />

<h3>Log Out Function: &lt;?php ssi_logout(); ?&gt;</h3>
<?php ssi_logout(); flush(); ?>

<hr />

<h3>Today's Birthdays Function: &lt;?php ssi_todaysBirthdays(); ?&gt;</h3>
<?php ssi_todaysBirthdays(); flush(); ?>

<hr />

<h3>Today's Holidays Function: &lt;?php ssi_todaysHolidays(); ?&gt;</h3>
<?php ssi_todaysHolidays(); flush(); ?>

<hr />

<h3>Today's Events Function: &lt;?php ssi_todaysEvents(); ?&gt;</h3>
<?php ssi_todaysEvents(); flush(); ?>

<hr />

<h3>Today's Calendar Function: &lt;?php ssi_todaysCalendar(); ?&gt;</h3>
<?php ssi_todaysCalendar(); flush(); ?>

<hr />

<h3>Recent Calendar Events Function: &lt;?php ssi_recentEvents(); ?&gt;</h3>
<?php ssi_recentEvents(); flush(); ?>

<hr />

<h3>Some notes on usage</h3>
All the functions have an output method parameter.  This can either be &quot;echo&quot; (the default) or &quot;array&quot;.<br />
If it is &quot;echo&quot;, the function will act normally - otherwise, it will return an array containing information about the requested task.<br />
For example, it might return a list of topics for ssi_recentTopics.<br />
<br />
<span onclick="if (getInnerHTML(this).indexOf('Bird') == -1) setInnerHTML(this, getInnerHTML(this) + '<br /><img src=&quot;http://www.simplemachines.org/images/chocobo.jpg&quot; title=&quot;Bird-san&quot; alt=&quot;Chocobo!&quot; />'); return false;">This functionality can be used to allow you to present the information in any way you wish.</span>

<hr />

<br />
<br />
<span style="color: #CCCCCC; font-size: smaller;">
<?php
echo 'This page took 'round(array_sum(explode(' 'microtime())) - array_sum(explode(' '$time_start)), 4), ' seconds to load.<br />';
?>

*ssi_examples.php last modified on <?php echo date('m/j/y'filemtime(__FILE__)); ?>
</span>
</body>
</html>

Should add it to Simple Portal on the next update. ;)

Am I looking in the wrong place? I changed this:
Code: [Select]
?php

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

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>


to this:

Code: [Select]
?php

require(dirname(Calendar) . '/SSI.php');

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>


I assume that's what I should be doing. I went back to my forum and nothing was there though. Im either wrong on this part or wrong on where I loaded it onto my server. Am I supposed to load it in a special place?

I just loaded it on there by it's lonesome as is.

I did not rename it and so it was named DIN1031 Calendar in my server. Do I need to rename it to Calendar?

I refuse to give up. Dont give up on me :p


Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: BrOzO76 on March 17, 2009, 11:56:04 PM
algun código para SMF 2?
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: Sioned on March 31, 2009, 12:23:14 PM
I was just wondering - is there any way to make the calendar have reoccuring events instead of having to put in the same entry every week?  :-*
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: mrtrc266 on March 31, 2009, 12:43:45 PM
That has been a huge demand for sometime now, seems like it should be a default feature for SMF.

The only thing I found was an outdated Mod on SMF, never tried it though I think the last version was for SMF 0.0.1 ;D
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: tfs on April 09, 2009, 03:33:51 PM
I'm using the calendar PHP posted in this thread, but it doesn't show all events.  I have an event scheduled every day from April 1st through April 6th, but only the one from the 1st shows up.

The regular calendar block shows all 6 events.
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: Blue on May 03, 2009, 12:42:08 PM
???1031, please help me.

I posted a problem in English Support about your calendar, but no one answered yet

Since the month change (April to May) the events stopped showing in the calendar altough they are showing in Future Events.

Holidays and Birthdays are fine. It's really odd.

Can you take a look? :) http://simpleportal.net/index.php?topic=2176.0 (http://simpleportal.net/index.php?topic=2176.0)

Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: geekfairy on May 04, 2009, 02:19:47 AM
I now have events working, but am wondering if another change is possible.

As it is now it displays by default the upcoming events, but not upcoming birthdays.

I would prefer to be able to have it also display upcoming birthdays for x amount of days prior to the event, the same as we can for events.

In SMF it normally shows down the bottom

Upcoming Birthdays: geekfairy
Upcoming Events: * test, * test 2

So is it possible to have something similar to what you have done for events? How many days in the future to show birthdays?

Thanks.
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: Blue on May 04, 2009, 08:47:17 AM
I now have events working, but am wondering if another change is possible.

You had the same problem than me. What did you do to put events working?
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: geekfairy on May 04, 2009, 09:28:19 AM
I wasn't using this code when it wasn't working.

I got it working by using the code in the DIN1031CalenderBlockV3.php on page three, and setting the events to show 7 days in the future worked fine :)
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: Blue on May 04, 2009, 09:30:04 AM
So, it wasn't my problem after all :'( thanks anyway
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: ehsizzup on May 05, 2009, 01:02:22 AM
How can I customize this calendar to show only events from one specific board?

Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: noelleon69 on June 07, 2009, 02:42:00 AM
How does the future events look like? I set it to 7 days and tried other combinations and I don't see any mention of future events. I noticed some typos in the coding, where events was spelt as eventes. After correcting those spelling mistakes I still don't see any mention of future events in the block. How did you guys get it to work?
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: VegasJay on June 03, 2010, 06:28:02 PM
So this is V3 the most advanced Version

The code is attached to the post, i extend the post limit with the code ;P.

Sorry that the day order is not correct on the pic, but that is fixed xD.

I am attempting to get * DIN1031CalenderBlockV3.php to run in a stand alone file in my SMF root directory.

This probably sounds like a strange thing to want to do, however my intent if I can get it to work is to then import the stand alone file and use it as an insert in our Newsletter.

When I run the code as a custom block in Single Portal, under SMF 2 RC3  it looks fine, however when I put the same code into a stand alone file in the root directory I get errors.

The current stumbling block is

Fatal error: Call to undefined function fatal_lang_error() in /home/kinkyv/public_html/forums/calendarKT.php  on line 71

It is pretty clear that I have to initialize some functions, but frankly I am too much of novice to attempt this.

Can anyone help me out ?

Jay Clark
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: Koops on June 05, 2010, 04:30:43 AM
Error :
Quote
8: Undefined index: calendar51

Has anyone encounted this error while using din1031's DIN1031CalenderBlockV3.php file?



Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: AngelinaBelle on June 07, 2010, 11:24:47 AM
VegasJay -- Have a look in ssi_examples.php to see how to create a standalone file that can do SMF stuff.
 
First, that page loads SSI.php with a require, then it starts doing the stuff it is supposed to be doing.
 
 
 
 
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: VegasJay on June 08, 2010, 03:55:59 PM
VegasJay -- Have a look in ssi_examples.php to see how to create a standalone file that can do SMF stuff.

Whoa, imagine how much I would know if I would only read the manual <grin>.

Actually thanks a bazillion for pointing this out to me I have been using SMF for at least 5 years and never thought to check out the distribution for goodies.

the calendar code now runs as a stand alone file, and my evil mind sees all kinds of other stuff I can now do to extend the functionality to other part of my site.

The next time you are in Vegas I owe you a brew or two down on the strip

jayr
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: AngelinaBelle on June 08, 2010, 04:45:27 PM
SSI.php was meant to help you bridge the gap between "other php stuff" and SMF.
So it has a TON of useful stuff, and lots of functions that you can call even from inside SMF -- SimplePortal certainly exploits the simplicity of the SSI interface.
 
Of course, writing standalone php files that don't do SimplePortal stuff is not really a SimplePortal issue. If you have any more questions, you'll probably get more and better SSI support over at simplemachines.org.
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: VegasJay on June 10, 2010, 10:24:07 PM
Of course, writing standalone php files that don't do SimplePortal stuff is not really a SimplePortal issue. If you have any more questions, you'll probably get more and better SSI support over at simplemachines.org.

I am a little reluctant to bother you again, since I am not sure this is a pure SimplePortal issue, but I think it might be useful to others so here goes ....

I try not to do the same thing twice in my systems, that is if I have something that works someplace, I want to use it again someplace else, if for no other reason than WHEN it breaks I only have to fix it in one place. (I don't believe in if it breaks)

With this in mind, I am using Simple Portal as a front end for an SMF site, and I am using the SMF site as a back end for a Newsletter that I am trying to turn into a monthly eZine.

SMF provides a buncha functionality, such as the classified ads section, that would take me years to develop on my own.

I decided to add a local weather report to the top page of the eZine, and I will probably get around to adding it to Simple Portal as a block as well.

Once I had the weather report in place I decided that it was just begging for a calendar as well, which is when I started looking at Simple Portal blocks for a way around writing my own code.

With your suggestion I was able to make DIN1031's code run as a stand alone, and was then able to import that stand alone page into my eZine top page.

So far so good ...

What is breaking my heart is that the formatting of the text is different when running in my stand alone page. See Below

(http://www.kinky-vegas.com/images/Links/CalendarBlock.jpg)

The slightly larger font in the DOW headers is kinda ugly, but it also is so big that it forces the columns in the eZine to resize.

As you can see it is the right size in the test block in Simple Portal.

I have done some poking around, and it appears that there is a problem linking to the style sheet.

Code: [Select]
//Put out the Daynames :)
// th vs td
foreach($day_names as $k => $d)
    $calendar .= '
        <td class="smalltext" abbr="'.$d.'">'.(!empty($day_name_length) ? $d : $day_names_short[$k]).'</td>';
$calendar .= "

Generates the DOW header, and wants to use the smalltext class, but since it cannot find the style sheet in the standalone PHP file it puts up a default 12 pt font.

The actual dates are formatted differently and show as a smaller font.

I can think of several ways I might be able to hack this, but the clean way to do it is to locate the style sheet used by SimplePortal and either put that code into my file, or point my file at the style sheet.

<sigh> I cannot figure out where the SimplePortal style sheet is located, I looked in sources and themes without a lotta luck.

If I am wasting your time please tell me so, but if I can make this work the way I want I think it might be useful to others

jayr
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: AngelinaBelle on June 11, 2010, 09:03:03 AM
You are correct that your question is not strictly a SimplePortal issue.  And maybe not even strictly an SMF issue.
 
Answer: You can always check the <head> section of the HTML to see which style files are being loaded.  You can be fairly certain that you can find selectors for all the CSS classes in one of them -- unless someone has made a mistake.
 
In this case:
SMF's most-used CSS file is index.css, which is found in the current theme's CSS folder, or else in the default theme's CSS folder if the current theme does not have one -- smalltext is in index.css.
SimplePortal's style file is portal.css, found in the default theme CSS folder.
 
I think that answers your question
 
-----------------------------------------------------------------
But there seems to be an unasked question:
 
"What's the easiest way to get some of SMF's and SimplePortal's cool features integrated into my E-Zine, which is going to be tied into a SimplePortal/SMF site anyway?"
 
Do you think you could produce your E-Zine within the framework of SMF and SimplePortal? If you could find an "almost perfect" custom theme, then customize it to suit, perhaps adding a little code to the theme's index.template.php to detect which page it is on and display just a little differently on the Zine's page.
 
In that case, you could do the Zine as the site's portal page (if you want it to be the front page) or else as a custom page (if you want users to enter on a splash page).
 
Because, if your zine works well in the SimplePortal/SMF framework, then it might be easier to just do it inside SimplePortal than to try to rip functionality out of SimplePortal and/or SMF.
 
------------------------------------
 
Whichever way you decide to go, I'm sure you are going to wind up with questions about general SimplePortal support, SimplePortal customization, and customizing themes specifically for SimplePortal stuff.  You'll make it easiest for everyone here at SimplePortal.net to help if you start new threads for these questions.  And don't forget -- for questions about SMF that aren't specific to SimplePortal, you may get much quicker (and sometimes even better!) support from the much larger community at simplemachines.org
 
Good luck with your zine, and have fun developing it.
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: VegasJay on June 11, 2010, 09:37:35 AM
Quote
"What's the easiest way to get some of SMF's and SimplePortal's   cool features integrated into my E-Zine, which is going to be tied into a   SimplePortal/SMF site anyway?"

Ouch, I hate it when someone makes me stop and think, action for actions sake is my motto.

Having said that I have kinda solved my original problem in a semi satisfactory way.

Original problem
My original problem was how to control the display of the calendar block when using it as an insert block in a another (non-SMF/SP portion of my system)

My semi satisfactory solution is after playing around with some formatting commands in the HTML portion of the block code, is to simply do an inline CSS in the block, using the class names already assigned in the block PHP code.

This works pretty well, and has the added advantage of making me more independent of the way SMF is set up.

Take home on the Original Problem
In a more general theme I figure I now have a method of extracting other parts from SMF and recycling them in another Non-SMF portion of my system. The advantage to doing this is fresh content in the non-SMF area with zero effort on the administrators part (Except WHEN it breaks of course)

If other semi-newbie coding impared system operators are attempting to do this and need help they can email me (jay.clark@cntlwire.com) and I will do my best to tell them how my kludge works. If enough folks want help I will attempt to write it up as an app note and post it some place.

The Blindingly Obvious
I have been slowly evolving away from standard front pages and websites towards using SMF as the guts of my systems, and only having a few custom pages for the rest of the website. Simple Portal was a huge step forward for me in this direction.

<shame faced grimace :whistle: > When I started the eZine project

it simply never occurred to me

that I could simply use Simple Portal and do the 80%/20% thing, Using Simple Portal to in effect create Simple eZine, more or less by simply doing a custom theme and building a few additional pages as needed. I have a lotta good, Manly, reasons for this, but I will spare you my rationalizations

Thank you, thank you, thank you
I have to give this some more thought, SMF hacks has been offering their newsletter mod for a while, probably should take a look at that, there are some other SMF 3rd parties out there with stuff as well that will probably give me some ideas as well.

jayr





Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: AngelinaBelle on June 11, 2010, 10:16:42 AM
We're all about simple here!
 
The thing about simple frameworks is that they work great as long as the inherent restrictions are OK for your needs.
 
Have fun!
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: Koops on June 21, 2010, 07:00:44 AM
Error :
Quote
8: Undefined index: calendar51

Has anyone encounted this error while using din1031's DIN1031CalenderBlockV3.php file?

no one? I now have 29000 errors in my error log for this block making it a pain in the ass to see anything else broken. :O
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: AngelinaBelle on June 21, 2010, 07:54:57 AM
I don't think this block has been updated in some time.
 
Have you tried using the block that comes with SimplePortal?
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: Koops on June 24, 2010, 12:06:32 AM
I don't think this block has been updated in some time.
 
Have you tried using the block that comes with SimplePortal?

yeah i've switched to that but it doesn't have the same functionality as the other block (ie. "*" links to editing of calender entries etc).
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: AngelinaBelle on August 09, 2010, 01:07:51 PM
Your best bet may be to start with what comes with SimplePortal, and add the features you need.
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: VegasJay on August 09, 2010, 02:55:20 PM
Your best bet may be to start with what comes with SimplePortal, and add the features you need.

Could you please point me at the page that contains the code for the calendar block ?  Have some ideas and need to see the code to see if what I am thinking of is even possible.

jayr
Title: Re: about calendar in SimplePortal 2 / SMF 1.1.X
Post by: AngelinaBelle on August 09, 2010, 07:30:33 PM
Portalblocks.php
SimplePortal 2.3.8 © 2008-2024, SimplePortal