Calendar decorators
| From: | Steven Levin | Date: | Fri, 19 Mar 2004 19:25:58 +0000 |
| Subject: | Calendar decorators | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-11404@lists.php.net to get a copy of this message | ||
Hello all,
I have created a calendar display using this wonderful library and now
I am trying to get it to actually show events. After selecting the days
out of the database I am wrapping them in a decorator class. But when
I pass my array of days to the Calendar_Month_Weekdays::build() I get
this error:
Fatal error: Call to a member function on a non-object in
/usr/local/lib/php/Calendar/Decorator.php on line 319
Here is a snipit of the code:
<pre>
require_once('Calendar/Month/Weekdays.php');
require_once('Calendar/Day.php');
$Month =& new Calendar_Month_Weekdays($this->_year, $this->_month);
$student = $this->_student->getId();
$sql = "SELECT ts, label FROM events WHERE student='$student' OR
global='1'";
$result = $DB->getAll($sql); /* Fetchmode assoc */
$selection = array();
if(is_array($result) && (sizeof($result) > 0)) {
foreach($result as $row) {
$Day = new Calendar_Day(1970, 1, 1);
$Day->setTimeStamp($row['ts']);
$StudentDay = new StudentDay($Day);
$StudentDay->setLabel($row['label']);
$selection[] = $StudentDay;
}
}
$Day = null;
$StudentDay = null;
$Month->build($selection); /* this call causes non-object error */
--
/* basic version of my decorator */
class StudentDay extends Calendar_Decorator {
var $_label = null;
function StudentDay(&$Day) {
parent::Calendar_Decorator($Day);
}
function setLabel($label) {
$this->_label = $label;
}
}
</pre>
Am I overlooking something?
--
Steven Levin
Appalachian State University
http://phpwebsite.appstate.edu