]>
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 | |
17 | $result = db_query($link, "SELECT | |
18 | feed_url,site_url, | |
38426fb1 AD |
19 | SUBSTRING(last_updated,1,19) AS last_updated |
20 | FROM ttrss_feeds WHERE id = '$id' AND | |
21 | auth_login = '' AND auth_pass = ''"); | |
f27d955a | 22 | |
38426fb1 | 23 | if (db_num_rows($result) == 1) { |
f27d955a | 24 | |
f27d955a | 25 | print "<div class=\"detailsPart\">"; |
f27d955a | 26 | |
38426fb1 AD |
27 | $feed_url = db_fetch_result($result, 0, "feed_url"); |
28 | $site_url = db_fetch_result($result, 0, "site_url"); | |
29 | $last_updated = db_fetch_result($result, 0, "last_updated"); | |
30 | ||
31 | if (get_pref($link, 'HEADLINES_SMART_DATE')) { | |
32 | $last_updated = smart_date_time(strtotime($last_updated)); | |
33 | } else { | |
34 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
35 | $last_updated = date($short_date, strtotime($last_updated)); | |
36 | } | |
37 | ||
38 | print __("Site:")." <a target=\"_new\" href='$site_url'>$site_url</a> ". | |
39 | "(<a target=\"_new\" href='$feed_url'>feed</a>), ". | |
40 | __("Last updated:")." $last_updated"; | |
41 | ||
42 | print "</div>"; | |
43 | ||
44 | $result = db_query($link, "SELECT | |
45 | ttrss_entries.title, | |
46 | content,link, | |
47 | substring(date_entered,1,19) as date_entered, | |
48 | substring(updated,1,19) as updated | |
49 | FROM ttrss_entries,ttrss_user_entries | |
50 | WHERE ttrss_entries.id = ref_id AND feed_id = '$id' | |
51 | ORDER BY updated DESC LIMIT 5"); | |
52 | ||
53 | if (db_num_rows($result) > 0) { | |
54 | ||
55 | print "<b>".__('Last headlines:')."</b><br>"; | |
56 | ||
57 | print "<div class=\"detailsPart\">"; | |
58 | print "<ul class=\"compact\">"; | |
59 | while ($line = db_fetch_assoc($result)) { | |
60 | ||
61 | if (get_pref($link, 'HEADLINES_SMART_DATE')) { | |
62 | $entry_dt = smart_date_time(strtotime($line["updated"])); | |
63 | } else { | |
64 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
65 | $entry_dt = date($short_date, strtotime($line["updated"])); | |
66 | } | |
67 | ||
68 | print "<li><a target=\"_new\" href=\"" . $line["link"] . "\">" . $line["title"] . "</a>" . | |
69 | " <span class=\"insensitive\">($entry_dt)</span></li>"; | |
70 | } | |
71 | print "</ul></div>"; | |
72 | } | |
73 | } else { | |
74 | print "<p>".__("Feed not found.")."</p>"; | |
f27d955a AD |
75 | } |
76 | ||
77 | print "</div>"; | |
78 | ||
79 | return; | |
80 | } | |
81 | ||
fe8d2059 AD |
82 | set_pref($link, "_PREFS_ACTIVE_TAB", "feedBrowser"); |
83 | ||
3692e98f | 84 | 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 |
85 | |
86 | $limit = db_escape_string($_GET["limit"]); | |
87 | ||
88 | if (!$limit) $limit = 25; | |
89 | ||
90 | $owner_uid = $_SESSION["uid"]; | |
91 | ||
92 | $result = db_query($link, "SELECT feed_url,COUNT(id) AS subscribers | |
93 | FROM ttrss_feeds WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf | |
94 | WHERE tf.feed_url = ttrss_feeds.feed_url | |
95 | AND owner_uid = '$owner_uid') GROUP BY feed_url | |
96 | ORDER BY subscribers DESC LIMIT $limit"); | |
97 | ||
e5e9b890 | 98 | print "<br/>"; |
f27d955a AD |
99 | |
100 | print "<div style=\"float : right\"> | |
3692e98f | 101 | ".__('Top')." <select id=\"feedBrowserLimit\">"; |
f27d955a AD |
102 | |
103 | foreach (array(25, 50, 100) as $l) { | |
104 | $issel = ($l == $limit) ? "selected" : ""; | |
105 | print "<option $issel>$l</option>"; | |
106 | } | |
107 | ||
108 | print "</select> | |
109 | <input type=\"submit\" class=\"button\" | |
3692e98f | 110 | onclick=\"updateBigFeedBrowser()\" value=\"".__('Show')."\"> |
f27d955a AD |
111 | </div>"; |
112 | ||
e5e9b890 | 113 | print "<div id=\"fbrOpToolbar\"> |
f27d955a | 114 | <input type='submit' class='button' onclick=\"feedBrowserSubscribe()\" |
e5e9b890 | 115 | disabled=\"true\" value=\"".__('Subscribe')."\"></div>"; |
f27d955a AD |
116 | |
117 | print "<ul class='nomarks' id='browseBigFeedList'>"; | |
118 | ||
119 | $feedctr = 0; | |
120 | ||
121 | while ($line = db_fetch_assoc($result)) { | |
122 | $feed_url = $line["feed_url"]; | |
123 | $subscribers = $line["subscribers"]; | |
124 | ||
125 | $det_result = db_query($link, "SELECT site_url,title,id | |
126 | FROM ttrss_feeds WHERE feed_url = '$feed_url' LIMIT 1"); | |
127 | ||
128 | $details = db_fetch_assoc($det_result); | |
129 | ||
130 | $icon_file = ICONS_DIR . "/" . $details["id"] . ".ico"; | |
131 | ||
132 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
133 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . | |
134 | "/".$details["id"].".ico\">"; | |
135 | } else { | |
136 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; | |
137 | } | |
138 | ||
139 | $check_box = "<input onclick='toggleSelectFBListRow(this)' class='feedBrowseCB' | |
140 | type=\"checkbox\" id=\"FBCHK-" . $details["id"] . "\">"; | |
141 | ||
142 | $class = ($feedctr % 2) ? "even" : "odd"; | |
143 | ||
144 | print "<li class='$class' id=\"FBROW-".$details["id"]."\">$check_box". | |
145 | "$feed_icon "; | |
146 | ||
147 | print "<a href=\"javascript:browserToggleExpand('".$details["id"]."')\">" . | |
148 | $details["title"] ."</a> " . | |
149 | "<span class='subscribers'>($subscribers)</span>"; | |
150 | ||
34a01a20 | 151 | print "<div class=\"browserDetails\" style=\"display : none\" id=\"BRDET-" . $details["id"] . "\">"; |
f27d955a AD |
152 | print "</div>"; |
153 | ||
154 | print "</li>"; | |
155 | ||
156 | ++$feedctr; | |
157 | } | |
158 | ||
159 | if ($feedctr == 0) { | |
89cb787e | 160 | print "<li>".__('No feeds found to subscribe.')."</li>"; |
f27d955a AD |
161 | } |
162 | ||
163 | print "</ul>"; | |
164 | ||
165 | print "</div>"; | |
166 | } | |
167 | ?> |