From 86f8a25059e2e2d9769db23ddecc115d2a5976c2 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 10 Jan 2004 15:31:26 +0000 Subject: Aggregator module improvements: + Added some a new theme fucntions to the aggregator to make it possible to theme the aggregator page. + Removed the and much hardcoded CSS as well as theme("box")-es. + Added the aggregator's theme functions to Doxygen's themeable group. + Added breadcrumb trails to the aggregator pages. + Updated the core themes to take advantages of the improved themeability. Screenshot: http://buytaert.net/temporary/aggregator-makeover.jpg --- modules/aggregator.module | 138 +++++++++++++++++++++------------------------- 1 file changed, 63 insertions(+), 75 deletions(-) (limited to 'modules/aggregator.module') diff --git a/modules/aggregator.module b/modules/aggregator.module index 52330386c..2c20319d5 100644 --- a/modules/aggregator.module +++ b/modules/aggregator.module @@ -123,19 +123,6 @@ function aggregator_update() { } } -function theme_aggregator_format_item($item, $feed = 0) { - global $user; - - if ($user->uid && module_exist("blog") && user_access("maintain personal blog")) { - $output .= "
". l("\"".", "node/add/blog", array("title" => t("Comment on this news item in your personal blog."), "class" => "blog-it"), "iid=$item->iid") ."
"; - } - - // external link - $output .= "link\">$item->title"; - - return $output; -} - function aggregator_bundle_block($attributes) { if ($attributes) { $keys = explode(",", $attributes); @@ -148,7 +135,7 @@ function aggregator_bundle_block($attributes) { $items = array(); while ($item = db_fetch_object($result)) { - $items[] = theme("aggregator_format_item", $item); + $items[] = theme("aggregator_block_item", $item); } return theme("item_list", $items); @@ -159,7 +146,7 @@ function aggregator_feed_block($feed) { $items = array(); while ($item = db_fetch_object($result)) { - $items[] = theme("aggregator_format_item", $item); + $items[] = theme("aggregator_block_item", $item); } return theme("item_list", $items); @@ -622,23 +609,11 @@ function aggregator_admin() { function aggregator_page_last() { $result = db_query_range("SELECT i.*, f.title AS ftitle, f.link AS flink FROM {item} i INNER JOIN {feed} f ON i.fid = f.fid ORDER BY i.timestamp DESC", 0, variable_get("aggregator_page_limit", 75)); - $output = "
"; + $output = "
"; while ($item = db_fetch_object($result)) { - $links = array(format_date($item->timestamp)); - if (module_exist("blog") && user_access("maintain personal blog")) { - $links[] = l(t("blog it"), "node/add/blog", array("title" => t("Comment on this news item in your personal blog.")), "iid=$item->iid"); - } - $links[] = l(t("feed"), "aggregator/feed/$item->fid", array("title" => t("Read more syndicated news from this feed."))); - - if ($item->link) { - $output .= "
\n"; - } - - if ($item->description) { - $output .= ""; - } + $output .= theme('aggregator_page_item', $item); } - $output .= "
link\">$item->title · ". l($item->ftitle, "aggregator/feed/$item->fid", array("title" => t("View more information about this feed."))) ."". theme("links", $links) ."
$item->description

\n"; + $output .= ""; print theme("page", $output); } @@ -646,69 +621,36 @@ function aggregator_page_last() { function aggregator_page_feed($fid) { $feed = db_fetch_object(db_query("SELECT * FROM {feed} WHERE fid = %d", $fid)); - $header = "

". t("Website") .":

link\">$feed->link

"; - $header .= "

". t("Description") .":

$feed->description

"; - $header .= "

". t("Last update") .":

". t("%time ago", array("%time" => format_interval(time() - $feed->checked))) ." url\">\"\"

\n"; + $info = $feed->description; + $info .= "

". t("URL") ."

link\">$feed->link url\">\"\"\n"; + $info .= "

". t("Last update") ."

". t("%time ago", array("%time" => format_interval(time() - $feed->checked))); $result = db_query_range("SELECT * FROM {item} WHERE fid = %d ORDER BY timestamp DESC", $fid, 0, variable_get("aggregator_page_limit", 75)); - - $output .= ""; while ($item = db_fetch_object($result)) { - $links = array(); - if (module_exist("blog") && user_access("maintain personal blog")) { - $links[] = l(t("blog it"), "node/add/blog", array("title" => t("Comment on this news item in your personal blog.")), "iid=$item->iid"); - } - $links[] = "link\">". t("visit") .""; - - if ($item->link) { - $output .= "\n"; - } - if ($item->description) { - $output .= ""; - } + $content .= theme('aggregator_page_item', $item); } - $output .= "
link\">$item->title". theme("links", $links) ."
$item->description

\n"; - print theme("header"); - print theme("box", $feed->title, $header); - print theme("box", t("Latest news"), $output); - print theme("footer"); + $output = "
$info
$content
"; + + print theme("page", $output, $feed->title, array(l(t('Home'), NULL), l(t('news aggregator'), 'aggregator'), l(t('news by source'), 'aggregator/feeds'))); } function aggregator_page_bundle($bid) { $bundle = db_fetch_object(db_query("SELECT * FROM {bundle} WHERE bid = %d", $bid)); - $header .= "

". t("Website") .":

". l($bundle->title, "aggregator/bundle/$bundle->bid") ."

"; - $header .= "

". t("Description") .":

". t("A composite news feed about") ." $bundle->attributes.

"; + $info = t("A composite news feed about") ." $bundle->attributes."; $keys = explode(",", $bundle->attributes); foreach ($keys as $key) $where[] = "i.attributes LIKE '%". trim($key) ."%'"; $result = db_query_range("SELECT i.*, f.title AS ftitle, f.link AS flink FROM {item} i, {feed} f WHERE (". implode(" OR ", $where) .") AND i.fid = f.fid ORDER BY timestamp DESC", 0, variable_get("aggregator_page_limit", 75)); - $output .= ""; while ($item = db_fetch_object($result)) { - if (module_exist("blog") && user_access("maintain personal blog")) { - $links[] = l(t("blog it"), "node/add/blog", array("title" => t("Comment on this news item in your personal blog.")), "iid=$item->iid"); - } - $links[] = l(t("feed"), "aggregator/feed/$item->fid", array("title" => t("Read more syndicated news from this feed."))); - $links[] = "link\">". t("visit") .""; - - if ($item->link) { - $output .= "\n"; - } - - if ($item->description) { - $output .= ""; - } - - unset($links); + $content .= theme('aggregator_page_item', $item); } - $output .= "
link\">$item->title · ". l($item->ftitle, "aggregator/feed/$item->fid", array("title" => t("View more information about this feed."))) ."". theme("links", $links) ."
$item->description

\n"; - print theme("header"); - print theme("box", $bundle->title, $header); - print theme("box", t("Latest news"), $output); - print theme("footer"); + $output = "
$info
$content
"; + + print theme("page", $output, $bundle->title, array(l(t('Home'), NULL), l(t('news aggregator'), 'aggregator'), l(t('news by topic'), 'aggregator/bundles'))); } function aggregator_page_sources() { @@ -805,4 +747,50 @@ function aggregator_page() { } } +/** + * @addtogroup themeable + * @{ + */ + +function theme_aggregator_block_item($item, $feed = 0) { + global $user; + + if ($user->uid && module_exist("blog") && user_access("maintain personal blog")) { + $output .= "
". l("\"".", "node/add/blog", array("title" => t("Comment on this news item in your personal blog."), "class" => "blog-it"), "iid=$item->iid") ."
"; + } + + // external link + $output .= "link\">$item->title"; + + return $output; +} + +function theme_aggregator_page_item($item) { + + static $last; + + $date = date("Ymd", $item->timestamp); + if ($date != $last) { + $last = $date; + $output .= "

". date("F j, Y", $item->timestamp) ."

\n"; + } + + $output .= "
\n"; + $output .= "
". date("H:i", $item->timestamp) ."
\n"; + $output .= "
\n"; + $output .= " \n"; + if ($item->description) { + $output .= "
$item->description
\n"; + } + if ($item->ftitle && $item->fid) { + $output .= "
". t('Source') .": ". l($item->ftitle, "aggregator/feed/$item->fid") ."
\n"; + } + $output .= "
\n"; + $output .= "
\n"; + + return $output; +} + +/** @} End of addtogroup themeable */ + ?> -- cgit v1.2.3