From: Sébastien SAUVAGE Date: Tue, 24 Sep 2013 09:10:18 +0000 (-0700) Subject: Merge pull request #112 from BoboTiG/master X-Git-Tag: v0.0.42beta~16 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=85c02058768eb779e33524c5530d842e0513f9ce;hp=0b88c6022d494c9c4de779ef10df3ecd1328a55c;p=github%2Fshaarli%2FShaarli.git Merge pull request #112 from BoboTiG/master RSS/Atom: add a parameter to print only the N last links --- diff --git a/index.php b/index.php index 8567efb5..9446c660 100644 --- a/index.php +++ b/index.php @@ -876,7 +876,7 @@ class linkdb implements Iterator, Countable, ArrayAccess } // ------------------------------------------------------------------------------------------ -// Ouput the last 50 links in RSS 2.0 format. +// Ouput the last N links in RSS 2.0 format. function showRSS() { header('Content-Type: application/rss+xml; charset=utf-8'); @@ -898,6 +898,7 @@ function showRSS() if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']); elseif (!empty($_GET['searchtags'])) $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags'])); else $linksToDisplay = $LINKSDB; + $nblinksToDisplay = !empty($_GET['nb']) ? max($_GET['nb'] + 0, 1) : 50; $pageaddr=htmlspecialchars(indexUrl()); echo ''; @@ -912,7 +913,7 @@ function showRSS() } $i=0; $keys=array(); foreach($linksToDisplay as $key=>$value) { $keys[]=$key; } // No, I can't use array_keys(). - while ($i<50 && $ifilterFulltext($_GET['searchterm']); elseif (!empty($_GET['searchtags'])) $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags'])); else $linksToDisplay = $LINKSDB; + $nblinksToDisplay = !empty($_GET['nb']) ? max($_GET['nb'] + 0, 1) : 50; $pageaddr=htmlspecialchars(indexUrl()); $latestDate = ''; $entries=''; $i=0; $keys=array(); foreach($linksToDisplay as $key=>$value) { $keys[]=$key; } // No, I can't use array_keys(). - while ($i<50 && $i