'iCalendar', 'url' => 'http://robinadr.com/projects/icalendar', 'author' => 'rob1n', 'authorurl' => 'http://robinadr.com/', 'version' => self::VERSION, 'description' => 'Provides an iCalendar feed of events on your blog that you can subscribe to in Google Calendar, iCal, or other calendar software.', 'license' => 'GPL 2.0' ); } public function filter_rewrite_rules( $rules ) { $rules[] = RewriteRule::create_url_rule( '"icalendar"', 'iCalendar', 'calendar' ); return $rules; } public function act( $action ) { switch ( $action ) { case 'calendar' : self::calendar(); break; } } public function calendar() { require_once dirname( __FILE__ ) . '/bennu/bennu.inc.php'; $ical = new iCalendar; $posts = Posts::get( array( 'content_type' => 'entry', 'status' => Post::status( 'published' ), 'nolimit' => true, 'orderby' => 'date ASC' ) ); foreach ( $posts as $post ) { $e = new iCalendar_event; $e->add_property( 'uid', $post->guid ); $e->add_property( 'summary', 'New Post: ' . $post->title ); $e->add_property( 'description', $post->content ); $e->add_property( 'attach', $post->permalink ); $e->add_property( 'dtstart', $post->pubdate ); $e->add_property( 'dtend', $post->pubdate ); $ical->add_component( $e ); unset( $e ); } unset( $posts ); $pages = Posts::get( array( 'content_type' => 'page', 'status' => Post::status( 'published' ), 'nolimit' => true, 'orderby' => 'date ASC' ) ); foreach ( $pages as $post ) { $e = new iCalendar_event; $e->add_property( 'uid', $post->guid ); $e->add_property( 'summary', 'New Page: ' . $post->title ); $e->add_property( 'description', $post->content ); $e->add_property( 'attach', $post->permalink ); $e->add_property( 'dtstart', $post->pubdate ); $e->add_property( 'dtend', $post->pubdate ); $ical->add_component( $e ); unset( $e ); } unset( $pages ); $comments = Comments::get( array( 'status' => Comment::STATUS_APPROVED ) ); foreach ( $comments as $comment ) { $e = new iCalendar_event; $e->add_property( 'summary', 'New Comment on ' . Post::get( array( 'id' => $comemnt->post_id ) ); $e->add_property( 'description', 'Comment by ' . $comment->name . ' (' . $comment->email . ' / ' . $comment->url . ' / ' . $comment->ip . "\n\n" . $comment->content ); $e->add_property( 'attach', $comment->permalink ); $e->add_property( 'dtstart', $comment->pubdate ); $e->add_property( 'dtend', $comment->pubdate ); $ical->add_component( $e ); unset( $e ); } unset( $comments ); ob_clean(); header( 'Content-Type: text/calendar' ); echo $ical->serialize(); } } ?>