<?php
if ( $rss ) {
$items = array();
while( $row = $modx->db->getRow( $q_query ) ) {
$items[] = array( “title”=> lang_decode( $row, “Title”),
“url”=>”http://” . str_replace( “//”, “/”, $_SERVER[‘HTTP_HOST’] . $modx->config[ “base_url” ] .
make_link( “ARTICLES_” . strtoupper( $row[ “ArticleGroup” ] ) , $row ) ),
“description”=> lang_decode( $row, “Brief”),
“date”=>strtotime( $row[ “ReleaseDate”] ) );
}
display_rss( lang( “LABEL_EXCELLENCE_CANADA”), lang( “LABEL_” . $dynamic_category ),
str_replace( “//”, “/”, make_link( $modx->documentIdentifier ) . “/rss” ) , $items, “Copyright 2012”, $langId . “-ca” );
}
function display_rss( $siteName, $feedName, $feedUrl, $feedItems, $feedCopyright=”Copyright 2011″, $feedLanguage=”en-ca” ) {
header(“Content-type: application/rss+xml”);
echo ‘<?xml version=”1.0″ encoding=”UTF-8″ ?’ . ‘>’;
foreach( array( “&”=>”&”, “>”=>”>”, “<“=>”<”, “‘”=> “'”, “\””=> “"” ) as $char=>$replace )
$feedName = str_replace($char, $replace, $feedName );
?>
<rss version=”2.0″ xmlns:atom=”http://www.w3.org/2005/Atom”>
<channel>
<title><?=$siteName . ” ” . $feedName?></title>
<link><?=”http://” . $_SERVER[‘HTTP_HOST’] . $feedUrl?></link>
<description><?=$feedName?></description>
<copyright><?= $feedCopyright?></copyright>
<language><?=$feedLanguage?></language>
<atom:link href=”<?=”http://” . $_SERVER[‘HTTP_HOST’] . $feedUrl ?>” rel=”self” type=”application/rss+xml” />
<?php
foreach( $feedItems as $item ) {
if ( empty( $item[ “description” ] ) ) $item[ “description” ] = $item[ “title” ];
foreach( array( “title”, “description” ) as $i ) {
$str = strip_tags( $item[ $i ] );
if ( strlen( $str ) > 255 ) {
$str = substr($str, 0, 255);
$pos = strrpos($str, ” “);
if ( $pos > 0 ) $str = substr($str, 0, $pos);
}
$item[ $i ] = trim( $str );
foreach( array( “&”=>”&”, “>”=>”>”,”<“=>”<”, “‘”=> “'”, “\””=> “"” ) as $char=>$replace ) {
$item[ $i ] = str_replace($char, $replace, $item[ $i ] );
}
}
?>
<item>
<title><?=strip_tags( $item[ “title” ] )?></title>
<link><?=$item[ “url” ]?></link>
<description><?=strip_tags( $item[ “description” ] )?></description>
<pubDate><?=date( “D, d M Y H:i:s O”, $item[ “date” ] ) ?></pubDate>
<guid isPermaLink=”false”><?=$item[ “url” ]?></guid>
</item>
<?php
}
?>
</channel>
</rss>
<?php
exit();
}