';
}
$calendar = '';
$year = $offset_year;
$month = $offset_month;
$uxtime_first_of_month = gmmktime(0, 0, 0, $month, 1, $year);
# Remember that mktime will automatically correct if invalid dates are entered
# for instance, mktime(0,0,0,12,32,1997) will be the date for Jan 1, 1998
# this provides a built in "rounding" feature to generate_calendar()
$month_weekday = gmdate('w', $uxtime_first_of_month);
$days_in_month = gmdate('t', $uxtime_first_of_month);
$day_names_long = array('SUNDAY', 'MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY');
$day_names_short = array('SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT');
$month_names = array('', 'JANUARY', 'FEBRUARY', 'MARCH', 'APRIL', 'MAY', 'JUNE', 'JULY', 'AUGUST', 'SEPTEMBER', 'OCTOBER', 'NOVEMBER', 'DECEMBER');
$month_name_short = Text::_($month_names[(int)$month] . '_SHORT');
$month_name_long = Text::_($month_names[(int)$month]);
$weekday = ($month_weekday + 7 - $first_day) % 7; # adjust for $first_day of week
$the_year = $Year_length ? $year : substr($year, -2); # full or last two digits
if (!function_exists('mb_convert_case')) {
$the_month = ucfirst(htmlentities($Month_length ? $month_name_short : $month_name_long, ENT_COMPAT, "UTF-8"));
$the_month_prev = ucfirst(htmlentities(Text::_($month_names[(int)$prev_month] . ($Month_length ? '_SHORT' : '')), ENT_COMPAT, "UTF-8"));
$the_month_next = ucfirst(htmlentities(Text::_($month_names[(int)$next_month] . ($Month_length ? '_SHORT' : '')), ENT_COMPAT, "UTF-8"));
$the_month_today = ucfirst(htmlentities(Text::_($month_names[(int)$today_month] . ($Month_length ? '_SHORT' : '')), ENT_COMPAT, "UTF-8"));
} else {
$the_month = mb_convert_case($Month_length ? $month_name_short : $month_name_long, MB_CASE_TITLE, "UTF-8");
$the_month_prev = mb_convert_case(Text::_($month_names[(int)$prev_month] . ($Month_length ? '_SHORT' : '')), MB_CASE_TITLE, "UTF-8");
$the_month_next = mb_convert_case(Text::_($month_names[(int)$next_month] . ($Month_length ? '_SHORT' : '')), MB_CASE_TITLE, "UTF-8");
$the_month_today = mb_convert_case(Text::_($month_names[(int)$today_month] . ($Month_length ? '_SHORT' : '')), MB_CASE_TITLE, "UTF-8");
}
$title = $the_month . ' ' . $the_year;
# Begin calendar. Uses a real
. See https://diveintomark.org/archives/2002/07/03
$calendar .= '' . "\n";
# Month navigation links
# use $url_base_nojs or $url_base_ajax followed by $props_prev, $props_home, or $props_next
$navi_nojs = '';
$navi_nojs .= $props_prev_year ? ('<< ') : '<< ';
$navi_nojs .= $props_prev ? ('< ') : '< ';
$navi_nojs .= $props_home ? ('' . $title . '') : $title;
$navi_nojs .= $props_next ? (' >') : ' >';
$navi_nojs .= $props_next_year ? (' >>') : ' >>';
$navi_nojs .= '';
$calendar .= $navi_nojs;
if ($use_ajax) {
$navi_ajax = '';
$navi_ajax .= $props_prev_year ? ('<< ') : '<< ';
$navi_ajax .= $props_prev ? ('< ') : '< ';
$navi_ajax .= $props_home ? ('' . $title . '') : $title;
$navi_ajax .= $props_next ? (' >') : ' >';
$navi_ajax .= $props_next_year ? (' >>') : ' >>';
$navi_ajax .= '';
$calendar .= $navi_ajax;
}
# If the day names should be shown ($day_name_length > 0)
if ($day_name_length) {
$calendar .= '';
# If day_name_length is >3, the full name of the day will be printed
if ($day_name_length > 3) {
for ($d = 0; $d < 7; ++$d) {
$dayname = Text::_($day_names_long[($d + $first_day) % 7]);
$calendar .= '| ' . $dayname . ' | ';
}
} else {
for ($d = 0; $d < 7; ++$d) {
$dayname = Text::_($day_names_short[($d + $first_day) % 7]);
if (function_exists('mb_substr')) {
$calendar .= ' ' . mb_substr($dayname, 0, $day_name_length, 'UTF-8') . ' | ';
} else {
$calendar .= ' ' . substr($dayname, 0, $day_name_length) . ' | ';
}
}
}
$calendar .= "
\n";
}
# Today
$config = Factory::getConfig();
$tzoffset = $config->get('config.offset');
$time = time() + (($tzoffset + $Time_offset) * 60 * 60); //25/2/08 Change for v 0.6 to incorporate server offset into time;
$today = date('j', $time);
$currmonth = date('m', $time);
$curryear = date('Y', $time);
# Switch off tooltips if neighter title nor text should be shown
if (($Show_Tooltips_Title == 0) && ($tooltips_max_events === '0')) {
$Show_Tooltips = 0;
}
$calendar .= '';
# Initial 'empty' days
for ($counti = 0; $counti < $weekday; $counti++) {
$calendar .= '| | ';
}
# The days of interest
for ($day = 1; $day <= $days_in_month; $day++, $weekday++) {
if ($weekday == 7) {
$weekday = 0; #start a new week
$calendar .= "
\n";
}
$istoday = ($day == $today) && ($currmonth == $month) && ($curryear == $year);
$tdbaseclass = ($istoday) ? 'mod_jemcalq_caltoday' : 'mod_jemcalq_calday';
# Space in front of daynumber when day < 10
$space = ($day < 10) ? ' ': '';
if (isset($days[$day][1])) {
$link = $days[$day][0];
$title = $days[$day][1];
if ($Show_Tooltips == 1) {
$calendar .= '';
if ($link) {
$tip = '';
$title = explode('+%+%+', $title);
if ($Show_Tooltips_Title == 1) {
if (count($title) > 1) {
$tipTitle = count($title) . ' ' . Text::_($CalTooltipsTitlePl);
} else {
$tipTitle = '1 ' . Text::_($CalTooltipsTitle);
}
} else {
$tipTitle = '';
}
if (version_compare(JVERSION, '3.2.7', 'lt')) {
# There is a bug in Joomla which will format complete tip text as title
# if $tipTitle is empty (because then no '::' will be added).
# So add it manually and let title param empty.
$tip = $tipTitle . '::';
$tipTitle = '';
}
# If user hadn't explicitely typed in a 0 list limited number or all events
if ($tooltips_max_events !== '0') {
$count = 0;
foreach ($title as $t) {
if (($tooltips_max_events > 0) && (++$count > $tooltips_max_events)) {
$tip .= '...';
break; // foreach
}
$tip .= trim($t) . ' ';
}
}
# J! version < 3.2.7: title already within $tip to ensure always '::' is present
# But with J! 3.3+ is a bug in script so we need to use the bad 'hasTooltip'
# which is default of class parameter.
$calendar .= HTMLHelper::tooltip($tip, $tipTitle, 'tooltip.png', $space . $day, $link);
}
$calendar .= ' | ';
} else {
$calendar .= '' . ($link ? '' . $space . $day . '' : $space . $day) . ' | ';
}
} else {
$calendar .= '' . $space . $day . ' | ';
}
}
# Remaining 'empty' days
for ($counti = $weekday; $counti < 7; $counti++) {
$calendar .= ' | ';
}
$calendar .= "
\n
\n";
echo $calendar;
if (!$use_ajax || empty($module->in_ajax_call)) {
echo " ";
}