[Comoblog-commit] modules/mod_rss2 index.php,NONE,1.1 mod_rss2.php,NONE,1.1 rss2.php,NONE,1.1
Status: Inactive
Brought to you by:
markwallis
|
From: iamdecal <iam...@us...> - 2005-11-28 11:05:51
|
Update of /cvsroot/comoblog/modules/mod_rss2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18402/mod_rss2 Added Files: index.php mod_rss2.php rss2.php Log Message: initial add NOT FOR RELEASE - WORK IN PROGRESS mod_rss2, this is an improved RSS feed mod that also provides a feed for comments as they are posted, it also adds a list of the latest comments to the side bar, to do the latest comments list should be seperate, however if we do that as another module there will be code replicated... i think the lastest comments code should be moved to the core code base, so that it van be used to generate a list for both the lastest comments module and the rss2 module. RSS templates need valdiating - is it worth adding support for ATOM etc? also links to blog lines, newgator my yahoo and the rest. --- NEW FILE: index.php --- --- NEW FILE: rss2.php --- <?php require ('../../include/config.inc.php'); require_once (CFG_BASE_PATH.'/modules/mod_rss2/include/mod_rss2.inc.php'); // RSS VERSION ////////////////////////////////////////////////////// // $rss_version = ''; if (isset($_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'] != '/') $rss_version = substr($_SERVER['PATH_INFO'],1,strlen($_SERVER['PATH_INFO'])-1); // ///////////////////////////////////////////////////////////////////// $blog['title'] = htmlspecialchars(strip_tags(CFG_TITLE)); $blog['link'] = CFG_SITE_URL; $blog['description'] = htmlspecialchars(strip_tags(CFG_INTRO_TEXT)); $blog['language'] = CFG_LANG; $blog['generator'] = 'EasyMoblog '.CFG_VERSION; $blog['logo'] = CFG_SITE_URL.'img/easymoblog/'.CFG_LOGO_IMG; $blog['copyright'] = htmlspecialchars(strip_tags(CFG_RSS2_COPYRIGHT)); switch ($rss_version) { case '1.0': break; case '2.0': break; case 'c1.0': break; case 'c2.0': break; default: die('You must specify a valid rss version'); break; } if (($rss_version =='1.0') or ($rss_version =='2.0')) { $posts = posts_last(CFG_HOWMANY_ITEMS); } else { $posts = comments_last(CFG_HOWMANY_ITEMS); } $tpl = new XTemplate('templates/'.$rss_version.'/rss2.tpl.xml'); $tpl->assign('VERSION', CFG_VERSION); $tpl->assign('BLOG', $blog); if ($posts) { for ($c = 0; $c < count($posts); $c++) { $posts[$c]['post_mail_subject'] = htmlspecialchars(strip_tags($posts[$c]['post_mail_subject'])); $posts[$c]['post_mail_body'] = htmlspecialchars(strip_tags($posts[$c]['post_mail_body'])); #$posts[$c]['post_mail_from'] = htmlspecialchars(strip_tags($posts[$c]['post_mail_from'])); $posts[$c]['post_mail_from'] = "iamdecal"; $post['post_category'] = ''; $tpl->assign('POST', $posts[$c]); if ($rss_version == '1.0') $tpl->parse('main.item'); if ($posts[$c]['post_images'] > 0) { $query = " select img_thumb, concat(img_id,'.',img_extension) as img_name, concat(img_id,'_thumb.',img_extension) as img_thumb_name, img_width, img_height from ".CFG_MYSQL_TABPREFIX."images where post_id = '".$posts[$c]['post_id']."' and img_display = 'attach' "; $res = mysql_query($query); while ($row = mysql_fetch_assoc($res)) { if ($row['img_thumb'] == 'Y') { $tpl->assign('IMAGE', $row); $tpl->parse('main.post.thumb_img'); } else { $tpl->assign('IMAGE', $row); $tpl->parse('main.post.img'); } } } $tpl->parse('main.post'); } } Header ('Content-type: text/xml'); $tpl->parse('main'); $tpl->out('main'); ?> --- NEW FILE: mod_rss2.php --- <?php function comments_last2 ($howmany) { if (CFG_USE_PATH_INFO == 'no') $iisbug = '?'; else $iisbug = ''; $query = "select p.post_mail_subject,p.post_id,c.comment_added as post_mail_date, c.comment_author_email as post_mail_from from easymoblog_posts p , easymoblog_comments c where p.post_id =c.post_id order by comment_id desc limit 0,".$howmany.";"; $res = mysql_query($query); if (!$res || !mysql_num_rows($res)) return (false); $rss = array(); while ($row = mysql_fetch_array($res)) { $row['post_permalink'] = CFG_SITE_URL.'post.php'.$iisbug.'/'.$row['post_id']; #$row['post_permalink'] = CFG_SITE_URL.'post/'.$row['post_id']; $rss[] = $row; } return ($rss); } $mod_contents = ''; $rss = comments_last2(10); $rss_tpl = new XTemplate (CFG_BASE_PATH.'/modules/mod_rss2/templates/rss2.tpl.html'); if ($rss) { for ($c = 0; $c < count($rss); $c++) { $rss[$c]['post_mail_subject'] = htmlspecialchars(strip_tags($rss[$c]['post_mail_subject'])); $rss[$c]['post_mail_from'] = htmlspecialchars(strip_tags($rss[$c]['post_mail_from'])); $rss_tpl->assign('RSS', $rss[$c]); $rss_tpl->parse('main.rss'); } $mod_contents .= $rss_tpl->parse('main'); $mod_contents .= $rss_tpl->text("main"); } else { $mod_contents =""; } ?> |