Dotclear

source: plugins/multiBlogFeeds/_public.php @ 763

Revision 763, 3.4 KB checked in by johan, 15 years ago (diff)

Add new plugin multiBlogFeeds (url feed of posts or comment for multiblog).

Line 
1<?php
2if (!defined('DC_RC_PATH')) { return; }
3
4header('Content-Type: application/rss+xml');
5
6$core->url->register('multiBlogFeedPosts','multiBlogFeedPosts','^multiBlogFeedPosts$',array('RssPostURL','multiBlogFeedPosts'));
7$core->url->register('multiBlogFeedComments','multiBlogFeedComments','^multiBlogFeedComments$',array('RssCommentURL','multiBlogFeedComments'));
8
9
10class RssPostURL extends dcUrlHandlers
11{
12        public static function multiBlogFeedPosts($args)
13        {
14                AfficheEntete("Nouveaux billets");
15                ListNewPosts($core);
16                AfficheBas();
17        }
18}
19class RssCommentURL extends dcUrlHandlers
20{
21        public static function multiBlogFeedComments($args)
22        {
23                AfficheEntete("Nouveaux commentaires");
24                ListNewComments($core);
25                AfficheBas();
26        }
27}
28
29
30function ListNewPosts($core)
31{
32      $query = "SELECT post_url, post_title, post_content, post_dt , blog_url FROM ".DC_DBPREFIX."post as post,".DC_DBPREFIX."blog as blog  WHERE post.blog_id=blog.blog_id AND post_status = 1 AND post_type = 'post' ORDER BY post_dt DESC LIMIT 50";
33      //echo $query;
34      global $core;
35      $res_post = $core->con->select($query);
36      while ($res_post->fetch())
37      {
38          $blog_url = $res_post->f('blog_url');
39          $post_url = $blog_url.'post/'.$res_post->f('post_url');
40        echo '<item>';
41        echo '<title>'.$res_post->f('post_title').'</title>';
42        echo '<link>'.$post_url.'</link>';
43        echo '<pubDate>'.$res_post->f('post_dt').'</pubDate>';
44        echo '<description>'.html::absoluteURLs(html::escapeHTML($res_post->f('post_content')),$core->blog->url).'</description>';
45        echo '</item>';
46      }
47}
48
49function ListNewComments($core)
50{
51      $query = "SELECT post_url, post_title, comment_content, comment_dt , blog_url FROM ".DC_DBPREFIX."comment as comment,".DC_DBPREFIX."post as post,".DC_DBPREFIX."blog as blog  WHERE post.post_id=comment.post_id AND post.blog_id=blog.blog_id AND comment_status = 1 ORDER BY comment_dt DESC LIMIT 50";
52      global $core;
53      $res_post = $core->con->select($query);
54      while ($res_post->fetch())
55      {
56          $blog_url = $res_post->f('blog_url');
57          $post_url = $blog_url.'post/'.$res_post->f('post_url');
58        echo '<item>';
59        echo '<title>'.$res_post->f('post_title').'</title>';
60        echo '<link>'.$post_url.'</link>';
61        echo '<pubDate>'.$res_post->f('comment_dt').'</pubDate>';
62        echo '<description>'.html::absoluteURLs(html::escapeHTML($res_post->f('comment_content')),$core->blog->url).'</description>';
63        echo '</item>';
64      }
65}
66
67function AfficheEntete($type)
68{
69     global $core;
70  echo '<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="'.$core->blog->url.'feed/rss2/xslt" ?><rss version="2.0"
71  xmlns:dc="http://purl.org/dc/elements/1.1/"
72  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
73  xmlns:content="http://purl.org/rss/1.0/modules/content/">
74  <channel>
75  <title>Feed - '.$type.' - '.$core->blog->name.'</title>
76  <link>'.$core->blog->url.'</link>
77  <description>'.html::escapeHTML($core->blog->desc).'</description>
78  <language>fr</language>
79  <pubDate>'.date('D, j F Y H:i:s').'</pubDate>
80  <generator>Dotclear</generator>';
81 }
82
83function AfficheBas()
84{
85echo '</channel>
86</rss>';
87}
88?>
Note: See TracBrowser for help on using the repository browser.

Sites map