/** Generates an array of all 'ec3_Day's between the start of * begin_month & end_month. * month_id is in the form: ec3_<year_num>_<month_num> */ function ec3_util_calendar_days($begin_month_id, $end_month_id) { $begin_date = substr($begin_month_id, 4) . '_1'; $end_date = substr($end_month_id, 4) . '_1'; global $ec3, $tablepost2cat, $tableposts, $wpdb; // Which posts are we interested in? if ($ec3->show_only_events) { // Category ID number for event posts. $where_post = "category_id = {$ec3->event_category}"; } else { $now = gmdate('Y-m-d H:i:59'); $where_post = "(post_date_gmt<='{$now}' OR category_id={$ec3->event_category})"; } $calendar_entries = $wpdb->get_results("SELECT DISTINCT\r\n post_title,\r\n post_date,\r\n DAYOFMONTH(post_date) AS day,\r\n MONTH(post_date) AS month,\r\n YEAR(post_date) AS year,\r\n (category_id = {$ec3->event_category}) AS is_event\r\n FROM {$tableposts},{$tablepost2cat}\r\n WHERE post_date >= '{$begin_date}'\r\n AND post_date < '{$end_date}'\r\n AND post_status = 'publish'\r\n AND id = post_id\r\n AND {$where_post}\r\n ORDER BY post_date ASC"); $calendar_days = array(); // result if ($calendar_entries) { $time_format = get_settings('time_format'); foreach ($calendar_entries as $ent) { $date = new ec3_Date($ent->year, $ent->month, $ent->day); $day_id = $date->day_id(); if (empty($calendar_days[$day_id])) { $calendar_days[$day_id] = new ec3_Day(); } $calendar_days[$day_id]->add_post("{$ent->post_title}", mysql2date($time_format, $ent->post_date), $ent->is_event); } } return $calendar_days; }