From 97fe958df9e66be1c08add741950d1b80267fc31 Mon Sep 17 00:00:00 2001
From: Dries Buytaert ". t("Website") .":". htmlentities($data[0]) ."
";
- // print "". htmlentities($data[0]) ."
";
+ $items = array_reverse(explode("title = ". htmlentities($title) ."\n\ndescription = ". htmlentities($description) ."\n\nlink = ". htmlentities($link) ."
";
- print "title = ". htmlentities($title) ."\n\ndescription = ". htmlentities($description) ."\n\nlink = ". htmlentities($link) ."
";
+ /*
+ ** Save this item:
+ */
- /*
- ** Save this item:
- */
-
- import_save_item(array(fid => $feed[fid], title => $title, link => $link, author => $author[1], description => $description, attributes => $feed[attributes]));
- }
+ import_save_item(array(fid => $feed[fid], title => $title, link => $link, author => $author[1], description => $description, attributes => $feed[attributes]));
}
}
- else {
- watchdog("warning", "failed to syndicate from '$feed[title]'". ($errstr ? ": $errstr" : ""));
- }
+ }
+ else {
+ watchdog("warning", "failed to syndicate from '$feed[title]'". ($errstr ? ": $errstr" : ""));
}
return "feed '$feed[title]' updated.";
@@ -273,8 +266,8 @@ function import_form_feed($edit = array()) {
$period = array(900 => format_interval(900), 1800 => format_interval(1800), 3600 => format_interval(3600), 7200 => format_interval(7200), 10800 => format_interval(10800), 21600 => format_interval(21600), 32400 => format_interval(32400), 43200 => format_interval(43200), 64800 => format_interval(64800), 86400 => format_interval(86400), 172800 => format_interval(172800), 259200 => format_interval(259200), 604800 => format_interval(604800), 1209600 => format_interval(1209600), 2419200 => format_interval(2419200));
- if ($edit[refresh]== "") $edit[refresh] = 3600;
- if ($edit[uncache]== "") $edit[uncache] = 2419200;
+ if ($edit[refresh] == "") $edit[refresh] = 3600;
+ if ($edit[uncache] == "") $edit[uncache] = 2419200;
$form .= form_textfield("Title", "title", $edit[title], 50, 64, "The name of the feed; typically the name of the website you syndicate content from.");
$form .= form_textfield("Url", "url", $edit[url], 50, 128, "The fully-qualified URL of the feed.");
@@ -345,23 +338,68 @@ function import_view() {
return $output;
}
-function import_view_feed() {
- $result = db_query("SELECT * FROM feed ORDER BY title");
- while ($feed = db_fetch_object($result)) {
- $output .= "$feed->title". ($feed->link ? " (". format_url($feed->link) .")" : "") ."". check_output($feed->description) ."
";
+function import_fd_form() {
+ global $REQUEST_URI;
+
+ $form .= form_textfield("Feed directory file", "url", "http://127.0.0.1/1.fd", 64, 128, "The fully-qualified URL of the feed directory file.");
+ $form .= form_submit("Collect feeds");
+
+ return form($REQUEST_URI, $form);
+}
+
+function import_fd_collect($edit) {
+ global $REQUEST_URI;
+
+ set_time_limit(180);
+
+ if ($fp = fopen($edit[url], "r")) {
+ // fetch data:
+ while (!feof($fp)) {
+ $data .= fgets($fp, 128);
+ }
+
+ // initialize the translation table:
+ $tt = array_flip(get_html_translation_table(HTML_ENTITIES));
+ $tt["'"] = "'";
+
+ $items = explode("", $data);
+
+ $output .= "";
+
+ return $output;
+ }
+ else {
+ print status("failed to open '$edit[url]': $errstr.");
}
- return $output;
}
-function import_view_bundle() {
- $result = db_query("SELECT * FROM bundle ORDER BY title");
- while ($bundle = db_fetch_object($result)) {
- $output .= "$bundle->title". import_bundle_block($bundle->attributes) ."
";
+function import_fd_import($edit) {
+ foreach ($edit as $title => $link) {
+ import_save_feed(array("title" => $title, "url" => $link, "refresh" => 3600, "uncache" => 2419200));
}
- return $output;
}
-function import_view_item() {
+function import_tag() {
global $REQUEST_URI;
$result = db_query("SELECT i.*, f.title AS feed FROM item i LEFT JOIN feed f ON i.fid = f.fid ORDER BY i.iid DESC LIMIT 50");
@@ -384,7 +422,7 @@ function import_admin() {
if (user_access("administer news feeds")) {
- print "add new feed | add new bundle | available feeds | available bundles | available items | overview | help
";
+ print "add new feed | add new bundle | import feeds | tag items | overview | help
";
switch($op) {
case "help":
@@ -402,6 +440,16 @@ function import_admin() {
else
print import_form_feed(import_get_feed($id));
break;
+ case "fd":
+ print import_fd_form();
+ break;
+ case "Collect feeds":
+ print import_fd_collect($edit);
+ break;
+ case "Import feeds":
+ print import_fd_import($edit);
+ print import_view();
+ break;
case "remove":
print status(import_remove(import_get_feed($id)));
print import_view();
@@ -410,9 +458,12 @@ function import_admin() {
print status(import_refresh(import_get_feed($id)));
print import_view();
break;
+ case "tag":
+ print import_tag();
+ break;
case "Save attributes":
print status(import_save_attributes($edit));
- print import_view_item();
+ print import_tag();
break;
case "Delete":
$edit[title] = 0;
@@ -426,14 +477,7 @@ function import_admin() {
print import_view();
break;
default:
- if ($type == "bundle")
- print import_view_bundle();
- else if ($type == "feed")
- print import_view_feed();
- else if ($type == "item")
- print import_view_item();
- else
- print import_view();
+ print import_view();
}
}
else {
@@ -486,7 +530,7 @@ function import_page_feed($fid) {
$header .= "
". t("Description") .":
". t("Last update") .":
". t("Last update") .":