From 012b771af9a919e6fdec0d6da5589ee6cd7075fe Mon Sep 17 00:00:00 2001 From: Romain d'Alverny Date: Sat, 30 Jun 2012 18:05:33 +0000 Subject: better output for news summary --- lib/news.php | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'lib/news.php') diff --git a/lib/news.php b/lib/news.php index 736af1dd2..bd11320cb 100644 --- a/lib/news.php +++ b/lib/news.php @@ -100,8 +100,18 @@ function get_feed($url, $count = 5, $cache_timeout = 5) } /** + * + * @param string $locale locale this feed is expected to be in + * @param string $title feed title + * @param string $link feed main site title + * @param string $feed feed url + * @param integer $count how many items to return + * @param string $skip url whose element we want to skip (why?) + * @param boolean split title that has been built by aggregator + * + * @return string */ -function show_feed($locale, $title, $link, $feed, $count = 5, $skip = null) { +function show_feed($locale, $title, $link, $feed, $count = 5, $skip = null, $split = false) { if (!is_null($skip)) $count += 5; @@ -117,8 +127,17 @@ function show_feed($locale, $title, $link, $feed, $count = 5, $skip = null) { if (!is_null($skip) && strpos($d['link'], $skip) !== false) continue; - $s .= sprintf('
  • %s %s
  • ', - $d['link'], $d['title'], news_date($d['date'], $locale)); + if ($split && strpos($d['title'], ' : ') !== false) { + $title = explode(' : ', $d['title']); + $source = ' / ' . array_shift($title); + $title = implode(' : ', $title); + } else { + $title = $d['title']; + $source = null; + } + + $s .= sprintf('
  • %s %s%s
  • ', + $d['link'], $title, news_date($d['date'], $locale), $source); } $s .= ''; echo $s; -- cgit v1.2.1