1 | <?php |
---|
2 | /** |
---|
3 | * Main include for news pages, comparable to |
---|
4 | * /lib/search.php, used only by /{de,en}/news.php |
---|
5 | * |
---|
6 | * |
---|
7 | **/ |
---|
8 | |
---|
9 | if(defined('T29')) return false; // no nesting (e.g. if called by menu.php) |
---|
10 | |
---|
11 | // Diese Datei macht eigentlich nur eines: Den RSS-Newsfeed erzeugen, |
---|
12 | // wenn gewüscht. |
---|
13 | |
---|
14 | $lib = dirname(__FILE__); |
---|
15 | |
---|
16 | if(isset($_GET["format"])) { |
---|
17 | |
---|
18 | $news_file = "/de/news.php"; |
---|
19 | $pubdate = filemtime("$lib/../".$news_file); |
---|
20 | |
---|
21 | require $lib.'/spyc.php'; |
---|
22 | $data = Spyc::YAMLLoad($neues_menu); |
---|
23 | $required_fields = array('titel', 'text', 'link', /*'bild'*/); |
---|
24 | |
---|
25 | # Hack, um die Sprache zu bekommen, von technikum29.php kopiert. |
---|
26 | require "$lib/host.php"; |
---|
27 | $host = t29Host::detect(); |
---|
28 | $file = $host->slash_filename; # e.g.: "/de/page.php" |
---|
29 | if(!isset($lang)) $lang = substr($file, 1, 2); |
---|
30 | if(!in_array($lang, array('de','en'))) $lang = "de"; # check if language exists |
---|
31 | |
---|
32 | require $lib.'/messages.php'; |
---|
33 | $msg = new t29Messages($lang); |
---|
34 | $p = $msg->get_shorthand_printer(); |
---|
35 | |
---|
36 | # und hostname davor. |
---|
37 | # $this->conf['lang_path'].'/'.self::news_file |
---|
38 | $news_url = "http://www.technikum29.de/$lang/news"; |
---|
39 | # if($host) $url = $host->rewrite_link($url); |
---|
40 | |
---|
41 | header("Content-Type: application/rss+xml"); |
---|
42 | header("Last-Modified: " . gmdate("D, d M Y H:i:s", $pubdate) . " GMT"); |
---|
43 | echo '<?xml version="1.0" encoding="utf-8"?>'; |
---|
44 | ?> |
---|
45 | |
---|
46 | <rss |
---|
47 | xmlns:atom="http://www.w3.org/2005/Atom" |
---|
48 | xml:lang="<?php print $lang; ?>" |
---|
49 | version="2.0"> |
---|
50 | <channel> |
---|
51 | <title><?php $p('rss-title'); ?></title> |
---|
52 | <link>http://www.technikum29.de</link> |
---|
53 | <description><?php $p('rss-description'); ?></description> |
---|
54 | <language><?php print $lang; ?></language> |
---|
55 | <copyright>℗ & © 2003-<?=date('Y'); ?> <?php $p('rss-copyright'); ?></copyright> |
---|
56 | <pubDate><?=date('r', $pubdate); ?></pubDate> |
---|
57 | <image> |
---|
58 | <url>http://www.technikum29.de/shared/img-v6/banner.<?php print $lang; ?>.png</url> |
---|
59 | <title>technikum29 Computermuseum</title> |
---|
60 | <link>http://www.technikum29.de/</link> |
---|
61 | </image> |
---|
62 | <!-- Time To Live: Cache validity time for channel until update in minutes --> |
---|
63 | <!--<ttl><?=60*12; ?></ttl>--><!-- half a day --> |
---|
64 | |
---|
65 | <atom:link href="http://www.technikum29.de/<?php print $lang; ?>/news.php?format=rss" rel="self" type="application/rss+xml" /> |
---|
66 | |
---|
67 | <?php |
---|
68 | foreach($data as $e) { |
---|
69 | // Kompatibilitaet im August 2014, Uebergangsphase |
---|
70 | if(!isset($e['text']) && isset($e['untertitel'])) $e['text'] = $e['untertitel']; |
---|
71 | if(!isset($e['link']) && isset($e['datum'])) $e['link'] = $news_url.'#'.str_replace(' ', '_', $e['datum']); |
---|
72 | |
---|
73 | if(!array_reduce(array_map(function($x) use ($required_fields,$e){ return isset($e[$x]); }, $required_fields), |
---|
74 | function($a,$b){ return $a && $b;}, true)) { |
---|
75 | ?> |
---|
76 | <item> |
---|
77 | <title>Fehlformatierung</title> |
---|
78 | <description><![CDATA[<html><body> |
---|
79 | <b>Leider ist dieser Eintrag nicht richtig formatiert</b>. Schauen Sie sich die News-Seite direkt an. |
---|
80 | <p><i>Details:</i></p> |
---|
81 | Eines der Fehler Felder <?php print implode(", ", $required_fields); ?> fehlt. |
---|
82 | Details: <pre><?php print var_dump($e); ?></pre> |
---|
83 | </body></html>]]> |
---|
84 | </description> |
---|
85 | <link>http://www.technikum29.de/de/news</link> |
---|
86 | </item> |
---|
87 | <?php |
---|
88 | } else { |
---|
89 | ?> |
---|
90 | <item> |
---|
91 | <title><?=$e['titel']; ?></title> |
---|
92 | <description><?php |
---|
93 | // if text contains tags like <em>, mark it as HTML |
---|
94 | if(strpos($e['text'], '<') !== false) { print '<![CDATA[<html><body>'; } |
---|
95 | print $e['text']; |
---|
96 | if(strpos($e['text'], '<') !== false) { print '</body></html>]]>'; } ?> |
---|
97 | </description> |
---|
98 | <author>Heribert Müller</author> |
---|
99 | <?php |
---|
100 | if($e['link']{0} == '#') $link = $news_url . $e['link']; |
---|
101 | else if($e['link']{0} == '/') $link = 'http://www.technikum29.de' . $e['link']; |
---|
102 | else $link = $e['link']; |
---|
103 | ?> |
---|
104 | <link><?=$link; ?></link> |
---|
105 | <guid idPermaLink="true"><?=$link; ?></guid> |
---|
106 | <pubDate><?=date('r', $pubdate); ?></pubDate> |
---|
107 | </item> |
---|
108 | <?php |
---|
109 | } |
---|
110 | } |
---|
111 | ?> |
---|
112 | |
---|
113 | </channel> |
---|
114 | </rss> |
---|
115 | <?php |
---|
116 | |
---|
117 | // rss ausgegeben, jetzt: exit um nicht noch Seite auszugeben. |
---|
118 | exit(); |
---|
119 | } else { |
---|
120 | // bin eingebunden von news-Seite |
---|
121 | require("$lib/technikum29.php"); |
---|
122 | // wichtig: |
---|
123 | return true; |
---|
124 | } |
---|
125 | |
---|