From 2714fae603e66ded154b983c8d04e6dca19eb55f Mon Sep 17 00:00:00 2001
From: Dries Buytaert <dries@buytaert.net>
Date: Wed, 27 Dec 2000 12:44:27 +0000
Subject: [PATCH] - small bugfixes and standarized "export" routines for
 modules to use.

---
 export                                      |  6 +-
 modules/diary.module                        |  9 +-
 modules/documentation.module                |  4 +-
 modules/{backend.module => headline.module} | 98 +++++++++++----------
 syndicate.rdf                               |  9 --
 themes/marvin/marvin.theme                  |  6 +-
 6 files changed, 68 insertions(+), 64 deletions(-)
 rename modules/{backend.module => headline.module} (69%)
 delete mode 100644 syndicate.rdf

diff --git a/export b/export
index 6b1fa9457dd0..7f1d68af8876 100644
--- a/export
+++ b/export
@@ -2,8 +2,10 @@
 
 include "includes/common.inc";
 
-if ($repository["backend"]) {
-  backend_rdf();
+function export($name, $module) {
+  global $REQUEST_URI;
+  module_execute($name, "export", explode("/", $REQUEST_URI));
 }
 
+module_iterate("export");
 ?>
\ No newline at end of file
diff --git a/modules/diary.module b/modules/diary.module
index 90981b3bda22..0e938d28cc7e 100644
--- a/modules/diary.module
+++ b/modules/diary.module
@@ -2,7 +2,8 @@
 
 $module = array("page"  => "diary_page",
                 "block" => "diary_block",
-                "admin" => "diary_admin");
+                "admin" => "diary_admin",
+                "export" => "diary_export");
 
 include "includes/common.inc";
 
@@ -297,4 +298,10 @@ function diary_admin() {
   }
 }
 
+function diary_export($uri) {
+  if ($uri[2] == "diary") {
+    print "TODO: export diary for user $uri[3]";
+  }
+}
+
 ?>
diff --git a/modules/documentation.module b/modules/documentation.module
index 887a671047b0..ae20534963a3 100644
--- a/modules/documentation.module
+++ b/modules/documentation.module
@@ -99,8 +99,8 @@ function documentation_page() {
     <TD VALIGN="top">If a module requires a spot in the administrator section it should implement <CODE>module_admin</CODE>.  The engine will automatically add a link to the administration menus and will call <CODE>module_admin</CODE> when this link is followed.  In order to make virtually any module maintainer's life easier, you don't have to worry about access rights or permissions for that matter.  The engine will only allow priveleged users to call exported <CODE>admin</CODE> functions.</TD>
    </TR>
    <TR>
-    <TD VALIGN="top"></TD>
-    <TD VALIGN="top"></TD>
+    <TD VALIGN="top"><CODE>export</CODE></TD>
+    <TD VALIGN="top">... All you have to do is examine the string and figure out where you're at.</TD>
    </TR>
    <TR>
     <TD VALIGN="top"></TD>
diff --git a/modules/backend.module b/modules/headline.module
similarity index 69%
rename from modules/backend.module
rename to modules/headline.module
index a06b26caaf90..fd405dc1758b 100644
--- a/modules/backend.module
+++ b/modules/headline.module
@@ -1,43 +1,16 @@
 <?
 
-$module = array("page"  => "backend_page",
-                "cron"  => "backend_cron",
-                "block" => "backend_block",
-                "admin" => "backend_admin");
+$module = array("page"  => "headline_page",
+                "cron"  => "headline_cron",
+                "block" => "headline_block",
+                "admin" => "headline_admin",
+                "export" => "headline_export");
 
 include "includes/common.inc";
 include "modules/backend.class";
 
-function backend_rdf() {
-  global $site_name, $site_url;
-  
-  header("Content-Type: text/plain");
-  
-  print "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
-  print "<rdf:RDF\n";
-  print " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n";
-  print " xmlns=\"http://my.netscape.com/rdf/simple/0.9/\">\n";
-
-  print "<channel>\n";
-  print " <title>$site_name</title>\n";
-  print " <link>$site_url</link>\n";
-  print " <description>$site_name</description>\n";
-  print "</channel>\n";
-
-  $result = db_query("SELECT * FROM stories WHERE status = 2 ORDER BY timestamp DESC LIMIT 10");
-
-  while ($story = db_fetch_object($result)) {
-    print "<item>\n";
-    print " <title>$story->subject</title>\n";
-    print " <link>". $site_url ."discussion.php?id=$story->id</link>\n";
-    print "</item>\n";
-  }
-
-  print "</rdf:RDF>\n";
 
-}
-
-function backend_blocks() {
+function headline_blocks() {
   global $theme;
  
   // Get channel info:
@@ -54,9 +27,9 @@ function backend_blocks() {
     // Load backend from database:
     $backend = new backend($channel->id);
     
-    // Read headlines from backend class:
+    // Read headline from backend class:
     $content = "";
-    for (reset($backend->headlines); $headline = current($backend->headlines); next($backend->headlines)) {
+    for (reset($backend->headline); $headline = current($backend->headline); next($backend->headline)) {
       $content .= "<LI>$headline</LI>\n";
     }
 
@@ -73,44 +46,44 @@ function backend_blocks() {
   $theme->footer();
 }
 
-function backend_page() {
+function headline_page() {
   global $type;
 
   switch($type) {
     case "rdf":
-      backend_rdf();
+      headline_rdf();
       break;
     default:
-      backend_blocks();
+      headline_blocks();
   }
 }
 
-function backend_cron() {
+function headline_cron() {
   $result = db_query("SELECT * FROM channel");
   while ($channel = db_fetch_object($result)) {
     $backend = new Backend($channel->id);
   }
 }
 
-function backend_block() {
+function headline_block() {
   $result = db_query("SELECT * FROM channel");
   while ($channel = db_fetch_object($result)) {
     $backend = new Backend($channel->id);
   
     $content = "";
-    for (reset($backend->headlines); $headline = current($backend->headlines); next($backend->headlines)) {
+    for (reset($backend->headline); $headline = current($backend->headline); next($backend->headline)) {
       $content .= "<LI>$headline</LI>\n";
     }
 
     $blocks[$channel->id]["subject"] = $backend->site;
     $blocks[$channel->id]["content"] = $content;
-    $blocks[$channel->id]["info"] = "$backend->site headlines";
+    $blocks[$channel->id]["info"] = "$backend->site headline";
     $blocks[$channel->id]["link"] = $backend->url;
   }
   return $blocks;
 }
 
-function backend_admin_main() {
+function headline_admin_main() {
   global $theme;
 
   // Get channel info:
@@ -158,27 +131,58 @@ function backend_admin_main() {
   print $output;
 }
 
-function backend_admin() {
+function headline_admin() {
   global $op, $id, $site, $url, $backend, $contact;
   
   switch($op) {
     case "refresh":
       $backend = new backend($id);
       $backend->refresh();
-      backend_admin_main();
+      headline_admin_main();
       break;
     case "delete":
       $backend = new backend($id);
       $backend->dump();
       $backend->delete();
-      backend_admin_main();
+      headline_admin_main();
       break;
     case "Add backend":
       $backend = new backend($id, $site, $url, $backend, $contact);
       $backend->add();
       // fall through:
     default:
-      backend_admin_main();
+      headline_admin_main();
+  }
+}
+
+function headline_export($uri) {
+  global $site_name, $site_url;
+  
+  if ($uri[2] == "headlines.rdf") {
+
+    header("Content-Type: text/plain");
+
+    print "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
+    print "<rdf:RDF\n";
+    print " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n";
+    print " xmlns=\"http://my.netscape.com/rdf/simple/0.9/\">\n";
+
+    print "<channel>\n";
+    print " <title>$site_name</title>\n";
+    print " <link>$site_url</link>\n";
+    print " <description>$site_name</description>\n";
+    print "</channel>\n";
+
+    $result = db_query("SELECT * FROM stories WHERE status = 2 ORDER BY timestamp DESC LIMIT 10");
+  
+    while ($story = db_fetch_object($result)) {
+      print "<item>\n";
+      print " <title>$story->subject</title>\n";
+      print " <link>". $site_url ."discussion.php?id=$story->id</link>\n";
+      print "</item>\n";
+    }
+
+    print "</rdf:RDF>\n";
   }
 }
 
diff --git a/syndicate.rdf b/syndicate.rdf
deleted file mode 100644
index 6b1fa9457dd0..000000000000
--- a/syndicate.rdf
+++ /dev/null
@@ -1,9 +0,0 @@
-<?
-
-include "includes/common.inc";
-
-if ($repository["backend"]) {
-  backend_rdf();
-}
-
-?>
\ No newline at end of file
diff --git a/themes/marvin/marvin.theme b/themes/marvin/marvin.theme
index 929fcc4949ca..2c952d5d0c51 100644
--- a/themes/marvin/marvin.theme
+++ b/themes/marvin/marvin.theme
@@ -53,7 +53,7 @@ function header($title) {
    function abstract($story) {
      print "\n<!-- story: \"$story->subject\" -->\n";     
      print "<TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"2\" WIDTH=\"100%\">\n";
-     print " <TR><TD COLSPAN=\"2\"><IMG SRC=\"themes/marvin/images/drop.gif\" ALT=\"\"> &nbsp; <B>$story->subject</B></TD></TR>\n";
+     print " <TR><TD COLSPAN=\"2\"><IMG SRC=\"themes/marvin/images/drop.gif\" ALT=\"\"> &nbsp; <B>". check_output($story->subject) ."</B></TD></TR>\n";
      print " <TR VALIGN=\"bottom\"><TD COLSPAN=\"2\" BGCOLOR=\"#000000\" WIDTH=\"100%\"><IMG SRC=\"themes/marvin/images/pixel.gif\" WIDTH=\"1\" HEIGHT=\"0\" ALT=\"\"></TD></TR>\n";
      print " <TR>\n";
      print "  <TD>\n";
@@ -76,7 +76,7 @@ function abstract($story) {
    function article($story, $reply) {
      print "\n<!-- story: \"$story->subject\" -->\n";
      print "<TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"2\" WIDTH=\"100%\">\n";
-     print " <TR><TD COLSPAN=\"2\"><IMG SRC=\"themes/marvin/images/drop.gif\" ALT=\"\"> &nbsp; <B>$story->subject</B></TD></TR>\n";
+     print " <TR><TD COLSPAN=\"2\"><IMG SRC=\"themes/marvin/images/drop.gif\" ALT=\"\"> &nbsp; <B>". check_output($story->subject) ."</B></TD></TR>\n";
      print " <TR VALIGN=\"bottom\"><TD COLSPAN=\"2\" BGCOLOR=\"#000000\" WIDTH=\"100%\"><IMG SRC=\"themes/marvin/images/pixel.gif\" WIDTH=\"1\" HEIGHT=\"0\" ALT=\"\"></TD></TR>\n";
      print " <TR>\n";
      print "  <TD>\n";
@@ -244,4 +244,4 @@ function footer() {
    }
  }
 
-?>
\ No newline at end of file
+?>
-- 
GitLab