1
wishcraft
#Comments #RSS #Feed for XOOPS

Put the following code in a file called something like comments.php in your XOOPS_ROOT_PATH where backend.php is featured and it will add a feed to your site for comments to import into twitter etc.

<?php
/**
 * XOOPS feed creator
 *
 * You may not change or alter any portion of this comment or credits
 * of supporting developers from this source code or any supporting source code
 * which is considered copyrighted (c) material of the original comment or credit authors.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @copyright       The XOOPS Project http://sourceforge.net/projects/xoops/
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
 * @since           2.0.0
 * @version         $Id: backend.php 4941 2010-07-22 17:13:36Z beckmi $
 */
 
include dirname(__FILE__) . DIRECTORY_SEPARATOR 'mainfile.php';

$GLOBALS['xoopsLogger']->activated false;
if (
function_exists('mb_http_output')) {
    
mb_http_output('pass');
}
header('Content-Type:text/xml; charset=utf-8');

include_once 
$GLOBALS['xoops']->path('class/template.php');
$tpl = new XoopsTpl();
$tpl->xoops_setCaching(2);
$tpl->xoops_setCacheTime(3600);
if (!
$tpl->is_cached('db:system_rss.html')) {
    
xoops_load('XoopsLocal');
    
$tpl->assign('channel_title'XoopsLocal::convert_encoding(htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES)));
    
$tpl->assign('channel_link'XOOPS_URL '/');
    
$tpl->assign('channel_desc'XoopsLocal::convert_encoding(htmlspecialchars($xoopsConfig['slogan'], ENT_QUOTES)));
    
$tpl->assign('channel_lastbuild'formatTimestamp(time(), 'rss'));
    
$tpl->assign('channel_webmaster'checkEmail($xoopsConfig['adminmail'], true));
    
$tpl->assign('channel_editor'checkEmail($xoopsConfig['adminmail'], true));
    
$tpl->assign('channel_category''News');
    
$tpl->assign('channel_generator''XOOPS');
    
$tpl->assign('channel_language'_LANGCODE);
    
$tpl->assign('image_url'XOOPS_URL '/images/logo.png');
    
$dimention getimagesize(XOOPS_ROOT_PATH '/images/logo.png');
    if (empty(
$dimention[0])) {
        
$width 88;
    } else {
        
$width = ($dimention[0] > 144) ? 144 $dimention[0];
    }
    if (empty(
$dimention[1])) {
        
$height 31;
    } else {
        
$height = ($dimention[1] > 400) ? 400 $dimention[1];
    }
    
$tpl->assign('image_width'$width);
    
$tpl->assign('image_height'$height);
    
    
$comments_handler xoops_gethandler('comment');
    
$criteria = new CriteriaCompo(new Criteria('com_status'2));
    if (isset(
$_REQUEST['modid'])&&is_numeric($_REQUEST['modid']))
        
$criteria->add(new Criteria('`com_modid`'intval($_REQUEST['modid'])));
    if (isset(
$_REQUEST['uid'])&&is_numeric($_REQUEST['uid']))
        
$criteria->add(new Criteria('`com_uid`'intval($_REQUEST['uid'])));
    
$criteria->setLimit(((isset($_REQUEST['num'])&&is_numeric($_REQUEST['num'])&&intval($_REQUEST['num'])>0)?intval($_REQUEST['num']):10));
    
$criteria->setSort('`com_created`');
    
$criteria->setOrder('DESC');
    
    
$module_handler xoops_gethandler('module');
    
$comments $comments_handler->getObjects($criteria);
    if (!empty(
$comments) && is_array($comments)) {
        
$myts =& MyTextSanitizer::getInstance();
        foreach (
$comments as $comment) {
            
$xoModule $module_handler->get($comment->getVar('com_modid'));
            
$comment_config $xoModule->getInfo('comments'); 
            
$tpl->append('items', array(
                
'title' => XoopsLocal::convert_encoding(htmlspecialchars($comment->getVar('com_title'), ENT_QUOTES)) ,
                
'link' => htmlspecialchars(XOOPS_URL '/modules/'.$xoModule->getVar('dirname').'/'.$comment_config['pageName'].'?'.$comment_config['itemName'].'='.$comment->getVar('com_itemid').'&com_id='.$comment->getVar('com_id').'&com_rootid='.$comment->getVar('com_rootid').'&com_mode='.$GLOBALS['xoopsConfig']['com_mode'].'&com_order=0'.(strlen($comment->getVar('com_exparams'))>0?'&'.$comment->getVar('com_exparams'):'').'#comment'.$comment->getVar('com_id')),
                
'guid' => htmlspecialchars(XOOPS_URL '/modules/'.$xoModule->getVar('dirname').'/'.$comment_config['pageName'].'?'.$comment_config['itemName'].'='.$comment->getVar('com_itemid').'&com_id='.$comment->getVar('com_id').'&com_rootid='.$comment->getVar('com_rootid').'&com_mode='.$GLOBALS['xoopsConfig']['com_mode'].'&com_order=0'.(strlen($comment->getVar('com_exparams'))>0?'&'.$comment->getVar('com_exparams'):'').'#comment'.$comment->getVar('com_id')),
                
'category' => XoopsLocal::convert_encoding(htmlspecialchars($xoModule->getVar('name'))) ,
                
'pubdate' => formatTimestamp($comment->getVar('com_created'), 'rss') ,
                
'description' => XoopsLocal::convert_encoding(htmlspecialchars($myts->displayTarea($comment->getVar('com_text'), $comment->getVar('dohtml'), $comment->getVar('dosmiley'), $comment->getVar('doxcode'), $comment->getVar('doimage'), $comment->getVar('dobr')), ENT_QUOTES))));
        }
    }
}
$tpl->display('db:system_rss.html');
?>

* Code Final Edited 10/04/2011 6:25:20 AEST
Resized Image
www.ohloh.net/accounts/226400

Follow, Like & Read:-

twitter.com/RegaltyFamily
github.com/Chronolabs-Cooperative
facebook.com/DrAntonyRoberts

2
wishcraft
Re: #Comments #RSS #Feed for XOOPS

By including the following function, you can customise the code for sending a twitter explicit RSS Feed Title so the words longer than xxx are and have a hash placed in front of them for twitters RSS Aggregation

function xoopsTweetString($title$doit=false$wordlen=4) {
    if (
$doit==true) {
        
$title_array explode(' '$title);
        
$title '';
        foreach(
$title_array as $item) {
            if (
strlen($item)>$wordlen
                
$title .= ' #'.$item;
            else 
                
$title .= ' '.$item;
        }
    }
    return 
trim($title);
}


The RSS Code with this included would look like:

<?php
/**
 * XOOPS feed creator
 *
 * You may not change or alter any portion of this comment or credits
 * of supporting developers from this source code or any supporting source code
 * which is considered copyrighted (c) material of the original comment or credit authors.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @copyright       The XOOPS Project http://sourceforge.net/projects/xoops/
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
 * @since           2.0.0
 * @version         $Id: backend.php 4941 2010-07-22 17:13:36Z beckmi $
 */
if (!function_exists('xoopsTweetString')) {
    function 
xoopsTweetString($title$doit=false$wordlen=4) {
        if (
$doit==true) {
            
$title_array explode(' '$title);
            
$title '';
            foreach(
$title_array as $item) {
                if (
strlen($item)>$wordlen
                    
$title .= ' #'.$item;
                else 
                    
$title .= ' '.$item;
            }
        }
        return 
trim($title);
    }
}

include 
dirname(__FILE__) . DIRECTORY_SEPARATOR 'mainfile.php';

$GLOBALS['xoopsLogger']->activated false;
if (
function_exists('mb_http_output')) {
    
mb_http_output('pass');
}
header('Content-Type:text/xml; charset=utf-8');

include_once 
$GLOBALS['xoops']->path('class/template.php');
$tpl = new XoopsTpl();
$tpl->xoops_setCaching(2);
$tpl->xoops_setCacheTime(3600);
if (!
$tpl->is_cached('db:system_rss.html')) {
    
xoops_load('XoopsLocal');
    
$tpl->assign('channel_title'XoopsLocal::convert_encoding(htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES)));
    
$tpl->assign('channel_link'XOOPS_URL '/');
    
$tpl->assign('channel_desc'XoopsLocal::convert_encoding(htmlspecialchars($xoopsConfig['slogan'], ENT_QUOTES)));
    
$tpl->assign('channel_lastbuild'formatTimestamp(time(), 'rss'));
    
$tpl->assign('channel_webmaster'checkEmail($xoopsConfig['adminmail'], true));
    
$tpl->assign('channel_editor'checkEmail($xoopsConfig['adminmail'], true));
    
$tpl->assign('channel_category''News');
    
$tpl->assign('channel_generator''XOOPS');
    
$tpl->assign('channel_language'_LANGCODE);
    
$tpl->assign('image_url'XOOPS_URL '/images/logo.png');
    
$dimention getimagesize(XOOPS_ROOT_PATH '/images/logo.png');
    if (empty(
$dimention[0])) {
        
$width 88;
    } else {
        
$width = ($dimention[0] > 144) ? 144 $dimention[0];
    }
    if (empty(
$dimention[1])) {
        
$height 31;
    } else {
        
$height = ($dimention[1] > 400) ? 400 $dimention[1];
    }
    
$tpl->assign('image_width'$width);
    
$tpl->assign('image_height'$height);
    
    
$comments_handler xoops_gethandler('comment');
    
$criteria = new CriteriaCompo(new Criteria('com_status'2));
    if (isset(
$_REQUEST['modid'])&&is_numeric($_REQUEST['modid']))
        
$criteria->add(new Criteria('`com_modid`'intval($_REQUEST['modid'])));
    if (isset(
$_REQUEST['uid'])&&is_numeric($_REQUEST['uid']))
        
$criteria->add(new Criteria('`com_uid`'intval($_REQUEST['uid'])));
    
$criteria->setLimit(((isset($_REQUEST['num'])&&is_numeric($_REQUEST['num'])&&intval($_REQUEST['num'])>0)?intval($_REQUEST['num']):10));
    
$criteria->setSort('`com_created`');
    
$criteria->setOrder('DESC');
    
    
$module_handler xoops_gethandler('module');
    
$comments $comments_handler->getObjects($criteria);
    if (!empty(
$comments) && is_array($comments)) {
        
$myts =& MyTextSanitizer::getInstance();
        foreach (
$comments as $comment) {
            
$xoModule $module_handler->get($comment->getVar('com_modid'));
            
$comment_config $xoModule->getInfo('comments'); 
            
$tpl->append('items', array(
                
'title' => XoopsLocal::convert_encoding(htmlspecialchars(xoopsTweetString($comment->getVar('com_title'), isset($_REQUEST['tweet']), ((isset($_REQUEST['tweetlen'])&&is_numeric($_REQUEST['tweetlen'])&&intval($_REQUEST['tweetlen'])>0)?intval($_REQUEST['tweetlen']):4)), ENT_QUOTES)) ,
                
'link' => htmlspecialchars(XOOPS_URL '/modules/'.$xoModule->getVar('dirname').'/'.$comment_config['pageName'].'?'.$comment_config['itemName'].'='.$comment->getVar('com_itemid').'&com_id='.$comment->getVar('com_id').'&com_rootid='.$comment->getVar('com_rootid').'&com_mode='.$GLOBALS['xoopsConfig']['com_mode'].'&com_order=0'.(strlen($comment->getVar('com_exparams'))>0?'&'.$comment->getVar('com_exparams'):'').'#comment'.$comment->getVar('com_id')),
                
'guid' => htmlspecialchars(XOOPS_URL '/modules/'.$xoModule->getVar('dirname').'/'.$comment_config['pageName'].'?'.$comment_config['itemName'].'='.$comment->getVar('com_itemid').'&com_id='.$comment->getVar('com_id').'&com_rootid='.$comment->getVar('com_rootid').'&com_mode='.$GLOBALS['xoopsConfig']['com_mode'].'&com_order=0'.(strlen($comment->getVar('com_exparams'))>0?'&'.$comment->getVar('com_exparams'):'').'#comment'.$comment->getVar('com_id')),
                
'category' => XoopsLocal::convert_encoding(htmlspecialchars($xoModule->getVar('name'))) ,
                
'pubdate' => formatTimestamp($comment->getVar('com_created'), 'rss') ,
                
'description' => XoopsLocal::convert_encoding(htmlspecialchars($myts->displayTarea($comment->getVar('com_text'), $comment->getVar('dohtml'), $comment->getVar('dosmiley'), $comment->getVar('doxcode'), $comment->getVar('doimage'), $comment->getVar('dobr')), ENT_QUOTES))));
        }
    }
}
$tpl->display('db:system_rss.html');
?>


To Turn this on you would dohttp://yoursite.com/comments.php?tweet=1
Resized Image
www.ohloh.net/accounts/226400

Follow, Like & Read:-

twitter.com/RegaltyFamily
github.com/Chronolabs-Cooperative
facebook.com/DrAntonyRoberts

3
wishcraft
Re: #Comments #RSS #Feed for XOOPS

Paul from Stop forum spam was amused by this it is a comments rss feed @ xortifyhttp://xortify.chronolabs.coop/comments.php?tweet=1 in tweet mode
Resized Image
www.ohloh.net/accounts/226400

Follow, Like & Read:-

twitter.com/RegaltyFamily
github.com/Chronolabs-Cooperative
facebook.com/DrAntonyRoberts

4
timgno
Re: #Comments #RSS #Feed for XOOPS
  • 2011/4/13 8:38

  • timgno

  • Module Developer

  • Posts: 1504

  • Since: 2007/6/21


thanks simon

a suggestion ... would be a better name backcoms.php?

Login

Who's Online

186 user(s) are online (122 user(s) are browsing Support Forums)


Members: 0


Guests: 186


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits