]> git.wh0rd.org - tt-rss.git/blame - modules/pref-feed-browser.php
add compact theme
[tt-rss.git] / modules / pref-feed-browser.php
CommitLineData
f27d955a
AD
1<?php
2 function module_pref_feed_browser($link) {
3
4 if (!ENABLE_FEED_BROWSER) {
5 print "Feed browser is administratively disabled.";
6 return;
7 }
8
9 $subop = $_REQUEST["subop"];
10
11 if ($subop == "details") {
12 $id = db_escape_string($_GET["id"]);
13
14 print "<div class=\"browserFeedInfo\">";
15 print "<b>Feed information:</b>";
16 print "<div class=\"detailsPart\">";
17
18 $result = db_query($link, "SELECT
19 feed_url,site_url,
20 SUBSTRING(last_updated,1,19) AS last_updated
21 FROM ttrss_feeds WHERE id = '$id'");
22
23 $feed_url = db_fetch_result($result, 0, "feed_url");
24 $site_url = db_fetch_result($result, 0, "site_url");
25 $last_updated = db_fetch_result($result, 0, "last_updated");
26
27 if (get_pref($link, 'HEADLINES_SMART_DATE')) {
28 $last_updated = smart_date_time(strtotime($last_updated));
29 } else {
30 $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
31 $last_updated = date($short_date, strtotime($last_updated));
32 }
33
34 print "Site: <a target=\"_new\" href='$site_url'>$site_url</a> ".
35 "(<a target=\"_new\" href='$feed_url'>feed</a>), ".
36 "Last updated: $last_updated";
37
38 print "</div>";
39
40 $result = db_query($link, "SELECT
41 ttrss_entries.title,
42 content,link,
43 substring(date_entered,1,19) as date_entered,
44 substring(updated,1,19) as updated
45 FROM ttrss_entries,ttrss_user_entries
46 WHERE ttrss_entries.id = ref_id AND feed_id = '$id'
47 ORDER BY updated DESC LIMIT 5");
48
49 if (db_num_rows($result) > 0) {
50
51 print "<b>Last headlines:</b><br>";
52
53 print "<div class=\"detailsPart\">";
54 print "<ul class=\"compact\">";
55 while ($line = db_fetch_assoc($result)) {
56
57 if (get_pref($link, 'HEADLINES_SMART_DATE')) {
58 $entry_dt = smart_date_time(strtotime($line["updated"]));
59 } else {
60 $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
61 $entry_dt = date($short_date, strtotime($line["updated"]));
62 }
63
64 print "<li><a target=\"_new\" href=\"" . $line["link"] . "\">" . $line["title"] . "</a>" .
65 "&nbsp;<span class=\"insensitive\">($entry_dt)</span></li>";
66 }
67 print "</ul></div>";
68 }
69
70 print "</div>";
71
72 return;
73 }
74
75 print "<p>This panel shows feeds subscribed by other users of this system, just in case you are interested in some of them too.</p>";
76
77 $limit = db_escape_string($_GET["limit"]);
78
79 if (!$limit) $limit = 25;
80
81 $owner_uid = $_SESSION["uid"];
82
83 $result = db_query($link, "SELECT feed_url,COUNT(id) AS subscribers
84 FROM ttrss_feeds WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
85 WHERE tf.feed_url = ttrss_feeds.feed_url
86 AND owner_uid = '$owner_uid') GROUP BY feed_url
87 ORDER BY subscribers DESC LIMIT $limit");
88
89
90 print "<div style=\"float : right\">
91 Top <select id=\"feedBrowserLimit\">";
92
93 foreach (array(25, 50, 100) as $l) {
94 $issel = ($l == $limit) ? "selected" : "";
95 print "<option $issel>$l</option>";
96 }
97
98 print "</select>
99 <input type=\"submit\" class=\"button\"
100 onclick=\"updateBigFeedBrowser()\" value=\"Show\">
101 </div>";
102
103 print "<p id=\"fbrOpToolbar\">Selection:
104 <input type='submit' class='button' onclick=\"feedBrowserSubscribe()\"
105 disabled=\"true\" value=\"Subscribe\">";
106
107 print "<ul class='nomarks' id='browseBigFeedList'>";
108
109 $feedctr = 0;
110
111 while ($line = db_fetch_assoc($result)) {
112 $feed_url = $line["feed_url"];
113 $subscribers = $line["subscribers"];
114
115 $det_result = db_query($link, "SELECT site_url,title,id
116 FROM ttrss_feeds WHERE feed_url = '$feed_url' LIMIT 1");
117
118 $details = db_fetch_assoc($det_result);
119
120 $icon_file = ICONS_DIR . "/" . $details["id"] . ".ico";
121
122 if (file_exists($icon_file) && filesize($icon_file) > 0) {
123 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL .
124 "/".$details["id"].".ico\">";
125 } else {
126 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
127 }
128
129 $check_box = "<input onclick='toggleSelectFBListRow(this)' class='feedBrowseCB'
130 type=\"checkbox\" id=\"FBCHK-" . $details["id"] . "\">";
131
132 $class = ($feedctr % 2) ? "even" : "odd";
133
134 print "<li class='$class' id=\"FBROW-".$details["id"]."\">$check_box".
135 "$feed_icon ";
136
137 print "<a href=\"javascript:browserToggleExpand('".$details["id"]."')\">" .
138 $details["title"] ."</a>&nbsp;" .
139 "<span class='subscribers'>($subscribers)</span>";
140
141 print "<div class=\"browserDetails\" id=\"BRDET-" . $details["id"] . "\">";
142 print "</div>";
143
144 print "</li>";
145
146 ++$feedctr;
147 }
148
149 if ($feedctr == 0) {
150 print "<li>No feeds found to subscribe.</li>";
151 }
152
153 print "</ul>";
154
155 print "</div>";
156 }
157?>