/** * getArticles * Returns an associative array with the sort key and the article handle. * @param integer $limit The number of elements to return * @param integer $start Where to start. DEFAULT: 0 * @param string $sort How to sort. Currently only mtime and title are supported. DEFAULT: mtime * @return array **/ function getArticles($limit, $start = 0, $sort = 'mtime') { global $BASEPATH; include_once $BASEPATH . 'config.php'; $dir = dir($GLOBALS['CONFIG']['data']); $result = array(); while (($entry = $dir->read()) !== false) { if (preg_match('/^title_([a-zA-Z0-9]+).html$/', $entry, $matches)) { switch ($sort) { case 'title': $result[getArticleTitle($matches[1])] = $matches[1]; break; default: $result[getArticlePublished($matches[1])] = $matches[1]; } } } if (in_array($sort, array('mtime'))) { krsort($result); } else { ksort($result); } return array_slice($result, $start, $limit); }
<div align="right"><?php echo getArticleCount(); ?> articles <a href="rss.php">RSS Feed</a></div> <?php foreach (getArticles(10) as $key => $article) { ?> <div class="title"><a href="article.php/<?php echo prepareTitle(getArticleTitle($article)); ?> "><?php echo getArticleTitle($article); ?> </a></div> <div class="published">Published: <?php echo date("F d Y H:i:s", getArticlePublished($article)); ?> </div> <div class="intro"><?php echo getArticleIntro($article); ?> </div> <?php } ?> <hr/> <div align="center"> <a href="http://sourceforge.net/project/tinynews"><img src="images/tinynews.gif" border=0></a> <a href="http://sourceforge.net"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=234340&type=1" width="88" height="31" border="0" alt="SourceForge.net Logo" /></a> </div> </body>
echo $CONFIG['site']['url']; ?> </link> <copyright>W&C Information Consultants CC</copyright> <?php foreach (getArticles(10) as $key => $article) { ?> <item> <title><?php echo htmlentities(strip_tags(getArticleTitle($article))); ?> </title> <description><?php echo htmlentities(strip_tags(getArticleIntro($article), 'ENT_QUOTES')); ?> </description> <link><?php echo $CONFIG['site']['url'] . 'article.php/' . prepareTitle(getArticleTitle($article)); ?> </link> <pubDate><?php echo strftime("%a, %d %b %Y %T %Z", getArticlePublished($article)); ?> </pubDate> </item> <?php } ?> </channel> </rss>