Nicer RSS feed

master
pecesama 2007-04-05 00:02:24 +00:00
parent 5184069b5f
commit ce6e59d2ef
2 changed files with 56 additions and 12 deletions

View File

@ -95,10 +95,10 @@ class gelato extends Conexion_Mysql {
function getVideoPlayer($url) { function getVideoPlayer($url) {
if (isYoutubeVideo($url)) { if (isYoutubeVideo($url)) {
$id_video = getYoutubeVideoUrl($url); $id_video = getYoutubeVideoUrl($url);
return "\t\t\t<div class=\"enlacevideo\"><object type=\"application/x-shockwave-flash\" style=\"width:500px;height:393px\" data=\"http://www.youtube.com/v/".$id_video."\"><param name=\"movie\" value=\"http://www.youtube.com/v/".$id_video."\" /></object></div>\n"; return "\t\t\t<object type=\"application/x-shockwave-flash\" style=\"width:500px;height:393px\" data=\"http://www.youtube.com/v/".$id_video."\"><param name=\"movie\" value=\"http://www.youtube.com/v/".$id_video."\" /></object>\n";
} elseif (isVimeoVideo($url)) { } elseif (isVimeoVideo($url)) {
$id_video = getVimeoVideoUrl($url); $id_video = getVimeoVideoUrl($url);
return "\t\t\t<div class=\"enlacevideo\"><object type=\"application/x-shockwave-flash\" style=\"width:500px;height:393px\" data=\"http://www.vimeo.com/moogaloop.swf?clip_id=".$id_video."\"><param name=\"movie\" value=\"http://www.vimeo.com/moogaloop.swf?clip_id=".$id_video."\" /></object></div>\n"; return "\t\t\t<object type=\"application/x-shockwave-flash\" style=\"width:500px;height:393px\" data=\"http://www.vimeo.com/moogaloop.swf?clip_id=".$id_video."\"><param name=\"movie\" value=\"http://www.vimeo.com/moogaloop.swf?clip_id=".$id_video."\" /></object>\n";
} else { } else {
return "This URL is not a supported video (YouTube or Vimeo)"; return "This URL is not a supported video (YouTube or Vimeo)";
} }
@ -107,7 +107,7 @@ class gelato extends Conexion_Mysql {
function getMp3Player($url) { function getMp3Player($url) {
if (isMP3($url)) { if (isMP3($url)) {
$playerUrl = $this->conf->urlGelato."/admin/scripts/player.swf?soundFile=".$url; $playerUrl = $this->conf->urlGelato."/admin/scripts/player.swf?soundFile=".$url;
return "\t\t\t<div class=\"enlacemp3\"><object type=\"application/x-shockwave-flash\" data=\"" . $playerUrl . "\" width=\"290\" height=\"24\"><param name=\"movie\" value=\"" . $playerUrl . "\" /><param name=\"quality\" value=\"high\" /><param name=\"menu\" value=\"false\" /><param name=\"wmode\" value=\"transparent\" /></object></div>\n"; return "\t\t\t<object type=\"application/x-shockwave-flash\" data=\"" . $playerUrl . "\" width=\"290\" height=\"24\"><param name=\"movie\" value=\"" . $playerUrl . "\" /><param name=\"quality\" value=\"high\" /><param name=\"menu\" value=\"false\" /><param name=\"wmode\" value=\"transparent\" /></object>\n";
} else { } else {
return "This URL is not a supported video (YouTube or Vimeo)"; return "This URL is not a supported video (YouTube or Vimeo)";
} }

58
rss.php
View File

@ -27,8 +27,6 @@
<title><?=htmlspecialchars(replaceAccents($conf->title));?></title> <title><?=htmlspecialchars(replaceAccents($conf->title));?></title>
<link><?=$conf->urlGelato;?></link> <link><?=$conf->urlGelato;?></link>
<description><?=htmlspecialchars(replaceAccents($conf->description));?></description> <description><?=htmlspecialchars(replaceAccents($conf->description));?></description>
<language>EN</language>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<generator>gelato CMS</generator> <generator>gelato CMS</generator>
<image> <image>
<url><?=$conf->urlGelato;?>/images/information.png</url> <url><?=$conf->urlGelato;?>/images/information.png</url>
@ -37,19 +35,50 @@
</image> </image>
<? <?
while($register = mysql_fetch_array($rs)) { while($register = mysql_fetch_array($rs)) {
$tit = ($register["title"]=="") ? htmlspecialchars($register["url"]) : htmlspecialchars($register["title"]); switch ($register["type"]) {
case "1":
$tit = ($register["title"]=="") ? htmlspecialchars(strip_tags($register["description"])) : htmlspecialchars($register["title"]);
$desc = htmlspecialchars($register["description"]); $desc = htmlspecialchars($register["description"]);
break;
case "2":
$tit = ($register["description"]=="") ? "Photo" : htmlspecialchars(strip_tags($register["description"]));
$desc = "<img src=\"".$register["url"]."\"/>";
break;
case "3":
$tit = "\"".htmlspecialchars(strip_tags($register["description"]))."\"";
$tmpStr = ($register["title"]!="") ? "<br /><br /> - <em>".htmlspecialchars($register["title"])."</em>" : "";
$desc = "\"".htmlspecialchars($register["description"])."\"".$tmpStr;
break;
case "4":
$tit = ($register["title"]=="") ? htmlspecialchars($register["url"]) : htmlspecialchars($register["title"]);
$tmpStr = ($register["description"]!="") ? "<br /><br /> - <em>".htmlspecialchars($register["description"])."</em>" : "";
$desc = "<a href=\"".htmlspecialchars($register["url"])."\">".$tit."</a>".$tmpStr;
break;
case "5":
$lines = explode("\n", $register["description"]);
$line = htmlspecialchars($lines[0]);
$tit = ($register["title"]=="") ? $line : htmlspecialchars($register["title"]);
$desc = $tumble->formatConversation(htmlspecialchars($register["description"]));
break;
case "6":
$tit = ($register["description"]=="") ? "Video" : htmlspecialchars(strip_tags($register["description"]));
$desc = $tumble->getVideoPlayer(htmlspecialchars($register["url"]));
break;
case "7":
$tit = ($register["description"]=="") ? "MP3" : htmlspecialchars(strip_tags($register["description"]));
$desc = $tumble->getMp3Player(htmlspecialchars($register["url"]));
break;
}
$url = htmlspecialchars($conf->urlGelato."/index.php/post/".$register["id_post"]."/"); $url = htmlspecialchars($conf->urlGelato."/index.php/post/".$register["id_post"]."/");
$formatedDate = gmdate("D, d M Y H:i:s \G\M\T", strtotime($register["date"])); $formatedDate = gmdate("D, d M Y H:i:s \G\M\T", strtotime($register["date"]));
?> ?>
<item> <item>
<title><?=$tit;?></title> <title><?=replaceAccentsWithAmp($tit);?></title>
<description><![CDATA[<?=replaceAccentsWithAmp($desc);?>]]></description>
<link><?=$url;?></link> <link><?=$url;?></link>
<description><?=$desc;?></description>
<pubDate><?=$formatedDate;?></pubDate>
<category>system:unfiled</category>
<guid isPermaLink="true"><?=$conf->urlGelato."/index.php/post/".$register["id_post"]."/";?></guid> <guid isPermaLink="true"><?=$conf->urlGelato."/index.php/post/".$register["id_post"]."/";?></guid>
<pubDate><?=$formatedDate;?></pubDate>
</item> </item>
<? <?
@ -73,4 +102,19 @@
$texto = str_replace("&uacute;","u", $texto); $texto = str_replace("&uacute;","u", $texto);
return $texto; return $texto;
} }
function replaceAccentsWithAmp($texto="") {
$texto = str_replace("&amp;Aacute;","A", $texto);
$texto = str_replace("&amp;Eacute;","E", $texto);
$texto = str_replace("&amp;Iacute;","I", $texto);
$texto = str_replace("&amp;Oacute;","O", $texto);
$texto = str_replace("&amp;Uacute;","U", $texto);
$texto = str_replace("&amp;aacute;","a", $texto);
$texto = str_replace("&amp;eacute;","e", $texto);
$texto = str_replace("&amp;iacute;","i", $texto);
$texto = str_replace("&amp;oacute;","o", $texto);
$texto = str_replace("&amp;uacute;","u", $texto);
$texto = str_replace("&amp;#39;"," ", $texto);
return $texto;
}
?> ?>