gen_html_preview.php (3936B)
1 <?php
2 function gen_preview($config) {
3
4 /* Gather news sources from selection */
5 $input_keys = preg_grep(
6 "/^source-[0-9]+$/",
7 array_keys($_POST)
8 );
9 $sources = array();
10 foreach ($input_keys as $key) {
11 $sources[$_POST[$key]] = $config["sources"][$_POST[$key]];
12 }
13
14
15 $feed = array();
16 foreach ($sources as $source) {
17 $tmp = parse_rss(
18 $source["rss"],
19 $source["topics"],
20 $config["publisher"][$source["publisher"][0]]["name"] . ": " .
21 $source["title"]
22 );
23 foreach ($tmp as $item) {
24 array_push($feed, $item);
25 }
26 }
27
28 uasort($feed, "sort_by_date_rev");
29
30
31 ?>
32
33 <!doctype html>
34 <html>
35
36 <!-- Head -->
37 <?php gen_html_head(); ?>
38
39 <!-- Body -->
40 <body>
41
42 <!-- Header / Navigation -->
43 <?php gen_html_navigation(); ?>
44
45 <!-- Explaination -->
46 <h3>Feed Vorabansicht</h3>
47 <p>Folgende Nachrichtenquellen wurden ausgewählt:</p>
48 <ul>
49 <?php
50 foreach ($sources as $source) {
51 $title = $config["publisher"][$source["publisher"][0]]["name"] . ": " .
52 $source["title"];
53 ?>
54 <li>
55 <a
56 href="<?php echo $source["web"]; ?>"
57 target="_blank"
58 rel="nofollow noindex ugc"
59 >
60 <?php echo $title; ?>
61 </a>
62 </li>
63 <?php
64 }
65 ?>
66 </ul>
67 <p>
68 Die neusten verfügbaren Nachrichten dieser Quellen werden unten
69 angezeigt. Die Nachrichtenquellen können hier direkt als OPML-Datei
70 exportiert und in einen RSS-Reader importiert werden.
71 </p>
72 <form id="sources-selection" method="post">
73 <button
74 type="submit"
75 name="action"
76 value="gen_opml"
77 title="Erzeugt die OPML-Datei, die in den RSS-Reader importiert werden kann"
78 >
79 Feed erzeugen
80 </button>
81 <button onlick="history.back();">
82 Zurück zur Übersicht
83 </button>
84
85 <?php
86 $cnt = 0;
87 foreach ($sources as $id => $source) {
88 $cnt++;
89 ?>
90
91 <input
92 type="hidden"
93 name="<?php echo "source-" . $cnt; ?>"
94 value="<?php echo $id; ?>"
95 >
96
97 <?php
98 }
99 ?>
100
101 </form>
102
103
104 <!-- Feed Preview -->
105 <div id="sources">
106 <h3>Nachrichten</h3>
107 <p>
108 Das ist die Vorabansicht der ausgewählten Nachrichtenquellen. So
109 oder so ähnlich würde der Feed aussehen, wenn er in einen RSS-Reader
110 importiert wird.
111 </p>
112
113 <?php
114 foreach ($feed as $item) {
115 ?>
116 <section>
117 <!-- Headline -->
118 <h3>
119 <a
120 href="<?php echo $item["link"]; ?>"
121 target="_blank"
122 rel="nofollow noindex ugc"
123 >
124 <?php echo $item["title"]; ?>
125 </a>
126 </h3>
127 <!-- Information -->
128 <em><?php echo $item["publ"]; ?></em>
129 <br>
130 <em><?php echo $item["date"]; ?></em>
131 <!-- Content -->
132 <p><?php echo $item["desc"]; ?></p>
133 <!-- Categories -->
134 <?php
135 foreach ($item["cats"] as $cat) {
136 ?>
137 <mark><?php echo $config["topics"][$cat]["name"]; ?></mark>
138 <?php
139 }
140 ?>
141 </section>
142
143 <?php
144 }
145 ?>
146 </div><!-- sources -->
147
148 <!-- FAQs / About-Section -->
149 <?php gen_html_faqs($config); ?>
150
151 <!-- Footer -->
152 <?php gen_html_footer($config); ?>
153
154 </body>
155
156 </html>
157
158 <?php
159 }
160 ?>