function serveArchives() { global $serendipity; $serendipity['view'] = 'archives'; $_args = locateHiddenVariables($serendipity['uriArguments']); /* We must always *assume* that Year, Month and Day are the first 3 arguments */ list(, $year, $month, $day) = $_args; if ($year == "archives") { unset($year); } $serendipity['GET']['action'] = 'read'; $serendipity['GET']['hidefooter'] = true; if (!isset($year)) { $year = date('Y'); $month = date('m'); $day = date('j'); $serendipity['GET']['action'] = null; $serendipity['GET']['hidefooter'] = null; } if (isset($year) && !is_numeric($year)) { $year = date('Y'); } if (isset($month) && !is_numeric($month)) { $month = date('m'); } if (isset($day) && !is_numeric($day)) { $day = date('d'); } switch ($serendipity['calendar']) { case 'gregorian': default: $gday = 1; if ($week) { $tm = strtotime('+ ' . ($week - 2) . ' WEEKS monday', mktime(0, 0, 0, 1, 1, $year)); $ts = mktime(0, 0, 0, date('m', $tm), date('j', $tm), $year); $te = mktime(23, 59, 59, date('m', $tm), date('j', $tm) + 7, $year); $date = serendipity_formatTime(WEEK . ' ' . $week . ', %Y', $ts, false); } else { if ($day) { $ts = mktime(0, 0, 0, $month, $day, $year); $te = mktime(23, 59, 59, $month, $day, $year); $date = serendipity_formatTime(DATE_FORMAT_ENTRY, $ts, false); } else { $ts = mktime(0, 0, 0, $month, $gday, $year); if (!isset($gday2)) { $gday2 = date('t', $ts); } $te = mktime(23, 59, 59, $month, $gday2, $year); $date = serendipity_formatTime('%B %Y', $ts, false); } } break; case 'persian-utf8': require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php'; $gday = 1; if ($week) { --$week; $week *= 7; ++$week; $day = $week; // convert day number of year to day number of month AND month number of year $j_days_in_month = array(0, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29); if ($g_y % 4 == 3) { $j_days_in_month[12]++; } for ($i = 1; isset($j_days_in_month[$i]); ++$i) { if ($day - $j_days_in_month[$i] > 0) { $day -= $j_days_in_month[$i]; } else { break; } } $tm = persian_mktime(0, 0, 0, $i, $day, $year); $ts = persian_mktime(0, 0, 0, persian_date_utf('m', $tm), persian_date_utf('j', $tm), $year); $te = persian_mktime(23, 59, 59, persian_date_utf('m', $tm), persian_date_utf('j', $tm) + 7, $year); $date = serendipity_formatTime(WEEK . ' ' . $week . '، %Y', $ts, false); } else { if ($day) { $ts = persian_mktime(0, 0, 0, $month, $day, $year); $te = persian_mktime(23, 59, 59, $month, $day, $year); $date = serendipity_formatTime(DATE_FORMAT_ENTRY, $ts, false); } else { $ts = persian_mktime(0, 0, 0, $month, $gday, $year); if (!isset($gday2)) { $gday2 = persian_date_utf('t', $ts); } $te = persian_mktime(23, 59, 59, $month, $gday2, $year); $date = serendipity_formatTime('%B %Y', $ts, false); } } list($year, $month, $day) = p2g($year, $month, $day); break; } $serendipity['range'] = array($ts, $te); if ($serendipity['GET']['action'] == 'read') { if ($serendipity['GET']['category']) { $cInfo = serendipity_fetchCategoryInfo($serendipity['GET']['category']); $serendipity['head_title'] = $cInfo['category_name']; } $serendipity['head_subtitle'] .= sprintf(ENTRIES_FOR, $date); } include S9Y_INCLUDE_PATH . 'include/genpage.inc.php'; }
function generate_content(&$title) { global $serendipity; $title = $this->get_config('title', $this->title); $ts = mktime(0, 0, 0, date('m'), 1); $add_query = ''; $category_set = isset($serendipity['GET']['category']); if ($category_set) { $base_query = 'C' . (int) $serendipity['GET']['category']; $add_query = '/' . $base_query; } $max_x = $this->get_config('count', 3); $show_count = serendipity_db_bool($this->get_config('show_count', false)); $hide_zero_count = serendipity_db_bool($this->get_config('hide_zero_count', false)); $freq = $this->get_config('frequency', 'months'); echo '<ul class="plainList">' . "\n"; if ($serendipity['dbType'] == 'sqlite' || $serendipity['dbType'] == 'sqlite3' || $serendipity['dbType'] == 'sqlite3oo') { $dist_sql = 'count(e.id) AS orderkey'; } else { $dist_sql = 'count(DISTINCT e.id) AS orderkey'; } for ($x = 0; $x < $max_x; $x++) { $current_ts = $ts; switch ($freq) { case 'months': switch ($serendipity['calendar']) { default: case 'gregorian': $linkStamp = date('Y/m', $ts); $ts_title = serendipity_formatTime("%B %Y", $ts, false); $ts = mktime(0, 0, 0, date('m', $ts) - 1, 1, date('Y', $ts)); // Must be last in 'case' statement break; case 'persian-utf8': require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php'; $linkStamp = persian_date_utf('Y/m', $ts); $ts_title = serendipity_formatTime("%B %Y", $ts, false); $ts = persian_mktime(0, 0, 0, persian_date_utf('m', $ts) - 1, 1, persian_date_utf('Y', $ts)); // Must be last in 'case' statement break; } break; case 'weeks': switch ($serendipity['calendar']) { default: case 'gregorian': $linkStamp = date('Y/\\WW', $ts); $ts_title = WEEK . ' ' . date('W, Y', $ts); $ts = mktime(0, 0, 0, date('m', $ts), date('d', $ts) - 7, date('Y', $ts)); break; case 'persian-utf8': require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php'; $linkStamp = persian_date_utf('Y/\\WW', $ts); $ts_title = WEEK . ' ' . persian_date_utf('W، Y', $ts); $ts = persian_mktime(0, 0, 0, persian_date_utf('m', $ts), persian_date_utf('d', $ts) - 7, persian_date_utf('Y', $ts)); break; } break; case 'days': switch ($serendipity['calendar']) { default: case 'gregorian': $linkStamp = date('Y/m/d', $ts); $ts_title = serendipity_formatTime("%B %e. %Y", $ts, false); $ts = mktime(0, 0, 0, date('m', $ts), date('d', $ts) - 1, date('Y', $ts)); // Must be last in 'case' statement break; case 'persian-utf8': require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php'; $linkStamp = persian_date_utf('Y/m/d', $ts); $ts_title = serendipity_formatTime("%e %B %Y", $ts, false); $ts = persian_mktime(0, 0, 0, persian_date_utf('m', $ts), persian_date_utf('d', $ts) - 1, persian_date_utf('Y', $ts)); // Must be last in 'case' statement break; } break; } $link = serendipity_rewriteURL(PATH_ARCHIVES . '/' . $linkStamp . $add_query . '.html', 'serendipityHTTPPath'); $html_count = ''; $hidden_by_zero_count = false; if ($show_count) { switch ($freq) { case 'months': $end_ts = $current_ts + date('t', $current_ts) * 24 * 60 * 60 - 1; break; case 'weeks': $end_ts = $current_ts + 7 * 24 * 60 * 60 - 1; break; case 'days': $end_ts = $current_ts + 24 * 60 * 60 - 1; break; } $ec = serendipity_fetchEntries(array($current_ts, $end_ts), false, '', false, false, null, '', false, true, $dist_sql, '', 'single', false, $category_set); if (is_array($ec)) { if (empty($ec['orderkey'])) { $ec['orderkey'] = '0'; } $hidden_by_zero_count = $hide_zero_count && $ec['orderkey'] == '0'; $html_count .= ' (' . $ec['orderkey'] . ')'; } } if (!$hidden_by_zero_count) { echo '<li><a href="' . $link . '" title="' . $ts_title . '">' . $ts_title . $html_count . '</a></li>' . "\n"; } } echo '<li><a href="' . $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?frontpage">' . RECENT . '</a></li>' . "\n"; echo '<li><a href="' . serendipity_rewriteURL(PATH_ARCHIVE . $add_query) . '">' . OLDER . '</a></li>' . "\n"; echo '</ul>' . "\n"; }
/** * Gather an archive listing of older entries and passes it to Smarty * * The archives are created according to the current timestamp and show the current year. * $serendipity['GET']['category'] is honoured like in serendipity_fetchEntries() * $serendipity['GET']['viewAuthor'] is honoured like in serendipity_fetchEntries() * * @access public * @return null */ function serendipity_printArchives() { global $serendipity; $f = serendipity_db_query("SELECT timestamp FROM {$serendipity['dbPrefix']}entries ORDER BY timestamp ASC LIMIT 1"); switch ($serendipity['calendar']) { case 'gregorian': default: $lastYear = date('Y', serendipity_serverOffsetHour($f[0][0])); $lastMonth = date('m', serendipity_serverOffsetHour($f[0][0])); $thisYear = date('Y', serendipity_serverOffsetHour()); $thisMonth = date('m', serendipity_serverOffsetHour()); break; case 'persian-utf8': require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php'; $lastYear = persian_date_utf('Y', serendipity_serverOffsetHour($f[0][0])); $lastMonth = persian_date_utf('m', serendipity_serverOffsetHour($f[0][0])); $thisYear = persian_date_utf('Y', serendipity_serverOffsetHour()); $thisMonth = persian_date_utf('m', serendipity_serverOffsetHour()); break; } $max = 1; if (isset($serendipity['GET']['category'])) { $cat_sql = serendipity_getMultiCategoriesSQL($serendipity['GET']['category']); $cat_get = '/C' . (int) $serendipity['GET']['category']; } else { $cat_sql = ''; $cat_get = ''; } if (isset($serendipity['GET']['viewAuthor'])) { $author_get = '/A' . (int) $serendipity['GET']['viewAuthor']; } else { $author_get = ''; } if ($serendipity['dbType'] == 'postgres' || $serendipity['dbType'] == 'pdo-postgres') { $distinct = 'DISTINCT e.id,'; } else { $distinct = ''; } $q = "SELECT {$distinct} e.timestamp\n FROM {$serendipity['dbPrefix']}entries e\n " . (!empty($cat_sql) ? "\n LEFT JOIN {$serendipity['dbPrefix']}entrycat ec\n ON e.id = ec.entryid\n LEFT JOIN {$serendipity['dbPrefix']}category c\n ON ec.categoryid = c.categoryid" : "") . "\n WHERE isdraft = 'false'" . (!serendipity_db_bool($serendipity['showFutureEntries']) ? " AND timestamp <= " . serendipity_db_time() : '') . (!empty($cat_sql) ? ' AND ' . $cat_sql : '') . (!empty($serendipity['GET']['viewAuthor']) ? ' AND e.authorid = ' . (int) $serendipity['GET']['viewAuthor'] : '') . (!empty($cat_sql) ? " GROUP BY e.id, e.timestamp" : ''); $entries =& serendipity_db_query($q, false, 'assoc'); $group = array(); if (is_array($entries)) { foreach ($entries as $entry) { $group[date('Ym', $entry['timestamp'])]++; } } $output = array(); for ($y = $thisYear; $y >= $lastYear; $y--) { $output[$y]['year'] = $y; for ($m = 12; $m >= 1; $m--) { /* If the month we are checking are in the future, we drop it */ if ($m > $thisMonth && $y == $thisYear) { continue; } /* If the month is lower than the lowest month containing entries, we're done */ if ($m < $lastMonth && $y <= $lastYear) { break; } switch ($serendipity['calendar']) { case 'gregorian': default: $s = serendipity_serverOffsetHour(mktime(0, 0, 0, $m, 1, $y), true); $e = serendipity_serverOffsetHour(mktime(23, 59, 59, $m, date('t', $s), $y), true); break; case 'persian-utf8': require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php'; $s = serendipity_serverOffsetHour(persian_mktime(0, 0, 0, $m, 1, $y), true); $e = serendipity_serverOffsetHour(persian_mktime(23, 59, 59, $m, date('t', $s), $y), true); break; } $entry_count = (int) $group[$y . (strlen($m) == 1 ? '0' : '') . $m]; /* A silly hack to get the maximum amount of entries per month */ if ($entry_count > $max) { $max = $entry_count; } $data = array(); $data['entry_count'] = $entry_count; $data['link'] = serendipity_archiveDateUrl($y . '/' . sprintf('%02s', $m) . $cat_get . $author_get); $data['link_summary'] = serendipity_archiveDateUrl($y . '/' . sprintf('%02s', $m) . $cat_get . $author_get, true); $data['date'] = $s; $output[$y]['months'][] = $data; } } $serendipity['smarty']->assign_by_ref('archives', $output); $serendipity['smarty']->assign_by_ref('max_entries', $max); serendipity_smarty_fetch('ARCHIVES', 'entries_archives.tpl', true); }
break; } } $tm = persian_mktime(0, 0, 0, $i, $day, $year); $ts = persian_mktime(0, 0, 0, persian_date_utf('m', $tm), persian_date_utf('j', $tm), $year); $te = persian_mktime(23, 59, 59, persian_date_utf('m', $tm), persian_date_utf('j', $tm) + 7, $year); $date = serendipity_formatTime(WEEK . ' ' . $week . '، %Y', $ts, false); } else { if ($day) { $ts = persian_mktime(0, 0, 0, $month, $day, $year); $te = persian_mktime(23, 59, 59, $month, $day, $year); $date = serendipity_formatTime(DATE_FORMAT_ENTRY, $ts, false); } else { $ts = persian_mktime(0, 0, 0, $month, $gday, $year); if (!isset($gday2)) { $gday2 = persian_date_utf('t', $ts); } $te = persian_mktime(23, 59, 59, $month, $gday2, $year); $date = serendipity_formatTime('%B %Y', $ts, false); } } list($year, $month, $day) = p2g($year, $month, $day); break; } $serendipity['range'] = array($ts, $te); if ($serendipity['GET']['action'] == 'read') { if ($serendipity['GET']['category']) { $cInfo = serendipity_fetchCategoryInfo($serendipity['GET']['category']); $serendipity['head_title'] = $cInfo['category_name']; } $serendipity['head_subtitle'] .= sprintf(ENTRIES_FOR, $date);
/** * Create a Unix timestamp for a Persian date * This function works only with day > 0 * * @author Omid Mottaghi * @access public * @param int hour * @param int minute * @param int second * @param int month * @param int day * @param int year * @param int is daylight savings time set? * @return int returned timestamp */ function persian_mktime($hour = '', $min = '', $sec = '', $mon = '', $day = '', $year = '', $is_dst = -1) { $j_days_in_month = array(31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29); if ((string) $hour == '') { $hour = persian_date_utf('H'); } if ((string) $min == '') { $min = persian_date_utf('i'); } if ((string) $sec == '') { $sec = persian_date_utf('s'); } if ((string) $day == '') { $day = persian_date_utf('j'); } if ((string) $mon == '') { $mon = persian_date_utf('n'); } if ((string) $year == '') { $year = persian_date_utf('Y'); } /* an ugly, beta code snippet to support days <= zero! it should work, but days in one or more months should calculate! */ /* if($day <= 0){ // change sign $day = abs($day); // calculate months and days that shall decrease // this do-while has a lot of errors!!! do{ // $month_days = $j_days_in_month[$mon] $months = floor($day/30); $days = $day % 30; }while(); $mon -= $months; $day -= $days; if ($day < 1) { $mon--; } } */ if ($mon <= 0) { // change sign $mon = abs($mon); // calculate years and months that shall decrease $years = floor($mon / 12); $months = $mon % 12; $year -= $years; $mon -= $months; if ($mon < 1) { $year--; $mon += 12; } } if ($day < 1) { $temp_month = $mon - 1; $temp_year = $year; if ($temp_month <= 0) { $temp_month = 12; $temp_year--; } if ($temp_month > 1 && ($temp_year % 4 == 0 && $temp_year % 100 != 0 || $temp_year % 400 == 0)) { $j_days_in_month[12] = 30; } else { $j_days_in_month[12] = 29; } $day += $j_days_in_month[$temp_month]; } list($year, $mon, $day) = p2g($year, $mon, $day); return mktime($hour, $min, $sec, $mon, $day, $year, $is_dst); }
function generate_content(&$title) { global $serendipity; $title = $this->title; // Usage of serendipity_serverOffsetHour is as follow: // * Whenever a date to display needs to be set, apply the timezone offset // * Whenever we USE the date anywhere in the database, subtract the timezone offset // * Whenever we DISPLAY the date, we do not apply additional timezone addition to it. if (!isset($serendipity['GET']['calendarZoom'])) { if (!isset($serendipity['range'])) { $serendipity['GET']['calendarZoom'] = serendipity_serverOffsetHour(time()); } else { $serendipity['GET']['calendarZoom'] = serendipity_serverOffsetHour($serendipity['range'][0]); } } $month = date('m', serendipity_serverOffsetHour($serendipity['GET']['calendarZoom'], true)); $year = date('Y', serendipity_serverOffsetHour($serendipity['GET']['calendarZoom'], true)); $bow = (int) $this->get_config('beginningOfWeek', 1); // Check for faulty input, is so - run the default if ($bow > 6) { $bow = 1; } // Catch faulty month $month = (int) $month; if ($month < 1) { $month = 1; } switch ($serendipity['calendar']) { default: case 'gregorian': // How many days does the month have? $ts = strtotime($year . '-' . sprintf('%02d', $month) . '-01'); $now = serendipity_serverOffsetHour(time()); $nrOfDays = date('t', $ts); $firstDayWeekDay = date('w', $ts); $firstts = $ts; $endts = mktime(0, 0, 0, $month + 1, 1, $year); break; case 'persian-utf8': require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php'; list(, $jy, $jm, $jd) = $serendipity['uriArguments']; if (isset($jd) && $jd) { list($gy, $gm, $gd) = p2g($jy, $jm, $jd); } elseif (isset($jm) && $jm) { list($gy, $gm, $gd) = p2g($jy, $jm, 1); } else { $gy = $year; $gm = $month; $gd = (int) date('d'); } list($year, $month, $day) = g2p($gy, $gm, $gd); // How many days does the month have? $ts = strtotime($gy . '-' . sprintf('%02d', $gm) . '-' . sprintf('%02d', $gd)); $now = serendipity_serverOffsetHour(time()); $nrOfDays = persian_strftime_utf('%m', $ts); $j_days_in_month = array(0, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29); if ($year % 4 == 3 && $nrOfDays == 12) { $nrOfDays = $j_days_in_month[(int) $nrOfDays] + 1; } else { $nrOfDays = $j_days_in_month[(int) $nrOfDays]; } // Calculate first timestamp of the month list($firstgy, $firstgm, $firstgd) = p2g($year, $month, 1); $firstts = mktime(0, 0, 0, $firstgm, $firstgd, $firstgy); // Calculate first persian day, week day name $firstDayWeekDay = date('w', $firstts); // Calculate end timestamp of the month list($end_year, $end_month, $end_day) = p2g($year, $month + 1, 1); $endts = mktime(0, 0, 0, $end_month, $end_day, $end_year); break; } // end switch // Calculate the first day of the week, based on the beginning of the week ($bow) if ($bow > $firstDayWeekDay) { $firstDayWeekDay = $firstDayWeekDay + 7 - $bow; } elseif ($bow < $firstDayWeekDay) { $firstDayWeekDay = $firstDayWeekDay - $bow; } else { $firstDayWeekDay = 0; } // Calculate the number of next/previous month if ($month > 1) { $previousMonth = $month - 1; $previousYear = $year; } else { $previousMonth = 12; $previousYear = $year - 1; } if ($month < 12) { $nextMonth = $month + 1; $nextYear = $year; } else { $nextMonth = 1; $nextYear = $year + 1; } // Get first and last entry $minmax = serendipity_db_query("SELECT MAX(timestamp) AS max, MIN(timestamp) AS min FROM {$serendipity['dbPrefix']}entries"); if (!is_array($minmax) || !is_array($minmax[0]) || $minmax[0]['min'] < 1 || $minmax[0]['max'] < 1) { // If no entry is available yet, allow scrolling a year back and forth $minmax = array('0' => array('min' => mktime(0, 0, 0, 1, 1, date('Y', $now) - 1), 'max' => mktime(0, 0, 0, 1, 1, date('Y', $now) + 1))); } // Find out about diary entries $add_query = ''; $base_query = ''; $cond = array(); $cond['and'] = "WHERE e.timestamp >= " . serendipity_serverOffsetHour($firstts, true) . "\n AND e.timestamp <= " . serendipity_serverOffsetHour($endts, true) . "\n " . (!serendipity_db_bool($serendipity['showFutureEntries']) ? " AND e.timestamp <= " . serendipity_db_time() : '') . "\n AND e.isdraft = 'false'"; serendipity_plugin_api::hook_event('frontend_fetchentries', $cond, array('noCache' => false, 'noSticky' => false, 'source' => 'calendar')); // Event Calendar $cat = $this->get_config('category', 'all'); if ($cat != 'all') { $catid = (int) $cat; } elseif (isset($serendipity['GET']['category'])) { $catid = (int) $serendipity['GET']['category']; } else { $catid = false; } if ($catid) { $base_query = 'C' . $catid; $add_query = '/' . $base_query; $querystring = "SELECT timestamp\n FROM {$serendipity['dbPrefix']}category c,\n {$serendipity['dbPrefix']}entrycat ec,\n {$serendipity['dbPrefix']}entries e\n {$cond['joins']}\n {$cond['and']}\n AND e.id = ec.entryid\n AND c.categoryid = ec.categoryid\n AND (" . serendipity_getMultiCategoriesSQL($catid) . ")"; } if (!isset($querystring)) { $querystring = "SELECT id, timestamp\n FROM {$serendipity['dbPrefix']}entries e\n {$cond['joins']}\n {$cond['and']}"; } $rows = serendipity_db_query($querystring); switch ($serendipity['calendar']) { default: case 'gregorian': $activeDays = array(); if (is_array($rows)) { foreach ($rows as $row) { $row['timestamp'] = serendipity_serverOffsetHour($row['timestamp']); $activeDays[date('j', $row['timestamp'])] = $row['timestamp']; } } $today_day = date('j', $now); $today_month = date('m', $now); $today_year = date('Y', $now); break; case 'persian-utf8': $activeDays = array(); if (is_array($rows)) { foreach ($rows as $row) { $row['timestamp'] = serendipity_serverOffsetHour($row['timestamp']); $activeDays[(int) persian_date_utf('j', $row['timestamp'])] = $row['timestamp']; } } $today_day = persian_date_utf('j', $now); $today_month = persian_date_utf('m', $now); $today_year = persian_date_utf('Y', $now); break; } // end switch $externalevents = array(); if (serendipity_db_bool($this->get_config('enableExtEvents', 'false'))) { serendipity_plugin_api::hook_event('frontend_calendar', $externalevents, array('Month' => $month, 'Year' => $year, 'TS' => $ts, 'EndTS' => $endts)); } // Print the calendar $currDay = 1; $nrOfRows = ceil(($nrOfDays + $firstDayWeekDay) / 7); for ($x = 0; $x < 6; $x++) { // Break out if we are out of days if ($currDay > $nrOfDays) { break; } // Prepare row for ($y = 0; $y < 7; $y++) { $cellProps = array(); $printDay = ''; $link = ''; if ($x == 0) { $cellProps['FirstRow'] = 1; } if ($y == 0) { $cellProps['FirstInRow'] = 1; } if ($y == 6) { $cellProps['LastInRow'] = 1; } if ($x == $nrOfRows - 1) { $cellProps['LastRow'] = 1; } // If it's not a blank day, we print the day if (($x > 0 || $y >= $firstDayWeekDay) && $currDay <= $nrOfDays) { $printDay = $currDay; if ($today_day == $currDay && $today_month == $month && $today_year == $year) { $cellProps['Today'] = 1; } if (isset($externalevents[$currDay])) { if (isset($externalevents[$currDay]['Class'])) { $cellProps[$externalevents[$currDay]['Class']] = 1; } if (isset($externalevents[$currDay]['Title'])) { $cellProps['Title'] = serendipity_specialchars($externalevents[$currDay]['Title']); } if (isset($externalevents[$currDay]['Extended'])) { foreach ($externalevents[$currDay]['Extended'] as $ext_key => $ext_val) { $cellProps[$ext_key] = $ext_val; } } } if (isset($activeDays[$currDay]) && $activeDays[$currDay] > 1) { $cellProps['Active'] = 1; $cellProps['Link'] = serendipity_archiveDateUrl(sprintf('%4d/%02d/%02d', $year, $month, $currDay) . $add_query); } $currDay++; } $smartyRows[$x]['days'][] = array('name' => $printDay, 'properties' => $cellProps, 'classes' => implode(' ', array_keys($cellProps))); } // end for } // end for $serendipity['smarty']->assignByRef('plugin_calendar_weeks', $smartyRows); $dow = array(); for ($i = 1; $i <= 7; $i++) { $dow[] = array('date' => mktime(0, 0, 0, 3, $bow + $i - 1, 2004)); } $serendipity['smarty']->assignByRef('plugin_calendar_dow', $dow); $plugin_calendar_data = array('month_date' => $ts, 'uri_previous' => serendipity_archiveDateUrl(sprintf('%04d/%02d', $previousYear, $previousMonth) . $add_query), 'uri_month' => serendipity_archiveDateUrl(sprintf('%04d/%02d', $year, $month) . $add_query), 'uri_next' => serendipity_archiveDateUrl(sprintf('%04d/%02d', $nextYear, $nextMonth) . $add_query), 'minScroll' => $minmax[0]['min'], 'maxScroll' => $minmax[0]['max']); $serendipity['smarty']->assignByRef('plugin_calendar_head', $plugin_calendar_data); echo serendipity_smarty_fetch('CALENDAR', 'plugin_calendar.tpl'); }