Jump to content

[SOLVED] Third party calendar formatting not displaying right when included


fdgloworm

Recommended Posts

Hello, all.

 

I don't know if this is an easy solution or not, but I have been searching this and other forums for days trying to find out the answer.

 

I have a third-party calendar app in PHP that I am attempting to put into my website, inside a <div> tag.  The tag is opened and closed correctly, and the calendar.php is included correctly.

 

Here:

<div id="content"><div id="breadCrumb"></div>
<h2 id="pageName">Events Calendar<hr></h2>
	<div id="calendar">
	<?php
	include ("calendar/calendar.php");
	?>
</div>
</div>

 

My problem is that the table and other HTML formatting in the included calendar.php isn't parsed correctly.  In other words, the calendar shows up, most of it looks right, but the table isn't there and the dates aren't clickable.

 

Here is the included file:

<?
/*  ©2004 Proverbs, LLC. All rights reserved.  */

$setday = 0;
$setmonth = 0;
$setyear = 0;
$setview = "calendar";

if (isset($_REQUEST['view']) && $_REQUEST['view'] != "")
$setview = $_REQUEST['view'];
if (isset($_REQUEST['day']) && $_REQUEST['day'] != "")
$setday = $_REQUEST['day'];
if (isset($_REQUEST['month']) && $_REQUEST['month'] != "")
$setmonth = $_REQUEST['month'];
if (isset($_REQUEST['year']) && $_REQUEST['year'] != "")
$setyear = $_REQUEST['year'];

if ($setview == "schedule")
require ('schedule.inc.php');
else
require ('calendar.inc.php');

$page->createpage($setday, $setmonth, $setyear);

$page->displaypage();
?>

 

Which then I believe pulls this calendar.inc.php or schedule.inc.php.  Both display without table formatting in the <div> mentioned above.

 

Here is calendar.inc.php:

<?
/*  ©2004 Proverbs, LLC. All rights reserved.  */

if (eregi("calendar.inc.php", $_SERVER['PHP_SELF']))
{
// redirect to calendar page
header("Location: calendar.php");
exit;
}

if(!defined("CALENDAR_PAGE")) 
{ 
define("CALENDAR_PAGE", TRUE); 

require ('base.inc.php');

class calendar_page extends base_calendar
{
	// Constructor
	function calendar_page()
	{
		$this->base_calendar();
	}

	function createpage($current_day, $current_month, $current_year)
	{
		// create the setup object
		$conf = new layout_setup;

		// create the language object
		$lang = new language;

		$adjustment = 3600 * $conf->time_adjustment;
		if ($conf->use_dst)
			$adjustment += 3600 * gmdate("I", time() + $adjustment);
		if ($current_month == "" || $current_month < 1 || $current_month > 12)
			$current_month = gmdate("n", time() + $adjustment);
		if ($current_year == "" || $current_year == 0)
			$current_year = gmdate("Y", time() + $adjustment);
		if ($current_year > (gmdate("Y", time() + $adjustment) + 10))
			$current_year = gmdate("Y", time() + $adjustment) + 10;
		if ($current_year < (gmdate("Y", time() + $adjustment) - 5))
			$current_year = gmdate("Y", time() + $adjustment) - 5;
		if ($current_year < 1980)
			$current_year = 1980;

		$browser_version = $this->makeheader();

		if ($browser_version > 0)
		{
			if ($browser_version == 1)
				$this->pagelayout .= '<link rel="stylesheet" type="text/css" href="navstylesheet.css.php" />
';
			if ($browser_version == 2)
				$this->pagelayout .= '<link rel="stylesheet" type="text/css" href="iestylesheet.css.php" />
';

			$this->pagelayout .= '<script type="text/javascript" src="caljavascript.js.php"></script>
<noscript><center><b>'.$lang->word_no_javascript.'</b></center></noscript>
';
			$this->closeheader();
		}
		else
		{
			$this->closeheader();
			unset($conf);
			unset($lang);
			// require alternate calendar
			require ('calendar.alt.php');
			$altcalendar = new alt_calendar_page;
			$this->pagelayout .= $altcalendar->createpage($current_day, $current_month, $current_year);
			return;
		}

		$this->activeday = $current_day;
		$this->activemonth = $current_month;
		$this->activeyear = $current_year;

		$nextmonth = $current_month + 1;
		$nextyear = $current_year;
		$prevmonth = $current_month - 1;
		$prevyear = $current_year;

		if ($current_month == 1)
		{
			$prevmonth = 12;
			$prevyear = $current_year - 1;
		}
		if ($current_month == 12)
		{
			$nextmonth = 1;
			$nextyear = $current_year + 1;	
		}

		$this->pagelayout .= '<center>
<form method="post" name="calendarPage" action="calendar.php">
<table class="calendar" cellspacing="0" cellpadding="0" border="0">
<tr>
<td class="calmenu" style="width: 100%; text-align: center" colspan="7">
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td nowrap class="calmenu" style="width: 250px">
 <b>'.$lang->word_today_date.': </b>'.$lang->month_long[gmdate("n", time() + $adjustment)].gmdate(" j, Y", time() + $adjustment).'
</td>
<td class="calmenu" style="width: 460px; text-align: right">
<b>'.$lang->word_month.': </b>
<select name="month">
';
		for ($i = 1; $i <= 12; $i++)
		{
			$this->pagelayout .= '<option value="'.$i.'"';
			if ($i == $this->activemonth)
				$this->pagelayout .= ' selected';
			$this->pagelayout .= '>'.$lang->month_long[$i].'</option>
';
		}

		$this->pagelayout .= '</select>
  
<b>'.$lang->word_year.': </b>
<select name="year">
';
		for ($i = (gmdate("Y") - 2); $i <= (gmdate("Y") + 10); $i++)
		{
			$this->pagelayout .= '<option value="'.$i.'"';
			if ($i == $this->activeyear)
				$this->pagelayout .= ' selected';
			$this->pagelayout .= '>'.$i.'</option>
';
		}

		$this->pagelayout .= '</select>  
<input type="button" style="width: 80px" name="refresh" value="'.$lang->word_refresh.'" onclick="ensureRefresh();" />   
<br />
';
		if ($conf->show_admin_link)
			$this->pagelayout .= '<a class="calmenu" href="caladmin/caladmin.php" target="caladmin"><u>'.$lang->word_administration.'</u></a>
';
		$this->pagelayout .= '</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="calhead" colspan="7">
<table class="calhead" cellspacing="0" cellpadding="0" border="0">
<tr>
<td class="caltitle" colspan="3">
<input type="hidden" name="day" value="" />
<input type="hidden" name="view" value="calendar" />
';
		if (trim($conf->calendar_title_image) != '')
			$this->pagelayout .= '<img src="'.$conf->calendar_title_image.'" alt="'.$conf->calendar_title_text.'" />';
		else
			$this->pagelayout .= $conf->calendar_title_text;

		$this->pagelayout .= '
</td>
</tr>
<tr>
<td class="calmonths" style="text-align: left">
 ';
		if ($prevyear > 1979 && $prevyear > (gmdate("Y", time()) - 6))
			$this->pagelayout .= '<a class="calmonths" href="calendar.php?month='.$prevmonth.'&year='.$prevyear.'"><b><< '.$lang->month_long[$prevmonth].' '.$prevyear.'</b></a>';

		$this->pagelayout .= '
</td>
<td class="calmonths" style="width: 300px; font-size: 16px">
<b>'.$lang->month_long[$current_month].' '.$current_year.'</b>
</td>
<td class="calmonths" style="text-align: right">
';
		if ($nextyear < (gmdate("Y", time()) + 11))
			$this->pagelayout .= '<a class="calmonths" href="calendar.php?month='.$nextmonth.'&year='.$nextyear.'"><b>'.$lang->month_long[$nextmonth].' '.$nextyear.' >></b></a>';
		else
			$this->pagelayout .= ' ';

		$this->pagelayout .= '
</td>
</tr>
</table>
</td>
</tr>
<tr>
';
	   if (isset($conf->calendar_start_day) && $conf->calendar_start_day <= 6 && $conf->calendar_start_day >= 0)
	      $n = $conf->calendar_start_day;
	   else
	      $n = 0;

	   for ($i = 0; $i < 7; $i++)
	   {
	      if ($n > 6)
	         $n = 0;

         $this->pagelayout .= '<td class="calweekday" nowrap>
<b>'.$lang->day_long[$n].'</b>
</td>
';
	      $n++;
	   }
		$this->pagelayout .= '</tr>
';

		$this->makecalendar($current_month, $current_year, $conf->calendar_start_day);

		$this->pagelayout .= '</table>
</form>
<a class="calmenu" style="font-size: 10px" href="http://www.proverbs.biz" target="_blank">Web Calendar ©2004 Proverbs, LLC. All rights reserved.</a>
</center>';
		unset($conf);
		unset($lang);
	}

	function makecalendar($current_month, $current_year, $startweekday)
	{
		$firstweekday = gmdate("w", gmmktime(0, 0, 0, $current_month, 1, $current_year));

		$lastday = 28;

		for ($i = $lastday; $i < 32; $i++)
		{
			if (checkdate($current_month, $i, $current_year))
				$lastday = $i;
		}

		$todayday = 0;

		$conf = new layout_setup;
		$adjustment = 3600 * $conf->time_adjustment;
		if ($conf->use_dst)
			$adjustment += 3600 * date("I", time() + $adjustment);

		if ($current_month == gmdate("n", time() + $adjustment) && $current_year == gmdate("Y", time() + $adjustment))
			$todayday = gmdate("j", time() + $adjustment);

		$calday = 1;
		$calaccess = new caldbaccess;
		while ($calday <= $lastday)
		{
			$this->pagelayout .= '<tr>
';
			for ($j = 0; $j < 7; $j++)
			{
				if ($j == 0)
					$n = $startweekday;
				else
				{
					if ($n < 6)
						$n = $n + 1;
					else
						$n = 0;
				}
				if (($calday == 1 && $firstweekday == $n) || ($calday > 1 && $calday <= $lastday))
				{
					$linesoftext = Array();
					$itemcount = $calaccess->GetCalendarDateEvents($calday, $current_month, $current_year);
					for ($x = 0; $x < $itemcount; $x++)
					{
						$calaccess->next_record();
						$linesoftext[] = $calaccess->f('short_description');
					}

					$itemcount = $calaccess->GetCalendarDayEvents($calday, $current_month, $current_year);
					for ($x = 0; $x < $itemcount; $x++)
					{
						$calaccess->next_record();
						$linesoftext[] = $calaccess->f('short_description');
					}

					if ($todayday > 0 && $todayday == $calday)
						$this->addcalday($calday, true, $linesoftext);
					else
						$this->addcalday($calday, false, $linesoftext);
					$calday++;
				}
				else
					$this->pagelayout .= '<td class="calday" style="cursor: default">
 
</td>
';
			}
			unset ($caldb);
			$this->pagelayout .= '</tr>
';
		}
		unset($conf);
	}

	function addcalday($curday, $istoday, $textdisplay)
	{
		// create the setup object
		$tempconf = new layout_setup;

		if ($istoday)
			$this->pagelayout .= '<td nowrap class="calday" style="background-color: #'.$tempconf->calendar_today_background_color.'" onmouseover="tdmv(this)" onmouseout="tdtmo(this)" onclick="sendDay('.$curday.', '.$this->activemonth.', '.$this->activeyear.')">
'.$curday.'<br />
';
		else	
			$this->pagelayout .= '<td nowrap class="calday" onmouseover="tdmv(this)" onmouseout="tdmu(this)" onclick="sendDay('.$curday.', '.$this->activemonth.', '.$this->activeyear.')">
'.$curday.'<br />
';

		unset($tempconf);

		// create the language object
		$templang = new language;

		if ($textdisplay != "" && count($textdisplay) > 0)
		{
			for ($i = 0; $i < count($textdisplay); $i++)
			{
				$displine = '';
				if (strlen(trim($textdisplay[$i])) > 21)
					$displine = trim(substr(trim($textdisplay[$i]), 0, 18)).'...';
				else
					$displine = trim($textdisplay[$i]);
				$displine .= '<br />
';
				if ($i < 4)
					$this->pagelayout .= $displine;
				if ($i == 5)
					$this->pagelayout .= '<center><< '.$templang->word_more.' >></center>
';
			}
		}

		unset($templang);

		$this->pagelayout .= '</td>
';
	}
}
}
// Create the calendar object.
$page = new calendar_page;
?>

 

Which uses the function makeheader() and pagelayout from this file:

 

<?
/*  ©2004 Proverbs, LLC. All rights reserved.  */

if (eregi("base.inc.php", $_SERVER['PHP_SELF']))
{
// redirect to calendar page
header("Location: calendar.php");
exit;
}

if(!defined("BASE_CALENDAR")) 
{ 
define("BASE_CALENDAR", TRUE); 

require ('setup.inc.php');
require ('language.inc.php');
require ('calaccess.inc.php');

class base_calendar
{
	var $pagelayout;
	var $activeday;
	var $activemonth;
	var $activeyear;

	// Constructor
	function base_calendar()
	{
		$this->pagelayout = '';
	}

	function checkbrowser()
	{
		// create the setup object
		$conf = new layout_setup;
		$javaallowed = $conf->enable_javacss;
		unset($conf);
		if (!isset($_SERVER['HTTP_USER_AGENT']) || !$javaallowed)
			return 0;
		if (eregi("Opera", $_SERVER['HTTP_USER_AGENT']) || eregi("Firefox", $_SERVER['HTTP_USER_AGENT']))
			return 1;
		if (eregi("MSIE", $_SERVER['HTTP_USER_AGENT']))
		{
			if (intval(trim(substr($_SERVER['HTTP_USER_AGENT'], 4 + strpos($_SERVER['HTTP_USER_AGENT'], "MSIE"), 2))) >= 4)
				return 2;
		}
		if (eregi("Netscape", $_SERVER['HTTP_USER_AGENT']))
		{
			if (eregi("Netscape6", $_SERVER['HTTP_USER_AGENT']))
				return 1;
			if (intval(trim(substr($_SERVER['HTTP_USER_AGENT'], 9 + strpos($_SERVER['HTTP_USER_AGENT'], "Netscape"), 2))) >= 6)
				return 1;
		}
		return 0;
	}

	function makeheader()
	{
		// create the setup object
		$conf = new layout_setup;
		// create the language object
		$lang = new language;

		$retversion = $this->checkbrowser();
		$this->pagelayout = '<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'.$lang->lang_value.'" lang="'.$lang->lang_value.'">
<head>
<title>'.$conf->calendar_title_text.'</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta name="Description" content="'.$conf->calendar_title_text.'" />
';
		unset($conf);
		unset($lang);
		return $retversion;
	}

	function closeheader()
	{
		$this->pagelayout .= '</head>
<div leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">
';
	}

	function displaypage()
	{
		$this->pagelayout .= '
</div>
</html>';

		echo $this->pagelayout;
	}
}
}
?>

 

Now, this webpage shows what it should look like, hosted at my site, displayed as a single file:

 

http://actoninfotech.dot5hosting.com/cgi-bin/ESTA/calendar/calendar.php

 

And this page shows how it is displaying inside the <div> tag:

 

http://actoninfotech.dot5hosting.com/cgi-bin/ESTA/calendar.php?month=8&year=2009

 

I know this is a long post for a short question:  what do I need to change to get the proper formatting and have the second <div> tagged link look like the first standalone link?  I have tried several different things, like taking the header, <html> and <body> tags out, thinking they were doubling up (tags inside tags) but that didn't do anything.  I am at a loss.  :facewall:

 

Any help would be appreciated.  Thanks.

 

fdgloworm

Link to comment
Share on other sites

Your code on this page appears to be messed up: http://actoninfotech.dot5hosting.com/cgi-bin/ESTA/calendar.php?month=8&year=2009

 

Looking at the source I see you have 2 sets of doctype and head tags being set. You need to clean it up so that it only has 1 set and see if that solves your problem.

 

Thank you for your reply.  I know the code needs cleaned up, but I wanted to get it working before I clean it up so I always have a working code to revert to if I break it. :)  Your point of the duplicate headers got me working in the right direction -> the stylesheet with the correct formatting wasn't pulled with a require() statement before it was needed therefore there was no formatting.  Then of course I had problems with duplicate CSS tags so I had to rename a few of the internal tags, and viola!  It's all up and working.  If anyone has hints and ideas on how to clean up the code without breaking it, I'm open to suggestions.  It's a mess since it's a third party PHP script I'm using inside a div tag in my own site.  It looks good and functions great in IE and Firefox, but doesn't look so good and works fine in Safari.  This one is going to take some time to clean, I think. :)

 

Again, thank you for the prompting on the headers.  That got me going in the right direction!

 

Aaron

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.