made events calendar 100% templatable
This commit is contained in:
parent
8fbbdf654c
commit
016c33171e
8 changed files with 312 additions and 1283 deletions
|
|
@ -68,3 +68,9 @@ webgui.
|
|||
- Added new toolbar icons.
|
||||
- Made the add content menu much more powerful.
|
||||
- Added new navigation system. (Len Kranendonk).
|
||||
- Made the date/time system more precise.
|
||||
- The Events Calendar is now 100% template driven.
|
||||
- The Events Calendar now allows for more than one drawn calendar per page.
|
||||
Choose with your pagination options.
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,12 @@ save you many hours of grief.
|
|||
WARNING: Be sure you install these modules BEFORE you attempt to
|
||||
upgrade or the upgrade will fail and you'll have a mess to
|
||||
clean up!
|
||||
|
||||
* If you've created any custom Events Calendar templates, they will
|
||||
no longer work due to the new template structure for events
|
||||
calendars. Your old templates will remain intact, however,
|
||||
so that you can migrate them manually to the new template
|
||||
variables.
|
||||
|
||||
|
||||
5.5.0
|
||||
|
|
|
|||
|
|
@ -517,3 +517,9 @@ INSERT INTO international VALUES (33,'Navigation',1,'Error: This identifier is a
|
|||
INSERT INTO international VALUES (20,'Navigation',1,'Delete this Navigation.',1077080098,'');
|
||||
INSERT INTO international VALUES (31,'Navigation',1,'Show hidden pages',1077080799,'');
|
||||
|
||||
delete from template where namespace='EventsCalendar' and templateId<1000;
|
||||
|
||||
INSERT INTO template VALUES (2,'Events List','<tmpl_if displayTitle>\r\n <h1><tmpl_var title></h1>\r\n</tmpl_if>\r\n\r\n<tmpl_if description>\r\n <tmpl_var description><p />\r\n</tmpl_if>\r\n\r\n<tmpl_if session.var.adminOn>\r\n <a href=\"<tmpl_var addevent.url>\"><tmpl_var addevent.label></a>\r\n <p />\r\n</tmpl_if>\r\n\r\n\n<tmpl_loop month_loop>\n <tmpl_loop day_loop>\n <tmpl_loop event_loop>\n <tmpl_if isFirstDayOfEvent>\n <tmpl_unless dateIsSameAsPrevious>\n <b>\n <tmpl_var start.month> <tmpl_var start.day><tmpl_unless startEndYearMatch>,\n <tmpl_ start.year> - \n <tmpl_var end.month> <tmpl_var end.day></tmpl_unless><tmpl_unless startEndMonthMatch> - <tmpl_var end.month> <tmpl_var end.day><tmpl_else><tmpl_unless startEndDayMatch> - <tmpl_var end.day></tmpl_unless></tmpl_unless>, <tmpl_var end.year>\n </b>\n </tmpl_unless>\n <blockquote>\n <tmpl_if session.var.adminOn>\n <a href=\"<tmpl_var url>\">\n </tmpl_if>\n <i><tmpl_var name></i>\n <tmpl_if session.var.adminOn>\n </a>\n </tmpl_if>\n <tmpl_if description>\n - <tmpl_var description>\n </tmpl_if description>\n </blockquote>\n </tmpl_if>\n </tmpl_loop>\n </tmpl_loop>\n</tmpl_loop>\n\n\n\n<tmpl_if pagination.pageCount.isMultiple>\n <div class=\"pagination\">\n <tmpl_var pagination.previousPage> · <tmpl_var pagination.pageList.upTo20> · <tmpl_var pagination.nextPage>\n </div>\n</tmpl_if>\n','EventsCalendar');
|
||||
INSERT INTO template VALUES (3,'Calendar Month (Small)','<tmpl_if displayTitle>\r\n <h1><tmpl_var title></h1>\r\n</tmpl_if>\r\n\r\n<tmpl_if description>\r\n <tmpl_var description><p />\r\n</tmpl_if>\r\n\r\n<tmpl_if session.var.adminOn>\r\n <a href=\"<tmpl_var addevent.url>\"><tmpl_var addevent.label></a>\r\n <p />\r\n</tmpl_if>\r\n\r\n\n\n\n<tmpl_loop month_loop>\n <table border=\"1\" width=\"100%\">\n <tr><td colspan=7 class=\"tableHeader\"><h2 align=\"center\"><tmpl_var month> <tmpl_var year></h2></td></tr>\n <tr>\n <tmpl_if session.user.firstDayOfWeek>\n <th class=\"tableData\"><tmpl_var monday.label.short></th>\n <th class=\"tableData\"><tmpl_var tuesday.label.short></th>\n <th class=\"tableData\"><tmpl_var wednesday.label.short></th>\n <th class=\"tableData\"><tmpl_var thursday.label.short></th>\n <th class=\"tableData\"><tmpl_var friday.label.short></th>\n <th class=\"tableData\"><tmpl_var saturday.label.short></th>\n <th class=\"tableData\"><tmpl_var sunday.label.short></th>\n <tmpl_else>\n <th class=\"tableData\"><tmpl_var sunday.label.short></th>\n <th class=\"tableData\"><tmpl_var monday.label.short></th>\n <th class=\"tableData\"><tmpl_var tuesday.label.short></th>\n <th class=\"tableData\"><tmpl_var wednesday.label.short></th>\n <th class=\"tableData\"><tmpl_var thursday.label.short></th>\n <th class=\"tableData\"><tmpl_var friday.label.short></th>\n <th class=\"tableData\"><tmpl_var saturday.label.short></th>\n </tmpl_if>\n </tr><tr>\n <tmpl_loop prepad_loop>\n <td> </td>\n </tmpl_loop>\n <tmpl_loop day_loop>\n <tmpl_if isStartOfWeek>\n <tr>\n </tmpl_if>\n <td class=\"table<tmpl_if isToday>Header<tmpl_else>Data</tmpl_if>\" width=\"28\" valign=\"top\" align=\"left\"><p><b>\n <tmpl_if url>\n <a href=\"<tmpl_var url>\"><tmpl_var day></a>\n <tmpl_else>\n <tmpl_var day>\n </tmpl_if>\n </b></p></td> \n <tmpl_if isEndOfWeek>\n </tr>\n </tmpl_if>\n </tmpl_loop>\n <tmpl_loop postpad_loop>\n <td> </td>\n </tmpl_loop>\n </tr>\n </table>\n</tmpl_loop>\n\n\n<tmpl_if pagination.pageCount.isMultiple>\n <div class=\"pagination\">\n <tmpl_var pagination.previousPage> · <tmpl_var pagination.pageList.upTo20> · <tmpl_var pagination.nextPage>\n </div>\n</tmpl_if>\n','EventsCalendar');
|
||||
INSERT INTO template VALUES (1,'Calendar Month (Big)','<tmpl_if displayTitle>\r\n <h1><tmpl_var title></h1>\r\n</tmpl_if>\r\n\r\n<tmpl_if description>\r\n <tmpl_var description><p />\r\n</tmpl_if>\r\n\r\n<tmpl_if session.var.adminOn>\r\n <a href=\"<tmpl_var addevent.url>\"><tmpl_var addevent.label></a>\r\n <p />\r\n</tmpl_if>\r\n\r\n<tmpl_loop month_loop>\n <table border=\"1\" width=\"100%\">\n <tr><td colspan=7 class=\"tableHeader\"><h2 align=\"center\"><tmpl_var month> <tmpl_var year></h2></td></tr>\n <tr>\n <tmpl_if session.user.firstDayOfWeek>\n <th class=\"tableData\"><tmpl_var monday.label></th>\n <th class=\"tableData\"><tmpl_var tuesday.label></th>\n <th class=\"tableData\"><tmpl_var wednesday.label></th>\n <th class=\"tableData\"><tmpl_var thursday.label></th>\n <th class=\"tableData\"><tmpl_var friday.label></th>\n <th class=\"tableData\"><tmpl_var saturday.label></th>\n <th class=\"tableData\"><tmpl_var sunday.label></th>\n <tmpl_else>\n <th class=\"tableData\"><tmpl_var sunday.label></th>\n <th class=\"tableData\"><tmpl_var monday.label></th>\n <th class=\"tableData\"><tmpl_var tuesday.label></th>\n <th class=\"tableData\"><tmpl_var wednesday.label></th>\n <th class=\"tableData\"><tmpl_var thursday.label></th>\n <th class=\"tableData\"><tmpl_var friday.label></th>\n <th class=\"tableData\"><tmpl_var saturday.label></th>\n </tmpl_if>\n </tr><tr>\n <tmpl_loop prepad_loop>\n <td> </td>\n </tmpl_loop>\n <tmpl_loop day_loop>\n <tmpl_if isStartOfWeek>\n <tr>\n </tmpl_if>\n <td class=\"table<tmpl_if isToday>Header<tmpl_else>Data</tmpl_if>\" width=\"14%\" valign=\"top\" align=\"left\"><p><b><tmpl_var day></b></p>\n <tmpl_loop event_loop>\n <tmpl_if name>\n ·<a href=\"<tmpl_var url>\"><tmpl_var name></a><br />\n </tmpl_if>\n </tmpl_loop>\n </td>\n <tmpl_if isEndOfWeek>\n </tr>\n </tmpl_if>\n </tmpl_loop>\n <tmpl_loop postpad_loop>\n <td> </td>\n </tmpl_loop>\n </tr>\n </table>\n</tmpl_loop>\n\n\n<tmpl_if pagination.pageCount.isMultiple>\n <div class=\"pagination\">\n <tmpl_var pagination.previousPage> · <tmpl_var pagination.pageList.upTo20> · <tmpl_var pagination.nextPage>\n </div>\n</tmpl_if>\n','EventsCalendar');
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -39,10 +39,15 @@ This package provides easy to use date math functions, which are normally a comp
|
|||
use WebGUI::DateTime;
|
||||
$epoch = WebGUI::DateTime::addToDate($epoch, $years, $months, $days);
|
||||
$epoch = WebGUI::DateTime::addToTime($epoch, $hours, $minutes, $seconds);
|
||||
$epoch = WebGUI::DateTime::arrayToEpoch(@date);
|
||||
($startEpoch, $endEpoch) = WebGUI::DateTime::dayStartEnd($epoch);
|
||||
@date = WebGUI::DateTime::epochToArray($epoch);
|
||||
$dateString = WebGUI::DateTime::epochToHuman($epoch, $formatString);
|
||||
$setString = WebGUI::DateTime::epochToSet($epoch);
|
||||
$day = WebGUI::DateTime::getDayName($dayInteger);
|
||||
$integer = WebGUI::DateTime::getDaysInMonth($epoch);
|
||||
$integer = WebGUI::DateTime::getDaysInInterval($start, $end);
|
||||
$integer = WebGUI::DateTime::getFirstDayInMonthPosition($epoch);
|
||||
$month = WebGUI::DateTime::getMonthName($monthInteger);
|
||||
$seconds = WebGUI::DateTime::getSecondsFromEpoch($seconds);
|
||||
$epoch = WebGUI::DateTime::humanToEpoch($dateString);
|
||||
|
|
@ -94,9 +99,9 @@ The number of days to add to the epoch.
|
|||
|
||||
sub addToDate {
|
||||
my ($year,$month,$day, $hour,$min,$sec, $newDate);
|
||||
($year,$month,$day, $hour,$min,$sec) = Date::Calc::Time_to_Date($_[0]);
|
||||
($year,$month,$day, $hour,$min,$sec) = epochToArray($_[0]);
|
||||
($year,$month,$day) = Date::Calc::Add_Delta_YMD($year,$month,$day, $_[1],$_[2],$_[3]);
|
||||
$newDate = Date::Calc::Date_to_Time($year,$month,$day, $hour,$min,$sec);
|
||||
$newDate = arrayToEpoch($year,$month,$day, $hour,$min,$sec);
|
||||
return $newDate;
|
||||
}
|
||||
|
||||
|
|
@ -130,12 +135,39 @@ The number of seconds to add to the epoch.
|
|||
|
||||
sub addToTime {
|
||||
my ($year,$month,$day, $hour,$min,$sec, $newDate);
|
||||
($year,$month,$day, $hour,$min,$sec) = Date::Calc::Time_to_Date($_[0]);
|
||||
($year,$month,$day, $hour,$min,$sec) = epochToArray($_[0]);
|
||||
($year,$month,$day, $hour,$min,$sec) = Date::Calc::Add_Delta_DHMS($year,$month,$day,$hour,$min,$sec,0,$_[1],$_[2],$_[3]);
|
||||
$newDate = Date::Calc::Date_to_Time($year,$month,$day, $hour,$min,$sec);
|
||||
$newDate = arrayToEpoch($year,$month,$day, $hour,$min,$sec);
|
||||
return $newDate;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 arrayToEpoch ( date )
|
||||
|
||||
Returns an epoch date.
|
||||
|
||||
=over
|
||||
|
||||
=item date
|
||||
|
||||
An array of the format year, month, day, hour, min, sec.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub arrayToEpoch {
|
||||
my $year = shift;
|
||||
my $month = shift;
|
||||
my $day = shift;
|
||||
my $hour = shift;
|
||||
my $min = shift;
|
||||
my $sec = shift;
|
||||
return Date::Calc::Date_to_Time($year,$month,$day,$hour,$min,$sec);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 dayStartEnd ( epoch )
|
||||
|
|
@ -154,12 +186,34 @@ The number of seconds since January 1, 1970.
|
|||
|
||||
sub dayStartEnd {
|
||||
my ($year,$month,$day, $hour,$min,$sec, $start, $end);
|
||||
($year,$month,$day, $hour,$min,$sec) = Date::Calc::Time_to_Date($_[0]);
|
||||
($year,$month,$day, $hour,$min,$sec) = epochToArray($_[0]);
|
||||
$start = Date::Calc::Date_to_Time($year,$month,$day,0,0,0);
|
||||
$end = Date::Calc::Date_to_Time($year,$month,$day,23,59,59);
|
||||
return ($start, $end);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 epochToArray ( epoch )
|
||||
|
||||
Returns a date array in the form of year, month, day, hour, min, sec.
|
||||
|
||||
=over
|
||||
|
||||
=item epoch
|
||||
|
||||
An epoch date.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub epochToArray {
|
||||
my $epoch = shift;
|
||||
return Date::Calc::Time_to_Date($epoch);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 epochToHuman ( [ epoch, format ] )
|
||||
|
|
@ -210,7 +264,7 @@ sub epochToHuman {
|
|||
$offset = $offset*3600;
|
||||
$temp = int($_[0]) || time();
|
||||
$temp = $temp+$offset;
|
||||
my ($year,$month,$day,$hour,$min,$sec) = Date::Calc::Time_to_Date($temp);
|
||||
my ($year,$month,$day,$hour,$min,$sec) = epochToArray($temp);
|
||||
$output = $_[1] || "%z %Z";
|
||||
#---GMT Offsets
|
||||
$temp = $session{user}{timeOffset}*100;
|
||||
|
|
@ -390,6 +444,89 @@ sub getDayName {
|
|||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDaysInMonth ( epoch )
|
||||
|
||||
Returns the total number of days in the month.
|
||||
|
||||
=over
|
||||
|
||||
=item epoch
|
||||
|
||||
An epoch date.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub getDaysInMonth {
|
||||
my $epoch = shift;
|
||||
my @date = WebGUI::DateTime::epochToArray($epoch);
|
||||
return Date::Calc::Days_in_Month($date[0], $date[1]);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDaysInInterval ( start, end )
|
||||
|
||||
Returns the number of days between two epoch dates.
|
||||
|
||||
=over
|
||||
|
||||
=item start
|
||||
|
||||
An epoch date.
|
||||
|
||||
=item end
|
||||
|
||||
An epoch date.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub getDaysInInterval {
|
||||
my $start = shift;
|
||||
my $end = shift;
|
||||
my @start = WebGUI::DateTime::epochToArray($start);
|
||||
my @end = WebGUI::DateTime::epochToArray($end);
|
||||
return Date::Calc::Delta_Days($start[0], $start[1], $start[2], $end[0], $end[1], $end[2]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getFirstDayInMonthPosition ( epoch) {
|
||||
|
||||
Returns the position (1 - 7) of the first day in the month.
|
||||
|
||||
=over
|
||||
|
||||
=item epoch
|
||||
|
||||
An epoch date.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub getFirstDayInMonthPosition {
|
||||
my $epoch = shift;
|
||||
my @date = WebGUI::DateTime::epochToArray($epoch);
|
||||
my $firstDayInFirstWeek = Date::Calc::Day_of_Week($date[0],$date[1],1);
|
||||
unless ($session{user}{firstDayOfWeek}) { #american format
|
||||
$firstDayInFirstWeek++;
|
||||
if ($firstDayInFirstWeek > 7) {
|
||||
$firstDayInFirstWeek = 1;
|
||||
}
|
||||
}
|
||||
return $firstDayInFirstWeek;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getSecondsFromEpoch ( epoch )
|
||||
|
|
@ -439,7 +576,7 @@ sub humanToEpoch {
|
|||
$date[3] = int($temp[0]);
|
||||
$date[4] = int($temp[1]);
|
||||
$date[5] = int($temp[2]);
|
||||
$output = Date::Calc::Date_to_Time(@date);
|
||||
$output = arrayToEpoch(@date);
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
|
@ -485,7 +622,7 @@ sub intervalToSeconds {
|
|||
|
||||
=head2 localtime ( epoch )
|
||||
|
||||
Returns an array of time elements. The elements are: years, months, days, hours, minutes, seconds, day of year, day of week, daylight savings time.
|
||||
Returns an array of time elements. The elements are: years, months, days, hours, minutes, seconds, day of year, day of week.
|
||||
|
||||
=over
|
||||
|
||||
|
|
@ -498,7 +635,14 @@ The number of seconds since January 1, 1970. Defaults to now.
|
|||
=cut
|
||||
|
||||
sub localtime {
|
||||
return Date::Calc::Localtime($_[0]||WebGUI::DateTime::time());
|
||||
my $epoch = shift;
|
||||
my ($year, $month, $day, $hour, $min, $sec) = Date::Calc::Today_and_Now();
|
||||
if ($epoch) {
|
||||
($year, $month, $day, $hour, $min, $sec) = epochToArray($epoch);
|
||||
}
|
||||
my $doy = Date::Calc::Day_of_Year($year,$month,$day);
|
||||
my $dow = Date::Calc::Day_of_Week($year,$month,$day);
|
||||
return ($year, $month, $day, $hour, $min, $sec, $doy, $dow);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -522,7 +666,7 @@ An epoch datestamp corresponding to the last month.
|
|||
|
||||
sub monthCount {
|
||||
my ($start, $end) = @_;
|
||||
my @delta = Date::Calc::Delta_YMDHMS( Date::Calc::Time_to_Date($start), Date::Calc::Time_to_Date($end));
|
||||
my @delta = Date::Calc::Delta_YMDHMS( epochToArray($start), epochToArray($end));
|
||||
my $change = (($delta[0]*12)+$delta[1])+1;
|
||||
return $change;
|
||||
}
|
||||
|
|
@ -546,10 +690,10 @@ The number of seconds since January 1, 1970.
|
|||
|
||||
sub monthStartEnd {
|
||||
my ($year,$month,$day, $hour,$min,$sec, $start, $end);
|
||||
($year,$month,$day, $hour,$min,$sec) = Date::Calc::Time_to_Date($_[0]);
|
||||
$start = Date::Calc::Date_to_Time($year,$month,1,0,0,0);
|
||||
($year,$month,$day, $hour,$min,$sec) = Date::Calc::Time_to_Date(addToDate($_[0],0,1,0));
|
||||
$end = Date::Calc::Date_to_Time($year,$month,1,0,0,0)-1;
|
||||
($year,$month,$day, $hour,$min,$sec) = epochToArray($_[0]);
|
||||
$start = arrayToEpoch($year,$month,1,0,0,0);
|
||||
($year,$month,$day, $hour,$min,$sec) = epochToArray(addToDate($_[0],0,1,0));
|
||||
$end = arrayToEpoch($year,$month,1,0,0,0)-1;
|
||||
return ($start, $end);
|
||||
}
|
||||
|
||||
|
|
@ -640,7 +784,7 @@ A string in the format of YYYY-MM-DD or YYYY-MM-DD HH:MM:SS.
|
|||
=cut
|
||||
|
||||
sub setToEpoch {
|
||||
my @now = Date::Calc::Time_to_Date(time());
|
||||
my @now = epochToArray(time());
|
||||
my ($date,$time) = split(/ /,$_[0]);
|
||||
my ($year, $month, $day) = split(/\-/,$date);
|
||||
my ($hour, $minute, $second) = split(/\:/,$time);
|
||||
|
|
@ -659,7 +803,7 @@ sub setToEpoch {
|
|||
} else {
|
||||
$day = $now[2];
|
||||
}
|
||||
return Date::Calc::Date_to_Time($year,$month,$day,$hour,$minute,$second);
|
||||
return arrayToEpoch($year,$month,$day,$hour,$minute,$second);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -671,7 +815,7 @@ Returns an epoch date for now.
|
|||
=cut
|
||||
|
||||
sub time {
|
||||
return Date::Calc::Date_to_Time(Date::Calc::Today_and_Now());
|
||||
return arrayToEpoch(Date::Calc::Today_and_Now());
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ our @EXPORT = qw(&www_theWg &www_genesis);
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_genesis {
|
||||
$session{page}{styleId} = -100000;
|
||||
$session{page}{styleId} = 2;
|
||||
my $output = '<html><head><title>About WebGUI</title>
|
||||
<style>.big {font-size: 23px;}</style>
|
||||
</head><body bgcolor="#ef4200" text="black" link="white" vlink="white">
|
||||
|
|
@ -37,7 +37,7 @@ sub www_genesis {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_theWg {
|
||||
$session{page}{styleId} = -100000;
|
||||
$session{page}{styleId} = 2;
|
||||
my $output = '<html><head><title>WebGUI</title></head><body BGCOLOR="black"><center>
|
||||
<nobr><font SIZE="1" FACE="Courier New, Courier"><font COLOR="white"></font><font COLOR="#1A1108">p</font><font COLOR="#24130C">a</font><font COLOR="#5C2605">c</font><font COLOR="#642206">kageW</font><font COLOR="#5C1F04">e</font><font COLOR="#642206">bGUI;ou</font><font COLOR="#5C2605">r</font><font COLOR="#642206">$VERSION="5.5.0</font><font COLOR="#5C2605">"</font><font COLOR="#642206">;usestr</font><font COLOR="#5C1F04">i</font><font COLOR="#642206">ctqw(v</font><font COLOR="#68290C">a</font><font COLOR="#5C1F04">r</font><font COLOR="#5C2605">s</font><font COLOR="#642206">s</font><font COLOR="#541604">u</font><font COLOR="#481404">b</font><font COLOR="#380B04">s</font><font COLOR="#0B0204">);useTie::CPHash;useW
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ package WebGUI::Wobject::EventsCalendar;
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use HTML::CalendarMonthSimple;
|
||||
use Tie::CPHash;
|
||||
use WebGUI::DateTime;
|
||||
use WebGUI::FormProcessor;
|
||||
|
|
@ -29,116 +28,6 @@ use WebGUI::Wobject;
|
|||
|
||||
our @ISA = qw(WebGUI::Wobject);
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _drawBigCalendar {
|
||||
my ($thisMonth, $calendar, $message, $start, $end, $sth, %event, $nextDate);
|
||||
tie %event, 'Tie::CPHash';
|
||||
$thisMonth = epochToHuman($_[1],"%M %y");
|
||||
$calendar = new HTML::CalendarMonthSimple('year'=>epochToHuman($_[1],"%y"),'month'=>epochToHuman($_[1],"%M"));
|
||||
$calendar->width("100%");
|
||||
$calendar->border(1);
|
||||
$calendar->cellclass("tableData");
|
||||
$calendar->todaycellclass("tableHeader");
|
||||
$calendar->headerclass("tableHeader");
|
||||
$calendar->mondayisfirstday($session{user}{firstDayOfWeek});
|
||||
$calendar->sunday(WebGUI::International::get(27));
|
||||
$calendar->weekdays(WebGUI::International::get(28),
|
||||
WebGUI::International::get(29),
|
||||
WebGUI::International::get(30),
|
||||
WebGUI::International::get(31),
|
||||
WebGUI::International::get(32));
|
||||
$calendar->saturday(WebGUI::International::get(33));
|
||||
$calendar->monthname(WebGUI::DateTime::getMonthName($calendar->month));
|
||||
$calendar->header('<h2 align="center">'.$calendar->monthname.' '.$calendar->year.'</h2>');
|
||||
($start,$end) = monthStartEnd($_[1]);
|
||||
my $canEdit = ($session{var}{adminOn} && WebGUI::Privilege::canEditWobject($_[0]->get("wobjectId")));
|
||||
my $query = "select * from EventsCalendar_event";
|
||||
$query .= " where wobjectId=".$_[0]->get("wobjectId") unless ($_[0]->get("isMaster"));
|
||||
$query .= " order by startDate,endDate";
|
||||
$sth = WebGUI::SQL->read($query);
|
||||
while (%event = $sth->hash) {
|
||||
if (epochToHuman($event{startDate},"%M %y") eq $thisMonth
|
||||
|| epochToHuman($event{endDate},"%M %y") eq $thisMonth) {
|
||||
$message = "";
|
||||
if ($canEdit) {
|
||||
$message = deleteIcon('func=deleteEvent&wid='.$_[0]->get("wobjectId").'&eid='.$event{EventsCalendar_eventId}
|
||||
.'&rid='.$event{EventsCalendar_recurringId})
|
||||
.editIcon('func=editEvent&wid='.$_[0]->get("wobjectId").'&eid='.$event{EventsCalendar_eventId})
|
||||
.' ';
|
||||
}
|
||||
$message .= '<a href="'.WebGUI::URL::page('wid='.$_[0]->get("wobjectId")
|
||||
.'&func=viewEvent&eid='.$event{EventsCalendar_eventId}).'">'.$event{name}.'</a>';
|
||||
$message .= '<br>';
|
||||
if ($event{startDate} == $event{endDate}) {
|
||||
$calendar->addcontent(epochToHuman($event{startDate},"%D"),$message);
|
||||
} else {
|
||||
$nextDate = $event{startDate};
|
||||
while($nextDate <= $event{endDate}) {
|
||||
if (epochToHuman($nextDate,"%M %y") eq $thisMonth) {
|
||||
$calendar->addcontent(epochToHuman($nextDate,"%D"),$message);
|
||||
}
|
||||
$nextDate = addToDate($nextDate,0,0,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$sth->finish;
|
||||
return $calendar->as_HTML;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _drawSmallCalendar {
|
||||
my ($thisMonth, $calendar, $message, $start, $end, $sth, %event, $nextDate);
|
||||
tie %event, 'Tie::CPHash';
|
||||
$thisMonth = epochToHuman($_[1],"%M %y");
|
||||
$calendar = new HTML::CalendarMonthSimple('year'=>epochToHuman($_[1],"%y"),'month'=>epochToHuman($_[1],"%M"));
|
||||
$calendar->width(200);
|
||||
$calendar->border(0);
|
||||
$calendar->cellclass("tableData");
|
||||
$calendar->todaycellclass("tableHeader");
|
||||
$calendar->headerclass("tableHeader");
|
||||
$calendar->mondayisfirstday($session{user}{firstDayOfWeek});
|
||||
$calendar->sunday(substr(WebGUI::International::get(27),0,1));
|
||||
#$calendar->showweekdayheaders(0);
|
||||
$calendar->weekdays(
|
||||
substr(WebGUI::International::get(28),0,1),
|
||||
substr(WebGUI::International::get(29),0,1),
|
||||
substr(WebGUI::International::get(30),0,1),
|
||||
substr(WebGUI::International::get(31),0,1),
|
||||
substr(WebGUI::International::get(32),0,1)
|
||||
);
|
||||
$calendar->saturday(substr(WebGUI::International::get(33),0,1));
|
||||
$calendar->monthname(WebGUI::DateTime::getMonthName($calendar->month));
|
||||
$calendar->header('<b>'.$calendar->monthname.' '.$calendar->year.'</b>');
|
||||
($start,$end) = monthStartEnd($_[1]);
|
||||
my $query = "select * from EventsCalendar_event";
|
||||
$query .= " where wobjectId=".$_[0]->get("wobjectId") unless ($_[0]->get("isMaster"));
|
||||
$query .= " order by startDate,endDate";
|
||||
$sth = WebGUI::SQL->read($query);
|
||||
while (%event = $sth->hash) {
|
||||
if (epochToHuman($event{startDate},"%M %y") eq $thisMonth || epochToHuman($event{endDate},"%M %y") eq $thisMonth) {
|
||||
if ($event{startDate} == $event{endDate}) {
|
||||
$calendar->setdatehref(epochToHuman($event{startDate},"%D"),
|
||||
WebGUI::URL::page('wid='.$_[0]->get("wobjectId")
|
||||
.'&func=viewEvent&eid='.$event{EventsCalendar_eventId}));
|
||||
#$calendar->datecellclass(epochToHuman($nextDate,"%D"),"highlight");
|
||||
} else {
|
||||
$nextDate = $event{startDate};
|
||||
while($nextDate <= $event{endDate}) {
|
||||
if (epochToHuman($nextDate,"%M %y") eq $thisMonth) {
|
||||
$calendar->setdatehref(epochToHuman($nextDate,"%D"),
|
||||
WebGUI::URL::page('wid='.$_[0]->get("wobjectId")
|
||||
.'&func=viewEvent&eid='.$event{EventsCalendar_eventId}));
|
||||
#$calendar->datecellclass(epochToHuman($nextDate,"%D"),"highlight");
|
||||
}
|
||||
$nextDate = addToDate($nextDate,0,0,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$sth->finish;
|
||||
return $calendar->as_HTML;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub duplicate {
|
||||
|
|
@ -183,7 +72,7 @@ sub new {
|
|||
defaultValue=>"current"
|
||||
},
|
||||
paginateAfter=>{
|
||||
defaultValue=>50
|
||||
defaultValue=>1
|
||||
},
|
||||
isMaster=>{
|
||||
defaultValue=>0,
|
||||
|
|
@ -441,10 +330,9 @@ sub www_editEventSave {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_view {
|
||||
my (%var, $junk, $sameDate, $p, @list, $date, $flag, %previous, @row, $i, $maxDate, $minDate);
|
||||
my ( $junk, $sameDate, $p, @list, $date, $flag, %previous, $maxDate, $minDate);
|
||||
# figure out the date range
|
||||
tie %previous, 'Tie::CPHash';
|
||||
$var{"addevent.url"} = WebGUI::URL::page('func=editEvent&eid=new&wid='.$_[0]->get("wobjectId"));
|
||||
$var{"addevent.label"} = WebGUI::International::get(20,$_[0]->get("namespace"));
|
||||
if ($_[0]->get("startMonth") eq "first") {
|
||||
my $query = "select min(startDate) from EventsCalendar_event";
|
||||
$query .= " where wobjectId=".$_[0]->get("wobjectId") unless ($_[0]->get("isMaster"));
|
||||
|
|
@ -462,13 +350,13 @@ sub www_view {
|
|||
$query .= " where wobjectId=".$_[0]->get("wobjectId") unless ($_[0]->get("isMaster"));
|
||||
($maxDate) = WebGUI::SQL->quickArray($query);
|
||||
} elsif ($_[0]->get("endMonth") eq "after12") {
|
||||
$maxDate = WebGUI::DateTime::addToDate($minDate,0,11,0);
|
||||
$maxDate = WebGUI::DateTime::addToDate($minDate,1,0,0);
|
||||
} elsif ($_[0]->get("endMonth") eq "after9") {
|
||||
$maxDate = WebGUI::DateTime::addToDate($minDate,0,8,0);
|
||||
$maxDate = WebGUI::DateTime::addToDate($minDate,0,9,0);
|
||||
} elsif ($_[0]->get("endMonth") eq "after6") {
|
||||
$maxDate = WebGUI::DateTime::addToDate($minDate,0,5,0);
|
||||
$maxDate = WebGUI::DateTime::addToDate($minDate,0,6,0);
|
||||
} elsif ($_[0]->get("endMonth") eq "after3") {
|
||||
$maxDate = WebGUI::DateTime::addToDate($minDate,0,2,0);
|
||||
$maxDate = WebGUI::DateTime::addToDate($minDate,0,3,0);
|
||||
}
|
||||
$maxDate = $maxDate || WebGUI::DateTime::time();
|
||||
($junk,$maxDate) = WebGUI::DateTime::dayStartEnd($maxDate);
|
||||
|
|
@ -476,77 +364,139 @@ sub www_view {
|
|||
unless ($session{form}{pn}) {
|
||||
$flag = 1;
|
||||
if ($_[0]->get("defaultMonth") eq "current") {
|
||||
$session{form}{pn} = WebGUI::DateTime::monthCount($minDate,WebGUI::DateTime::time());
|
||||
$session{form}{pn} = round(WebGUI::DateTime::monthCount($minDate,WebGUI::DateTime::time())/$_[0]->getValue("paginateAfter"));
|
||||
} elsif ($_[0]->get("defaultMonth") eq "last") {
|
||||
$session{form}{pn} = WebGUI::DateTime::monthCount($minDate,$maxDate);
|
||||
} else {
|
||||
$session{form}{pn} = 1;
|
||||
}
|
||||
}
|
||||
for ($i=1;$i<=$monthCount;$i++) {
|
||||
if ($session{form}{pn} == ($i)) {
|
||||
|
||||
# create template variables
|
||||
my %var;
|
||||
$var{"addevent.url"} = WebGUI::URL::page('func=editEvent&eid=new&wid='.$_[0]->get("wobjectId"));
|
||||
$var{"addevent.label"} = WebGUI::International::get(20,$_[0]->get("namespace"));
|
||||
my @monthloop;
|
||||
for (my $i=1;$i<=$monthCount;$i++) {
|
||||
# if ($session{form}{pn} == ($i)) {
|
||||
my $thisMonth = WebGUI::DateTime::addToDate($minDate,0,($i-1),0);
|
||||
$var{"calendar.big"} = $_[0]->_drawBigCalendar($thisMonth);
|
||||
$var{"calendar.small"} = $_[0]->_drawSmallCalendar($thisMonth);
|
||||
}
|
||||
$row[$i-1] = "page";
|
||||
}
|
||||
$p = WebGUI::Paginator->new(WebGUI::URL::page("func=view&wid=".$_[0]->get("wobjectId")),1);
|
||||
$p->setDataByArrayRef(\@row);
|
||||
$var{"calendar.firstPage"} = $p->getFirstPageLink;
|
||||
$var{"calendar.lastPage"} = $p->getLastPageLink;
|
||||
$var{"calendar.nextPage"} = $p->getNextPageLink;
|
||||
$var{"calendar.pageList"} = $p->getPageLinks;
|
||||
$var{"calendar.previousPage"} = $p->getPreviousPageLink;
|
||||
$var{"calendar.multiplePages"} = ($p->getNumberOfPages > 1);
|
||||
if ($flag) {
|
||||
$flag = 0;
|
||||
$session{form}{pn} = "";
|
||||
my ($monthStart, $monthEnd) = WebGUI::DateTime::monthStartEnd($thisMonth);
|
||||
my @thisMonthDate = WebGUI::DateTime::epochToArray($thisMonth);
|
||||
# get event information
|
||||
my $query = "select * from EventsCalendar_event where ";
|
||||
$query .= " wobjectId=".$_[0]->get("wobjectId")." and " unless ($_[0]->get("isMaster"));
|
||||
$query .= " (endDate>=$monthStart or endDate<=$monthEnd) and (startDate>=$monthStart or startDate<=$monthEnd) order by startDate,endDate";
|
||||
my %events;
|
||||
my %previous;
|
||||
my $sth = WebGUI::SQL->read($query);
|
||||
while (my $event = $sth->hashRef) {
|
||||
my $eventLength = WebGUI::DateTime::getDaysInInterval($event->{startDate},$event->{endDate});
|
||||
my $startYear = epochToHuman($event->{startDate},"%y");
|
||||
my $startMonth = epochToHuman($event->{startDate},"%c");
|
||||
my $startDay = epochToHuman($event->{startDate},"%D");
|
||||
my $endYear = epochToHuman($event->{endDate},"%y");
|
||||
my $endMonth = epochToHuman($event->{endDate},"%c");
|
||||
my $endDay = epochToHuman($event->{endDate},"%D");
|
||||
for (my $i=0; $i<=$eventLength; $i++) {
|
||||
my @date = WebGUI::DateTime::epochToArray(WebGUI::DateTime::addToDate($event->{startDate},0,0,$i));
|
||||
if ($date[1] == $thisMonthDate[1]) {
|
||||
push(@{$events{$date[2]}}, {
|
||||
description=>$event->{description},
|
||||
name=>$event->{name},
|
||||
'start.date.human'=>WebGUI::DateTime::epochToHuman($event->{startDate},"%z"),
|
||||
'start.time.human'=>WebGUI::DateTime::epochToHuman($event->{startDate},"%Z"),
|
||||
'start.date.epoch'=>$event->{startDate},
|
||||
'start.year'=>$startYear,
|
||||
'start.month'=>$startMonth,
|
||||
'start.day'=>$startDay,
|
||||
'end.date.human'=>WebGUI::DateTime::epochToHuman($event->{endDate},"%z"),
|
||||
'end.time.human'=>WebGUI::DateTime::epochToHuman($event->{endDate},"%Z"),
|
||||
'end.date.epoch'=>$event->{endDate},
|
||||
'end.year'=>$endYear,
|
||||
'end.month'=>$endMonth,
|
||||
'end.day'=>$endDay,
|
||||
'startEndYearMatch'=>($startYear eq $endYear),
|
||||
'startEndMonthMatch'=>($startMonth eq $endMonth),
|
||||
'startEndDayMatch'=>($startDay eq $endDay),
|
||||
isFirstDayOfEvent=>($i == 0),
|
||||
dateIsSameAsPrevious=>($startYear."-".$startMonth."-".$startDay eq $previous{start}
|
||||
&& $endYear."-".$endMonth."-".$endDay eq $previous{end}),
|
||||
daysInEvent=>($eventLength+1),
|
||||
url=>WebGUI::URL::page('wid='.$_[0]->get("wobjectId").'&func=viewEvent&eid='.$event->{EventsCalendar_eventId})
|
||||
});
|
||||
}
|
||||
}
|
||||
$previous{start} = $startYear."-".$startMonth."-".$startDay;
|
||||
$previous{end} = $endYear."-".$endMonth."-".$endDay;
|
||||
}
|
||||
$sth->finish;
|
||||
|
||||
my $dayOfWeekCounter = 1;
|
||||
my $firstDayInFirstWeek = WebGUI::DateTime::getFirstDayInMonthPosition($thisMonth);
|
||||
my $daysInMonth = WebGUI::DateTime::getDaysInMonth($thisMonth);
|
||||
my @prepad;
|
||||
while ($dayOfWeekCounter < $firstDayInFirstWeek) {
|
||||
push(@prepad,{
|
||||
count => $dayOfWeekCounter
|
||||
});
|
||||
$dayOfWeekCounter++;
|
||||
}
|
||||
my @date = WebGUI::DateTime::epochToArray($thisMonth);
|
||||
my @dayloop;
|
||||
for (my $dayCounter=1; $dayCounter <= $daysInMonth; $dayCounter++) {
|
||||
push(@dayloop, {
|
||||
dayOfWeek => $dayOfWeekCounter,
|
||||
day=>$dayCounter,
|
||||
isStartOfWeek=>($dayOfWeekCounter==1),
|
||||
isEndOfWeek=>($dayOfWeekCounter==7),
|
||||
isToday=>(WebGUI::DateTime::getDaysInInterval(
|
||||
WebGUI::DateTime::setToEpoch($date[0]."-".$date[1]."-".$dayCounter),
|
||||
WebGUI::DateTime::time()) == 0),
|
||||
event_loop=>\@{$events{$dayCounter}},
|
||||
url=>$events{$dayCounter}->[0]->{url}
|
||||
});
|
||||
if ($dayOfWeekCounter == 7) {
|
||||
$dayOfWeekCounter = 1;
|
||||
} else {
|
||||
$dayOfWeekCounter++;
|
||||
}
|
||||
}
|
||||
my @postpad;
|
||||
while ($dayOfWeekCounter <= 7 && $dayOfWeekCounter > 1) {
|
||||
push(@postpad,{
|
||||
count => $dayOfWeekCounter
|
||||
});
|
||||
$dayOfWeekCounter++;
|
||||
}
|
||||
push(@monthloop, {
|
||||
'daysInMonth'=>$daysInMonth,
|
||||
'day_loop'=>\@dayloop,
|
||||
'prepad_loop'=>\@prepad,
|
||||
'postpad_loop'=>\@postpad,
|
||||
'month'=>WebGUI::DateTime::getMonthName($date[1]),
|
||||
'year'=>$date[0]
|
||||
});
|
||||
# }
|
||||
# $row[$i-1] = "page";
|
||||
}
|
||||
$p = WebGUI::Paginator->new(WebGUI::URL::page("func=view&wid=".$_[0]->get("wobjectId")),$_[0]->get("paginateAfter"));
|
||||
my $query = "select * from EventsCalendar_event where ";
|
||||
$query .= " wobjectId=".$_[0]->get("wobjectId")." and " unless ($_[0]->get("isMaster"));
|
||||
$query .= " endDate>=$minDate and startDate<=$maxDate order by startDate,endDate";
|
||||
$p->setDataByQuery($query);
|
||||
my $events = $p->getPageData;
|
||||
foreach my $event (@$events) {
|
||||
if ($event->{startDate} == $previous{startDate} && $event->{endDate} == $previous{endDate}) {
|
||||
$sameDate = 1;
|
||||
} else {
|
||||
$sameDate = 0;
|
||||
}
|
||||
$date = epochToHuman($event->{startDate},"%c %D");
|
||||
if (epochToHuman($event->{startDate},"%y") ne epochToHuman($event->{endDate},"%y")) {
|
||||
$date .= ", ".epochToHuman($event->{startDate},"%y");
|
||||
$flag = 1;
|
||||
}
|
||||
if ($flag || epochToHuman($event->{startDate},"%c") ne epochToHuman($event->{endDate},"%c")) {
|
||||
$date .= " - ".epochToHuman($event->{endDate},"%c %D");
|
||||
} elsif (epochToHuman($event->{startDate},"%D") ne epochToHuman($event->{endDate},"%D")) {
|
||||
$date .= " - ".epochToHuman($event->{endDate},"%D");
|
||||
}
|
||||
$flag = 0;
|
||||
$date .= ", ".epochToHuman($event->{endDate},"%y");
|
||||
%previous = %{$event};
|
||||
push(@list, {
|
||||
"list.date"=>$date,
|
||||
"list.title"=>$event->{name},
|
||||
"list.description"=>$event->{description},
|
||||
"list.sameAsPrevious"=>$sameDate,
|
||||
"list.url"=>WebGUI::URL::page('func=viewEvent&wid='.$_[0]->get("wobjectId").'&eid='
|
||||
.$event->{EventsCalendar_eventId}),
|
||||
"list.controls"=>deleteIcon('func=deleteEvent&wid='.$_[0]->get("wobjectId").'&eid='
|
||||
.$event->{EventsCalendar_eventId}.'&rid='.$event->{EventsCalendar_recurringId})
|
||||
.editIcon('func=editEvent&wid='.$_[0]->get("wobjectId").'&eid='.$event->{EventsCalendar_eventId})
|
||||
});
|
||||
}
|
||||
$var{list_loop} = \@list;
|
||||
$var{"list.firstPage"} = $p->getFirstPageLink;
|
||||
$var{"list.lastPage"} = $p->getLastPageLink;
|
||||
$var{"list.nextPage"} = $p->getNextPageLink;
|
||||
$var{"list.pageList"} = $p->getPageLinks;
|
||||
$var{"list.previousPage"} = $p->getPreviousPageLink;
|
||||
$var{"list.multiplePages"} = ($p->getNumberOfPages > 1);
|
||||
$p->setDataByArrayRef(\@monthloop);
|
||||
$var{month_loop} = $p->getPageData;
|
||||
$p->appendTemplateVars(\%var);
|
||||
$var{'sunday.label'} = WebGUI::DateTime::getDayName(7);
|
||||
$var{'monday.label'} = WebGUI::DateTime::getDayName(1);
|
||||
$var{'tuesday.label'} = WebGUI::DateTime::getDayName(2);
|
||||
$var{'wednesday.label'} = WebGUI::DateTime::getDayName(3);
|
||||
$var{'thursday.label'} = WebGUI::DateTime::getDayName(4);
|
||||
$var{'friday.label'} = WebGUI::DateTime::getDayName(5);
|
||||
$var{'saturday.label'} = WebGUI::DateTime::getDayName(6);
|
||||
$var{'sunday.label.short'} = substr(WebGUI::DateTime::getDayName(7),0,1);
|
||||
$var{'monday.label.short'} = substr(WebGUI::DateTime::getDayName(1),0,1);
|
||||
$var{'tuesday.label.short'} = substr(WebGUI::DateTime::getDayName(2),0,1);
|
||||
$var{'wednesday.label.short'} = substr(WebGUI::DateTime::getDayName(3),0,1);
|
||||
$var{'thursday.label.short'} = substr(WebGUI::DateTime::getDayName(4),0,1);
|
||||
$var{'friday.label.short'} = substr(WebGUI::DateTime::getDayName(5),0,1);
|
||||
$var{'saturday.label.short'} = substr(WebGUI::DateTime::getDayName(6),0,1);
|
||||
return $_[0]->processTemplate($_[0]->get("templateId"),\%var);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ DBI->install_driver("mysql"); # Change to match your database driver.
|
|||
#----------------------------------------
|
||||
# Distributed utilities external to WebGUI.
|
||||
#----------------------------------------
|
||||
use HTML::CalendarMonthSimple ();
|
||||
#use HTML::Parser (); # commented because it is causing problems with attachments
|
||||
#use HTML::TagFilter (); # commented because it is causing problems with attachments
|
||||
use Net::LDAP ();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue