Home
Download
Add-ons
Help
Forum
Organisation
Project
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
May 25, 2012, 09:25:19 PM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
Wollen Sie dem WebsiteBaker Team beitreten?
Nähere Informationen finden Sie unter
hier
und auf unserer
neuen Webseite
.
155528
Posts in
21713
Topics by
7737
Members
Latest Member:
chris85
WebsiteBaker Community Forum
English
Droplets (PHP code for use with Droplet module) & Snippets (raw PHP code)
(Moderator:
Argos
)
Droplet -> Generate_Calender
Pages:
1
[
2
]
Go Down
Author
Topic: Droplet -> Generate_Calender (Read 6174 times)
tiesy
Offline
Posts: 124
Re: Droplet -> Generate_Calender
«
Reply #25 on:
November 17, 2009, 07:01:38 PM »
OK, I found out one thing (and yes, with your code not opened with Word, WebBird! ):
on a WB2.7-installation (online) the "n"s are shown.
on a WB2.8-installation (xampp) there are no "n"s. Everything is right there
Where is the problem, deleting all "\n" in the calendar_droplet.ph
p? Without them, it works in 2.7 and 2.8
Logged
pcwacht
AddOn Development
Offline
Posts: 2858
Re: Droplet -> Generate_Calender
«
Reply #26 on:
November 18, 2009, 08:25:50 AM »
The \n only generates a linebreak in your html source, not in your output on your screen.
It is only there for source reading purposes
It is safe to delete them all.
Have fun,
John
Logged
http://www.ictwacht.nl
= Dutch ICT info
http://www.pcwacht.nl
= My first
both still work in progress, since years.....
WebBird
Guest
Re: Droplet -> Generate_Calender
«
Reply #27 on:
November 18, 2009, 10:47:57 AM »
I tried with 2.7 and can confirm that. Seems to be a bug in the Droplets module.
Edit: Found this in line 59 of the droplets.php:
Code:
$content = stripslashes($fetch_content['code']);
Droplets 1.0.1 (WB 2.8 ) does this:
Code:
$codedata = ($fetch_content['code']);
So, the problem is caused by the droplets module. There are two ways to get around it:
* Remove all \-thingies from droplet codes (ALL droplet codes!)
* Correct the Droplets module (remove "stripslashes" in line 59)
But, I think the best way is:
Upgrade to 2.8!
«
Last Edit: November 18, 2009, 10:56:59 AM by WebBird
»
Logged
tiesy
Offline
Posts: 124
Re: Droplet -> Generate_Calender
«
Reply #28 on:
November 24, 2009, 04:27:55 PM »
Ok, I think the mysterious "\n"-problem is solved so far. I have a little enhancement that shows a tooltip with the short decscription of the calendar entries. That was easy to do, only add the "title"-attribute to "a href":
Change line:
Code:
$days[ $row['day'] ] = array( NULL, NULL, "<span style='font-weight: bold; border: 1px solid #f00;'><a href='".$row['url']."' target='_blank'>".$row['day']."</a></span>" );
To:
Code:
$days[ $row['day'] ] = array( NULL, NULL, "<span style='font-weight: bold; border: 1px solid #f00;'><a href='".$row['url']."' title='".$row['descr']."' target='_blank'>".$row['day']."</a></span>" );
What would make it to a really very nice droplet:
- make previous and next-Links work
- automatically link (not hardcoded) to the page where the Event Calendar-Module is placed.
Logged
WebBird
Guest
Re: Droplet -> Generate_Calender
«
Reply #29 on:
November 24, 2009, 06:21:56 PM »
Quote from: tiesy on November 24, 2009, 04:27:55 PM
- make previous and next-Links work
Sorry, but this is not possible with Droplets.
Edit:
You may include the droplet more than once to have the previous and next month shown, too.
Quote from: tiesy on November 24, 2009, 04:27:55 PM
- automatically link (not hardcoded) to the page where the Event Calendar-Module is placed.
An easy way is to set a variable in the droplet.
Logged
taurus66
Offline
Posts: 23
Re: Droplet -> Generate_Calender
«
Reply #30 on:
January 17, 2010, 07:18:30 PM »
Hi Webbird,
l like this Droplet a lot!
Little Problem: The Droplet doesn't switch to German, it stays in english.
Something I could have done wrong?
Eventcalendar -as all parts of my site
www.sft98.de
runs in german.
Thanks,
Bernd
«
Last Edit: February 02, 2010, 08:02:19 PM by mr-fan
»
Logged
pcwacht
AddOn Development
Offline
Posts: 2858
Re: Droplet -> Generate_Calender
«
Reply #31 on:
January 17, 2010, 07:53:43 PM »
http://www.websitebaker2.org/forum/index.php/topic,15895.msg103993.html#msg103993
John
Logged
http://www.ictwacht.nl
= Dutch ICT info
http://www.pcwacht.nl
= My first
both still work in progress, since years.....
taurus66
Offline
Posts: 23
Re: Droplet -> Generate_Calender
«
Reply #32 on:
January 17, 2010, 08:20:14 PM »
Quote from: pcwacht on January 17, 2010, 07:53:43 PM
http://www.websitebaker2.org/forum/index.php/topic,15895.msg103993.html#msg103993
Sorry John, I don't understand what you are trying to say.
Logged
pcwacht
AddOn Development
Offline
Posts: 2858
Re: Droplet -> Generate_Calender
«
Reply #33 on:
January 17, 2010, 08:37:41 PM »
At that post there is an explanation how to set this droplet to work with German-time output
John
Logged
http://www.ictwacht.nl
= Dutch ICT info
http://www.pcwacht.nl
= My first
both still work in progress, since years.....
WebBird
Guest
Re: Droplet -> Generate_Calender
«
Reply #34 on:
January 18, 2010, 10:21:03 AM »
Quote from: taurus66 on January 17, 2010, 07:18:30 PM
Hi Webbird,
l like this Droplet a lot!
Thank you, but please note that the droplet was provided by "pcwacht". I only added the "Events" binding.
Logged
taurus66
Offline
Posts: 23
Re: Droplet -> Generate_Calender
«
Reply #35 on:
January 18, 2010, 07:17:20 PM »
Quote from: WebBird on January 18, 2010, 10:21:03 AM
Quote from: taurus66 on January 17, 2010, 07:18:30 PM
Hi Webbird,
l like this Droplet a lot!
Thank you, but please note that the droplet was provided by "pcwacht". I only added the "Events" binding.
Oooops, sorry Webbird, sorry pcwacht.
Quote
At that post there is an explanation how to set this droplet to work with German-time output
Ahhh, ok, unterstand. I have these lines in the Droplet. Shouldn't that work?
$locale = 'de_DE';
if ( isset( $locale ) ) {
// store old locale
$oldlocale = setlocale(LC_TIME, NULL); #save current locale
setlocale( LC_TIME, $locale );
}
Logged
pcwacht
AddOn Development
Offline
Posts: 2858
Re: Droplet -> Generate_Calender
«
Reply #36 on:
January 18, 2010, 08:16:22 PM »
Yups it should
What it does is it tells php date and time output should be in German format
Look here for more info and other locale entries
http://nl2.php.net/manual/en/function.setlocale.php
Especially this might be interesting:
http://nl2.php.net/manual/en/function.setlocale.php#77795
http://nl2.php.net/manual/en/function.setlocale.php#62748
And here some more info :
http://www.freeopenbook.com/php5manual/function.setlocale.html
Good luck,
John
Logged
http://www.ictwacht.nl
= Dutch ICT info
http://www.pcwacht.nl
= My first
both still work in progress, since years.....
WebBird
Guest
Re: Droplet -> Generate_Calender
«
Reply #37 on:
January 19, 2010, 11:32:49 AM »
You can try to check the correct locale setting adding this code AFTER the code you quoted above:
Code:
echo "Current locale setting: ", setlocale(LC_TIME, NULL), "<br />";
Logged
WebBird
Guest
Re: Droplet -> Generate_Calender
«
Reply #38 on:
January 28, 2010, 05:37:44 PM »
I found that the locale is resetted BEFORE the month name is generated. So do the following:
FIND (~line 68)
Code:
// reset locale
setlocale(LC_TIME, $oldlocale);
CUT and INSERT AFTER:
Code:
$title = htmlentities(ucfirst($month_name)).' '.$year; #note that some locales don't capitalize month and day names
(After cutting, about 4 lines later.)
Complete new code I am working with:
Code:
global $wb, $database;
$days = array();
$day_name_length = 2;
$month_href = NULL;
$where = NULL;
$first_day = 1;
$pn = array();
$events = 0;
$oldlocale = setlocale(LC_TIME, NULL); #save current locale
setlocale(LC_TIME, 'de_DE');
if(!isset($year)) {$year = date('Y', time()); };
if(!isset($month)) {$month = date('n', time()); };
if ( isset( $section ) ) { $where = "AND section_id='$section'"; }
$today = date('j',time());
// Get Events from "Event Calendar" Module (1.8c)
$sql = "SELECT DAY(date) AS day, event_desc AS descr, evweb_url AS url FROM ".TABLE_PREFIX."mod_event_dates WHERE YEAR(date) = '$year' AND MONTH(date) = '$month' $where";
$result = $database->query($sql);
if ( $result->numRows() > 0 ) {
while( $row = $result->fetchRow() ) {
$text = $row['day'];
if ( ! empty( $row['descr'] ) ) {
$text .= ' <span>'.$row['descr'].'</span>';
}
if ( ! empty( $row['url'] ) ) {
$days[ $row['day'] ]
= array(
NULL,
NULL,
"<span style='font-weight: bold; border: 1px solid #f00;'>"
. "<a class='tooltip' href='".$row['url']."' target='_blank'>"
. $text
. "</a></span>"
);
}
else {
$days[ $row['day'] ]
= array(
NULL,
NULL,
"<span style='font-weight: bold; border: 1px solid #f00;'>"
. "<a class='tooltip' href='#'>"
. $text
. "</a></span>"
);
}
$events++;
}
}
if ( ! isset( $days[$today] ) ) {
$days[$today] = array( NULL, 'calendar-today' );
}
$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()
$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
// reset locale
setlocale(LC_TIME, $oldlocale);
#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="calendar-prev">'.($pl ? '<a href="'.htmlspecialchars($pl).'">'.$p.'</a>' : $p).'</span> ';
if($n) $n = ' <span class="calendar-next">'.($nl ? '<a href="'.htmlspecialchars($nl).'">'.$n.'</a>' : $n).'</span>';
$calendar = '<table class="calendar">'."\n".
'<caption class="calendar-month">'.$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 abbr="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</th>';
$calendar .= "</tr>\n<tr>";
}
if($weekday > 0) $calendar .= '<td 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>";
}
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>$day</td>";
}
if($weekday != 7) $calendar .= '<td colspan="'.(7-$weekday).'"> </td>'; #remaining "empty" days
$calendar .= "</tr>\n</table><br />\n";
if ( $events == 0 ) {
$calendar .= 'Keine Termine für diesen Monat.<br />';
}
else {
$calendar .= $events.' '.'Termin'
. ( $events > 1 ? 'e' : '' )
. ' für diesen Monat.<br />';
}
return $calendar;
Logged
crnogorac081
AddOn Development
Offline
Posts: 1706
Re: Droplet -> Generate_Calender
«
Reply #39 on:
January 28, 2010, 09:08:02 PM »
Is it possible to have a droplet inside droplet, for example something like:
Code:
$pn = array('<'=>'[[evcal?year=$year&month=$month-1]]','>'=>'[[evcal?year=$year&month=$month+1]]');
And somehow like this to generate prev and next links
BTW droplet is great !!! It would be nice to have something like this for news and topics modules as well..
Logged
Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
WebBird
Guest
Re: Droplet -> Generate_Calender
«
Reply #40 on:
January 29, 2010, 10:50:33 AM »
Stefek made a topic version of this droplet. Try the Forum Search.
Logged
taurus66
Offline
Posts: 23
Re: Droplet -> Generate_Calender
«
Reply #41 on:
February 05, 2010, 03:11:28 PM »
Quote from: WebBird on January 19, 2010, 11:32:49 AM
You can try to check the correct locale setting adding this code AFTER the code you quoted above:
Code:
echo "Current locale setting: ", setlocale(LC_TIME, NULL), "<br />";
Hi Webbird,
System tells me "Current locale setting: C"
Gruß,
Bernd
Logged
taurus66
Offline
Posts: 23
Re: Droplet -> Generate_Calender
«
Reply #42 on:
February 05, 2010, 03:13:31 PM »
Quote from: WebBird on January 28, 2010, 05:37:44 PM
I found that the locale is resetted BEFORE the month name is generated. So do the following:
FIND (~line 68)
Code:
// reset locale
setlocale(LC_TIME, $oldlocale);
CUT and INSERT AFTER:
Code:
$title = htmlentities(ucfirst($month_name)).' '.$year; #note that some locales don't capitalize month and day names
(After cutting, about 4 lines later.)
No, this doesn't work, too
Logged
WebBird
Guest
Re: Droplet -> Generate_Calender
«
Reply #43 on:
February 05, 2010, 03:40:59 PM »
Are you sure you did it right?
Logged
taurus66
Offline
Posts: 23
Re: Droplet -> Generate_Calender
«
Reply #44 on:
February 05, 2010, 05:09:39 PM »
Quote from: WebBird on February 05, 2010, 03:40:59 PM
Are you sure you did it right?
I'm only sure, that 'm not sure
Here's the code I took from you and changed as you told ... I hope I did
Code:
global $wb, $database;
$days = array();
$day_name_length = 2;
$month_href = NULL;
$where = NULL;
$first_day = 1;
$pn = array();
$events = 0;
$oldlocale = setlocale(LC_TIME, NULL); #save current locale
setlocale(LC_TIME, 'de_DE');
if(!isset($year)) {$year = date('Y', time()); };
if(!isset($month)) {$month = date('n', time()); };
if ( isset( $section ) ) { $where = "AND section_id='$section'"; }
$today = date('j',time());
// Get Events from "Event Calendar" Module (1.8c)
$sql = "SELECT DAY(date) AS day, event_desc AS descr, evweb_url AS url FROM ".TABLE_PREFIX."mod_event_dates WHERE YEAR(date) = '$year' AND MONTH(date) = '$month' $where";
$result = $database->query($sql);
if ( $result->numRows() > 0 ) {
while( $row = $result->fetchRow() ) {
$text = $row['day'];
if ( ! empty( $row['descr'] ) ) {
$text .= ' <span>'.$row['descr'].'</span>';
}
if ( ! empty( $row['url'] ) ) {
$days[ $row['day'] ] = array(NULL,NULL,"<span style='font-weight: bold; border: 1px solid #f00;'>"."<a class='tooltip' href='http://www.sft98.de/pages/kalender.php'>".$row['day']."</a></span>" );
}
else {
$days[ $row['day'] ] = array(NULL,NULL,"<span style='font-weight: bold; border: 1px solid #f00;'>"."<a class='tooltip' href='http://www.sft98.de/pages/kalender.php'>".$row['day']."</a></span>");
}
$events++;
}
}
if ( ! isset( $days[$today] ) ) {
$days[$today] = array( NULL, 'calendar-today' );
}
$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()
$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
// reset locale
setlocale(LC_TIME, $oldlocale);
#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="calendar-prev">'.($pl ? '<a href="'.htmlspecialchars($pl).'">'.$p.'</a>' : $p).'</span> ';
if($n) $n = ' <span class="calendar-next">'.($nl ? '<a href="'.htmlspecialchars($nl).'">'.$n.'</a>' : $n).'</span>';
$calendar = '<table class="calendar">'."\n".
'<caption class="calendar-month">'.$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 abbr="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</th>';
$calendar .= "</tr>\n<tr>";
}
if($weekday > 0) $calendar .= '<td 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>";
}
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>$day</td>";
}
if($weekday != 7) $calendar .= '<td colspan="'.(7-$weekday).'"> </td>'; #remaining "empty" days
$calendar .= "</tr>\n</table><br />\n";
if ( $events == 0 ) {
$calendar .= 'Keine Termine für diesen Monat.<br /><br />';
}
else {
$calendar .= $events.' '.'Termin'
. ( $events > 1 ? 'e' : '' )
. ' für diesen Monat.<br /><br />';
}
return $calendar;
Logged
WebBird
Guest
Re: Droplet -> Generate_Calender
«
Reply #45 on:
February 06, 2010, 06:25:17 PM »
Hm, looks okay. And works for me.
Don't know what's wrong. Maybe your webserver doesn't implement that locale.
Just don't know.
Logged
taurus66
Offline
Posts: 23
Re: Droplet -> Generate_Calender
«
Reply #46 on:
February 06, 2010, 06:29:21 PM »
Quote from: WebBird on February 06, 2010, 06:25:17 PM
Hm, looks okay. And works for me.
Don't know what's wrong. Maybe your webserver doesn't implement that locale.
Just don't know.
Ok, thanks a million anyway.
Logged
spoonxaver
Offline
Posts: 1
Re: Droplet -> Generate_Calender - modification Look Calendar
«
Reply #47 on:
June 05, 2010, 09:20:57 PM »
Here is my modifikation this droplet:
This modification writte events for actual month inline.
Code:
global $wb, $database;
$days = array();
$day_name_length = 8;
$month_href = NULL;
$where = NULL;
$first_day = 1;
$pn = array();
$events = 0;
$oldlocale = setlocale(LC_TIME, NULL); #save current locale
setlocale(LC_TIME, 'en_EN');
if(!isset($year)) {$year = date('Y', time()); };
if(!isset($month)) {$month = date('n', time()); };
if ( isset( $section ) ) { $where = "AND section_id='$section'"; }
$today = date('j',time());
// Get Events from "Event Calendar" Module (1.8c)
$sql = "SELECT DAY(date) AS day, date AS mesic, event_desc AS descr, evweb_url AS url FROM ".TABLE_PREFIX."mod_event_dates WHERE YEAR(date) = '$year' AND MONTH(date) = '$month' $where";
$result = $database->query($sql);
if ( $result->numRows() > 0 ) {
while( $row = $result->fetchRow() ) {
$text = $row['mesic'];
$textMonth = $row['mesic'];
if ( ! empty( $row['descr'] ) ) {
$text .= ' <span>'.$row['descr'].'</span>';
}
if ( ! empty( $row['url'] ) ) {
$days[ $row['day'] ]
= array(
NULL,
NULL,
"<span class='menuCalendar'>"
. "<a href='".$row['url']."' title='".$row['descr']."' target='_blank'>".$row['textMonth']."</a></span>"
);
}
else {
$days[ $row['day'] ]
= array(
NULL,
NULL,
"<span class='menuCalendar'>"
. "<a class='tooltip' href='#'>"
. $text
// . $textMonth
. "</a></span>"
);
}
$events++;
}
}
if ( ! isset( $days[$today] ) ) {
$days[$today] = array( NULL, 'calendar-today' );
}
$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()
$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
// reset locale
setlocale(LC_TIME, $oldlocale);
#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="calendar-prev">'.($pl ? '<a href="'.htmlspecialchars($pl).'">'.$p.'</a>' : $p).'</span> ';
if($n) $n = ' <span class="calendar-next">'.($nl ? '<a href="'.htmlspecialchars($nl).'">'.$n.'</a>' : $n).'</span>';
$calendar = '<table class="calendar">'."\n".'<caption class="calendar-month">'.$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 abbr="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</th>';
$calendar .= "</tr>\n<tr class='calendar-month'>";
}
*/
/*if($weekday > 0) $calendar .= '<td 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>";
}
if(isset($days[$day]) and is_array($days[$day])){
@list($link, $classes, $content) = $days[$day];
if(is_null($content)) $content = $day;
$calendar .= '<tr><td'.($classes ? ' class="'.htmlspecialchars($classes).'">' : '>').
($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).'</td></tr>';
}
}
#remaining "empty" days
//if($weekday != 7) $calendar .= '<td colspan="'.(7-$weekday).'"> </td>';
$calendar .= "</tr>\n</table><br />\n";
if ( $events == 0 ) {
$calendar .= 'Nothing for this Month.<br />';
}
else {
$calendar .= $events.' '.'Termins'
. ( $events > 1 ? 'e' : '' )
. ' for this Month.<br />';
}
return $calendar;
«
Last Edit: June 06, 2010, 10:59:47 AM by spoonxaver
»
Logged
BlackBird
AddOn Development
Offline
Posts: 2069
Re: Droplet -> Generate_Calender
«
Reply #48 on:
June 05, 2010, 09:30:39 PM »
Please explain your modification. What did you do? Why?
Logged
Alle großen Veränderungen beginnen im Kleinen
capt_funk
Offline
Posts: 2
Re: Droplet -> Generate_Calender
«
Reply #49 on:
April 10, 2012, 02:40:25 PM »
I modified the droplet some to display the upcoming events (next 7 days) beneath the calendar. This droplet shows the weekday and the title of the event from the Envent Calendar.
Code:
global $wb, $database;
$days = array();
$day_name_length = 2;
$month_href = NULL;
$first_day = 1;
$pn = array();
$oldlocale = setlocale(LC_TIME, NULL); #save current locale
setlocale(LC_TIME, 'de_DE');
if(!isset($year)) {$year = date('Y', time()); };
if(!isset($month)) {$month = date('n', time()); };
// Get Events from "Event Calendar" Module (1.8c)
$sql = "SELECT DAY(date) AS day, event_desc AS descr, evweb_url AS url FROM ".TABLE_PREFIX."mod_event_dates WHERE YEAR(date) = '$year' AND MONTH(date) = '$month'";
$result = $database->query($sql);
if ( $result->numRows() > 0 ) {
while( $row = $result->fetchRow() ) {
if ( ! empty( $row['url'] ) ) {
$days[ $row['day'] ] = array( NULL, NULL, "<span style='font-weight: bold; color: #006;'><a href='".$row['url']."' target='_blank'>".$row['day']."</a></span>" );
}
else {
$days[ $row['day'] ] = array( NULL, NULL, "<span style='font-weight: bold; color: #006;'>".$row['day']."</span>" );
}
}
}
$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()
$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
// reset locale
setlocale(LC_TIME, $oldlocale);
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="calendar-prev">'.($pl ? '<a href="'.htmlspecialchars($pl).'">'.$p.'</a>' : $p).'</span> ';
if($n) $n = ' <span class="calendar-next">'.($nl ? '<a href="'.htmlspecialchars($nl).'">'.$n.'</a>' : $n).'</span>';
$calendar = '<table width=140 class="calendar">'."\n".
'<caption class="calendar-month" style="font-weight: bold;">'.$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 style="font-size: 10px; font-weight: normal;" abbr="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</th>';
$calendar .= "</tr>\n<tr>";
}
if($weekday > 0) $calendar .= '<td 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>";
}
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>$day</td>";
}
if($weekday != 7) $calendar .= '<td colspan="'.(7-$weekday).'"> </td>'; #remaining "empty" days
$month_events=array();
$today=date('j')."<br>\n";
$weekday=date('N');
$days_de=array("Mo","Di","Mi","Do","Fr","Sa","So");
$sql="SELECT DAY(date) AS day, event_desc AS descr, evweb_url AS url FROM ".TABLE_PREFIX."mod_event_dates WHERE YEAR(date) = '$year' AND MONTH(date) = '$month'";
$result=$database->query($sql);
while($row=$result->fetchrow()){
$temp=date('N',mktime(0,0,0,$month,$row['day'],$year));
$weekday=$days_de[$temp-1];
$month_events[$row['day']].=substr("<tr><td>$weekday</td><td><span style='font-weight: bold;'> ".$row['descr'],0,75)."</span></td></tr>\n";
}
for($i=0;$i<7;$i++){ //get events for the next 7 days
$week_events.=$month_events[$today+$i];
}
return $calendar."</tr>\n</table>\n"."\n<table width=140 cellpadding=0>$week_events\n</table>";
To modify the amout of days ahead displayed under the calendar, modify the for-loop at the end (change 7 to whatever you need). An example of the droplet in action can be viewed here:
http://scvillip.de/
Logged
Pages:
1
[
2
]
Go Up
Jump to:
Please select a destination:
-----------------------------
General
-----------------------------
=> General Announcements
=> Security Announcements
=> Documentation
=> WebsiteBaker Website Showcase
=> Guest Area & Off-Topic
-----------------------------
English
-----------------------------
=> WebsiteBaker 2.9
===> Announcements
===> Help/Support
=====> Modules / Extensions
===> Suggestions
===> Software bugs
=> Help & Support
=> Modules
=> Droplets (PHP code for use with Droplet module) & Snippets (raw PHP code)
=> jQuery
=> Templates, Menus & Design
=> WebsiteBaker Language Files
=> WebsiteBaker 2.x discussion
=> WebsiteBaker 3
=> Archive (posts up to 2007)
-----------------------------
Deutsch (German)
-----------------------------
=> Ankündigungen
=> WebsiteBaker 2.9
===> Ankündigungen
===> Hilfe/Support
=====> Module / Extensions
===> Vorschläge
===> Softwarefehler
===> Erfahrungs und Testberichte
=> Hilfe/Support
=> Module & Snippets
=> Templates & Design
=> Tutorials
=> jQuery
=> Diskussion über WB
=> Off-Topic
=> Archiv für Themen bis 2007
-----------------------------
Nederlands (Dutch)
-----------------------------
=> Aankondigingen
=> Hulp & Ondersteuning
=> Niet-Terzake (Off Topic)
-----------------------------
Francais (French)
-----------------------------
=> Help/Support
-----------------------------
Italiano (Italian)
-----------------------------
=> Help/Support
-----------------------------
Bakery (WB shop module)
-----------------------------
=> Bakery English
=> Bakery Deutsch
-----------------------------
KeepInTouch (Multi Contact Module)
-----------------------------
=> KeepInTouch English
=> KeepInTouch Deutsch
Loading...