]>
Commit | Line | Data |
---|---|---|
f27d955a AD |
1 | <?php |
2 | function module_pref_feed_browser($link) { | |
3 | ||
4 | if (!ENABLE_FEED_BROWSER) { | |
89cb787e | 5 | print __("Feed browser is administratively disabled."); |
f27d955a AD |
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\">"; | |
89cb787e | 15 | print "<b>".__('Feed information:')."</b>"; |
f27d955a AD |
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 | ||
89cb787e | 51 | print "<b>".__('Last headlines:')."</b><br>"; |
f27d955a AD |
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 | " <span class=\"insensitive\">($entry_dt)</span></li>"; | |
66 | } | |
67 | print "</ul></div>"; | |
68 | } | |
69 | ||
70 | print "</div>"; | |
71 | ||
72 | return; | |
73 | } | |
74 | ||
fe8d2059 AD |
75 | set_pref($link, "_PREFS_ACTIVE_TAB", "feedBrowser"); |
76 | ||
3692e98f | 77 | print "<div>".__('This panel shows feeds subscribed by other users of this system, just in case you are interested in them too.')."</div>"; |
f27d955a AD |
78 | |
79 | $limit = db_escape_string($_GET["limit"]); | |
80 | ||
81 | if (!$limit) $limit = 25; | |
82 | ||
83 | $owner_uid = $_SESSION["uid"]; | |
84 | ||
85 | $result = db_query($link, "SELECT feed_url,COUNT(id) AS subscribers | |
86 | FROM ttrss_feeds WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf | |
87 | WHERE tf.feed_url = ttrss_feeds.feed_url | |
88 | AND owner_uid = '$owner_uid') GROUP BY feed_url | |
89 | ORDER BY subscribers DESC LIMIT $limit"); | |
90 | ||
91 | ||
92 | print "<div style=\"float : right\"> | |
3692e98f | 93 | ".__('Top')." <select id=\"feedBrowserLimit\">"; |
f27d955a AD |
94 | |
95 | foreach (array(25, 50, 100) as $l) { | |
96 | $issel = ($l == $limit) ? "selected" : ""; | |
97 | print "<option $issel>$l</option>"; | |
98 | } | |
99 | ||
100 | print "</select> | |
101 | <input type=\"submit\" class=\"button\" | |
3692e98f | 102 | onclick=\"updateBigFeedBrowser()\" value=\"".__('Show')."\"> |
f27d955a AD |
103 | </div>"; |
104 | ||
3692e98f | 105 | print "<p id=\"fbrOpToolbar\"> |
f27d955a | 106 | <input type='submit' class='button' onclick=\"feedBrowserSubscribe()\" |
3692e98f | 107 | disabled=\"true\" value=\"".__('Subscribe')."\">"; |
f27d955a AD |
108 | |
109 | print "<ul class='nomarks' id='browseBigFeedList'>"; | |
110 | ||
111 | $feedctr = 0; | |
112 | ||
113 | while ($line = db_fetch_assoc($result)) { | |
114 | $feed_url = $line["feed_url"]; | |
115 | $subscribers = $line["subscribers"]; | |
116 | ||
117 | $det_result = db_query($link, "SELECT site_url,title,id | |
118 | FROM ttrss_feeds WHERE feed_url = '$feed_url' LIMIT 1"); | |
119 | ||
120 | $details = db_fetch_assoc($det_result); | |
121 | ||
122 | $icon_file = ICONS_DIR . "/" . $details["id"] . ".ico"; | |
123 | ||
124 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
125 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . | |
126 | "/".$details["id"].".ico\">"; | |
127 | } else { | |
128 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; | |
129 | } | |
130 | ||
131 | $check_box = "<input onclick='toggleSelectFBListRow(this)' class='feedBrowseCB' | |
132 | type=\"checkbox\" id=\"FBCHK-" . $details["id"] . "\">"; | |
133 | ||
134 | $class = ($feedctr % 2) ? "even" : "odd"; | |
135 | ||
136 | print "<li class='$class' id=\"FBROW-".$details["id"]."\">$check_box". | |
137 | "$feed_icon "; | |
138 | ||
139 | print "<a href=\"javascript:browserToggleExpand('".$details["id"]."')\">" . | |
140 | $details["title"] ."</a> " . | |
141 | "<span class='subscribers'>($subscribers)</span>"; | |
142 | ||
143 | print "<div class=\"browserDetails\" id=\"BRDET-" . $details["id"] . "\">"; | |
144 | print "</div>"; | |
145 | ||
146 | print "</li>"; | |
147 | ||
148 | ++$feedctr; | |
149 | } | |
150 | ||
151 | if ($feedctr == 0) { | |
89cb787e | 152 | print "<li>".__('No feeds found to subscribe.')."</li>"; |
f27d955a AD |
153 | } |
154 | ||
155 | print "</ul>"; | |
156 | ||
157 | print "</div>"; | |
158 | } | |
159 | ?> |