]>
Commit | Line | Data |
---|---|---|
1cd17194 | 1 | <? |
090e250b AD |
2 | $op = $_GET["op"]; |
3 | ||
4 | if ($op == "rpc") { | |
5 | header("Content-Type: application/xml"); | |
6 | } | |
1cd17194 | 7 | |
82baad4a | 8 | require_once "config.php"; |
648472a7 | 9 | require_once "db.php"; |
82baad4a AD |
10 | require_once "functions.php"; |
11 | require_once "magpierss/rss_fetch.inc"; | |
1cd17194 | 12 | |
648472a7 | 13 | $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); |
d76a3b03 | 14 | |
648472a7 AD |
15 | if (DB_TYPE == "pgsql") { |
16 | pg_query("set client_encoding = 'utf-8'"); | |
17 | } | |
090e250b | 18 | |
331900c6 | 19 | $fetch = $_GET["fetch"]; |
175847de | 20 | |
090e250b AD |
21 | function getLabelCounters($link) { |
22 | ||
23 | $result = db_query($link, "SELECT count(id) as count FROM ttrss_entries | |
24 | WHERE marked = true"); | |
25 | ||
26 | $count = pg_fetch_result($result, 0, "count"); | |
27 | ||
28 | print "<label id=\"-1\" counter=\"$count\"/>"; | |
29 | ||
30 | $result = db_query($link, "SELECT id,sql_exp,description FROM | |
31 | ttrss_labels ORDER by description"); | |
32 | ||
33 | while ($line = db_fetch_assoc($result)) { | |
34 | ||
35 | $id = -$line["id"] - 11; | |
36 | ||
37 | error_reporting (0); | |
38 | ||
39 | $tmp_result = pg_query("SELECT count(id) as count FROM ttrss_entries | |
40 | WHERE " . $line["sql_exp"]); | |
41 | ||
42 | $count = pg_fetch_result($tmp_result, 0, "count"); | |
43 | ||
44 | print "<feed id=\"$id\" counter=\"$count\"/>"; | |
45 | ||
46 | error_reporting (E_ERROR | E_WARNING | E_PARSE); | |
47 | ||
48 | } | |
49 | } | |
50 | ||
51 | function getFeedCounters($link) { | |
52 | ||
53 | $result = db_query($link, "SELECT id, | |
54 | (SELECT count(id) FROM ttrss_entries WHERE feed_id = ttrss_feeds.id | |
55 | AND unread = true) as count | |
56 | FROM ttrss_feeds"); | |
57 | ||
58 | while ($line = db_fetch_assoc($result)) { | |
59 | ||
60 | $id = $line["id"]; | |
61 | $count = $line["count"]; | |
62 | ||
63 | print "<feed id=\"$id\" counter=\"$count\"/>"; | |
64 | } | |
65 | } | |
66 | ||
c3b81db0 | 67 | function outputFeedList($link) { |
175847de | 68 | |
1a66d16e AD |
69 | print "<html><head> |
70 | <title>Tiny Tiny RSS : Feedlist</title> | |
71 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\"> | |
72 | <script type=\"text/javascript\" src=\"functions.js\"></script> | |
73 | <script type=\"text/javascript\" src=\"feedlist.js\"></script> | |
74 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> | |
75 | </head><body>"; | |
254e0e4b AD |
76 | |
77 | print "<ul class=\"feedList\" id=\"feedList\">"; | |
78 | ||
79 | /* virtual feeds */ | |
80 | ||
81 | $result = db_query($link, "SELECT count(id) as num_starred | |
82 | FROM ttrss_entries WHERE marked = true"); | |
83 | $num_starred = db_fetch_result($result, 0, "num_starred"); | |
84 | ||
7bb699de | 85 | printFeedEntry(-1, "odd", "Starred articles", $num_starred, "images/mark_set.png"); |
254e0e4b | 86 | |
48f0adb0 AD |
87 | if (ENABLE_LABELS) { |
88 | ||
090e250b | 89 | $result = db_query($link, "SELECT id,sql_exp,description FROM |
48f0adb0 AD |
90 | ttrss_labels ORDER by description"); |
91 | ||
92 | if (db_num_rows($result) > 0) { | |
93 | print "<li><hr></li>"; | |
94 | } | |
95 | ||
96 | while ($line = db_fetch_assoc($result)) { | |
090e250b AD |
97 | |
98 | error_reporting (0); | |
48f0adb0 | 99 | |
090e250b AD |
100 | $tmp_result = pg_query("SELECT count(id) as count FROM ttrss_entries |
101 | WHERE " . $line["sql_exp"]); | |
102 | ||
103 | $count = pg_fetch_result($tmp_result, 0, "count"); | |
104 | ||
105 | error_reporting (E_ERROR | E_WARNING | E_PARSE); | |
106 | ||
48f0adb0 | 107 | printFeedEntry(-$line["id"]-11, |
090e250b | 108 | "odd", $line["description"], $count, "images/label.png"); |
48f0adb0 AD |
109 | |
110 | } | |
111 | } | |
112 | ||
254e0e4b AD |
113 | print "<li><hr></li>"; |
114 | ||
648472a7 | 115 | $result = db_query($link, "SELECT *, |
d76a3b03 AD |
116 | (SELECT count(id) FROM ttrss_entries |
117 | WHERE feed_id = ttrss_feeds.id) AS total, | |
118 | (SELECT count(id) FROM ttrss_entries | |
119 | WHERE feed_id = ttrss_feeds.id AND unread = true) as unread | |
120 | FROM ttrss_feeds ORDER BY title"); | |
1cd17194 | 121 | |
1a66d16e AD |
122 | $actid = $_GET["actid"]; |
123 | ||
254e0e4b | 124 | /* real feeds */ |
1cd17194 AD |
125 | |
126 | $lnum = 0; | |
127 | ||
76798ff3 AD |
128 | $total_unread = 0; |
129 | ||
648472a7 | 130 | while ($line = db_fetch_assoc($result)) { |
a1a8a2be | 131 | |
6f428bc5 | 132 | $feed = $line["title"]; |
2c1dd701 | 133 | $feed_id = $line["id"]; |
13ad9102 AD |
134 | |
135 | $subop = $_GET["subop"]; | |
2c1dd701 | 136 | |
d76a3b03 AD |
137 | $total = $line["total"]; |
138 | $unread = $line["unread"]; | |
139 | ||
e828e31e AD |
140 | // $class = ($lnum % 2) ? "even" : "odd"; |
141 | ||
142 | $class = "odd"; | |
a1a8a2be AD |
143 | |
144 | if ($unread > 0) $class .= "Unread"; | |
145 | ||
1a66d16e AD |
146 | if ($actid == $feed_id) { |
147 | $class .= "Selected"; | |
148 | } | |
149 | ||
76798ff3 AD |
150 | $total_unread += $unread; |
151 | ||
254e0e4b | 152 | printFeedEntry($feed_id, $class, $feed, $unread, "icons/$feed_id.ico"); |
476cac42 | 153 | |
e828e31e AD |
154 | ++$lnum; |
155 | } | |
82baad4a | 156 | |
a1a8a2be | 157 | print "</table>"; |
1cd17194 | 158 | |
caa4e57f AD |
159 | print "<div class=\"invisible\" id=\"FEEDTU\">$total_unread</div>"; |
160 | ||
c3b81db0 AD |
161 | } |
162 | ||
163 | ||
164 | if ($op == "rpc") { | |
165 | ||
166 | $subop = $_GET["subop"]; | |
167 | ||
090e250b AD |
168 | if ($subop == "getLabelCounters") { |
169 | print "<rpc-reply>"; | |
170 | getLabelCounters($link); | |
171 | print "</rpc-reply>"; | |
172 | } | |
173 | ||
174 | if ($subop == "getFeedCounters") { | |
175 | print "<rpc-reply>"; | |
176 | getFeedCounters($link); | |
177 | print "</rpc-reply>"; | |
178 | } | |
179 | ||
180 | if ($subop == "getAllCounters") { | |
181 | print "<rpc-reply>"; | |
182 | getLabelCounters($link); | |
183 | getFeedCounters($link); | |
184 | print "</rpc-reply>"; | |
185 | ||
186 | } | |
187 | ||
f4c10d44 AD |
188 | if ($subop == "mark") { |
189 | $mark = $_GET["mark"]; | |
648472a7 | 190 | $id = db_escape_string($_GET["id"]); |
f4c10d44 AD |
191 | |
192 | if ($mark == "1") { | |
193 | $mark = "true"; | |
194 | } else { | |
195 | $mark = "false"; | |
196 | } | |
197 | ||
648472a7 | 198 | $result = db_query($link, "UPDATE ttrss_entries SET marked = $mark |
f4c10d44 AD |
199 | WHERE id = '$id'"); |
200 | } | |
201 | ||
caa4e57f | 202 | if ($subop == "updateFeed") { |
648472a7 | 203 | $feed_id = db_escape_string($_GET["feed"]); |
9cfc649a | 204 | |
648472a7 | 205 | $result = db_query($link, |
caa4e57f | 206 | "SELECT feed_url FROM ttrss_feeds WHERE id = '$feed_id'"); |
9cfc649a | 207 | |
648472a7 AD |
208 | if (db_num_rows($result) > 0) { |
209 | $feed_url = db_fetch_result($result, 0, "feed_url"); | |
caa4e57f AD |
210 | // update_rss_feed($link, $feed_url, $feed_id); |
211 | } | |
9cfc649a | 212 | |
caa4e57f | 213 | print "DONE-$feed_id"; |
9cfc649a | 214 | |
caa4e57f | 215 | return; |
9cfc649a AD |
216 | } |
217 | ||
090e250b | 218 | if ($subop == "forceUpdateAllFeeds" || $subop == "updateAllFeeds") { |
c3b81db0 | 219 | update_all_feeds($link, true); |
c3b81db0 | 220 | |
090e250b AD |
221 | print "<rpc-reply>"; |
222 | getLabelCounters($link); | |
223 | getFeedCounters($link); | |
224 | print "</rpc-reply>"; | |
c3b81db0 AD |
225 | } |
226 | ||
227 | if ($subop == "catchupPage") { | |
228 | ||
229 | $ids = split(",", $_GET["ids"]); | |
230 | ||
231 | foreach ($ids as $id) { | |
232 | ||
648472a7 | 233 | db_query($link, "UPDATE ttrss_entries SET unread=false,last_read = NOW() |
c3b81db0 AD |
234 | WHERE id = '$id'"); |
235 | ||
236 | } | |
237 | ||
238 | print "Marked active page as read."; | |
239 | } | |
c3b81db0 AD |
240 | } |
241 | ||
242 | if ($op == "feeds") { | |
243 | ||
244 | $subop = $_GET["subop"]; | |
245 | ||
246 | if ($subop == "catchupAll") { | |
648472a7 | 247 | db_query($link, "UPDATE ttrss_entries SET last_read = NOW(),unread = false"); |
c3b81db0 AD |
248 | } |
249 | ||
250 | outputFeedList($link); | |
251 | ||
1cd17194 AD |
252 | } |
253 | ||
254 | if ($op == "view") { | |
255 | ||
d76a3b03 AD |
256 | $id = $_GET["id"]; |
257 | ||
648472a7 | 258 | $result = db_query($link, "UPDATE ttrss_entries SET unread = false,last_read = NOW() WHERE id = '$id'"); |
a1a8a2be | 259 | |
70830c87 AD |
260 | $addheader = $_GET["addheader"]; |
261 | ||
648472a7 | 262 | $result = db_query($link, "SELECT title,link,content,feed_id,comments, |
b7f4bda2 AD |
263 | (SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url |
264 | FROM ttrss_entries | |
d76a3b03 | 265 | WHERE id = '$id'"); |
1cd17194 | 266 | |
70830c87 | 267 | if ($addheader) { |
f0601b87 | 268 | print "<html><head> |
70830c87 AD |
269 | <title>Tiny Tiny RSS : Article $id</title> |
270 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\"> | |
c05608c2 | 271 | <script type=\"text/javascript\" src=\"functions.js\"></script> |
70830c87 | 272 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> |
f0601b87 | 273 | </head><body>"; |
70830c87 AD |
274 | } |
275 | ||
d76a3b03 | 276 | if ($result) { |
1cd17194 | 277 | |
648472a7 | 278 | $line = db_fetch_assoc($result); |
1cd17194 | 279 | |
b7f4bda2 AD |
280 | if ($line["icon_url"]) { |
281 | $feed_icon = "<img class=\"feedIcon\" src=\"" . $line["icon_url"] . "\">"; | |
282 | } else { | |
283 | $feed_icon = " "; | |
284 | } | |
d76a3b03 | 285 | |
f7181e9b AD |
286 | if ($line["comments"] && $line["link"] != $line["comments"]) { |
287 | $entry_comments = "(<a href=\"".$line["comments"]."\">Comments</a>)"; | |
288 | } else { | |
289 | $entry_comments = ""; | |
290 | } | |
291 | ||
e828e31e AD |
292 | print "<div class=\"postReply\">"; |
293 | ||
294 | print "<div class=\"postHeader\"><table>"; | |
295 | ||
296 | print "<tr><td><b>Title:</b></td> | |
297 | <td width='100%'>" . $line["title"] . "</td></tr>"; | |
f7181e9b | 298 | |
e828e31e | 299 | print "<tr><td><b>Link:</b></td> |
f7181e9b AD |
300 | <td width='100%'> |
301 | <a href=\"" . $line["link"] . "\">".$line["link"]."</a> | |
302 | $entry_comments</td></tr>"; | |
e828e31e AD |
303 | |
304 | print "</table></div>"; | |
305 | ||
306 | print "<div class=\"postIcon\">" . $feed_icon . "</div>"; | |
307 | print "<div class=\"postContent\">" . $line["content"] . "</div>"; | |
308 | ||
309 | print "</div>"; | |
310 | ||
090e250b AD |
311 | print "<script type=\"text/javascript\"> |
312 | update_label_counters(); | |
313 | </script>"; | |
d76a3b03 | 314 | } |
70830c87 AD |
315 | |
316 | if ($addheader) { | |
317 | print "</body></html>"; | |
318 | } | |
1cd17194 AD |
319 | } |
320 | ||
321 | if ($op == "viewfeed") { | |
322 | ||
323 | $feed = $_GET["feed"]; | |
d76a3b03 | 324 | $skip = $_GET["skip"]; |
476cac42 | 325 | $subop = $_GET["subop"]; |
f175937c | 326 | $view_mode = $_GET["view"]; |
f0601b87 | 327 | $addheader = $_GET["addheader"]; |
cb1083a1 | 328 | $limit = $_GET["limit"]; |
a1a8a2be | 329 | |
8d7008c7 AD |
330 | if (!$feed) { |
331 | print "Error: no feed to display."; | |
332 | return; | |
333 | } | |
334 | ||
ac53063a AD |
335 | if (!$skip) $skip = 0; |
336 | ||
476cac42 | 337 | if ($subop == "undefined") $subop = ""; |
1cd17194 | 338 | |
f0601b87 AD |
339 | if ($addheader) { |
340 | print "<html><head> | |
ac43eba1 | 341 | <title>Tiny Tiny RSS : Feed $feed</title> |
f0601b87 AD |
342 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\"> |
343 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> | |
344 | <script type=\"text/javascript\" src=\"functions.js\"></script> | |
345 | <script type=\"text/javascript\" src=\"viewfeed.js\"></script> | |
346 | </head><body>"; | |
347 | } | |
348 | ||
254e0e4b | 349 | if ($feed >= 0) { |
d76a3b03 | 350 | |
254e0e4b AD |
351 | $result = db_query($link, |
352 | "SELECT *,SUBSTRING(last_updated,1,16) as last_updated_s | |
353 | FROM ttrss_feeds WHERE id = '$feed'"); | |
354 | ||
355 | if ($result) { | |
356 | ||
357 | $line = db_fetch_assoc($result); | |
358 | ||
359 | update_rss_feed($link, $line["feed_url"], $feed); | |
360 | ||
361 | if ($subop == "MarkAllRead") { | |
362 | ||
363 | db_query($link, "UPDATE ttrss_entries SET unread = false,last_read = NOW() | |
364 | WHERE feed_id = '$feed'"); | |
365 | } | |
a1a8a2be AD |
366 | } |
367 | } | |
d76a3b03 | 368 | |
175847de | 369 | print "<table class=\"headlinesList\" id=\"headlinesList\" width=\"100%\">"; |
ac53063a | 370 | |
c374a3fe AD |
371 | $search = $_GET["search"]; |
372 | ||
f175937c | 373 | if ($search) { |
ac53063a AD |
374 | $search_query_part = "(upper(title) LIKE upper('%$search%') |
375 | OR content LIKE '%$search%') AND"; | |
f175937c AD |
376 | } else { |
377 | $search_query_part = ""; | |
378 | } | |
379 | ||
380 | $view_query_part = ""; | |
381 | ||
382 | if ($view_mode == "Starred") { | |
383 | $view_query_part = " marked = true AND "; | |
ac53063a AD |
384 | } |
385 | ||
ac43eba1 AD |
386 | if ($view_mode == "Unread") { |
387 | $view_query_part = " unread = true AND "; | |
388 | } | |
389 | ||
254e0e4b | 390 | /* $result = db_query($link, "SELECT count(id) AS total_entries |
36bf7496 AD |
391 | FROM ttrss_entries WHERE |
392 | $search_query_part | |
393 | feed_id = '$feed'"); | |
e6d1c0a0 | 394 | |
254e0e4b | 395 | $total_entries = db_fetch_result($result, 0, "total_entries"); */ |
e6d1c0a0 | 396 | |
648472a7 | 397 | /* $result = db_query("SELECT count(id) AS unread_entries |
ac43eba1 AD |
398 | FROM ttrss_entries WHERE |
399 | $search_query_part | |
400 | unread = true AND | |
401 | feed_id = '$feed'"); | |
402 | ||
648472a7 | 403 | $unread_entries = db_fetch_result($result, 0, "unread_entries"); */ |
ac43eba1 | 404 | |
8d7008c7 | 405 | if ($limit && $limit != "All") { |
82c9223c | 406 | $limit_query_part = "LIMIT " . $limit; |
ad3cb710 | 407 | } |
f0601b87 | 408 | |
254e0e4b AD |
409 | $vfeed_query_part = ""; |
410 | ||
411 | if ($feed >= 0) { | |
412 | $query_strategy_part = "feed_id = '$feed'"; | |
48f0adb0 | 413 | } else if ($feed == -1) { // starred virtual feed |
254e0e4b | 414 | $query_strategy_part = "marked = true"; |
48f0adb0 AD |
415 | $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE |
416 | id = feed_id) as feed_title,"; | |
417 | } else if ($feed <= -10) { // labels | |
418 | $label_id = -$feed - 11; | |
419 | ||
420 | $tmp_result = db_query($link, "SELECT sql_exp FROM ttrss_labels | |
421 | WHERE id = '$label_id'"); | |
422 | ||
423 | $query_strategy_part = db_fetch_result($tmp_result, 0, "sql_exp"); | |
424 | ||
254e0e4b AD |
425 | $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE |
426 | id = feed_id) as feed_title,"; | |
427 | } else { | |
48f0adb0 | 428 | $query_strategy_part = "id > 0"; // dumb |
254e0e4b AD |
429 | } |
430 | ||
48f0adb0 AD |
431 | if ($feed < -10) error_reporting (0); |
432 | ||
648472a7 | 433 | $result = db_query($link, "SELECT |
c05a19f3 AD |
434 | id,title,updated,unread,feed_id,marked,link,last_read, |
435 | SUBSTRING(last_read,1,19) as last_read_noms, | |
254e0e4b | 436 | $vfeed_query_part |
c05a19f3 | 437 | SUBSTRING(updated,1,19) as updated_noms |
b197f117 AD |
438 | FROM |
439 | ttrss_entries | |
440 | WHERE | |
ac53063a | 441 | $search_query_part |
f175937c | 442 | $view_query_part |
254e0e4b | 443 | $query_strategy_part ORDER BY updated DESC |
f0601b87 | 444 | $limit_query_part"); |
d76a3b03 | 445 | |
48f0adb0 AD |
446 | if (!$result) { |
447 | print "<tr><td colspan='4' align='center'> | |
448 | Could not display feed (query failed). Please check match syntax or local configuration.</td></tr>"; | |
449 | return; | |
450 | } | |
451 | ||
a1a8a2be | 452 | $lnum = 0; |
48f0adb0 AD |
453 | |
454 | error_reporting (E_ERROR | E_WARNING | E_PARSE); | |
455 | ||
e1123aee | 456 | $num_unread = 0; |
d76a3b03 | 457 | |
648472a7 | 458 | while ($line = db_fetch_assoc($result)) { |
d76a3b03 | 459 | |
a1a8a2be | 460 | $class = ($lnum % 2) ? "even" : "odd"; |
d76a3b03 | 461 | |
ad99045e AD |
462 | $id = $line["id"]; |
463 | $feed_id = $line["feed_id"]; | |
464 | ||
c43f77f5 | 465 | // printf("L %d (%s) > U %d (%s) = %d<br>", |
c05a19f3 | 466 | // strtotime($line["last_read_noms"]), $line["last_read_noms"], |
c43f77f5 AD |
467 | // strtotime($line["updated"]), $line["updated"], |
468 | // strtotime($line["last_read"]) >= strtotime($line["updated"])); | |
469 | ||
470 | if ($line["last_read"] != "" && $line["updated"] != "" && | |
c05a19f3 | 471 | strtotime($line["last_read_noms"]) < strtotime($line["updated_noms"])) { |
c43f77f5 AD |
472 | |
473 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/updated.png\" | |
474 | alt=\"Updated\">"; | |
475 | ||
476 | } else { | |
477 | ||
5bfef089 | 478 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.gif\" |
c43f77f5 AD |
479 | alt=\"Updated\">"; |
480 | ||
481 | } | |
b197f117 | 482 | |
8158c57a | 483 | if ($line["unread"] == "t" || $line["unread"] == "1") { |
a1a8a2be | 484 | $class .= "Unread"; |
e1123aee AD |
485 | ++$num_unread; |
486 | } | |
d76a3b03 | 487 | |
8158c57a | 488 | if ($line["marked"] == "t" || $line["marked"] == "1") { |
f4c10d44 AD |
489 | $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_set.png\" |
490 | alt=\"Reset mark\" onclick='javascript:toggleMark($id, false)'>"; | |
491 | } else { | |
492 | $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_unset.png\" | |
493 | alt=\"Set mark\" onclick='javascript:toggleMark($id, true)'>"; | |
494 | } | |
495 | ||
ac43eba1 | 496 | $content_link = "<a id=\"FTITLE-$id\" href=\"javascript:view($id,$feed_id);\">" . |
b197f117 AD |
497 | $line["title"] . "</a>"; |
498 | ||
d5224f0d | 499 | print "<tr class='$class' id='RROW-$id'>"; |
5f89f780 | 500 | // onclick=\"javascript:view($id,$feed_id)\"> |
b197f117 | 501 | |
8d7008c7 AD |
502 | print "<td valign='center' align='center'>$update_pic</td>"; |
503 | print "<td valign='center' align='center'>$marked_pic</td>"; | |
b197f117 | 504 | |
8d7008c7 | 505 | print "<td width='25%'> |
a3ee2a38 | 506 | <a href=\"javascript:view($id,$feed_id);\">".$line["updated"]."</a></td>"; |
254e0e4b AD |
507 | |
508 | if ($line["feed_title"]) { | |
509 | print "<td width='50%'>$content_link</td>"; | |
510 | print "<td width='20%'>".$line["feed_title"]."</td>"; | |
511 | } else { | |
512 | print "<td width='70%'>$content_link</td>"; | |
513 | } | |
d76a3b03 | 514 | |
a1a8a2be | 515 | print "</tr>"; |
d76a3b03 | 516 | |
a1a8a2be AD |
517 | ++$lnum; |
518 | } | |
d76a3b03 | 519 | |
ac53063a | 520 | if ($lnum == 0) { |
a82065a1 | 521 | print "<tr><td align='center'>No articles found.</td></tr>"; |
047bae73 | 522 | } |
ac53063a | 523 | |
254e0e4b | 524 | /* while ($lnum < HEADLINES_PER_PAGE) { |
047bae73 AD |
525 | ++$lnum; |
526 | print "<tr><td> </td></tr>"; | |
254e0e4b | 527 | } */ |
a2015351 | 528 | |
a1a8a2be | 529 | print "</table>"; |
d76a3b03 | 530 | |
254e0e4b AD |
531 | if ($feed >= 0) { |
532 | ||
533 | $result = db_query($link, "SELECT count(id) as unread FROM ttrss_entries | |
534 | WHERE feed_id = ttrss_feeds.id AND $query_strategy_part | |
535 | AND unread = true"); | |
48f0adb0 AD |
536 | |
537 | $unread = db_fetch_result($result, 0, "unread"); | |
538 | ||
254e0e4b AD |
539 | } else if ($feed == -1) { |
540 | $result = db_query($link, "SELECT count(id) as unread FROM ttrss_entries | |
541 | WHERE $query_strategy_part"); | |
542 | ||
48f0adb0 AD |
543 | $unread = db_fetch_result($result, 0, "unread"); |
544 | ||
254e0e4b | 545 | } else { |
48f0adb0 | 546 | // print "[viewfeed] feed type not implemented<br>"; |
090e250b AD |
547 | |
548 | error_reporting(0); | |
549 | $result = db_query($link, "SELECT count(id) as unread FROM ttrss_entries | |
550 | WHERE $query_strategy_part"); | |
551 | ||
552 | $unread = db_fetch_result($result, 0, "unread"); | |
553 | ||
554 | error_reporting (E_ERROR | E_WARNING | E_PARSE); | |
254e0e4b | 555 | } |
d76a3b03 | 556 | |
090e250b AD |
557 | if (!$unread) $unread = 0; |
558 | ||
6113ef7d AD |
559 | // update unread/total counters and status for active feed in the feedlist |
560 | // kludge, because iframe doesn't seem to support onload() | |
561 | ||
562 | print "<script type=\"text/javascript\"> | |
bb7cface AD |
563 | document.onkeydown = hotkey_handler; |
564 | ||
1a66d16e AD |
565 | var p_document = parent.frames['feeds-frame'].document; |
566 | ||
567 | var feedr = p_document.getElementById(\"FEEDR-\" + $feed); | |
1a66d16e | 568 | var feedu = p_document.getElementById(\"FEEDU-\" + $feed); |
6113ef7d | 569 | |
0c674406 AD |
570 | if (feedu) { |
571 | feedu.innerHTML = \"$unread\"; | |
572 | } | |
573 | ||
574 | var feedctr = p_document.getElementById(\"FEEDCTR-\" + $feed); | |
6113ef7d | 575 | |
090e250b | 576 | if ($unread > 0 && $feed >= 0 && !feedr.className.match(\"Unread\")) { |
6113ef7d | 577 | feedr.className = feedr.className + \"Unread\"; |
0c674406 | 578 | feedctr.className = ''; |
6113ef7d AD |
579 | } else if ($unread <= 0) { |
580 | feedr.className = feedr.className.replace(\"Unread\", \"\"); | |
0c674406 | 581 | feedctr.className = 'invisible'; |
6113ef7d | 582 | } |
c05608c2 | 583 | |
090e250b AD |
584 | update_label_counters(); |
585 | ||
90e395dc | 586 | // p_notify(\"\"); |
0c674406 | 587 | |
6113ef7d | 588 | </script>"; |
d76a3b03 | 589 | |
f0601b87 AD |
590 | if ($addheader) { |
591 | print "</body></html>"; | |
592 | } | |
593 | ||
1cd17194 AD |
594 | } |
595 | ||
0e091d38 | 596 | if ($op == "pref-rpc") { |
331900c6 | 597 | |
0e091d38 | 598 | $subop = $_GET["subop"]; |
331900c6 | 599 | |
83fe4d6d AD |
600 | if ($subop == "unread") { |
601 | $ids = split(",", $_GET["ids"]); | |
602 | foreach ($ids as $id) { | |
648472a7 | 603 | db_query($link, "UPDATE ttrss_entries SET unread = true WHERE feed_id = '$id'"); |
83fe4d6d | 604 | } |
0e091d38 AD |
605 | |
606 | print "Marked selected feeds as read."; | |
83fe4d6d AD |
607 | } |
608 | ||
609 | if ($subop == "read") { | |
610 | $ids = split(",", $_GET["ids"]); | |
611 | foreach ($ids as $id) { | |
648472a7 | 612 | db_query($link, "UPDATE ttrss_entries |
b197f117 | 613 | SET unread = false,last_read = NOW() WHERE feed_id = '$id'"); |
83fe4d6d | 614 | } |
0e091d38 AD |
615 | |
616 | print "Marked selected feeds as unread."; | |
617 | ||
618 | } | |
619 | ||
620 | } | |
621 | ||
622 | if ($op == "pref-feeds") { | |
623 | ||
624 | $subop = $_GET["subop"]; | |
625 | ||
508a81e1 | 626 | if ($subop == "editSave") { |
648472a7 AD |
627 | $feed_title = db_escape_string($_GET["t"]); |
628 | $feed_link = db_escape_string($_GET["l"]); | |
508a81e1 AD |
629 | $feed_id = $_GET["id"]; |
630 | ||
648472a7 | 631 | $result = db_query($link, "UPDATE ttrss_feeds SET |
508a81e1 AD |
632 | title = '$feed_title', feed_url = '$feed_link' WHERE id = '$feed_id'"); |
633 | ||
83fe4d6d AD |
634 | } |
635 | ||
331900c6 | 636 | if ($subop == "remove") { |
331900c6 | 637 | |
b0b4abcf | 638 | if (!WEB_DEMO_MODE) { |
331900c6 | 639 | |
b0b4abcf AD |
640 | $ids = split(",", $_GET["ids"]); |
641 | ||
642 | foreach ($ids as $id) { | |
648472a7 AD |
643 | db_query($link, "BEGIN"); |
644 | db_query($link, "DELETE FROM ttrss_entries WHERE feed_id = '$id'"); | |
645 | db_query($link, "DELETE FROM ttrss_feeds WHERE id = '$id'"); | |
646 | db_query($link, "COMMIT"); | |
d5caaae5 AD |
647 | |
648 | if (file_exists(ICONS_DIR . "/$id.ico")) { | |
649 | unlink(ICONS_DIR . "/$id.ico"); | |
650 | } | |
b0b4abcf | 651 | } |
331900c6 AD |
652 | } |
653 | } | |
654 | ||
655 | if ($subop == "add") { | |
b0b4abcf AD |
656 | |
657 | if (!WEB_DEMO_MODE) { | |
331900c6 | 658 | |
648472a7 | 659 | $feed_link = db_escape_string($_GET["link"]); |
b0b4abcf | 660 | |
648472a7 | 661 | $result = db_query($link, |
b0b4abcf | 662 | "INSERT INTO ttrss_feeds (feed_url,title) VALUES ('$feed_link', '')"); |
331900c6 | 663 | |
648472a7 | 664 | $result = db_query($link, |
e9c54861 | 665 | "SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_link'"); |
331900c6 | 666 | |
648472a7 | 667 | $feed_id = db_fetch_result($result, 0, "id"); |
331900c6 | 668 | |
b0b4abcf AD |
669 | if ($feed_id) { |
670 | update_rss_feed($link, $feed_link, $feed_id); | |
671 | } | |
672 | } | |
331900c6 | 673 | } |
a0d53889 AD |
674 | |
675 | print "<table class=\"prefAddFeed\"><tr> | |
676 | <td><input id=\"fadd_link\"></td> | |
677 | <td colspan=\"4\" align=\"right\"> | |
678 | <a class=\"button\" href=\"javascript:addFeed()\">Add feed</a></td></tr> | |
679 | </table>"; | |
680 | ||
648472a7 | 681 | $result = db_query($link, "SELECT |
c0e5a40e AD |
682 | id,title,feed_url,substring(last_updated,1,16) as last_updated |
683 | FROM | |
684 | ttrss_feeds ORDER by title"); | |
1cd17194 | 685 | |
331900c6 | 686 | print "<p><table width=\"100%\" class=\"prefFeedList\" id=\"prefFeedList\">"; |
007bda35 | 687 | print "<tr class=\"title\"> |
603c27f8 | 688 | <td> </td><td>Select</td><td width=\"40%\">Title</td> |
0afbd851 | 689 | <td width=\"40%\">Link</td><td>Last updated</td></tr>"; |
007bda35 AD |
690 | |
691 | $lnum = 0; | |
692 | ||
648472a7 | 693 | while ($line = db_fetch_assoc($result)) { |
007bda35 AD |
694 | |
695 | $class = ($lnum % 2) ? "even" : "odd"; | |
9b307248 | 696 | |
331900c6 | 697 | $feed_id = $line["id"]; |
603c27f8 AD |
698 | |
699 | $edit_feed_id = $_GET["id"]; | |
700 | ||
9b307248 AD |
701 | if ($subop == "edit" && $feed_id != $edit_feed_id) { |
702 | $class .= "Grayed"; | |
703 | } | |
704 | ||
331900c6 | 705 | print "<tr class=\"$class\" id=\"FEEDR-$feed_id\">"; |
007bda35 | 706 | |
c0e5a40e AD |
707 | $icon_file = ICONS_DIR . "/$feed_id.ico"; |
708 | ||
709 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
710 | $feed_icon = "<img width=\"16\" height=\"16\" | |
711 | src=\"" . ICONS_URL . "/$feed_id.ico\">"; | |
712 | } else { | |
713 | $feed_icon = " "; | |
714 | } | |
715 | print "<td align='center'>$feed_icon</td>"; | |
716 | ||
9b307248 | 717 | if (!$edit_feed_id || $subop != "edit") { |
603c27f8 AD |
718 | |
719 | print "<td><input onclick='toggleSelectRow(this);' | |
331900c6 | 720 | type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>"; |
603c27f8 AD |
721 | |
722 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . | |
723 | $line["title"] . "</td>"; | |
724 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . | |
725 | $line["feed_url"] . "</td>"; | |
9b307248 AD |
726 | |
727 | ||
728 | } else if ($feed_id != $edit_feed_id) { | |
729 | ||
e9c54861 AD |
730 | print "<td><input disabled=\"true\" type=\"checkbox\" |
731 | id=\"FRCHK-".$line["id"]."\"></td>"; | |
9b307248 AD |
732 | |
733 | print "<td>".$line["title"]."</td>"; | |
734 | print "<td>".$line["feed_url"]."</td>"; | |
735 | ||
603c27f8 AD |
736 | } else { |
737 | ||
e9c54861 | 738 | print "<td><input disabled=\"true\" type=\"checkbox\"></td>"; |
603c27f8 AD |
739 | |
740 | print "<td><input id=\"iedit_title\" value=\"".$line["title"]."\"></td>"; | |
741 | print "<td><input id=\"iedit_link\" value=\"".$line["feed_url"]."\"></td>"; | |
742 | ||
743 | } | |
0afbd851 AD |
744 | |
745 | if (!$line["last_updated"]) $line["last_updated"] = "Never"; | |
746 | ||
007bda35 | 747 | print "<td>" . $line["last_updated"] . "</td>"; |
603c27f8 | 748 | |
007bda35 AD |
749 | print "</tr>"; |
750 | ||
751 | ++$lnum; | |
752 | } | |
753 | ||
0afbd851 AD |
754 | if ($lnum == 0) { |
755 | print "<tr><td colspan=\"5\" align=\"center\">No feeds defined.</td></tr>"; | |
756 | } | |
757 | ||
007bda35 AD |
758 | print "</table>"; |
759 | ||
603c27f8 AD |
760 | print "<p>"; |
761 | ||
762 | if ($subop == "edit") { | |
763 | print "Edit feed: | |
e828e31e AD |
764 | <input type=\"submit\" class=\"button\" |
765 | onclick=\"javascript:feedEditCancel()\" value=\"Cancel\"> | |
766 | <input type=\"submit\" class=\"button\" | |
8158c57a | 767 | onclick=\"javascript:feedEditSave()\" value=\"Save\">"; |
603c27f8 AD |
768 | } else { |
769 | ||
603c27f8 AD |
770 | print " |
771 | Selection: | |
e828e31e AD |
772 | <input type=\"submit\" class=\"button\" |
773 | onclick=\"javascript:editSelectedFeed()\" value=\"Edit\"> | |
774 | <input type=\"submit\" class=\"button\" | |
775 | onclick=\"javascript:removeSelectedFeeds()\" value=\"Remove\">"; | |
776 | ||
f92db4f5 AD |
777 | if (ENABLE_PREFS_CATCHUP_UNCATCHUP) { |
778 | print " | |
e828e31e AD |
779 | <input type=\"submit\" class=\"button\" |
780 | onclick=\"javascript:readSelectedFeeds()\" value=\"Mark as read\"> | |
781 | <input type=\"submit\" class=\"button\" | |
782 | onclick=\"javascript:unreadSelectedFeeds()\" value=\"Mark as unread\"> "; | |
f92db4f5 AD |
783 | } |
784 | print " | |
e828e31e AD |
785 | All feeds: |
786 | <input type=\"submit\" | |
8158c57a | 787 | class=\"button\" onclick=\"gotoExportOpml()\" value=\"Export OPML\">"; |
10c5820d | 788 | |
603c27f8 AD |
789 | } |
790 | ||
007bda35 AD |
791 | } |
792 | ||
a0d53889 AD |
793 | if ($op == "pref-filters") { |
794 | ||
795 | $subop = $_GET["subop"]; | |
796 | ||
797 | if ($subop == "editSave") { | |
a0d53889 | 798 | |
648472a7 AD |
799 | $regexp = db_escape_string($_GET["r"]); |
800 | $descr = db_escape_string($_GET["d"]); | |
801 | $match = db_escape_string($_GET["m"]); | |
802 | $filter_id = db_escape_string($_GET["id"]); | |
0afbd851 | 803 | |
648472a7 | 804 | $result = db_query($link, "UPDATE ttrss_filters SET |
4b3dff6e | 805 | reg_exp = '$regexp', |
0afbd851 AD |
806 | description = '$descr', |
807 | filter_type = (SELECT id FROM ttrss_filter_types WHERE | |
808 | description = '$match') | |
809 | WHERE id = '$filter_id'"); | |
a0d53889 AD |
810 | } |
811 | ||
812 | if ($subop == "remove") { | |
813 | ||
814 | if (!WEB_DEMO_MODE) { | |
815 | ||
816 | $ids = split(",", $_GET["ids"]); | |
817 | ||
818 | foreach ($ids as $id) { | |
648472a7 | 819 | db_query($link, "DELETE FROM ttrss_filters WHERE id = '$id'"); |
a0d53889 AD |
820 | |
821 | } | |
822 | } | |
823 | } | |
824 | ||
825 | if ($subop == "add") { | |
826 | ||
de435974 | 827 | if (!WEB_DEMO_MODE) { |
a0d53889 | 828 | |
8158c57a | 829 | $regexp = db_escape_string($_GET["regexp"]); |
648472a7 | 830 | $match = db_escape_string($_GET["match"]); |
a0d53889 | 831 | |
648472a7 | 832 | $result = db_query($link, |
4b3dff6e | 833 | "INSERT INTO ttrss_filters (reg_exp,filter_type) VALUES |
de435974 AD |
834 | ('$regexp', (SELECT id FROM ttrss_filter_types WHERE |
835 | description = '$match'))"); | |
836 | } | |
a0d53889 AD |
837 | } |
838 | ||
648472a7 | 839 | $result = db_query($link, "SELECT description |
a0d53889 AD |
840 | FROM ttrss_filter_types ORDER BY description"); |
841 | ||
842 | $filter_types = array(); | |
843 | ||
648472a7 | 844 | while ($line = db_fetch_assoc($result)) { |
a0d53889 AD |
845 | array_push($filter_types, $line["description"]); |
846 | } | |
847 | ||
848 | print "<table class=\"prefAddFeed\"><tr> | |
ea6774cf | 849 | <td><input id=\"fadd_regexp\"></td> |
a0d53889 | 850 | <td>"; |
bdc00fe0 | 851 | print_select("fadd_match", "Title", $filter_types); |
a0d53889 AD |
852 | |
853 | print"</td><td colspan=\"4\" align=\"right\"> | |
854 | <a class=\"button\" href=\"javascript:addFilter()\">Add filter</a></td></tr> | |
855 | </table>"; | |
856 | ||
648472a7 | 857 | $result = db_query($link, "SELECT |
4b3dff6e | 858 | id,reg_exp,description, |
a0d53889 AD |
859 | (SELECT name FROM ttrss_filter_types WHERE |
860 | id = filter_type) as filter_type_name, | |
861 | (SELECT description FROM ttrss_filter_types | |
862 | WHERE id = filter_type) as filter_type_descr | |
863 | FROM | |
4b3dff6e | 864 | ttrss_filters ORDER by reg_exp"); |
a0d53889 AD |
865 | |
866 | print "<p><table width=\"100%\" class=\"prefFilterList\" id=\"prefFilterList\">"; | |
867 | ||
868 | print "<tr class=\"title\"> | |
0afbd851 AD |
869 | <td width=\"5%\">Select</td><td width=\"40%\">Filter expression</td> |
870 | <td width=\"40%\">Description</td><td width=\"10%\">Match</td></tr>"; | |
a0d53889 AD |
871 | |
872 | $lnum = 0; | |
873 | ||
648472a7 | 874 | while ($line = db_fetch_assoc($result)) { |
a0d53889 AD |
875 | |
876 | $class = ($lnum % 2) ? "even" : "odd"; | |
877 | ||
878 | $filter_id = $line["id"]; | |
879 | $edit_filter_id = $_GET["id"]; | |
880 | ||
881 | if ($subop == "edit" && $filter_id != $edit_filter_id) { | |
882 | $class .= "Grayed"; | |
883 | } | |
884 | ||
885 | print "<tr class=\"$class\" id=\"FILRR-$filter_id\">"; | |
886 | ||
4b3dff6e | 887 | $line["regexp"] = htmlspecialchars($line["reg_exp"]); |
ea6774cf AD |
888 | $line["description"] = htmlspecialchars($line["description"]); |
889 | ||
a0d53889 AD |
890 | if (!$edit_filter_id || $subop != "edit") { |
891 | ||
0afbd851 AD |
892 | if (!$line["description"]) $line["description"] = "[No description]"; |
893 | ||
a0d53889 AD |
894 | print "<td><input onclick='toggleSelectRow(this);' |
895 | type=\"checkbox\" id=\"FICHK-".$line["id"]."\"></td>"; | |
896 | ||
897 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . | |
4b3dff6e | 898 | $line["reg_exp"] . "</td>"; |
a0d53889 AD |
899 | |
900 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . | |
901 | $line["description"] . "</td>"; | |
902 | ||
903 | print "<td>".$line["filter_type_descr"]."</td>"; | |
904 | ||
905 | } else if ($filter_id != $edit_filter_id) { | |
906 | ||
0afbd851 AD |
907 | if (!$line["description"]) $line["description"] = "[No description]"; |
908 | ||
a0d53889 AD |
909 | print "<td><input disabled=\"true\" type=\"checkbox\" |
910 | id=\"FICHK-".$line["id"]."\"></td>"; | |
911 | ||
4b3dff6e | 912 | print "<td>".$line["reg_exp"]."</td>"; |
a0d53889 AD |
913 | print "<td>".$line["description"]."</td>"; |
914 | print "<td>".$line["filter_type_descr"]."</td>"; | |
915 | ||
916 | } else { | |
917 | ||
918 | print "<td><input disabled=\"true\" type=\"checkbox\"></td>"; | |
919 | ||
4b3dff6e | 920 | print "<td><input id=\"iedit_regexp\" value=\"".$line["reg_exp"]. |
a0d53889 AD |
921 | "\"></td>"; |
922 | ||
923 | print "<td><input id=\"iedit_descr\" value=\"".$line["description"]. | |
924 | "\"></td>"; | |
925 | ||
926 | print "<td>"; | |
927 | print_select("iedit_match", $line["filter_type_descr"], $filter_types); | |
928 | print "</td>"; | |
929 | ||
930 | } | |
931 | ||
932 | ||
933 | print "</tr>"; | |
934 | ||
935 | ++$lnum; | |
936 | } | |
937 | ||
0afbd851 AD |
938 | if ($lnum == 0) { |
939 | print "<tr><td colspan=\"4\" align=\"center\">No filters defined.</td></tr>"; | |
940 | } | |
941 | ||
a0d53889 AD |
942 | print "</table>"; |
943 | ||
944 | print "<p>"; | |
945 | ||
946 | if ($subop == "edit") { | |
e828e31e AD |
947 | print "Edit feed: |
948 | <input type=\"submit\" class=\"button\" | |
949 | onclick=\"javascript:filterEditCancel()\" value=\"Cancel\"> | |
950 | <input type=\"submit\" class=\"button\" | |
951 | onclick=\"javascript:filterEditSave()\" value=\"Save\">"; | |
a0d53889 AD |
952 | |
953 | } else { | |
954 | ||
955 | print " | |
e828e31e AD |
956 | Selection: |
957 | <input type=\"submit\" class=\"button\" | |
958 | onclick=\"javascript:editSelectedFilter()\" value=\"Edit\"> | |
959 | <input type=\"submit\" class=\"button\" | |
960 | onclick=\"javascript:removeSelectedFilters()\" value=\"Remove\">"; | |
a0d53889 AD |
961 | } |
962 | } | |
963 | ||
48f0adb0 AD |
964 | if ($op == "pref-labels") { |
965 | ||
966 | $subop = $_GET["subop"]; | |
967 | ||
968 | if ($subop == "editSave") { | |
969 | ||
970 | $sql_exp = $_GET["s"]; | |
971 | $descr = $_GET["d"]; | |
972 | $label_id = db_escape_string($_GET["id"]); | |
973 | ||
974 | // print "$sql_exp : $descr : $label_id"; | |
975 | ||
976 | $result = db_query($link, "UPDATE ttrss_labels SET | |
977 | sql_exp = '$sql_exp', | |
978 | description = '$descr' | |
979 | WHERE id = '$label_id'"); | |
980 | } | |
981 | ||
982 | if ($subop == "remove") { | |
983 | ||
984 | if (!WEB_DEMO_MODE) { | |
985 | ||
986 | $ids = split(",", $_GET["ids"]); | |
987 | ||
988 | foreach ($ids as $id) { | |
989 | db_query($link, "DELETE FROM ttrss_labels WHERE id = '$id'"); | |
990 | ||
991 | } | |
992 | } | |
993 | } | |
994 | ||
995 | if ($subop == "add") { | |
996 | ||
997 | if (!WEB_DEMO_MODE) { | |
998 | ||
999 | $exp = $_GET["exp"]; | |
1000 | ||
1001 | $result = db_query($link, | |
1002 | "INSERT INTO ttrss_labels (sql_exp,description) | |
1003 | VALUES ('$exp', '$exp')"); | |
1004 | } | |
1005 | } | |
1006 | ||
1007 | print "<table class=\"prefAddFeed\"><tr> | |
1008 | <td><input id=\"ladd_expr\"></td>"; | |
1009 | ||
1010 | print"<td colspan=\"4\" align=\"right\"> | |
1011 | <a class=\"button\" href=\"javascript:addLabel()\">Add label</a></td></tr> | |
1012 | </table>"; | |
1013 | ||
1014 | $result = db_query($link, "SELECT | |
1015 | id,sql_exp,description | |
1016 | FROM | |
1017 | ttrss_labels ORDER by description"); | |
1018 | ||
1019 | print "<p><table width=\"100%\" class=\"prefLabelList\" id=\"prefLabelList\">"; | |
1020 | ||
1021 | print "<tr class=\"title\"> | |
1022 | <td width=\"5%\">Select</td><td width=\"40%\">SQL expression</td> | |
1023 | <td width=\"40%\">Caption</td></tr>"; | |
1024 | ||
1025 | $lnum = 0; | |
1026 | ||
1027 | while ($line = db_fetch_assoc($result)) { | |
1028 | ||
1029 | $class = ($lnum % 2) ? "even" : "odd"; | |
1030 | ||
1031 | $label_id = $line["id"]; | |
1032 | $edit_label_id = $_GET["id"]; | |
1033 | ||
1034 | if ($subop == "edit" && $label_id != $edit_label_id) { | |
1035 | $class .= "Grayed"; | |
1036 | } | |
1037 | ||
1038 | print "<tr class=\"$class\" id=\"LILRR-$label_id\">"; | |
1039 | ||
1040 | $line["sql_exp"] = htmlspecialchars($line["sql_exp"]); | |
1041 | $line["description"] = htmlspecialchars($line["description"]); | |
1042 | ||
1043 | if (!$edit_label_id || $subop != "edit") { | |
1044 | ||
1045 | if (!$line["description"]) $line["description"] = "[No caption]"; | |
1046 | ||
1047 | print "<td><input onclick='toggleSelectRow(this);' | |
1048 | type=\"checkbox\" id=\"LICHK-".$line["id"]."\"></td>"; | |
1049 | ||
1050 | print "<td><a href=\"javascript:editLabel($label_id);\">" . | |
1051 | $line["sql_exp"] . "</td>"; | |
1052 | ||
1053 | print "<td><a href=\"javascript:editLabel($label_id);\">" . | |
1054 | $line["description"] . "</td>"; | |
1055 | ||
1056 | } else if ($label_id != $edit_label_id) { | |
1057 | ||
1058 | if (!$line["description"]) $line["description"] = "[No description]"; | |
1059 | ||
1060 | print "<td><input disabled=\"true\" type=\"checkbox\" | |
1061 | id=\"LICHK-".$line["id"]."\"></td>"; | |
1062 | ||
1063 | print "<td>".$line["sql_exp"]."</td>"; | |
1064 | print "<td>".$line["description"]."</td>"; | |
1065 | ||
1066 | } else { | |
1067 | ||
1068 | print "<td><input disabled=\"true\" type=\"checkbox\"></td>"; | |
1069 | ||
1070 | print "<td><input id=\"iedit_expr\" value=\"".$line["sql_exp"]. | |
1071 | "\"></td>"; | |
1072 | ||
1073 | print "<td><input id=\"iedit_descr\" value=\"".$line["description"]. | |
1074 | "\"></td>"; | |
1075 | ||
1076 | } | |
1077 | ||
1078 | ||
1079 | print "</tr>"; | |
1080 | ||
1081 | ++$lnum; | |
1082 | } | |
1083 | ||
1084 | if ($lnum == 0) { | |
1085 | print "<tr><td colspan=\"4\" align=\"center\">No labels defined.</td></tr>"; | |
1086 | } | |
1087 | ||
1088 | print "</table>"; | |
1089 | ||
1090 | print "<p>"; | |
1091 | ||
1092 | if ($subop == "edit") { | |
1093 | print "Edit label: | |
1094 | <input type=\"submit\" class=\"button\" | |
1095 | onclick=\"javascript:labelEditCancel()\" value=\"Cancel\"> | |
1096 | <input type=\"submit\" class=\"button\" | |
1097 | onclick=\"javascript:labelEditSave()\" value=\"Save\">"; | |
1098 | ||
1099 | } else { | |
1100 | ||
1101 | print " | |
1102 | Selection: | |
1103 | <input type=\"submit\" class=\"button\" | |
1104 | onclick=\"javascript:editSelectedLabel()\" value=\"Edit\"> | |
1105 | <input type=\"submit\" class=\"button\" | |
1106 | onclick=\"javascript:removeSelectedLabels()\" value=\"Remove\">"; | |
1107 | } | |
1108 | } | |
1109 | ||
e828e31e AD |
1110 | if ($op == "error") { |
1111 | print "<div width=\"100%\" align='center'>"; | |
1112 | $msg = $_GET["msg"]; | |
1113 | print $msg; | |
1114 | print "</div>"; | |
1115 | } | |
1116 | ||
4b3dff6e | 1117 | db_close($link); |
1cd17194 | 1118 | ?> |