1
playsome
Article module - begging for help
  • 2009/9/8 17:10

  • playsome

  • Not too shy to talk

  • Posts: 197

  • Since: 2009/4/15


Hello,

I have been working on my site for a while now, I have already posted about the article module (2.00RC) as have alot of people. I have managed to use it in my site and it is a great module for news especially i think for a gaming site.

I have already made several template modifications to get it looking nice, as I come closer to launching my site I have just a couple of probs.

the RSS feed for the module (for the index page) seems to only show the very first 10 articles I posted, RSS feeds per category seem to work fine so I am looking for a bit of help trying to fix this problem if possible.

This is not related to the article module but I was also wondering if anyone knows how to get the short URLs hack working with the xml page?

Finally one more request - it would be awesome if a developer could take a look at this module and try and fix some of the bigger problems with it, not just for me but for the community, it really is too good a module to be left to die. I have opened up my site so you can see what ive donw with the templates and how well the module works for my site (barring the bugs) www.playsome.co.uk/news/.

you can view the xml.php file here and if any developer wants to take a look at the module to fix it youc an download it here.

I hope someone can help.

2
sailjapan
Re: Article module - begging for help

Thank you very much for sharing!
I too wish this mod hadn't been abandoned, it looked to have so much potential, but I just couldn't get my head around all the bugs.

If there's a mod developer out there who's looking for a worthwhile project, I'd highly recommend looking at this one!

3
playsome
Re: Article module + short URL on xml - begging for help
  • 2009/9/9 16:47

  • playsome

  • Not too shy to talk

  • Posts: 197

  • Since: 2009/4/15


Hey,

I am still needing a bit of help with the xml.php and URLrewrite here is my problem.

I want to use feedburner for the rss feeds for articles on a per category basis, since the category rss works fine (rss for the index page shows old articles), however when viewing the xml file it still shows the old url's i.e it shows the /modules/ part.

Is there a way to include smarty into the xml file so that it will show the shortened URL's which where created by the xoReWriteModules hack? My only reason for wanting to do this is because if google indexes my feedburner page or xml page then there could be the same content on google but under 2 different URL's and google may penalize me for duplicate content.

I know you can create XML files with smarty but thats about it, I dont have a great deal of money but I could paypal someone $10 if the could fix this problem.

Cheers.

4
Mamba
Re: Article module + short URL on xml - begging for help
  • 2009/9/9 21:05

  • Mamba

  • Moderator

  • Posts: 11366

  • Since: 2004/4/23


You did a very nice job with your Website!!! Congratulations!!!

I wish, we could create a team around Article - it is a very good module, and worth of maintaining it. Your changes and contributions are definitely appreciated!!!!

Anybody else who would like to contribute?

5
playsome
Re: Article module + short URL on xml - begging for help
  • 2009/9/10 18:11

  • playsome

  • Not too shy to talk

  • Posts: 197

  • Since: 2009/4/15


Hi,

Thanks Mamba I appreciate your kind comments about my site.

With regards to the xml.php file showing the old url's I have almost fixed it, I think.

This is probably a very dirty way of doing it but as my php knowledge is very limited this is all I could think, basically I had to hard code the shortened URL into the xml.php file like this:

I replaced all link code, for example I changed this:
"link"            => XOOPS_URL "/modules/" $GLOBALS["artdirname"] . "/view.article.php" URL_DELIMITER $article_obj->getVar("art_id") . "/c" $category_id,


into this:
"link"            => XOOPS_URL "/news/" "/view.article.php" URL_DELIMITER $article_obj->getVar("art_id") . "/c" $category_id,


It now shows the shortened url in the xml.php file as you can see here

There is however a small problem, there is an extra / in the URL, this does not cause a problem but I would like it removed, I think it has to do with URL_DELIMITER but when i removed this part it messed up the link.

I have uploaded the code from xml.php into a text file if someone could take a look at it and hopefully fix this problem. Youc an view the text file here

Thanks

6
ghia
Re: Article module - begging for help
  • 2009/9/10 18:37

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Your double slash comes from:
"/news/" "/view.article.php"

It should be:
"/news/view.article.php"


7
playsome
Re: Article module - begging for help
  • 2009/9/10 19:12

  • playsome

  • Not too shy to talk

  • Posts: 197

  • Since: 2009/4/15


Hi Ghia,

thanks for your help this has worked, but I think ive missed something but I have looked and cant find what ive missed.

The extra / is now gone from the URL in links on the index rss here but it remains on the image link.

The extra / is still present on the URL links on the category RSS here and also on the image link.

Here is the code for xml.php:
<?php
/**
 * Article module for XOOPS
 *
 * 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         http://www.fsf.org/copyleft/gpl.html GNU public license
 * @package         article
 * @since           1.0
 * @author          Taiwen Jiang <phppp@users.sourceforge.net>
 * @version         $Id: xml.php 2283 2008-10-12 03:36:13Z phppp $
 */
 
ob_start();
include 
"header.php";
error_reporting(0);
$xoopsLogger->activated false;

if (
art_parse_args($args_num$args$args_str)) {
    
$args["article"] = !empty($args["article"]) ? $args["article"] : @$args_num[0];
    
$args["type"] = @$args_str[0];
}

$article_id intval( empty($_GET["article"]) ? @$args["article"] : $_GET["article"] );
$category_id intval( empty($_GET["category"]) ? @$args["category"] : $_GET["category"] );
$page intval( empty($_GET["page"]) ? @$args["page"] : $_GET["page"] );
$uid intval( empty($_GET["uid"]) ? @$args["uid"] : $_GET["uid"] );
$type = empty($_GET["type"]) ? (empty($_GET["op"]) ? @$args["type"] : $_GET["op"]) : $_GET["type"];
$type strtoupper($type);

$category_handler =& xoops_getmodulehandler("category"$GLOBALS["artdirname"]);
$article_handler =& xoops_getmodulehandler("article"$GLOBALS["artdirname"]);
$article_obj =& $article_handler->get($article_id);
if (
$article_id 0) {
    
$criteria = new CriteriaCompo(new Criteria("ac.ac_publish"0">"));
    
$categories_obj =& $category_handler->getByArticle($article_id$criteria);
    if (
count($categories_obj) ==|| !in_array($category_idarray_keys($categories_obj))) $category_id=0;
    unset(
$categories_obj);
    
$category_id = empty($category_id)?$article_obj->getVar("cat_id"):$category_id;
}

$category_obj =& $category_handler->get($category_id);

$_uid = empty($xoopsUser) ? $xoopsUser->getVar("uid");
$isAuthor = ( $article_obj->isNew() || $_uid == $article_obj->getVar("uid") );
$isAdmin $category_handler->getPermission($category_obj"moderate");

if (
$isAuthor || ($isAdmin && $article_handler->getCategoryStatus($category_id$article_id) !== NULL)) {
} elseif (
    empty(
$category_id)
    || !
$category_handler->getPermission($category_obj"view")
    || !
$article_obj->getVar("art_time_publish")
    ){
    
art_trackback_response(1art_constant("MD_NOACCESS"));
}

if (
$type == "RDF"$type "RSS1.0";
if (
$type == "RSS"$type "RSS0.91";

$valid_format = array("RSS0.91""RSS1.0""RSS2.0""PIE0.1""MBOX""OPML""ATOM""ATOM0.3""HTML""JS");
if (empty(
$type) || !in_array($type$valid_format)) {
    
$type "RSS";
}

if (
$article_id 0) {
    
$myuid = empty($xoopsUser) ? $xoopsUser->getVar("uid");
    
$isAuthor = ($article_obj->isNew() || $myuid == $article_obj->getVar("uid"));
    
$isAdmin $category_handler->getPermission($category_obj"moderate");
    
    if (
$isAuthor || ($isAdmin && $article_handler->getCategoryStatus($category_id$article_id)!==NULL)){
    } elseif (
        empty(
$category_id)
        || !
$category_handler->getPermission($category_obj"view")
        || !
$article_obj->getVar("art_time_publish")
        ){
        
art_trackback_response(1art_constant("MD_NOACCESS"));
    }
}
$xml_charset = empty($xoopsModuleConfig["do_rssutf8"]) ? _CHARSET "UTF-8";

include_once 
XOOPS_ROOT_PATH '/class/template.php';

$tpl = new XoopsTpl();
$tpl->caching 2;
$tpl->cache_lifetime 3600;
load_functions("cache");
$xoopsCachedTemplateId md5mod_generateCacheId() . str_replaceXOOPS_URL''$_SERVER['REQUEST_URI'] ) );
if (!
$tpl->is_cached('db:system_dummy.html'$xoopsCachedTemplateId)) {
    if (!empty(
$article_id)) $source "article";
    elseif (!empty(
$category_id)) $source "category";
    elseif (!empty(
$uid)) $source "author";
    else 
$source "index";
    
    
$items = array();

    switch (
$source) {
        case 
"article":
            
$category_id = empty($category_id)?$article_obj->getVar("cat_id"):$category_id;
            
$category_obj =& $category_handler->get($category_id);
    
            if (empty(
$category_obj) || !$category_handler->getPermission($category_obj"view")) {
                
art_trackback_response(1art_constant("MD_NOACCESS"));
            }
    
            
$pagetitle art_constant("MD_ARTICLE");
            
$rssdesc art_constant("MD_XMLDESC_ARTICLE");
    
            
$author $article_obj->getAuthor(true);
            
$text $article_obj->getText($page);
    
            
$content art_constant("MD_CATEGORY") . ": " $category_obj->getVar("cat_title");
            if (
$text["title"]) {
                
$content .= "<br />" art_constant("MD_SUBTITLE") . ": " $text["title"];
            }
            
$source_author $author["author"];
            
$source_source $article_obj->getVar("art_source");
            if (!empty(
$source_author)||!empty($source_source)) {
                
$content .= "<br />" art_constant("MD_SOURCE") . ": " $source_author "(" $source_source ")";
            }
            if (
$article_obj->getVar("art_keywords")) {
                
$content .=    "<br />" art_constant("MD_KEYWORDS") . ": " $article_obj->getVar("art_keywords");
            }
            if (
$summary $article_obj->getSummary()) {
                
$content .=    "<br />" art_constant("MD_SUMMARY") . ": " $summary;
            }
            
$content .=    $text["body"] . "<br />";
            
$items[] = array(
                
"title"            => $article_obj->getVar("art_title"),
                
"link"            => XOOPS_URL "/news/view.article.php" URL_DELIMITER $article_obj->getVar("art_id") . "/c" $category_id,
                
"description"    => $content,
                
"descriptionHtmlSyndicated" => true,
                
"date"            => $article_obj->getTime("rss"),
                
"source"        => XOOPS_URL "/modules/" $GLOBALS["artdirname"] . "/",
                
"author"        => $author["name"]
                );
            
$xml_link XOOPS_URL "/news/view.article.php" URL_DELIMITER $article_obj->getVar("art_id") . "/c" $category_id;
                
            break;
    
        case 
"category":
            
$category_obj =& $category_handler->get($category_id);
    
            if (empty(
$category_obj) || !$category_handler->getPermission($category_obj"access")) {
                
art_trackback_response(1art_constant("MD_NOACCESS"));
            }
            
$pagetitle art_constant("MD_CATEGORY");
            
$rssdesc sprintf(art_constant("MD_XMLDESC_CATEGORY"), $category_obj->getVar("cat_title"));
    
            
$criteria = new CriteriaCompo(new Criteria("ac.ac_publish"0">"));
            
$articles_obj =& $article_handler->getByCategory(
                
$category_id,
                
$xoopsModuleConfig["articles_perpage"],
                
0,
                
$criteria,
                array(
"a.art_title""a.art_time_publish""a.art_keywords""a.art_summary""a.uid""a.art_source")
            );
    
            foreach (
$articles_obj as $id => $article) {
                
$uids[$article->getVar("uid")] = 1;
            }
            
$users art_getUnameFromId(array_keys($uids));
    
            foreach (
$articles_obj as $id => $article) {
                
$content art_constant("MD_TITLE") . ": " $article->getVar("art_title"). "<br />";
                
$content .=    art_constant("MD_SUMMARY") . ": " $article->getSummary(true);
                
$items[] = array(
                    
"title"            => $article->getVar("art_title"),
                    
"link"            => XOOPS_URL "/news/view.article.php" URL_DELIMITER $article->getVar("art_id") . "/c" $category_id,
                    
"description"    => $content,
                    
"descriptionHtmlSyndicated" => true,
                    
"date"            => $article->getTime("rss"),
                    
"source"        => XOOPS_URL "/modules/" $GLOBALS["artdirname"] . "/",
                    
"author"        => $users[$article->getVar("uid")]
                    );
            }
            
$xml_link XOOPS_URL "/news/view.category.php" URL_DELIMITER $category_id;
            break;
    
        case 
"author":
            
$author_name XoopsUser::getUnameFromId($uid);
            
$pagetitle art_constant("MD_AUTHOR");
            
$rssdesc sprintf(art_constant("MD_XMLDESC_AUTHOR"), $author_name);
    
            
$categories_obj $category_handler->getAllByPermission("access", array("cat_title""cat_moderator"));
            
$categories_id array_keys($categories_obj);
            if (
count($categories_id) == 0) {
                
$items = array();
                break;
            }
            
$criteria = new CriteriaCompo(new Criteria("a.uid"intval($uid)));
            
$criteria->add(new Criteria("ac.ac_publish"0">"));
            
$articles_obj =& $article_handler->getByCategory(
                
$categories_id,
                
$xoopsModuleConfig["articles_perpage"],
                
0,
                
$criteria,
                array(
"a.art_title""a.cat_id""a.art_time_publish""a.art_keywords""a.art_summary""a.art_source")
            );
            foreach (
$articles_obj as $id => $article) {
                
$content art_constant("MD_CATEGORY") . ": " $categories_obj[$article->getVar("cat_id")]->getVar("cat_title") . "<br />";
                
$content .= art_constant("MD_TITLE") . ": " $article->getVar("art_title") . "<br />";
                
$content .=    art_constant("MD_SUMMARY") . ": " $article->getSummary(true);
                
$items[] = array(
                    
"title"            => $article->getVar("art_title"),
                    
"link"            => XOOPS_URL "/news/view.article.php" URL_DELIMITER $article->getVar("art_id") . "/c" $article->getVar("cat_id"),
                    
"description"    => $content,
                    
"descriptionHtmlSyndicated" => true,
                    
"date"            => $article->getTime("rss"),
                    
"source"        => XOOPS_URL "/modules/" $GLOBALS["artdirname"] . "/",
                    
"author"        => $author_name
                    
);
            }
            
$xml_link XOOPS_URL "/news/view.author.php" URL_DELIMITER $uid;
            break;
    
        case 
"index":
        default:
            
$pagetitle art_constant("MD_INDEX");
            
$rssdesc art_constant("MD_XMLDESC_INDEX");
    
            
$categories_obj $category_handler->getAllByPermission("access", array("cat_title""cat_moderator"));
            
$categories_id array_keys($categories_obj);
            if(
count($categories_id)==0){
                
$items=array();
                break;
            }
            
$criteria = new CriteriaCompo(new Criteria("cat_id""(".implode(",",$categories_id).")""IN"));
            
$criteria->add(new Criteria("art_time_publish"0">"));
            
$criteria->setLimit($xoopsModuleConfig["articles_perpage"]);
            
$articles_obj $article_handler->getAll($criteria
                array(
"art_title""uid""cat_id""art_time_publish""art_keywords""art_summary""art_source")
            );
            
            
$articles_obj =& $article_handler->getPublished(
                
$xoopsModuleConfig["articles_perpage"],
                
0,
                
$criteria,
                array(
"art_title""uid""cat_id""art_time_publish""art_keywords""art_summary""art_author""art_source")
            );
            
            foreach (
$articles_obj as $id => $article) {
                
$uids[$article->getVar("uid")] = 1;
            }
            
$users art_getUnameFromId(array_keys($uids));
    
            foreach (
$articles_obj as $id => $article) {
                
$content art_constant("MD_CATEGORY") . ": " $categories_obj[$article->getVar("cat_id")]->getVar("cat_title") . "<br />";
                
$content .= art_constant("MD_TITLE") . ": " $article->getVar("art_title") . "<br />";
                
$content .=    art_constant("MD_SUMMARY") . ": " $article->getSummary(true);
                
$items[] = array(
                    
"title"            => $article->getVar("art_title"),
                    
"link"            => XOOPS_URL "/news/view.article.php" URL_DELIMITER $article->getVar("art_id") . "/c" $article->getVar("cat_id"),
                    
"description"    => $content,
                    
"descriptionHtmlSyndicated" => true,
                    
"date"            => $article->getTime("rss"),
                    
"source"        => XOOPS_URL "/modules/" $GLOBALS["artdirname"] . "/",
                    
"author"        => $users[$article->getVar("uid")]
                    );
            }
            
$xml_link XOOPS_URL "/news/";
            break;
    }
    
    
$xml_charset = empty($xoopsModuleConfig["do_rssutf8"]) ? _CHARSET "UTF-8";
    
    
$xml_handler =& xoops_getmodulehandler("xml"$GLOBALS["artdirname"]);
    
$xml $xml_handler->create($type);
    
$xml->setVar("encoding"$xml_charset);
    
$xml->setVar("title"$xoopsConfig["sitename"] . " :: " $pagetitle,"UTF-8"$xml_charsettrue);
    
$xml->setVar("description"$rssdesctrue);
    
$xml->setVar("descriptionHtmlSyndicated"true);
    
$xml->setVar("link"$xml_link);
    
$xml->setVar("syndicationURL"XOOPS_URL "/" xoops_getenv("PHP_SELF"));
    
$xml->setVar("webmaster"checkEmail($xoopsConfig["adminmail"], true));
    
$xml->setVar("editor"checkEmail($xoopsConfig["adminmail"], true));
    
$xml->setVar("category"$xoopsModule->getVar("name"), true);
    
$xml->setVar("generator"$xoopsModule->getInfo("version"));
    
$xml->setVar("language"_LANGCODE);
    
    
$dimention = @getimagesize(XOOPS_ROOT_PATH "/modules/" $GLOBALS["artdirname"] . "/" $xoopsModule->getInfo("image"));
    
$image = array(
        
"width"            => @$dimention[0],
        
"height"        => @$dimention[1],
        
"title"            => $xoopsConfig["sitename"] . " :: " $pagetitle,
        
"url"            => XOOPS_URL "/modules/" $GLOBALS["artdirname"] . "/" $xoopsModule->getInfo("image"),
        
"link"            => XOOPS_URL "/news/",
        
"description"    => $rssdesc
        
);
    
$xml->setImage($image);
    
    
/*
    $item = array(
        "title" => $datatitle,
        "link" => $dataurl,
        "description" => $datadesc,
        "descriptionHtmlSyndicated" => true,
        "date" => $datadate,
        "source" => $datasource,
        "author" => $dataauthor
        );
    */
    
$xml->addItems($items);
    
    
//$dummy_content = $xml_handler->display($xml, XOOPS_CACHE_PATH."/".$GLOBALS["artdirname"].".xml.tmp");
    
$dummy_content $xml_handler->display($xml);
    
    
$tpl->assign_by_ref('dummy_content'$dummy_content);
}
//$content = ob_get_contents();
ob_end_clean();

header('Content-Type:text/xml; charset=' $xml_charset);
$tpl->display('db:system_dummy.html'$xoopsCachedTemplateId);
?>


Thanks for your help.

8
playsome
Re: Article module - begging for help
  • 2009/9/10 19:33

  • playsome

  • Not too shy to talk

  • Posts: 197

  • Since: 2009/4/15


I think its OK now, sorry, must have been a browser cache issue.

I have just one last problem, the xml for the index page here shows the first 10 articles i posted in reverse date format and it does not change as i post more articles, the rss per category shows the latest articles so that is fine, how can I fix the rss for the index page so the latest articles show and in the correct date order?

Thanks

9
ghia
Re: Article module - begging for help
  • 2009/9/10 23:14

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


The handlers are gathering the records based on the criteria assembled. Some handlers may using an order clause for the publicizing date (or maybe article id) in decending mode. Check the handlers' code.
Maybe it is also possible to provide something in the calling parameters of the handler.

10
playsome
Re: Article module - begging for help
  • 2009/9/12 13:49

  • playsome

  • Not too shy to talk

  • Posts: 197

  • Since: 2009/4/15


Hi Ghia, thanks for your help, to be honest I did not understand what you said, I'm afraid my knowledge of PHP is limited and that stuff is just way over my head.

However I have made a couple of hacks to xml.php code if anyone is interested in using it.

1. Before when viewing RSS for a category the page title showed as SiteName::Category, it did not show the actual category name it just showed the word 'category', I have modified it so the pagetitle shows the actual category name example here

2. Hardcoded in links to shortened URLs created by the XoWreriteModules hack by Dugris before the links showed the old "/modules/" urls

3. Hardcoded in a diifferent image so it can show a custom image (image would display on feedburner pages) instead of the module logo.

Here is my revised code for xml.php:
<?php
/**
 * Article module for XOOPS
 *
 * 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         http://www.fsf.org/copyleft/gpl.html GNU public license
 * @package         article
 * @since           1.0
 * @author          Taiwen Jiang <phppp@users.sourceforge.net>
 * @version         $Id: xml.php 2283 2008-10-12 03:36:13Z phppp $
 */
 
ob_start();
include 
"header.php";
error_reporting(0);
$xoopsLogger->activated false;

if (
art_parse_args($args_num$args$args_str)) {
    
$args["article"] = !empty($args["article"]) ? $args["article"] : @$args_num[0];
    
$args["type"] = @$args_str[0];
}

$article_id intval( empty($_GET["article"]) ? @$args["article"] : $_GET["article"] );
$category_id intval( empty($_GET["category"]) ? @$args["category"] : $_GET["category"] );
$page intval( empty($_GET["page"]) ? @$args["page"] : $_GET["page"] );
$uid intval( empty($_GET["uid"]) ? @$args["uid"] : $_GET["uid"] );
$type = empty($_GET["type"]) ? (empty($_GET["op"]) ? @$args["type"] : $_GET["op"]) : $_GET["type"];
$type strtoupper($type);

$category_handler =& xoops_getmodulehandler("category"$GLOBALS["artdirname"]);
$article_handler =& xoops_getmodulehandler("article"$GLOBALS["artdirname"]);
$article_obj =& $article_handler->get($article_id);
if (
$article_id 0) {
    
$criteria = new CriteriaCompo(new Criteria("ac.ac_publish"0">"));
    
$categories_obj =& $category_handler->getByArticle($article_id$criteria);
    if (
count($categories_obj) ==|| !in_array($category_idarray_keys($categories_obj))) $category_id=0;
    unset(
$categories_obj);
    
$category_id = empty($category_id)?$article_obj->getVar("cat_id"):$category_id;
}

$category_obj =& $category_handler->get($category_id);

$_uid = empty($xoopsUser) ? $xoopsUser->getVar("uid");
$isAuthor = ( $article_obj->isNew() || $_uid == $article_obj->getVar("uid") );
$isAdmin $category_handler->getPermission($category_obj"moderate");

if (
$isAuthor || ($isAdmin && $article_handler->getCategoryStatus($category_id$article_id) !== NULL)) {
} elseif (
    empty(
$category_id)
    || !
$category_handler->getPermission($category_obj"view")
    || !
$article_obj->getVar("art_time_publish")
    ){
    
art_trackback_response(1art_constant("MD_NOACCESS"));
}

if (
$type == "RDF"$type "RSS1.0";
if (
$type == "RSS"$type "RSS0.91";

$valid_format = array("RSS0.91""RSS1.0""RSS2.0""PIE0.1""MBOX""OPML""ATOM""ATOM0.3""HTML""JS");
if (empty(
$type) || !in_array($type$valid_format)) {
    
$type "RSS";
}

if (
$article_id 0) {
    
$myuid = empty($xoopsUser) ? $xoopsUser->getVar("uid");
    
$isAuthor = ($article_obj->isNew() || $myuid == $article_obj->getVar("uid"));
    
$isAdmin $category_handler->getPermission($category_obj"moderate");
    
    if (
$isAuthor || ($isAdmin && $article_handler->getCategoryStatus($category_id$article_id)!==NULL)){
    } elseif (
        empty(
$category_id)
        || !
$category_handler->getPermission($category_obj"view")
        || !
$article_obj->getVar("art_time_publish")
        ){
        
art_trackback_response(1art_constant("MD_NOACCESS"));
    }
}
$xml_charset = empty($xoopsModuleConfig["do_rssutf8"]) ? _CHARSET "UTF-8";

include_once 
XOOPS_ROOT_PATH '/class/template.php';

$tpl = new XoopsTpl();
$tpl->caching 2;
$tpl->cache_lifetime 3600;
load_functions("cache");
$xoopsCachedTemplateId md5mod_generateCacheId() . str_replaceXOOPS_URL''$_SERVER['REQUEST_URI'] ) );
if (!
$tpl->is_cached('db:system_dummy.html'$xoopsCachedTemplateId)) {
    if (!empty(
$article_id)) $source "article";
    elseif (!empty(
$category_id)) $source "category";
    elseif (!empty(
$uid)) $source "author";
    else 
$source "index";
    
    
$items = array();

    switch (
$source) {
        case 
"article":
            
$category_id = empty($category_id)?$article_obj->getVar("cat_id"):$category_id;
            
$category_obj =& $category_handler->get($category_id);
    
            if (empty(
$category_obj) || !$category_handler->getPermission($category_obj"view")) {
                
art_trackback_response(1art_constant("MD_NOACCESS"));
            }
    
            
$pagetitle art_constant("MD_ARTICLE");
            
$rssdesc art_constant("MD_XMLDESC_ARTICLE");
    
            
$author $article_obj->getAuthor(true);
            
$text $article_obj->getText($page);
    
            
$content art_constant("MD_CATEGORY") . ": " $category_obj->getVar("cat_title");
            if (
$text["title"]) {
                
$content .= "<br />" art_constant("MD_SUBTITLE") . ": " $text["title"];
            }
            
$source_author $author["author"];
            
$source_source $article_obj->getVar("art_source");
            if (!empty(
$source_author)||!empty($source_source)) {
                
$content .= "<br />" art_constant("MD_SOURCE") . ": " $source_author "(" $source_source ")";
            }
            if (
$article_obj->getVar("art_keywords")) {
                
$content .=    "<br />" art_constant("MD_KEYWORDS") . ": " $article_obj->getVar("art_keywords");
            }
            if (
$summary $article_obj->getSummary()) {
                
$content .=    "<br />" art_constant("MD_SUMMARY") . ": " $summary;
            }
            
$content .=    $text["body"] . "<br />";
            
$items[] = array(
                
"title"            => $article_obj->getVar("art_title"),
                
"link"            => XOOPS_URL "/news/view.article.php" URL_DELIMITER $article_obj->getVar("art_id") . "/c" $category_id,
                
"description"    => $content,
                
"descriptionHtmlSyndicated" => true,
                
"date"            => $article_obj->getTime("rss"),
                
"source"        => XOOPS_URL "/modules/" $GLOBALS["artdirname"] . "/",
                
"author"        => $author["name"]
                );
            
$xml_link XOOPS_URL "/news/view.article.php" URL_DELIMITER $article_obj->getVar("art_id") . "/c" $category_id;
                
            break;
    
        case 
"category":
            
$category_obj =& $category_handler->get($category_id);
    
            if (empty(
$category_obj) || !$category_handler->getPermission($category_obj"access")) {
                
art_trackback_response(1art_constant("MD_NOACCESS"));
            }
            
$pagetitle art_constant("MD_CATEGORY");
            
$rssdesc sprintf(art_constant("MD_XMLDESC_CATEGORY"), $category_obj->getVar("cat_title"));
    
            
$criteria = new CriteriaCompo(new Criteria("ac.ac_publish"0">"));
            
$articles_obj =& $article_handler->getByCategory(
                
$category_id,
                
$xoopsModuleConfig["articles_perpage"],
                
0,
                
$criteria,
                array(
"a.art_title""a.art_time_publish""a.art_keywords""a.art_summary""a.uid""a.art_source")
            );
    
            foreach (
$articles_obj as $id => $article) {
                
$uids[$article->getVar("uid")] = 1;
            }
            
$users art_getUnameFromId(array_keys($uids));
    
            foreach (
$articles_obj as $id => $article) {
                
$content art_constant("MD_TITLE") . ": " $article->getVar("art_title"). "<br />";
                
$content .=    art_constant("MD_SUMMARY") . ": " $article->getSummary(true);
                
$items[] = array(
                    
"title"            => $article->getVar("art_title"),
                    
"link"            => XOOPS_URL "/news/view.article.php" URL_DELIMITER $article->getVar("art_id") . "/c" $category_id,
                    
"description"    => $content,
                    
"descriptionHtmlSyndicated" => true,
                    
"date"            => $article->getTime("rss"),
                    
"source"        => XOOPS_URL "/modules/" $GLOBALS["artdirname"] . "/",
                    
"author"        => $users[$article->getVar("uid")]
                    );
            }
            
$xml_link XOOPS_URL "/news/view.category.php" URL_DELIMITER $category_id;
            break;
    
        case 
"author":
            
$author_name XoopsUser::getUnameFromId($uid);
            
$pagetitle art_constant("MD_AUTHOR");
            
$rssdesc sprintf(art_constant("MD_XMLDESC_AUTHOR"), $author_name);
    
            
$categories_obj $category_handler->getAllByPermission("access", array("cat_title""cat_moderator"));
            
$categories_id array_keys($categories_obj);
            if (
count($categories_id) == 0) {
                
$items = array();
                break;
            }
            
$criteria = new CriteriaCompo(new Criteria("a.uid"intval($uid)));
            
$criteria->add(new Criteria("ac.ac_publish"0">"));
            
$articles_obj =& $article_handler->getByCategory(
                
$categories_id,
                
$xoopsModuleConfig["articles_perpage"],
                
0,
                
$criteria,
                array(
"a.art_title""a.cat_id""a.art_time_publish""a.art_keywords""a.art_summary""a.art_source")
            );
            foreach (
$articles_obj as $id => $article) {
                
$content art_constant("MD_CATEGORY") . ": " $categories_obj[$article->getVar("cat_id")]->getVar("cat_title") . "<br />";
                
$content .= art_constant("MD_TITLE") . ": " $article->getVar("art_title") . "<br />";
                
$content .=    art_constant("MD_SUMMARY") . ": " $article->getSummary(true);
                
$items[] = array(
                    
"title"            => $article->getVar("art_title"),
                    
"link"            => XOOPS_URL "/news/view.article.php" URL_DELIMITER $article->getVar("art_id") . "/c" $article->getVar("cat_id"),
                    
"description"    => $content,
                    
"descriptionHtmlSyndicated" => true,
                    
"date"            => $article->getTime("rss"),
                    
"source"        => XOOPS_URL "/modules/" $GLOBALS["artdirname"] . "/",
                    
"author"        => $author_name
                    
);
            }
            
$xml_link XOOPS_URL "/news/view.author.php" URL_DELIMITER $uid;
            break;
    
        case 
"index":
        default:
            
$pagetitle art_constant("MD_INDEX");
            
$rssdesc art_constant("MD_XMLDESC_INDEX");
    
            
$categories_obj $category_handler->getAllByPermission("access", array("cat_title""cat_moderator"));
            
$categories_id array_keys($categories_obj);
            if(
count($categories_id)==0){
                
$items=array();
                break;
            }
            
$criteria = new CriteriaCompo(new Criteria("cat_id""(".implode(",",$categories_id).")""IN"));
            
$criteria->add(new Criteria("art_time_publish"0">"));
            
$criteria->setLimit($xoopsModuleConfig["articles_perpage"]);
            
$articles_obj $article_handler->getAll($criteria
                array(
"art_title""uid""cat_id""art_time_publish""art_keywords""art_summary""art_source")
            );
            
/*
            $articles_obj =& $article_handler->getPublished(
                $xoopsModuleConfig["articles_perpage"],
                0,
                $criteria,
                array("art_title", "uid", "cat_id", "art_time_publish", "art_keywords", "art_summary", "art_author", "art_source")
            );
            */
            
foreach ($articles_obj as $id => $article) {
                
$uids[$article->getVar("uid")] = 1;
            }
            
$users art_getUnameFromId(array_keys($uids));
    
            foreach (
$articles_obj as $id => $article) {
                
$content art_constant("MD_CATEGORY") . ": " $categories_obj[$article->getVar("cat_id")]->getVar("cat_title") . "<br />";
                
$content .= art_constant("MD_TITLE") . ": " $article->getVar("art_title") . "<br />";
                
$content .=    art_constant("MD_SUMMARY") . ": " $article->getSummary(true);
                
$items[] = array(
                    
"title"            => $article->getVar("art_title"),
                    
"link"            => XOOPS_URL "/news/view.article.php" URL_DELIMITER $article->getVar("art_id") . "/c" $article->getVar("cat_id"),
                    
"description"    => $content,
                    
"descriptionHtmlSyndicated" => true,
                    
"date"            => $article->getTime("rss"),
                    
"source"        => XOOPS_URL "/news/",
                    
"author"        => $users[$article->getVar("uid")]
                    );
            }
            
$xml_link XOOPS_URL "/news/";
            break;
    }
    
    
$xml_charset = empty($xoopsModuleConfig["do_rssutf8"]) ? _CHARSET "UTF-8";
    
    
$xml_handler =& xoops_getmodulehandler("xml"$GLOBALS["artdirname"]);
    
$xml $xml_handler->create($type);
    
$xml->setVar("encoding"$xml_charset);
    
//edited line below to add cat_title 11sep09
    
$xml->setVar("title"$xoopsConfig["sitename"] . " : " $category_obj->getVar("cat_title"),"UTF-8"$xml_charsettrue);
    
$xml->setVar("description"$rssdesctrue);
    
$xml->setVar("descriptionHtmlSyndicated"true);
    
$xml->setVar("link"$xml_link);
    
$xml->setVar("syndicationURL"XOOPS_URL "/" xoops_getenv("PHP_SELF"));
    
$xml->setVar("webmaster"checkEmail($xoopsConfig["adminmail"], true));
    
$xml->setVar("editor"checkEmail($xoopsConfig["adminmail"], true));
    
$xml->setVar("category"$xoopsModule->getVar("name"), true);
    
$xml->setVar("generator"$xoopsModule->getInfo("version"));
    
$xml->setVar("language"_LANGCODE);
    
    
//$dimention = @getimagesize(XOOPS_ROOT_PATH . "/modules/" . $GLOBALS["artdirname"] . "/" . $xoopsModule->getInfo("image"));
    
$image = array(
        
"width"            => @$dimention[0],
        
"height"        => @$dimention[1],
        
"title"            => $xoopsConfig["sitename"],
        
"url"            => XOOPS_URL "/images/psnews_feed_img.gif",
        
"link"            => XOOPS_URL "/news/",
        
"description"    => $rssdesc
        
);
    
$xml->setImage($image);
    
    
/*
    $item = array(
        "title" => $datatitle,
        "link" => $dataurl,
        "description" => $datadesc,
        "descriptionHtmlSyndicated" => true,
        "date" => $datadate,
        "source" => $datasource,
        "author" => $dataauthor
        );
    */
    
$xml->addItems($items);
    
    
$dummy_content $xml_handler->display($xmlXOOPS_CACHE_PATH."/".$GLOBALS["artdirname"].".xml.tmp");
    
$dummy_content $xml_handler->display($xml);
    
    
$tpl->assign_by_ref('dummy_content'$dummy_content);
}
//$content = ob_get_contents();
ob_end_clean();

header('Content-Type:text/xml; charset=' $xml_charset);
$tpl->display('db:system_dummy.html'$xoopsCachedTemplateId);
?>


Something you may have to change to suit your own site.

Things still needing fixed or hacked:

1. Feeds for index page RSS need fixed to show 10 most recent articles instead of the 10 oldest.

2. Hack to show the uploaded article image in the feed would be good to.

playsome

Login

Who's Online

114 user(s) are online (63 user(s) are browsing Support Forums)


Members: 0


Guests: 114


more...

Donat-O-Meter

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

Latest GitHub Commits