From 8271f6c3613c0c6c196628b82bcd4f0182fac92c Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 14 Jul 2001 19:02:36 +0000 Subject: - A lot of (a) visual and (b) navigational improvements to import.module. --- modules/import.module | 181 ++++++++++++++++++++++---------------------------- 1 file changed, 81 insertions(+), 100 deletions(-) (limited to 'modules/import.module') diff --git a/modules/import.module b/modules/import.module index ec13e786b..f43ebf4c6 100644 --- a/modules/import.module +++ b/modules/import.module @@ -27,10 +27,6 @@ function import_link($type) { $links[] = "news feeds"; } - if ($type == "menu" && user_access("administer news feeds")) { - $links[] = "". t("update all news") .""; - } - if ($type == "page" && user_access("access news feeds")) { $links[] = "". t("news feeds") .""; } @@ -52,27 +48,15 @@ function import_update() { } } -function import_format_item($item, $feed = 0, $description = 0) { - global $user; +function import_format_item($item, $feed = 0) { + global $theme, $user; if ($user->id && user_access("post blogs")) { - $output .= "iid\">\"" "; - } - - if ($feed != 1) { - $output .= "fid\">\"". "; + $output .= "iid\">image("blog.gif") ."\" border=\"0\" width=\"12\" height=\"16\" alt=\"" . t("Blog this item") . "\" /> "; } $output .= "link) ."\" target=\"new\">". check_output($item->title) .""; - if ($description && ($feed != 1)) { - $output .= "   ". format_url($item->flink, $item->ftitle) .""; - } - - if ($description) { - $output .= "
". check_output($item->description) ."
\n"; - } - return $output ."
"; } @@ -83,24 +67,22 @@ function import_bundle_block($attributes) { foreach ($keys as $key) $where[] = "attributes LIKE '%". trim($key) ."%'"; $result = db_query("SELECT * FROM item WHERE ". implode(" OR ", $where) ." ORDER BY iid DESC LIMIT ". variable_get("import_block_limit", 15)); + } - while ($item = db_fetch_object($result)) { - $output .= import_format_item($item, 0); - } - - return $output; + while ($item = db_fetch_object($result)) { + $output .= import_format_item($item); } + + return $output; } function import_feed_block($feed) { $result = db_query("SELECT * FROM item WHERE fid = '$feed->fid' ORDER BY iid DESC LIMIT ". variable_get("import_block_limit", 15)); while ($item = db_fetch_object($result)) { - $output .= import_format_item($item, 1); + $output .= import_format_item($item); } - $output .= "
". t("Last update:") ." ". format_interval(time() - $feed->timestamp) ." ". t("ago"); - return $output; } @@ -109,57 +91,33 @@ function import_block() { } function import_get_bundles($attributes = 0) { - - if ($attributes) { - $keys = explode(",", $attributes); - foreach ($keys as $key) $where[] = "attributes LIKE '%". trim($key) ."%'"; - $result = db_query("SELECT * FROM item WHERE ". implode(" OR ", $where) ." ORDER BY iid DESC LIMIT ". variable_get("import_block_limit", 15)); - } - else { - $result = db_query("SELECT * FROM item ORDER BY iid DESC LIMIT ". variable_get("import_block_limit", 15)); - } - - while ($item = db_fetch_object($result)) { - $output .= import_format_item($item, 0); - } - - $blocks[0][subject] = format_url("module.php?mod=import", t("Latest news")); - $blocks[0][content] = $output; - $blocks[0][info] = t("Latest news"); - $result = db_query("SELECT * FROM bundle ORDER BY title"); + $i = 0; while ($bundle = db_fetch_object($result)) { + $block[$i][subject] = $bundle->title; + $block[$i][content] = import_bundle_block($bundle->attributes) ."

bid\">". t("details") ."

"; + $block[$i][info] = "$bundle->title bundle"; + $i++; - $blocks[$i][subject] = format_url("module.php?mod=import&op=bundle&id=$bundle->bid", $bundle->title); - $blocks[$i][content] = import_bundle_block($bundle->attributes); - $blocks[$i][info] = "$bundle->title bundle"; } - return $blocks; + return $block; } function import_get_feeds($attributes = 0) { - - if ($attributes) { - $keys = explode(",", $attributes); - foreach ($keys as $key) $where[] = "attributes LIKE '%". trim($key) ."%'"; - $result = db_query("SELECT * FROM feed WHERE ". implode(" OR ", $where) ." ORDER BY fid"); - } - else { - $result = db_query("SELECT * FROM feed ORDER BY fid"); - } + $result = db_query("SELECT * FROM feed ORDER BY fid"); $i = 0; while ($feed = db_fetch_object($result)) { - $blocks[$i][subject] = format_url("module.php?mod=import&op=feed&id=$feed->fid", $feed->title); - $blocks[$i][content] = import_feed_block($feed); - $blocks[$i][info] = "$feed->title feed"; + $block[$i][subject] = $feed->title; + $block[$i][content] = import_feed_block($feed) ."

fid\">". t("details") ."

"; + $block[$i][info] = "$feed->title feed"; $i++; } - return $blocks; + return $block; } function import_remove($feed) { @@ -448,23 +406,28 @@ function import_admin() { } } -function import_page_all() { +function import_page_last() { global $theme; - // Display mode 1: - // $output .= t("This page displays the latest news syndicated from external news feeds.") ."

". t("view news by topic") ."
". t("view news by source") ."


"; - - // Display mode 2: - //$output .= "
". t("view news by topic") ."
"; - //$output .= "
". t("view news by source") ."
"; - - // Display mode 3: - $output .= "
[ ". t("view news by topic") ." | ". t("view news by source") ." ]
"; - $result = db_query("SELECT i.*, f.title AS ftitle, f.link AS flink FROM item i LEFT JOIN feed f ON i.fid = f.fid ORDER BY i.iid DESC LIMIT ". variable_get("import_page_limit", 75)); + + $output .= ""; while ($item = db_fetch_object($result)) { - $output .= import_format_item($item, 0, 1); + $links[] = "iid\">". t("blog") .""; + $links[] = "fid\">". t("feed") .""; + $links[] = "". t("by topic") .""; + $links[] = "". t("by source") .""; + + if ($item->link) { + $output .= "\n"; + } + if ($item->description) { + $output .= ""; + } + + unset($links); } + $output .= "
". format_url($item->link, $item->title) ." · fid\">$item->ftitle". $theme->links($links) ."
". check_output($item->description) ."

\n"; $theme->header(); $theme->box(t("Latest news"), $output); @@ -474,41 +437,71 @@ function import_page_all() { function import_page_feed($fid) { global $theme; - $result = db_query("SELECT * FROM feed WHERE fid = '". check_input($fid) ."'"); - $feed = db_fetch_object($result); + $feed = db_fetch_object(db_query("SELECT * FROM feed WHERE fid = '". check_input($fid) ."'")); - $header .= "url\">"; - $header .= $feed->title . " link\" target=\"new\">\""."; + $header .= "

". t("Website") .":

". format_url($feed->link) ."

"; + $header .= "

". t("Description") .":

". check_output($feed->description) ."

"; + $header .= "

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

". format_interval(time() - $feed->timestamp) ." ". t("ago") ."

"; $result = db_query("SELECT * FROM item WHERE fid = '". check_input($fid) ."' ORDER BY iid DESC LIMIT ". variable_get("import_page_limit", 75)); + + $output .= ""; while ($item = db_fetch_object($result)) { - $output .= import_format_item($item, 1, 1); - } + $links[] = "iid\">". t("blog") .""; + $links[] = "link\">". t("visit") .""; - $output .= t("Last update:") ." ". format_interval(time() - $feed->timestamp) ." ". t("ago"); + if ($item->link) { + $output .= "\n"; + } + if ($item->description) { + $output .= ""; + } + + unset($links); + } + $output .= "
". format_url($item->link, $item->title) ."". $theme->links($links) ."
". check_output($item->description) ."

\n"; + $output .= "url\">image("xml.gif") ."\" width=\"36\" height=\"14\" align=\"right\" border=\"0\" />\n"; $theme->header(); - $theme->box($header, $output); + $theme->box(check_output($feed->title), $header); + $theme->box(t("Latest news"), $output); $theme->footer(); } function import_page_bundle($bid) { global $theme; - $bundle = db_fetch_object(db_query("SELECT * FROM bundle where bid = '". check_input($bid) ."'")); - $header = $bundle->title ." ". t("bundle") ." (". t("by feed") .")"; + $bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = '". check_input($bid) ."'")); + + $header .= "

". t("Website") .":

". format_url("module.php?mod=import&op=bundle&id=$bundle->bid") ."

"; + $header .= "

". t("Description") .":

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

"; $keys = explode(",", $bundle->attributes); foreach ($keys as $key) $where[] = "i.attributes LIKE '%". trim($key) ."%'"; $result = db_query("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 iid DESC LIMIT ". variable_get("import_page_limit", 75)); + $output .= ""; while ($item = db_fetch_object($result)) { - $output .= import_format_item($item, 0, 1); + $links[] = "iid\">". t("blog") .""; + $links[] = "fid\">". t("feed") .""; + $links[] = "link\">". t("visit") .""; + + if ($item->link) { + $output .= "\n"; + } + if ($item->description) { + $output .= ""; + } + + unset($links); } + $output .= "
". format_url($item->link, $item->title) ." · fid\">$item->ftitle". $theme->links($links) ."
". check_output($item->description) ."

\n"; $theme->header(); - $theme->box($header, $output); + $theme->box(check_output($bundle->title), $header); + $theme->box(t("Latest news"), $output); $theme->footer(); + } function import_page_bundles() { @@ -519,11 +512,6 @@ function import_page_feeds() { import_page_blocks(import_get_feeds()); } -function import_page_bundle_feeds($bid) { - $bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = '". check_input($bid) ."'")); - import_page_blocks(import_get_feeds($bundle->attributes)); -} - function import_page_blocks($blocks) { global $theme; @@ -557,7 +545,7 @@ function import_page() { if (user_access("access news feeds")) { switch($op) { case "all": - import_page_all(); + import_page_last(); break; case "feed": import_page_feed($id); @@ -565,21 +553,14 @@ function import_page() { case "bundle": import_page_bundle($id); break; - case "bundlefeeds": - import_page_bundle_feeds($id); - break; case "bundles": import_page_bundles(); break; case "feeds": import_page_feeds(); break; - case "update": - import_update(); - import_page_all(); - break; default: - import_page_all(); + import_page_last(); } } } -- cgit v1.2.3