Hallo,
danke für deine Antwort :-D, hab jetzt mal nach den SELECT Anweisungen gesucht und die folgenden gefunden:
template-functions.php
[B]/** Generates an array of all 'ec3_Day's between the start of
* begin_month & end_month. Indexed by day_id.
* month_id is in the form: ec3_<year_num>_<month_num> */[/B]
function ec3_util_calendar_days($begin_month_id,$end_month_id)
{
$begin_date=date('Y-m-d 00:00:00',ec3_dayid2php($begin_month_id));
$end_date =date('Y-m-d 00:00:00',ec3_dayid2php($end_month_id));
global $ec3, $wpdb;
[COLOR=Red]$sql=
[/COLOR][COLOR=Red]"SELECT DISTINCT
id,
post_title,
GREATEST(start,'$begin_date') AS start_date,
LEAST(end,'$end_date') AS end_date,
allday,
1 AS is_event
FROM $wpdb->posts,$ec3->schedule
WHERE post_status='publish'
AND post_id=id
AND end>='$begin_date'
AND start<'$end_date'";[/COLOR]
if(!$ec3->show_only_events)
{
[B]// We are interested in normal posts, as well as events.[/B]
[COLOR=Red]$sql="( $sql ) UNION
( SELECT DISTINCT
id,
post_title,
post_date AS start_date,
post_date AS end_date,
0 AS allday,
0 AS is_event
FROM $wpdb->posts
WHERE post_status='publish'
AND post_date>='$begin_date'
AND post_date<'$end_date'
AND post_date<NOW()
)";[/COLOR]
}
$sql.=' ORDER BY id, allday DESC, start_date, is_event DESC';
$calendar_entries = $wpdb->get_results($sql);
$calendar_days = array(); // result
if(!$calendar_entries)
return $calendar_days;
$current_post_id=0;
$current_day_id ='';
$time_format=get_settings('time_format');
$allday=str_replace(' ',' ',__('all day','ec3')); // #160==nbsp
foreach($calendar_entries as $ent)
{
if($current_post_id!=$ent->id)
{
$current_post_id=$ent->id;
$current_day_id='';
}
$date=ec3_mysql2date($ent->start_date);
$end_date=ec3_mysql2date($ent->end_date);
while(true)
{
$day_id=$date->day_id();
if($current_day_id==$day_id)
break;
$current_day_id=$day_id;
if(empty($calendar_days[$day_id]))
$calendar_days[$day_id] = new ec3_Day();
if($ent->allday)
$time=$allday;
else
$time=mysql2date($time_format,$ent->start_date);
//?? Should only record start time on FIRST day.
$calendar_days[$day_id]->add_post($ent->post_title,$time,$ent->is_event);
if($date->to_unixdate()==$end_date->to_unixdate())
break;
$date->increment_day();
}
}
return $calendar_days;
}
Alles anzeigen
template-functions.php
[B]// Find the upcoming events.[/B]
[COLOR=Red]$calendar_entries = $wpdb->get_results(
"SELECT DISTINCT
p.id AS id,
post_title,
start,
u.$ec3->wp_user_nicename AS author,
allday
FROM $ec3->schedule s
LEFT JOIN $wpdb->posts p ON s.post_id=p.id
LEFT JOIN $wpdb->users u ON p.post_author = u.id
WHERE p.post_status='publish'
AND end>='$ec3->today' $and_before
ORDER BY start $limit_numposts"
);[/COLOR]
echo "<!-- Generated by Event Calendar v$ec3->version -->\n";
if($calendar_entries)
{
$time_format=get_settings('time_format');
$current_month=false;
$current_date=false;
$data=array();
foreach($calendar_entries as $entry)
{
[B]// To use %SINCE%, you need Dunstan's 'Time Since' plugin.[/B]
if(function_exists('time_since'))
$data['SINCE']=time_since( time(), ec3_to_time($entry->start) );
[B]// Month changed?[/B]
$data['MONTH']=mysql2date($month_format,$entry->start);
if((!$current_month || $current_month!=$data['MONTH']) && $template_month)
{
if($current_date)
echo "</li>\n";
if($current_month)
echo "</li>\n";
echo "<li class='ec3_list ec3_list_month'>"
. ec3_format_str($template_month,$data)."\n<ul>\n";
$current_month=$data['MONTH'];
$current_date=false;
}
[B]// Date changed?[/B]
$data['DATE'] =mysql2date($date_format, $entry->start);
if((!$current_date || $current_date!=$data['DATE']) && $template_day)
{
if($current_date)
echo "</ul></li>\n";
echo "<li class='ec3_list ec3_list_day'>"
. ec3_format_str($template_day,$data)."\n<ul>\n";
$current_date=$data['DATE'];
}
if($entry->allday)
$data['TIME']=__('all day','ec3');
else
$data['TIME']=mysql2date($time_format,$entry->start);
$data['TITLE'] =$entry->post_title;
$data['LINK'] =get_permalink($entry->id);
$data['AUTHOR']=$entry->author;
echo " <li>".ec3_format_str($template_event,$data)."</li>\n";
}
if($current_date)
echo "</ul></li>\n";
if($current_month)
echo "</ul></li>\n";
}
else
{
echo "<li>".__('No events.','ec3')."</li>\n";
}
echo "</ul>\n";
}
define('EC3_DEFAULT_FORMAT_SINGLE','<tr><td colspan="3">%s</td></tr>');
define('EC3_DEFAULT_FORMAT_RANGE','<tr><td class="ec3_start">%1$s</td>'
. '<td class="ec3_to">%3$s</td><td class="ec3_end">%2$s</td></tr>');
define('EC3_DEFAULT_FORMAT_WRAPPER','<table class="ec3_schedule">%s</table>');
Alles anzeigen
date.php
[B]/** Utility function. Calculates the value of month/year for the current
* page. Code block from wp-includes/template-functions-general.php
* (get_calendar function). */[/B]
function from_date()
{
global
$m,
$monthnum,
$wpdb,
$year;
if (isset($_GET['w'])) {
$w = ''.intval($_GET['w']);
}
[B]// Let's figure out when we are[/B]
if (!empty($monthnum) && !empty($year)) {
$thismonth = ''.zeroise(intval($monthnum), 2);
$thisyear = ''.intval($year);
} elseif (!empty($w)) {
[B]// We need to get the month from MySQL[/B]
$thisyear = ''.intval(substr($m, 0, 4));
$d = (($w - 1) * 7) + 6; [B]//it seems MySQL's weeks disagree with PHP's[/B]
$thismonth = $wpdb->get_var[COLOR=Red]("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')");[/COLOR]
} elseif (!empty($m)) {
[B] // $calendar = substr($m, 0, 6);[/B]
$thisyear = ''.intval(substr($m, 0, 4));
if (strlen($m) < 6) {
$thismonth = '01';
} else {
$thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2);
}
} else {
$thisyear=ec3_strftime("%Y");
$thismonth=ec3_strftime("%m");
}
$this->year_num =intval($thisyear);
$this->month_num=intval($thismonth);
$this->day_num =1;
}
Alles anzeigen
eventcalendar3.php
[B]/** Read the schedule table for the posts, and add an ec3_schedule array
* to each post. */[/B]
function ec3_filter_the_posts($posts)
{
if('array'!=gettype($posts) || 0==count($posts))
return $posts;
$post_ids=array();
// Can't use foreach, because it gets *copies* (in PHP<5)
for($i=0; $i<count($posts); $i++)
{
$post_ids[]=intval($posts[$i]->ID);
$posts[$i]->ec3_schedule=array();
}
global $ec3,$wp_query,$wpdb;
$schedule=$wpdb->get_results(
[COLOR=Red]"SELECT post_id,start,end,allday,rpt,IF(end>='$ec3->today',1,0) AS active
FROM $ec3->schedule
WHERE post_id IN (".implode(',',$post_ids).")
ORDER BY start"[/COLOR]
);
[B]// Flip $post_ids so that it maps post ID to position in the $posts array.[/B]
$post_ids=array_flip($post_ids);
if($post_ids && $schedule)
foreach($schedule as $s)
{
$i=$post_ids[$s->post_id];
$posts[$i]->ec3_schedule[]=$s;
}
return $posts;
}
function ec3_action_wp_head()
{
global $ec3,$month,$month_abbrev;
?>
Alles anzeigen