summaryrefslogtreecommitdiff
path: root/modules/export.module
blob: 3464d4222677f693bfa1613aeeed98af14b257b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php

function export_export_rdf() {
  global $status;

  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>". variable_get(site_name, "drupal") ."</title>\n";
  print " <link>". path_uri() ."</link>\n";
  print " <description>". variable_get(site_name, "drupal") ."</description>\n";
  print "</channel>\n";

  $result = db_query("SELECT * FROM node WHERE promote = '1' AND status = '$status[posted]' ORDER BY timestamp DESC LIMIT 10");

  while ($node = db_fetch_object($result)) {
    print "<item>\n";
    print " <title>". check_export($node->title) ."</title>\n";
    print " <link>". path_uri() ."node.php?id=$node->nid</link>\n";
    print "</item>\n";
  }

  print "</rdf:RDF>\n";
}

function export_export_rss() {
  global $status;

  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://purl.org/rss/1.0/\">\n\n";

  print "<channel rdf:about=\"". path_uri() ."export.php?headlines.rss\">\n";
  print "   <title>". variable_get(site_name, "drupal") ."</title>\n";
  print "   <link>". path_uri() ."</link>\n";
  print "   <description>". variable_get(site_name, "drupal") ."</description>\n";

  print "  <items>\n";
  print "    <rdf:Seq>\n";

  $result = db_query("SELECT * FROM node WHERE promote = '1' AND status = '$status[posted]' ORDER BY timestamp DESC LIMIT 10");

  while ($node = db_fetch_object($result)) {
    print "      <rdf:li resource=\"". path_uri() ."node.php?id=$node->nid\" />\n";
  }

  print "    </rdf:Seq>\n";
  print "  </items>\n";
  print "</channel>\n\n";

  $result = db_query("SELECT * FROM node WHERE promote = '1' AND status = '$status[posted]' ORDER BY timestamp DESC LIMIT 10");

  while ($node = db_fetch_object($result)) {
    print "<item rdf:about=\"". path_uri() ."node.php?id=$node->nid\">\n";
    print "  <title>". check_export($node->title) ."</title>\n";
    print "  <link>". path_uri() ."node.php?id=$node->nid</link>\n";
    print "</item>\n";
  }

  print "</rdf:RDF>\n";
}

function export_export($query) {
  switch ($query) {
    case "headlines.rss":
      export_export_rss();
      break;
    case "headlines.rdf":
    case "default":
      export_export_rdf();
  }
}

?>