add pubDates, that rocks
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Mon, 17 Jan 2005 09:28:40 +0000 (09:28 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:27:46 +0000 (23:27 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-371

include/rss.inc.php
templates/carnet/rss.tpl
templates/rss.tpl

index 96ad35b..bda7c26 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-function _rss_encode_date($s) {
-    return date('r', strtotime($s));
+function _rss_encode_date($d) {
+    if (preg_match('/^\d{14}$/', $d)) {
+        $t = mktime(substr($d,8,2), substr($d,10,2), substr($d,12,2), substr($d,4,2), substr($d,6,2), substr($d,0,4));
+    } else {
+        $t = strtotime($d);
+    }
+    return date('r', $t);
 }
 
 function to_rss ($s)
index 81d3230..3ba28d0 100644 (file)
     </image>
     {foreach from=$notifs->_data item=c key=cid}
     {foreach from=$c item=promo}
-    {section name=row loop=$promo}
+    {foreach from=$promo item=x}
     <item>
       <title>
-        [{$notifs->_cats[$cid].short}] {$promo[row].prenom} {$promo[row].nom} (le {$promo[row].date|date_format})
+        [{$notifs->_cats[$cid].short}] {$x.prenom} {$x.nom} ({$x.promo}) - le {$x.date|date_format}
       </title>
-      <link>{#globals.baseurl#}/fiche.php?user={$promo[row].bestalias}</link>
-      <pubDate>{$promo[row]->known|rss_date}</pubDate>
+      <link>{#globals.baseurl#}/fiche.php?user={$x.bestalias}</link>
+      <description><![CDATA[
+        {if !$x.contact}
+        <a href="{#globals.baseurl#}/carnet/mescontacts.php?action=ajouter&amp;user={$x.bestalias}">
+          ajouter &agrave; mes contacts
+        </a>
+        {/if}
+        ]]></description>
+      <pubDate>{$x->known|rss_date}</pubDate>
     </item>
-    {/section}
+    {/foreach}
     {/foreach}
     {/foreach}
   </channel>
index 6604455..a36161e 100644 (file)
@@ -34,6 +34,7 @@
       <title>{$line.titre|strip_tags}</title>
       <link>{#globals.baseurl#}/login.php#newsid{$line.id}</link>
       <description><![CDATA[{$line.texte|nl2br}]]></description>
+      <pubDate>{$line.creation_date|rss_date}</pubDate>
     </item>
     {/iterate}
   </channel>