function widget($args, $instance) { extract($args, EXTR_SKIP); echo $before_widget . $before_title; echo ec3_widget_title($instance['title'], 'Upcoming Events'); echo $after_title; if (ec3_check_installed(__('Upcoming Events', 'ec3'))) { // Parse $limit: // NUMBER - limits number of posts // NUMBER days - next NUMBER of days $limit = $instance['limit']; $num = intval($limit); $query = new WP_Query(); if (preg_match('/^ *([0-9]+) *d(ays?)?/', $limit, $matches)) { $query->query('ec3_days=' . intval($matches[1])); } elseif ($num > 0) { $query->query('ec3_after=today&posts_per_page=' . $num); } elseif ($num < 0) { $query->query('ec3_before=today&order=asc&posts_per_page=' . abs($num)); } else { $query->query('ec3_after=today&posts_per_page=5'); } echo "<ul class='ec3_events'>"; echo '<!-- Generated by Event-Calendar v' . ec3_get_version() . ' -->' . "\n"; if ($query->have_posts()) { $current_date = false; for ($evt = ec3_iter_all_events_q($query); $evt->valid(); $evt->next()) { // Date changed? $date = ec3_get_date(); if (!$current_date || $current_date != $date) { if ($current_date) { echo "</ul></li>\n"; } echo "<li class='ec3_list ec3_list_day'>{$date}:\n<ul>\n"; $current_date = $date; } // Print the event. echo ' <li><a href="' . get_permalink() . '">' . get_the_title() . ' (' . ec3_get_start_time() . ')</a></li>' . "\n"; } if ($current_date) { echo "</ul></li>\n"; } } else { echo "<li>" . __('No events.', 'ec3') . "</li>\n"; } echo "</ul>\n"; } echo $after_widget; }
function make_event(&$event) { if ($this->dayobj->date == substr($event->start, 0, 10)) { $title = ec3_get_start_time(); // same day if ($this->dayobj->date == substr($event->end, 0, 10)) { $title .= ' - ' . ec3_get_end_time(); } else { $title .= '...'; } } else { if ($this->dayobj->date == substr($event->end, 0, 10)) { $title = '...' . ec3_get_end_time(); } else { $title .= '...' . __('all day', 'ec3') . '...'; } } return "\n\t " . '<p class="ec3_event"><a title="' . $title . '" href="' . get_permalink() . '">' . get_the_title() . '</a></p>'; }
/** Formats the schedule for the current post as one or more 'iconlets'. * Returns the HTML fragment as a string. */ function ec3_get_iconlets_active() { if (!ec3_is_event()) { return ''; } global $ec3; $result = ''; $current = false; $this_year = date('Y'); for ($evt = ec3_iter_post_events(); $evt->valid(); $evt->next()) { $year_start = ec3_get_start_date('Y'); $month_start = ec3_get_start_date('M'); $day_start = ec3_get_start_date('j'); // Don't bother about intra-day details. Empeche d'afficher plusieur fois le même jour. /*if($current==$day_start.$month_start.$year_start) continue;*/ $current = $day_start . $month_start . $year_start; // Grey-out past events. if ($ec3->event->active) { // Only put the year in if it isn't *this* year. if ($year_start != $this_year) { $month_start .= ' ’' . substr($year_start, 2); } // OK, make the iconlet. $result .= "<div class='ec3_iconlet'><table><tbody>"; if (!$ec3->event->allday) { // Event with start time. $time_start = ec3_get_start_time(); if (substr($ec3->event->start, 0, 10) < substr($ec3->event->end, 0, 10)) { $month_end = ec3_get_end_date('M'); $day_end = ec3_get_end_date('j'); $time_end = ec3_get_end_time(); $result .= "<tr class='ec3_month'>" . "<td class='ec3_multi_start'>{$month_start}</td>" . "<td class='ec3_multi_end'>{$month_end}</td></tr>"; $result .= "<tr class='ec3_day'>" . "<td class='ec3_multi_start'>{$day_start}</td>" . "<td class='ec3_multi_end'>{$day_end}</td></tr>"; $result .= "<tr class='ec3_time'>" . "<td>{$time_start}</td>" . "<td>{$time_end}</td></tr>"; } else { $result .= "<tr class='ec3_month'><td>{$month_start}</td></tr>" . "<tr class='ec3_day'><td>{$day_start}</td></tr>" . "<tr class='ec3_time'><td>{$time_start}</td></tr>"; } } elseif (substr($ec3->event->start, 0, 10) == substr($ec3->event->end, 0, 10)) { // Single, all-day event. $result .= "<tr class='ec3_month'><td>{$month_start}</td></tr>" . "<tr class='ec3_day'><td>{$day_start}</td></tr>"; } else { // Multi-day event. $month_end = ec3_get_end_date('M'); $day_end = ec3_get_end_date('j'); $result .= "<tr class='ec3_month'>" . "<td class='ec3_multi_start'>{$month_start}</td>" . "<td class='ec3_multi_end'>{$month_end}</td></tr>"; $result .= "<tr class='ec3_day'>" . "<td class='ec3_multi_start'>{$day_start}</td>" . "<td class='ec3_multi_end'>{$day_end}</td></tr>"; } //echo stripslashes($ec3->event->info_shed); if (!empty($ec3->event->info_shed)) { $bulle = stripslashes($ec3->event->info_shed); $result .= "<tr><td class='bulle'>{$bulle}</td></tr></tbody></table></div>\n"; } else { $result .= "</tbody></table></div>\n"; } } else { $result .= ""; } } return apply_filters('ec3_filter_iconlets_active', $result); }
function make_event(&$event) { global $post; if ($this->dayobj->date == substr($event->start, 0, 10)) { return $this->make_post($post) . ' @' . ec3_get_start_time(); } else { return '...' . $this->make_post($post); } // continued from previous day. }
function _add_detail($event = FALSE) { global $id, $post, $ec3_htmlspecialchars; // Record the post's title for today. $title = get_the_title(); if (empty($this->dayobj->titles)) { $this->dayobj->titles = array(); } $safe_title = $title; //strip_tags($title); $safe_title = str_replace(array(',', '@'), ' ', $ec3_htmlspecialchars(stripslashes($safe_title), ENT_QUOTES, get_option('blog_charset'), FALSE)); if (!empty($event)) { if ($this->dayobj->date == substr($event->start, 0, 10)) { $safe_title .= ' @' . ec3_get_start_time(); } else { $safe_title = '...' . $safe_title; } } $this->dayobj->titles[] = $safe_title; // Make a unique <detail> element. if (array_key_exists($id, $this->details)) { return; } $link = get_permalink(); $title = preg_replace('/–/', '-', $title); $title = preg_replace('/’/', '\'', $title); $d = " <detail id=\"pid_{$id}\" title=\"{$title}\" link=\"{$link}\" "; $excerpt = get_the_excerpt(); if (empty($excerpt)) { $d .= " />\n"; } else { $d .= "><excerpt><![CDATA[{$excerpt}]]></excerpt></detail>\n"; } $this->details[$id] = $d; }