Forums / All Other Contributions/Addons / Event Calendar v3

Event Calendar v3

Locked
Results 1 to 20 of 500
This thread is locked. New replies are disabled.
02 Oct 2007, 18:41
#1
stav avatar

stav

New Zenner

Join Date:
Oct 2004
Posts:
39
Plugin Contributions:
0

Event Calendar v3

I started to port the events calendar from osc to zen.

The most of the work is done. The admin section working OK and half of the frontend.
Some coding is needed to be done for the calendar year_view in main and the block.

I have this error in the calendar.php class.

Fatal error: Call to a member function on a non-object in /WebServer/includes/classes/calendar.php on line 120

Here is calendar class

[php]
<?php

class Calendar
{
/*
Constructor for the Calendar class
*/
function Calendar()
{
}

/*
Get the array of strings used to label the days of the week. This array contains seven
elements, one for each day of the week. The first entry in this array represents Sunday.
*/
function getDayNames()
{
return $this->dayNames;
}

/*
Set the array of strings used to label the days of the week. This array must contain seven
elements, one for each day of the week. The first entry in this array represents Sunday.
*/
function setDayNames($names)
{

$this->dayNames = $names;
}

/*
Get the array of strings used to label the months of the year. This array contains twelve
elements, one for each month of the year. The first entry in this array represents January.
*/
function getMonthNames()
{
$this->monthNames;
}

/*
Set the array of strings used to label the months of the year. This array must contain twelve
elements, one for each month of the year. The first entry in this array represents January.
*/
function setMonthNames($names)
{
$this->monthNames = $names;
}

/*
Gets the start day of the week. This is the day that appears in the first column
of the calendar. Sunday = 0.
*/
function getStartDay()
{
return $this->startDay;
}

/*
Sets the start day of the week. This is the day that appears in the first column
of the calendar. Sunday = 0.
*/
function setStartDay($day)
{
$this->startDay = $day;
}


/*
Gets the start month of the year. This is the month that appears first in the year
view. January = 1.
*/
function getStartMonth()
{
return $this->startMonth;
}

/*
Sets the start month of the year. This is the month that appears first in the year
view. January = 1.
*/
function setStartMonth($month)
{
$this->startMonth = $month;
}


/*
Return the URL to link to in order to display a calendar for a given month/year.
You must override this method if you want to activate the "forward" and "back"
feature of the calendar.

Note: If you return an empty string from this function, no navigation link will
be displayed. This is the default behaviour.

If the calendar is being displayed in "year" view, $month will be set to 1.
*/

function getCalendarLink($month, $year)
{
return "?_month=$month&_year=$year";
}

function pad($s, $n)
{
$r = $s;
while (strlen($r) < $n)
{
$r = "0".$r;
}
return $r;
}

function getFileName($day, $month, $year)
{
return $this->pad($year, 4) ."-". $this->pad($month, 2) ."-". $this->pad($day, 2);
}

function getDbLink($day, $month, $year)
{
$dateString = $this->getFileName($day, $month, $year);

//get all events that have the provided date in their duration.
$event = $db->Execute("select start_date from " . TABLE_EVENTS_CALENDAR
. " where '" . $dateString . "' between start_date and end_date");
//if(zen_db_num_rows($request) > 0)
if($event->RecordCount() > 0)
{
//while($event = zen_db_fetch_array($request))
while (!$event->EOF)
{ //get the first event for this day's start date for the link
list($year_start, $month_start, $day_start) = split ('[/.-]', $event->fields['start_date']);

break;
$event->MoveNext();

}

$bname = FILENAME_EVENTS_CALENDAR;
return "index.php?main_page=".$bname."&_day=$day_start&_month=$month_start&_year=$year_start";
}
}

/*
Return the HTML for the current month
*/
function getCurrentMonthView()
{
$d = getdate(time());
return $this->getMonthView($d["mon"], $d["year"]);
}


/*
Return the HTML for the current year
*/
function getCurrentYearView()
{
$d = getdate(time());
return $this->getYearView($d["year"]);
}


/*
Return the HTML for a specified month
*/
function getMonthView($month, $year)
{
return $this->getMonthHTML($month, $year);
}

/*
Return the HTML for a specified year
*/
function getYearView($year)
{
return $this->getYearHTML($year);
}


/********************************************************************************

The rest are private methods. No user-servicable parts inside.

You shouldn't need to call any of these functions directly.

*********************************************************************************/

/*
Calculate the number of days in a month, taking into account leap years.
*/
function getDaysInMonth($month, $year)
{
if ($month < 1 || $month > 12)
{
return 0;
}

$d = $this->daysInMonth[$month - 1];

if ($month == 2)
{
// Check for leap year
if ($year%4 == 0)
{
if ($year%100 == 0)
{
if ($year%400 == 0)
{
$d = 29;
}
}
else
{
$d = 29;
}
}
}
return $d;
}

/*
Generate the HTML for a given month
*/
function getMonthHTML($m, $y, $show = 1)
{
$s = "";

$a = $this->adjustDate($m, $y);
$month = $a[0];
$year = $a[1];

$daysInMonth = $this->getDaysInMonth($month, $year);
$date = getdate(mktime(12, 0, 0, $month, 1, $year));

$first = $date["wday"];
$monthName = $this->monthNames[$month - 1];

$prev = $this->adjustDate($month - 1, $year);
$next = $this->adjustDate($month + 1, $year);

$this_month = date('m');
$this_year = date('Y');
$header = $monthName . (($show > 0) ? " " . $year : "");
$D = $this->monthNames[11].' ';
$J = $this->monthNames[0].' ';

if ($show == 1)
{
$prevMonth = '<a href='. FILENAME_EVENTS_CALENDAR_CONTENT . $this->getCalendarLink($prev[0], $prev[1]).' target=calendar title='. $this->monthNames[$month - 2] . (($month-2 < 1) ? $D.($year-1) : ' '. $year) .' ><</a>';
$nextMonth = '<a href='. FILENAME_EVENTS_CALENDAR_CONTENT . $this->getCalendarLink($next[0], $next[1]).' target=calendar title='. $this->monthNames[$month + 0] . (($month+0 > 11) ? $J.($year+1) : ' '. $year) .' >></a>';
}
else
{
$prevMonth = "";
$nextMonth = "";
}

$s .= "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n";
$s .= "<tr class=\"calendarHeader\">\n";
$linkHeader = zen_href_link(FILENAME_EVENTS_CALENDAR, "_month=$month&_year=$year");
$s .= "<td align=\"left\"><a href=\"$linkHeader\" target=\"_parent\">$header</a></td>\n";
$s .= "<td align=\"center\" class=\"yearHeader\">\n";
if(mktime (0,0,0,$month ,0,$year) > mktime (0,0,0,$this_month ,0,$this_year)){
$s .= $prevMonth;
}else{
// $s .= " ";
$s .= $prevMonth;
}
$s .= "</td>\n";
$s .= "<td align=\"center\" class=\"yearHeader\">$nextMonth</td></tr>\n";
$s .= "<tr><td colspan=\"3\">\n";
$s .= "<table cellspacing=\"1\" cellpadding=\"0\" border=\"0\" class=\"calendarMonth\"><tr class=\"calendarHeader\">\n";
$s .= "<td align=\"center\" valign=\"middle\">" . $this->dayNames[($this->startDay)%7] . "</td>\n";
$s .= "<td align=\"center\" valign=\"middle\">" . $this->dayNames[($this->startDay+1)%7] . "</td>\n";
$s .= "<td align=\"center\" valign=\"middle\">" . $this->dayNames[($this->startDay+2)%7] . "</td>\n";
$s .= "<td align=\"center\" valign=\"middle\">" . $this->dayNames[($this->startDay+3)%7] . "</td>\n";
$s .= "<td align=\"center\" valign=\"middle\">" . $this->dayNames[($this->startDay+4)%7] . "</td>\n";
$s .= "<td align=\"center\" valign=\"middle\">" . $this->dayNames[($this->startDay+5)%7] . "</td>\n";
$s .= "<td align=\"center\" valign=\"middle\">" . $this->dayNames[($this->startDay+6)%7] . "</td>\n";
$s .= "</tr>\n";

// We need to work out what date to start at so that the first appears in the correct column
$d = $this->startDay + 1 - $first;
while ($d > 1)
{
$d -= 7;
}

// Make sure we know when today is, so that we can use a different CSS style
$today = getdate(time());
$start_day = $this->getStartDay();
$click = BOX_CLICK_LINK;
while ($d <= $daysInMonth)
{
$s .= "<tr>\n";
for ($i = 0; $i < 7; $i++)
{
$class = (($i < (6-$start_day) &! $i <= $start_day) ? (($year == $today["year"] && $month == $today["mon"] && $d == $today["mday"]) ? "calendarToday" : "calendar" ) : (($year == $today["year"] && $month == $today["mon"] && $d == $today["mday"]) ? "calendarToday" : "calendarWeekend"));
if ($d > 0 && $d <= $daysInMonth)
{
$link = $this->getDbLink($d, $month, $year);
$s .= (($link == "") ? "<td class=\"$class\" align=\"left\" valign=\"bottom\">" : "<td class=\"$class\" onclick=top.window.location=\"$link\" align=\"left\" valign=\"bottom\" style=\"cursor: hand;\">" );
if($show == 1){
$s .= (($link == "") ? $d : "<a href=\"$link\" target=\"_parent\" title=\"$click\">$d</a>");
}else{
$s .= (($link == "") ? $d : "<a href=\"$link\" title=\"$click\">$d</a>");
}
}
else
{
$s .= "<td class=\"empty\"> ";
}
$s .= "</td>\n";
$d++;
}
$s .= "</tr>\n";
}
$s .= "</table>\n";
$s .= "</td></tr></table>\n";
return $s;
}


/*
Generate the HTML for a given year
*/
function getYearHTML($year)
{
$year_view = 1;
$s = "";
$prev = FILENAME_EVENTS_CALENDAR . $this->getCalendarLink(1, $year - 1) .'&year_view=1';
$next = FILENAME_EVENTS_CALENDAR . $this->getCalendarLink(1, $year + 1) .'&year_view=1';
$this_year = date('Y');

$s .= "<table align=\"center\" cellspacing=\"2\" cellpadding=\"0\" border=\"0\" style=\"cursor: default\">\n";
$s .= "<tr>";

if($year > $this_year){
$s .= "<td class=\"yearHeader\" align=\"center\" align=\"left\">" . (($prev == "") ? " " : "<a href=\"$prev\"><<</a>") . "</td>\n";
}else{
$s .= "<td class=\"yearHeader\" align=\"center\" align=\"left\"> </td>\n";
}

$s .= "<td height=\"20\" class=\"yearHeader\" align=\"center\">" . (($this->startMonth > 1) ? $year . " - " . ($year + 1) : $year) ."</td>\n";
$s .= "<td class=\"yearHeader\" align=\"center\" align=\"right\">" . (($next == "") ? " " : "<a href=\"$next\">>></a>") . "</td>\n";
$s .= "</tr>\n";
$s .= "<tr>";
$s .= "<td valign=\"top\">" . $this->getMonthHTML(0 + $this->startMonth, $year, 0) ."</td>\n";
$s .= "<td valign=\"top\">" . $this->getMonthHTML(1 + $this->startMonth, $year, 0) ."</td>\n";
$s .= "<td valign=\"top\">" . $this->getMonthHTML(2 + $this->startMonth, $year, 0) ."</td>\n";
$s .= "</tr>\n";
$s .= "<tr>\n";
$s .= "<td valign=\"top\">" . $this->getMonthHTML(3 + $this->startMonth, $year, 0) ."</td>\n";
$s .= "<td valign=\"top\">" . $this->getMonthHTML(4 + $this->startMonth, $year, 0) ."</td>\n";
$s .= "<td valign=\"top\">" . $this->getMonthHTML(5 + $this->startMonth, $year, 0) ."</td>\n";
$s .= "</tr>\n";
$s .= "<tr>\n";
$s .= "<td valign=\"top\">" . $this->getMonthHTML(6 + $this->startMonth, $year, 0) ."</td>\n";
$s .= "<td valign=\"top\">" . $this->getMonthHTML(7 + $this->startMonth, $year, 0) ."</td>\n";
$s .= "<td valign=\"top\">" . $this->getMonthHTML(8 + $this->startMonth, $year, 0) ."</td>\n";
$s .= "</tr>\n";
$s .= "<tr>\n";
$s .= "<td valign=\"top\">" . $this->getMonthHTML(9 + $this->startMonth, $year, 0) ."</td>\n";
$s .= "<td valign=\"top\">" . $this->getMonthHTML(10 + $this->startMonth, $year, 0) ."</td>\n";
$s .= "<td valign=\"top\">" . $this->getMonthHTML(11 + $this->startMonth, $year, 0) ."</td>\n";
$s .= "</tr>\n";
$s .= "</table>\n";
return $s;
}

/*
Adjust dates to allow months > 12 and < 0. Just adjust the years appropriately.
e.g. Month 14 of the year 2001 is actually month 2 of year 2002.
*/
function adjustDate($month, $year)
{
$a = array();
$a[0] = $month;
$a[1] = $year;
while ($a[0] > 12)
{
$a[0] -= 12;
$a[1]++;
}
while ($a[0] <= 0)
{
$a[0] += 12;
$a[1]--;
}
return $a;
}



/*
The start day of the week. This is the day that appears in the first column
of the calendar. Sunday = 0.
*/
var $startDay = '1';


/*
The start month of the year. This is the month that appears in the first slot
of the calendar in the year view. January = 1.
*/
var $startMonth = '1';

/*
The labels to display for the days of the week. The first entry in this array
represents Sunday.
*/
var $dayNames = array('Su','Mo','Tu','We','Th','Fr','Sa');

/*
The labels to display for the months of the year. The first entry in this array
represents January.
*/
var $monthNames = array('January','February','March','April','May','June','July','August','September','October','November','December');

/*
The number of days in each month. You're unlikely to want to change this...
The first entry in this array represents January.
*/
var $daysInMonth = array('31', '28', '31', '30', '31', '30', '31', '31', '30', '31', '30', '31');
}

?>
[/php]

I think that the problem is with the var $daysInMonth and the function that uses this var in the last line

If i comment last line the calendar is working ok with months years but without the days.
// var $daysInMonth = array('31', '28', '31', '30', '31', '30', '31', '31', '30', '31', '30', '31');

Here is the full ported code for zencart

oscommerce.com/community/contributions,1061 and here is the original osc events callendar.

Here you can see the year_view of the events calendar

Maybe anyone can take look at the code please?.

Thanks.
03 Oct 2007, 20:02
#2
titangen avatar

titangen

Zen Follower

Join Date:
May 2005
Posts:
177
Plugin Contributions:
0

Re: Event Calendar v3

Looks good great id for now I use google calendar but can change the layout

:clap:
04 Oct 2007, 17:46
#3
stav avatar

stav

New Zenner

Join Date:
Oct 2004
Posts:
39
Plugin Contributions:
0

Re: Event Calendar v3

Ok I solved the error by adding

global $db; to the getDbLink() function.
04 Oct 2007, 21:39
#4
misty avatar

misty

Inactive

Join Date:
Apr 2004
Posts:
5,752
Plugin Contributions:
1

Re: Event Calendar v3

stav:

Ok I solved the error by adding

global $db; to the getDbLink() function.

Great work.. so does your zip file(link above) contain latest
files to enable correct working of this ported calendar mod?
05 Oct 2007, 17:52
#5
titangen avatar

titangen

Zen Follower

Join Date:
May 2005
Posts:
177
Plugin Contributions:
0

Re: Event Calendar v3

I've try to make the changes like stav explain but don't work

regards
05 Oct 2007, 18:13
#6
stav avatar

stav

New Zenner

Join Date:
Oct 2004
Posts:
39
Plugin Contributions:
0

Re: Event Calendar v3

The events calendar is not ready for production site. I can say that is an alpha version for now.

At this time you can use onlu the list mode of events, the callendar view is not ready.
06 Oct 2007, 02:29
#7
stav avatar

stav

New Zenner

Join Date:
Oct 2004
Posts:
39
Plugin Contributions:
0

Re: Event Calendar v3

I have updated the events calendar now is functional the calendar view in main and in the sidebox.

Some cleaning is nedded to be done and small bug fixes. You can download and test it from here.

Sorry about my bad english.
07 Oct 2007, 13:05
#8
stav avatar

stav

New Zenner

Join Date:
Oct 2004
Posts:
39
Plugin Contributions:
0

Re: Event Calendar v3

Tthe events calendar v1.0 RC1 is on the way to the contributions/other modules.

and waiting for aproval .

Until then you can download the contribution from the link in the previous post.
22 Oct 2007, 08:43
#9
bigjoed avatar

bigjoed

Zen Follower

Join Date:
Apr 2006
Posts:
152
Plugin Contributions:
0

Re: Event Calendar v3

When trying to add a new event I get the following error:

Fatal error: Cannot use string offset as an array in mywebsite.com/admin/includes/classes/table_block.php on line 77

Can anybody tell me what am I doing wrong?

Thanks
26 Oct 2007, 15:17
#10
dezinejunkie avatar

dezinejunkie

New Zenner

Join Date:
Jan 2007
Posts:
49
Plugin Contributions:
0

Re: Event Calendar v3

Hi: Ive installed Events Calendar. Im using Apple Zen Temp with drop down menus. The Events Cal is appearing on my sideboxes funky.
The HOME part of the drop menu is there with the calendar.

I installed the Sql patch. and the tablenupdate file. I gave the permissins on the image folder also. The caledar reads fine on the side bar with the correct date highlighted in yellow. When i view selected month the sideboxes are showing up on the left side of page. (Apple Zen is a default rt side boxes only) Start Date End Date And Title are showing up on page in yellow bar with a subhead of NO events Found. Above it reads All Events.
Any idea where the snag is. I checked all install files and did not miss one. thanks for the help, im new at all of this.:censored:

1)Install database sql file tabelenupdate.sql from admin/tools/install sql patches

2)Add all files to your folders in your zencart directory

3)Make writable chmod(0777) images/events_images directory

4)Edit includes/templates/your_template/common/tpl_main_page.php

//Add at top first line before "<?php " this code:

<?php
if (isset($_GET['eventmode']) && $_GET['eventmode'] == 'eventframe') {
require($body_code);
}else{
?>

//Add at bottom last line after "?> " this code:

<?php
}
?>
26 Oct 2007, 15:33
#11
dezinejunkie avatar

dezinejunkie

New Zenner

Join Date:
Jan 2007
Posts:
49
Plugin Contributions:
0

Re: Event Calendar v3

I wanted to add also the Admin Panel seems to be functioning correctly.
I added an event but the sidebox is showing on Left side of page with the year calendar at a glance off center page.

DezineJunkie:

Hi: Ive installed Events Calendar. Im using Apple Zen Temp with drop down menus. The Events Cal is appearing on my sideboxes funky.
The HOME part of the drop menu is there with the calendar.

I installed the Sql patch. and the tablenupdate file. I gave the permissins on the image folder also. The caledar reads fine on the side bar with the correct date highlighted in yellow. When i view selected month the sideboxes are showing up on the left side of page. (Apple Zen is a default rt side boxes only) Start Date End Date And Title are showing up on page in yellow bar with a subhead of NO events Found. Above it reads All Events.
Any idea where the snag is. I checked all install files and did not miss one. thanks for the help, im new at all of this.:censored:

1)Install database sql file tabelenupdate.sql from admin/tools/install sql patches

2)Add all files to your folders in your zencart directory

3)Make writable chmod(0777) images/events_images directory

4)Edit includes/templates/your_template/common/tpl_main_page.php

//Add at top first line before "<?php " this code:

<?php
if (isset($_GET['eventmode']) && $_GET['eventmode'] == 'eventframe') {
require($body_code);
}else{
?>

//Add at bottom last line after "?> " this code:

<?php
}
?>
28 Oct 2007, 23:43
#12
dezinejunkie avatar

dezinejunkie

New Zenner

Join Date:
Jan 2007
Posts:
49
Plugin Contributions:
0

Re: Event Calendar v3

can anyone figure out why this is showing up this way in side boxes with the drop menu running over it?
29 Oct 2007, 13:25
#13
knighs2 avatar

knighs2

New Zenner

Join Date:
May 2007
Posts:
42
Plugin Contributions:
0

Re: Event Calendar v3

Hi Guys,

Sorry if im about to sound real stupid. Ive installed this mod (now on two sites) but can find anywhere in my admin section where i can access it.

Where in admin should it be ?

Thanks
Shane
02 Nov 2007, 17:15
#14
dezinejunkie avatar

dezinejunkie

New Zenner

Join Date:
Jan 2007
Posts:
49
Plugin Contributions:
0

Re: Event Calendar v3

Hi im using Apple Zen temp and my event cal is not showing correctly.
here is a screenshot of it.
in not sure how to fix, ive checked all the files and are loading correctly.
the rest of the install is working the links and showing the year etc.
just the pull down menu in apple zen is over the calendar.
how to fix this??? :frusty:
08 Nov 2007, 10:56
#15
aled avatar

aled

New Zenner

Join Date:
Nov 2007
Posts:
2
Plugin Contributions:
0

Re: Event Calendar v3

bigjoed:

When trying to add a new event I get the following error:

Fatal error: Cannot use string offset as an array in mywebsite.com/admin/includes/classes/table_block.php on line 77

Can anybody tell me what am I doing wrong?

Thanks



I've modified the file table_block.php on line 77 and it seems to work but please make some test.
replace line 77 in admin\includes\classes\table_block.php

$tableBox_string .= '>' . $contents[$i]['text'] . '</td>' . "\n";

with:

if(isset($contents[$i]['text'])){
$tableBox_string .= '>' . $contents[$i]['text'] . '</td>' . "\n";
} else {
$tableBox_string .= '>' . $contents['text'] . '</td>' . "\n";
}



I'm not sure this modify not create some other bugs, but for the moment is the best I can do! If is there some guru who want help us, we are waiting for Him!!!
Bye
16 Nov 2007, 13:39
#16
sarahl avatar

sarahl

Zen Follower

Join Date:
May 2004
Posts:
471
Plugin Contributions:
0

Re: Event Calendar v3

I would like this as well - did anyone get any futher?
27 Nov 2007, 16:32
#17
bettysue avatar

bettysue

Inactive

Join Date:
May 2004
Posts:
747
Plugin Contributions:
0

Re: Event Calendar v3

Anyone had the problem in Admin of the event manager showing up with the options like this ?:

TABLE_HEADING_ID TABLE_HEADING_SIZE TABLE_HEADING_TITLE TABLE_HEADING_DATE_ADDED TABLE_HEADING_DATE_START TABLE_HEADING_DATE_END TABLE_HEADING_LINKS Action

TEXT_NO_EVENTS

All of the files have been uploaded (except the ones starting with the period) and the db patch applied. Don't know what I could have missed.

thank you,

betty
02 Jan 2008, 13:34
#18
bigjoed avatar

bigjoed

Zen Follower

Join Date:
Apr 2006
Posts:
152
Plugin Contributions:
0

Re: Event Calendar v3

I'm having a problem with this contribution. Whenever I try to view any of the calendar pages I get this:

1109 Unknown table 'p' in field list
in:
[select count(p.products_id) as total ]


I have three websites but only one gives me the problem. I'm using zencart 1.3.7. I do not get the error however if I change to the classic template.

Anybody having the same problem?
13 Feb 2008, 20:57
#19
micah_kritzman avatar

micah_kritzman

New Zenner

Join Date:
Feb 2008
Posts:
2
Plugin Contributions:
0

Re: Event Calendar v3

Has anyone had any luck getting this running in 1.3.8?

Thanks,

Micah
21 Feb 2008, 13:00
#20
diannev avatar

diannev

New Zenner

Join Date:
Jul 2007
Posts:
27
Plugin Contributions:
1

Re: Event Calendar v3

Mine is working in 1.3.7 BUT if you go straight from the home page to the shopping cart (to complete an order) the back button now goes to the calendar (now full screen on main_page.

If anyone has any ideas I'd be grateful.