Browse Source

Nicer RSS feed

pecesama 17 years ago
parent
commit
ce6e59d2ef
2 changed files with 56 additions and 12 deletions
  1. 3 3
      classes/gelato.class.php
  2. 53 9
      rss.php

+ 3 - 3
classes/gelato.class.php View File

@@ -95,10 +95,10 @@ class gelato extends Conexion_Mysql {
95 95
 	function getVideoPlayer($url) {
96 96
 		if (isYoutubeVideo($url)) {
97 97
 			$id_video = getYoutubeVideoUrl($url);
98
-			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";
98
+			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";
99 99
 		} elseif (isVimeoVideo($url)) {
100 100
 			$id_video = getVimeoVideoUrl($url);
101
-			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";
101
+			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";
102 102
 		} else {
103 103
 			return "This URL is not a supported video (YouTube or Vimeo)";
104 104
 		}		
@@ -107,7 +107,7 @@ class gelato extends Conexion_Mysql {
107 107
 	function getMp3Player($url) {
108 108
 		if (isMP3($url)) {
109 109
 			$playerUrl = $this->conf->urlGelato."/admin/scripts/player.swf?soundFile=".$url;
110
-			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";
110
+			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";
111 111
 		} else {
112 112
 			return "This URL is not a supported video (YouTube or Vimeo)";
113 113
 		}		

+ 53 - 9
rss.php View File

@@ -27,8 +27,6 @@
27 27
 		<title><?=htmlspecialchars(replaceAccents($conf->title));?></title>
28 28
 		<link><?=$conf->urlGelato;?></link>
29 29
 		<description><?=htmlspecialchars(replaceAccents($conf->description));?></description>
30
-		<language>EN</language>
31
-		<docs>http://blogs.law.harvard.edu/tech/rss</docs>
32 30
 		<generator>gelato CMS</generator>
33 31
 		<image>
34 32
 			<url><?=$conf->urlGelato;?>/images/information.png</url>
@@ -37,19 +35,50 @@
37 35
 		</image>
38 36
 <?
39 37
 		while($register = mysql_fetch_array($rs)) {
40
-			$tit = ($register["title"]=="") ? htmlspecialchars($register["url"]) : htmlspecialchars($register["title"]);
41
-			$desc = htmlspecialchars($register["description"]);
38
+			switch ($register["type"]) {
39
+				case "1":
40
+					$tit = ($register["title"]=="") ? htmlspecialchars(strip_tags($register["description"])) : htmlspecialchars($register["title"]);
41
+					$desc = htmlspecialchars($register["description"]);
42
+					break;
43
+				case "2":
44
+					$tit = ($register["description"]=="") ? "Photo" : htmlspecialchars(strip_tags($register["description"]));
45
+					$desc = "<img src=\"".$register["url"]."\"/>";
46
+					break;
47
+				case "3":
48
+					$tit = "\"".htmlspecialchars(strip_tags($register["description"]))."\"";
49
+					$tmpStr = ($register["title"]!="") ? "<br /><br /> - <em>".htmlspecialchars($register["title"])."</em>" : "";
50
+					$desc = "\"".htmlspecialchars($register["description"])."\"".$tmpStr;
51
+					break;
52
+				case "4":
53
+					$tit = ($register["title"]=="") ? htmlspecialchars($register["url"]) : htmlspecialchars($register["title"]);
54
+					$tmpStr = ($register["description"]!="") ? "<br /><br /> - <em>".htmlspecialchars($register["description"])."</em>" : "";
55
+					$desc = "<a href=\"".htmlspecialchars($register["url"])."\">".$tit."</a>".$tmpStr;
56
+					break;
57
+				case "5":
58
+					$lines = explode("\n", $register["description"]);
59
+					$line = htmlspecialchars($lines[0]);
60
+					$tit = ($register["title"]=="") ? $line : htmlspecialchars($register["title"]);
61
+					$desc = $tumble->formatConversation(htmlspecialchars($register["description"]));
62
+					break;
63
+				case "6":
64
+					$tit = ($register["description"]=="") ? "Video" : htmlspecialchars(strip_tags($register["description"]));
65
+					$desc = $tumble->getVideoPlayer(htmlspecialchars($register["url"]));
66
+					break;
67
+				case "7":
68
+					$tit = ($register["description"]=="") ? "MP3" : htmlspecialchars(strip_tags($register["description"]));
69
+					$desc = $tumble->getMp3Player(htmlspecialchars($register["url"]));
70
+					break;
71
+			}
42 72
 			$url = htmlspecialchars($conf->urlGelato."/index.php/post/".$register["id_post"]."/");
43 73
 			$formatedDate = gmdate("D, d M Y H:i:s \G\M\T", strtotime($register["date"]));
44 74
 			?>
45 75
 
46 76
 			<item>
47
-				<title><?=$tit;?></title>
77
+				<title><?=replaceAccentsWithAmp($tit);?></title>
78
+				<description><![CDATA[<?=replaceAccentsWithAmp($desc);?>]]></description>
48 79
 				<link><?=$url;?></link>
49
-				<description><?=$desc;?></description>
50
-				<pubDate><?=$formatedDate;?></pubDate>
51
-				<category>system:unfiled</category>
52
-				<guid isPermaLink="true"><?=$conf->urlGelato."/index.php/post/".$register["id_post"]."/";?></guid>
80
+				<guid isPermaLink="true"><?=$conf->urlGelato."/index.php/post/".$register["id_post"]."/";?></guid>				
81
+				<pubDate><?=$formatedDate;?></pubDate>				
53 82
 			</item>
54 83
 
55 84
 <?		
@@ -73,4 +102,19 @@
73 102
 		$texto = str_replace("&uacute;","u", $texto);
74 103
 		return $texto;
75 104
 	}
105
+	
106
+	function replaceAccentsWithAmp($texto="") {
107
+		$texto = str_replace("&amp;Aacute;","A", $texto);
108
+		$texto = str_replace("&amp;Eacute;","E", $texto);
109
+		$texto = str_replace("&amp;Iacute;","I", $texto);
110
+		$texto = str_replace("&amp;Oacute;","O", $texto);
111
+		$texto = str_replace("&amp;Uacute;","U", $texto);
112
+		$texto = str_replace("&amp;aacute;","a", $texto);
113
+		$texto = str_replace("&amp;eacute;","e", $texto);
114
+		$texto = str_replace("&amp;iacute;","i", $texto);
115
+		$texto = str_replace("&amp;oacute;","o", $texto);
116
+		$texto = str_replace("&amp;uacute;","u", $texto);
117
+		$texto = str_replace("&amp;#39;"," ", $texto);
118
+		return $texto;
119
+	}
76 120
 ?>