} //get a DateTime for one month after currently viewed and disable URL if required $this_datetime->add(new DateInterval("P1M")); if ($this_datetime <= $last_event_time) { $next = JRoute::_('index.php?option=' . $this->option . '&' . $next_month->toDateURL($this->task)); $next_text = JText::_('EVENTS_CAL_LANG_NEXTMONTH'); } else { $next = "javascript:void(0);"; $next_text = JText::_('EVENTS_CAL_LANG_NO_EVENTFOR') . ' ' . JText::_('EVENTS_CAL_LANG_NEXTMONTH'); } $content = '<table class="ecalendar">' . "\n"; $content .= ' <caption>'; if ($this->shownav) { $content .= '<a class="prv" href="' . $prev . '" title="' . $prev_text . '">‹</a> <a class="nxt" href="' . $next . '" title="' . $next_text . '">›</a> '; } $content .= \Components\Events\Helpers\Html::getMonthName($cal_month) . '</caption>' . "\n"; $content .= ' <thead>' . "\n"; $content .= ' <tr>' . "\n"; for ($i = 0; $i < 7; $i++) { $content .= ' <th scope="col">' . $day_name[($i + $startday) % 7] . '</th>' . "\n"; } $content .= ' </tr>' . "\n"; $content .= ' </thead>' . "\n"; $content .= ' <tbody>' . "\n"; $content .= ' <tr>' . "\n"; // dmcd May 7/04 fix to fill in end days out of month correctly $dayOfWeek = $startday; $start = (date("w", mktime(0, 0, 0, $cal_month, 1, $cal_year)) - $startday + 7) % 7; $d = date("t", mktime(0, 0, 0, $cal_month, 0, $cal_year)) - $start + 1; $kownt = 0; for ($a = $start; $a > 0; $a--) {
/** * Short description for '_calendar' * * Long description (if any) ... * * @param unknown $timeWithOffset Parameter description (if any) ... * @param number $startday Parameter description (if any) ... * @param unknown $time Parameter description (if any) ... * @param unknown $linkString Parameter description (if any) ... * @param array &$day_name Parameter description (if any) ... * @param boolean $monthMustHaveEvent Parameter description (if any) ... * @return string Return description (if any) ... */ private function _calendar($timeWithOffset, $startday, $time, $linkString, &$day_name, $monthMustHaveEvent = false) { $database = App::get('db'); $cal_year = date("Y", $time); $cal_month = date("m", $time); $calmonth = date("n", $time); $to_day = date("Y-m-d", $timeWithOffset); // Start building the table $content = '<table class="mod_events_calendar">' . "\n"; $content .= ' <caption>' . "\n"; if ($this->params->get('show_nav_prev_month')) { $content .= ' <a class="prev month" href="' . Route::url('index.php?option=com_events&year=' . ($cal_month == 1 ? $cal_year - 1 : $cal_year) . '&month=' . ($cal_month == 1 ? 12 : $cal_month - 1)) . '">' . Html::getMonthName($cal_month == 1 ? 12 : $cal_month - 1) . '</a>' . "\n"; } $content .= ' <a class="current month" href="' . Route::url('index.php?option=com_events&year=' . $cal_year . '&month=' . $cal_month) . '">' . Html::getMonthName($cal_month) . '</a>' . "\n"; if ($this->params->get('show_nav_next_month')) { $content .= ' <a class="next month" href="' . Route::url('index.php?option=com_events&year=' . ($cal_month == 12 ? $cal_year + 1 : $cal_year) . '&month=' . ($cal_month == 12 ? 1 : $cal_month + 1)) . '">' . Html::getMonthName($cal_month == 12 ? 1 : $cal_month + 1) . '</a>' . "\n"; } $content .= ' </caption>' . "\n"; $content .= ' <thead>' . "\n"; $content .= ' <tr>' . "\n"; // Days name rows for ($i = 0; $i < 7; $i++) { $content .= ' <th>' . $day_name[($i + $startday) % 7] . '</th>' . "\n"; } $content .= ' </tr>' . "\n"; $content .= ' </thead>' . "\n"; $content .= ' <tbody>' . "\n"; $content .= ' <tr>' . "\n"; // Fix to fill in end days out of month correctly $dayOfWeek = $startday; $start = (date("w", mktime(0, 0, 0, $cal_month, 1, $cal_year)) - $startday + 7) % 7; $d = date("t", mktime(0, 0, 0, $cal_month, 0, $cal_year)) - $start + 1; $kownt = 0; for ($a = $start; $a > 0; $a--) { $content .= ' <td class="daylink"> </td>' . "\n"; $dayOfWeek++; $kownt++; } $monthHasEvent = false; $lastDayOfMonth = date("t", mktime(0, 0, 0, $cal_month, 1, $cal_year)); $rd = 0; for ($d = 1; $d <= $lastDayOfMonth; $d++) { $do = $d < 10 ? "0{$d}" : "{$d}"; $selected_date = "{$cal_year}-{$cal_month}-{$do}"; $sql = "SELECT `#__events`.* FROM `#__events`, `#__categories` as b" . " WHERE #__events.catid = b.id " . " AND ((publish_up >= '{$selected_date} 00:00:00' AND publish_up <= '{$selected_date} 23:59:59')" . " OR (publish_down >= '{$selected_date} 00:00:00' AND publish_down <= '{$selected_date} 23:59:59')" . " OR (publish_up <= '{$selected_date} 00:00:00' AND publish_down >= '{$selected_date} 23:59:59')) AND state='1'" . " AND (#__events.scope IS NULL OR #__events.scope=" . $database->quote('event') . ")" . " ORDER BY publish_up ASC"; $database->setQuery($sql); $rows = $database->loadObjectList(); $mark_bold = ''; $mark_close_bold = ''; $class = $selected_date == $to_day ? 'todaynoevents' : 'daynoevents'; // do we have events if (count($rows) > 0) { $class = 'daywithevents'; if ($selected_date == $to_day) { $class = 'todaywithevents'; } } // Only adds link if event scheduled that day $content .= ' <td class="' . $class . '">'; if ($class == 'todaywithevents' || $class == 'daywithevents') { $content .= '<a class="mod_events_daylink" href="' . Route::url('index.php?option=com_events&year=' . $cal_year . '&month=' . $cal_month . '&day=' . $do) . '">' . $d . '</a>'; } else { $content .= "{$d}"; } $content .= '</td>' . "\n"; $rd++; // Check if Next week row if ((1 + $dayOfWeek++) % 7 == $startday) { $content .= ' </tr>' . "\n" . ' <tr>' . "\n"; $rd = $rd >= 7 ? 0 : $rd; } } // Fill in any blank days for the rest of the row for ($d = $rd; $d <= 6; $d++) { $content .= ' <td> </td>' . "\n"; } // Finish off the table $content .= ' </tr>' . "\n"; $content .= ' </tbody>' . "\n"; $content .= '</table>' . "\n"; // Now check to see if this month needs to have at least 1 event in order to display if (!$monthMustHaveEvent || $monthHasEvent) { return $content; } else { return ''; } }