[EventCalendar] Problem with archive order, and a Google Calendar request

Dr. Peter Troxler peter.troxler at gmx.net
Fri Sep 21 15:29:34 UTC 2007


On 19-sep-2007, at 12:16, Lorenzo De Tomasi wrote:

>> Secondly, is it possible to have links to add individual events to
>> Google Calendar, 30Boxes, etc? This would be really, really useful!

A nice idea ... implemented it on <http://www.scope34.org>

I made some major modifications to the file eventcalendar3.php (the  
function ec3_filter_query_vars_ical) and modify the  
template_functions.php

the schedule includes the link with the icon pointing to the ical  
file of the event, e.g. <http://www.scope34.org/?ec3_ical&id=82> (I  
am passing the post-ID as a parameter there)

this could be something like (around line 518, look for the return  
sprintf($format_wrapper,$result); statement
   // iCalendar link.
   $webcal=get_settings('home') . "/?ec3_ical&id=" . $post->ID;
   // Macintosh always understands webcal:// protocol.
   // It's hard to guess on other platforms, so stick to http://
   if(strstr($_SERVER['HTTP_USER_AGENT'],'Mac OS X'))
       $webcal=preg_replace('/^http:/','webcal:',$webcal);
   $ec3_export_button = "\t<a id='ec3_publish' href='$webcal'"
      . " title='" . __('Subscribe to iCalendar.','ec3') ."'>\n"
      . "\t     <img src='$ec3->myfiles/publish.gif' alt='iCalendar' / 
 >\n"
      . "\t    </a>\n";
	
   return sprintf($format_wrapper,$result) . $ec3_export_button;


the ec3_filter_query_vars_ical function reads this id parameter into  
an array and extends the WHERE part of the sql query with an AND  
p.id= ... clause

so the first part of my ec3_filter_query_vars_ical reads now (from  
about line 335)
function ec3_filter_query_vars_ical()
{
   // check if we get id parameters in the query
   $posts_ids=explode(',',$_GET['id']);
   if ( strlen($posts_ids[0]) > 0) {
		$post_id_query = " AND (p.id=" . implode(" OR p.id=", $posts_ids) .  
")";
	}
   $wpvarstoreset=NULL;

	//
   // Generate the iCalendar

   $name=preg_replace('/([\\,;])/','\\\\$1',get_bloginfo_rss('name'));
   $filename=preg_replace('/[^0-9a-zA-Z]/','',$name).'.ics';

   header("Content-Type: text/calendar");
   header("Content-Disposition: inline; filename=$filename");
   header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');
   header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
   header('Cache-Control: no-cache, must-revalidate, max-age=0');
   header('Pragma: no-cache');

	echo "BEGIN:VCALENDAR\r\n";
   echo "VERSION:2.0\r\n";
   echo "X-WR-CALNAME:$name\r\n";


   global $ec3,$wpdb;

	$calendar_entries = $wpdb->get_results(
     "SELECT
          post_id,
          sched_id,
          post_title,
          post_excerpt,
          DATE_FORMAT(start,IF(allday,'%Y%m%d','%Y-%m-%d %H:%i')) AS  
dt_start,
          IF( allday,
              DATE_FORMAT(DATE_ADD(end, INTERVAL 1 DAY),'%Y%m%d'),
              DATE_FORMAT(end,'%Y-%m-%d %H:%i')
            ) AS dt_end,
          $ec3->wp_user_nicename AS user_nicename,
          IF(allday,'TRANSPARENT','OPAQUE') AS transp,
          allday
        FROM $wpdb->posts p
        LEFT  JOIN $wpdb->users   u ON p.post_author=u.ID
        INNER JOIN $ec3->schedule s ON p.id=s.post_id
        WHERE post_status='publish' " . $post_id_query . "
        ORDER BY start"
   );


the rest of the file remains unchanged

diff files attached (hope they come through, otherwise available on  
request)

/ pt


>
> One way is to create a microformat hcalendar xhtml template for the
> post and to use Mozilla Operator add on to send it to your preferred
> calendar.
> This is a technical issue: I'm trying to modify the plugin to do this…
> -- 
> Lorenzo De Tomasi
> Designer multimodale
> http://www.ipernico.it
> http://www.isotype.org (in costruzione)
>
> _______________________________________________
> Blog: http://wpcal.firetree.net/
> EventCalendar at firetree.net mailing list
> Unsubscribe: http://penguin.firetree.net/eventcalendar

-------------- next part --------------
A non-text attachment was scrubbed...
Name: eventcalendar3.diff
Type: application/octet-stream
Size: 2177 bytes
Desc: not available
Url : http://penguin.firetree.net/pipermail/eventcalendar/attachments/20070921/8e48ca95/eventcalendar3.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: template-functions.diff
Type: application/octet-stream
Size: 1027 bytes
Desc: not available
Url : http://penguin.firetree.net/pipermail/eventcalendar/attachments/20070921/8e48ca95/template-functions.obj


More information about the EventCalendar mailing list