/** * setSelection * * @access public * @return void */ public function setSelection() { $hoursInDay = $this->cE->getHoursInDay(); for ($i = 1; $i <= $hoursInDay; $i++) { $hour = new Calendar_Hour(2000, 1, 1, 1); // Create Day with dummy values $hour->setTimestamp($this->cE->dateToStamp($this->year, $this->month, $this->day, $i)); $this->children[$i] = new TimetableEvent($hour); $stamp1 = $this->cE->dateToStamp($this->year, $this->month, $this->day, $i); $stamp2 = $this->cE->dateToStamp($this->year, $this->month, $this->day, $i + 1); foreach ($this->timetable->events as $event) { if ($stamp1 >= $event['start'] && $stamp1 < $event['end'] || $stamp2 > $event['start'] && $stamp2 <= $event['end'] || $stamp1 <= $event['start'] && $stamp2 >= $event['end']) { $this->children[$i]->addEntry($event); $this->children[$i]->setSelected(); } } } }
$Second =& new Calendar_Second($_POST['y'], $_POST['m'], $_POST['d'], $_POST['h'], $_POST['i'], $_POST['s']); if (!$Second->isValid()) { $V =& $Second->getValidator(); echo '<p>Validation failed:</p>'; while ($error = $V->fetch()) { echo $error->toString() . '<br>'; } } else { echo '<p>Validation success.</p>'; echo '<p>New timestamp is: ' . $Second->getTimeStamp() . ' which could be used to update a database, for example'; } } else { $Year = new Calendar_Year($_POST['y']); $Month = new Calendar_Month($_POST['y'], $_POST['m']); $Day = new Calendar_Day($_POST['y'], $_POST['m'], $_POST['d']); $Hour = new Calendar_Hour($_POST['y'], $_POST['m'], $_POST['d'], $_POST['h']); $Minute = new Calendar_Minute($_POST['y'], $_POST['m'], $_POST['d'], $_POST['h'], $_POST['i']); $Second = new Calendar_Second($_POST['y'], $_POST['m'], $_POST['d'], $_POST['h'], $_POST['i'], $_POST['s']); ?> <p><b>Set the alarm clock</p></p> <form action="<?php echo $_SERVER['PHP_SELF']; ?> " method="post"> Year: <input type="text" name="y" value="<?php echo $_POST['y']; ?> " size="4"> Month:<select name="m"> <?php $selection = array($Month);
function testHour() { $Unit = new Calendar_Hour(2000, 12, 20, 24); $Validator =& $Unit->getValidator(); $this->assertFalse($Validator->isValidHour()); }
function getEntry() { return $this->entry; } } // Create a day to view the hours for $Day =& new Calendar_Day(2003, 10, 24); // A sample query to get the data for today (NOT ACTUALLY USED HERE) $sql = "\n SELECT\n *\n FROM\n diary\n WHERE\n eventtime >= '" . $Day->thisDay(TRUE) . "'\n AND\n eventtime < '" . $Day->nextDay(TRUE) . "';"; // An array simulating data from a database $result = array(array('eventtime' => mktime(9, 0, 0, 10, 24, 2003), 'entry' => 'Meeting with sales team'), array('eventtime' => mktime(11, 0, 0, 10, 24, 2003), 'entry' => 'Conference call with Widget Inc.'), array('eventtime' => mktime(15, 0, 0, 10, 24, 2003), 'entry' => 'Presentation to board of directors')); // An array to place selected hours in $selection = array(); // Loop through the "database result" foreach ($result as $row) { $Hour = new Calendar_Hour(2000, 1, 1, 1); // Create Hour with dummy values $Hour->setTimeStamp($row['eventtime']); // Set the real time with setTimeStamp // Create the decorator, passing it the Hour $DiaryEvent = new DiaryEvent($Hour); // Attach the payload $DiaryEvent->setEntry($row['entry']); // Add the decorator to the selection $selection[] = $DiaryEvent; } // Build the hours in that day, passing the selection $Day->build($selection); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html>
function renderDayView($y, $m, $d, &$used_hours_arr) { global $TemplateDir, $template, $WebUploadDir, $WebTemplateDir, $WebBaseDir, $ClassDir, $i18n, $ActiveOption, $userid; include_once $ClassDir . "URLHelper.class.php"; // Create a day to view the hours for $Day =& new Calendar_Day($y, $m, $d); $selection = array(); // search specify day webcasts $apf_schedule = DB_DataObject::factory('ApfSchedule'); $apf_schedule->setPublishDate(DB_DataObject_Cast::date($y, $m, $d)); // $apf_schedule->debugLevel(4); $apf_schedule->setUserid($userid); $apf_schedule->find(); $result = array(); $SHOW_CONFIRM_BUTTON = true; $selected_hours = 0; while ($apf_schedule->fetch()) { $row = $apf_schedule->toArray(); // Var_Dump::display($row); $start_hour = $this->getHourByTime($apf_schedule->getPublishStarttime()); $end_hour = $this->getHourByTime($apf_schedule->getPublishEndtime()); if ($row['webcast_status'] != 'file' && !$row['webcast_file']) { $SHOW_CONFIRM_BUTTON = false; } for ($index = $start_hour; $index <= $end_hour; $index++) { $used_hours_arr["{$index}:00:00"] = "{$index}:00"; } $selected_hours += $end_hour - $start_hour + 1; $Hour = new Calendar_Hour(2000, 1, 1, 1); // Create Hour with dummy values $Hour->setTimeStamp(mktime($start_hour, 0, 0, $m, $d, $y)); // Set the real time with setTimeStamp // Create the decorator, passing it the Hour $DiaryEvent = new DiaryEvent($Hour); // Attach the payload $DiaryEvent->setEndHour($end_hour); $DiaryEvent->setID($row['id']); $DiaryEvent->setStatu($row['active']); $DiaryEvent->setImages($row['image'] ? popFile($WebUploadDir . $row['image']) : ""); $DiaryEvent->setEntry("<a href=\"{$WebBaseDir}/schedule/apf_schedule/list/" . $row['id'] . "?y={$y}&m={$m}&d={$d}\">" . $apf_schedule->getTitle() . "</a>"); // Add the decorator to the selection $selection[] = $DiaryEvent; } if ($selected_hours < 24) { $SHOW_CONFIRM_BUTTON = false; } if ($SHOW_CONFIRM_BUTTON) { $template->setVar(array("CONFIRM_LINK" => '<li><input type="submit" name="save" value="Status To Confirm" class="admin_action_cancel" onclick="if (confirm(\'Are you sure?\')) { document.admin_list_form.todo.value=\'confirm\';document.admin_list_form.submit(); };return false;" /></li>')); } $Day->build($selection); $Day_String = ""; $DayViewTitle = date('D d F Y', $Day->thisDay(TRUE)); $temp_end_hour = ""; while ($Hour =& $Day->fetch()) { $hour = $Hour->thisHour(); $minute = $Hour->thisMinute(); // Office hours only... if ($hour >= 0 && $hour <= 24) { $Day_String .= "<tr class=\"calnone\">\n"; $Day_String .= "<td>{$hour}:{$minute}</td>\n"; // If the hour is selected, call the decorator method... if ($Hour->isSelected()) { $temp_end_hour = $Hour->getEndHour(); $merge_hour = $temp_end_hour - $hour + 1; $css_class_name = "calentryfilled_" . $Hour->getStatu(); $Day_String .= "<td rowspan=\"{$merge_hour}\" class=\"{$css_class_name}\"><INPUT TYPE=\"checkbox\" NAME=\"SelectID[]\" value=\"" . $Hour->getID() . "\"></td><td class=\"{$css_class_name}\" rowspan=\"{$merge_hour}\">" . $Hour->getEntry() . "</td><td rowspan=\"{$merge_hour}\"> " . $Hour->getImages() . "</td><td rowspan=\"{$merge_hour}\"> " . $ActiveOption[$Hour->getStatu()] . "</td><td rowspan=\"{$merge_hour}\"><ul class=\"admin_td_actions\">\n <li><a onclick=\"if (confirm('Are you sure?')) { f = document.createElement('form'); document.body.appendChild(f); f.method = 'POST'; f.action = this.href; f.submit(); };return false;\" href=\"{$WebBaseDir}/schedule/apf_schedule/del/" . $Hour->getID() . "?y={$y}&m={$m}&d={$d}\"><img alt=\"delete\" title=\"delete\" src=\"" . URLHelper::getWebBaseURL() . $WebTemplateDir . "/images/delete_icon.png\" /></a></li>\n</ul></td>\n"; } else { if ($temp_end_hour && $hour <= $temp_end_hour) { $Day_String .= ""; } else { $Day_String .= "<td> </td><td> </td><td> </td><td> </td><td> </td>\n"; } } $Day_String .= "</tr>\n"; } } $header_time = $i18n->_("Time"); $header_entry = $i18n->_("Entry"); $header_image = $i18n->_("Image"); $header_status = $i18n->_("Status"); $header_action = $i18n->_("Action"); $header_schedule_for = $i18n->_("YourScheduleFor"); $calendar_str = <<<EOD <table> <caption><b>{$header_schedule_for}{$DayViewTitle} </b></caption> <tr class="calentryhead"> <th width="8%">{$header_time}</th> <th width="1%"> <input type="checkbox" onClick="selectAll(this.checked,'SelectID[]')"/></th> <th>{$header_entry}</th> <th width="10%">{$header_image}</th> <th width="10%">{$header_status}</th> <th width="10%">{$header_action}</th> </tr> {$Day_String} </table> EOD; return $calendar_str; }
/** * setSelection * * @access public * @return void */ public function setSelection() { $hoursInDay = $this->cE->getHoursInDay(); $firstDayOfweek = $this->week->toArray($this->week->thisWeek); for ($j = 0; $j < 7; $j++) { for ($i = 0; $i < $hoursInDay; $i++) { $hour = new Calendar_Hour(2000, 1, 1, 1); // Create Day with dummy values $hour->setTimestamp($this->cE->dateToStamp($this->year, $this->month, $firstDayOfweek['day'] + $j, $i)); $this->children[$i][$j] = new TimetableEvent($hour); $stamp1 = $this->cE->dateToStamp($this->year, $this->month, $firstDayOfweek['day'] + $j, $i); $stamp2 = $this->cE->dateToStamp($this->year, $this->month, $firstDayOfweek['day'] + $j, $i + 1); foreach ($this->timetable->events as $event) { if ($stamp1 >= $event['start'] && $stamp1 < $event['end'] || $stamp2 > $event['start'] && $stamp2 <= $event['end'] || $stamp1 <= $event['start'] && $stamp2 >= $event['end']) { $this->children[$i][$j]->addEntry($event); $this->children[$i][$j]->setSelected(); } } } } }