return array_search($method, $csrf_ignored) !== false;\r
}\r
\r
- private function feedlist_init_cat($cat_id, $hidden = false) {\r
- $obj = array();\r
- $cat_id = (int) $cat_id;\r
-\r
- if ($cat_id > 0) {\r
- $cat_unread = ccache_find($this->link, $cat_id, $_SESSION["uid"], true);\r
- } else if ($cat_id == 0 || $cat_id == -2) {\r
- $cat_unread = getCategoryUnread($this->link, $cat_id);\r
- }\r
-\r
- $obj['id'] = 'CAT:' . $cat_id;\r
- $obj['items'] = array();\r
- $obj['name'] = getCategoryTitle($this->link, $cat_id);\r
- $obj['type'] = 'feed';\r
- $obj['unread'] = (int) $cat_unread;\r
- $obj['hidden'] = $hidden;\r
- $obj['bare_id'] = $cat_id;\r
-\r
- return $obj;\r
- }\r
-\r
- private function feedlist_init_feed($feed_id, $title = false, $unread = false, $error = '', $updated = '') {\r
- $obj = array();\r
- $feed_id = (int) $feed_id;\r
-\r
- if (!$title)\r
- $title = getFeedTitle($this->link, $feed_id, false);\r
-\r
- if ($unread === false)\r
- $unread = getFeedUnread($this->link, $feed_id, false);\r
-\r
- $obj['id'] = 'FEED:' . $feed_id;\r
- $obj['name'] = $title;\r
- $obj['unread'] = (int) $unread;\r
- $obj['type'] = 'feed';\r
- $obj['error'] = $error;\r
- $obj['updated'] = $updated;\r
- $obj['icon'] = getFeedIcon($feed_id);\r
- $obj['bare_id'] = $feed_id;\r
-\r
- return $obj;\r
- }\r
-\r
private function format_headline_subtoolbar($feed_site_url, $feed_title,\r
$feed_id, $is_cat, $search, $match_on,\r
$search_mode, $view_mode, $error) {\r
$vgroup_last_feed, $reply);\r
}\r
\r
- private function outputFeedList($special = true) {\r
-\r
- $feedlist = array();\r
-\r
- $enable_cats = get_pref($this->link, 'ENABLE_FEED_CATS');\r
-\r
- $feedlist['identifier'] = 'id';\r
- $feedlist['label'] = 'name';\r
- $feedlist['items'] = array();\r
-\r
- $owner_uid = $_SESSION["uid"];\r
-\r
- /* virtual feeds */\r
-\r
- if ($special) {\r
-\r
- if ($enable_cats) {\r
- $cat_hidden = get_pref($this->link, "_COLLAPSED_SPECIAL");\r
- $cat = $this->feedlist_init_cat(-1, $cat_hidden);\r
- } else {\r
- $cat['items'] = array();\r
- }\r
-\r
- foreach (array(-4, -3, -1, -2, 0) as $i) {\r
- array_push($cat['items'], $this->feedlist_init_feed($i));\r
- }\r
-\r
- if ($enable_cats) {\r
- array_push($feedlist['items'], $cat);\r
- } else {\r
- $feedlist['items'] = array_merge($feedlist['items'], $cat['items']);\r
- }\r
-\r
- $result = db_query($this->link, "SELECT * FROM\r
- ttrss_labels2 WHERE owner_uid = '$owner_uid' ORDER by caption");\r
-\r
- if (db_num_rows($result) > 0) {\r
-\r
- if (get_pref($this->link, 'ENABLE_FEED_CATS')) {\r
- $cat_hidden = get_pref($this->link, "_COLLAPSED_LABELS");\r
- $cat = $this->feedlist_init_cat(-2, $cat_hidden);\r
- } else {\r
- $cat['items'] = array();\r
- }\r
-\r
- while ($line = db_fetch_assoc($result)) {\r
-\r
- $label_id = -$line['id'] - 11;\r
- $count = getFeedUnread($this->link, $label_id);\r
-\r
- $feed = $this->feedlist_init_feed($label_id, false, $count);\r
-\r
- $feed['fg_color'] = $line['fg_color'];\r
- $feed['bg_color'] = $line['bg_color'];\r
-\r
- array_push($cat['items'], $feed);\r
- }\r
-\r
- if ($enable_cats) {\r
- array_push($feedlist['items'], $cat);\r
- } else {\r
- $feedlist['items'] = array_merge($feedlist['items'], $cat['items']);\r
- }\r
- }\r
- }\r
-\r
- $this->feedlist_process_category('root', &$feedlist);\r
-\r
-/* if (get_pref($this->link, 'ENABLE_FEED_CATS')) {\r
- if (get_pref($this->link, "FEEDS_SORT_BY_UNREAD")) {\r
- $order_by_qpart = "order_id,category,unread DESC,title";\r
- } else {\r
- $order_by_qpart = "order_id,category,title";\r
- }\r
- } else {\r
- if (get_pref($this->link, "FEEDS_SORT_BY_UNREAD")) {\r
- $order_by_qpart = "unread DESC,title";\r
- } else {\r
- $order_by_qpart = "title";\r
- }\r
- } */\r
-\r
- /* real feeds */\r
-\r
- /* if ($enable_cats)\r
- $order_by_qpart = "ttrss_feed_categories.order_id,category,\r
- ttrss_feeds.order_id,title";\r
- else\r
- $order_by_qpart = "title";\r
-\r
- $query = "SELECT ttrss_feeds.id, ttrss_feeds.title,\r
- ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated_noms,\r
- cat_id,last_error,\r
- COALESCE(ttrss_feed_categories.title, '".__('Uncategorized')."') AS category,\r
- ttrss_feed_categories.collapsed,\r
- value AS unread\r
- FROM ttrss_feeds LEFT JOIN ttrss_feed_categories\r
- ON (ttrss_feed_categories.id = cat_id)\r
- LEFT JOIN ttrss_counters_cache\r
- ON\r
- (ttrss_feeds.id = feed_id)\r
- WHERE\r
- ttrss_feeds.owner_uid = '$owner_uid' AND parent_cat IS NULL\r
- ORDER BY $order_by_qpart";\r
-\r
- $result = db_query($this->link, $query);\r
-\r
- $actid = $_REQUEST["actid"];\r
-\r
- if (db_num_rows($result) > 0) {\r
-\r
- $category = "";\r
-\r
- if (!$enable_cats)\r
- $cat['items'] = array();\r
- else\r
- $cat = false;\r
-\r
- while ($line = db_fetch_assoc($result)) {\r
-\r
- $feed = htmlspecialchars(trim($line["title"]));\r
-\r
- if (!$feed) $feed = "[Untitled]";\r
-\r
- $feed_id = $line["id"];\r
- $unread = $line["unread"];\r
-\r
- $cat_id = $line["cat_id"];\r
- $tmp_category = $line["category"];\r
-\r
- if ($category != $tmp_category && $enable_cats) {\r
-\r
- $category = $tmp_category;\r
-\r
- $collapsed = sql_bool_to_bool($line["collapsed"]);\r
-\r
- // workaround for NULL category\r
- if ($category == __("Uncategorized")) {\r
- $collapsed = get_pref($this->link, "_COLLAPSED_UNCAT");\r
- }\r
-\r
- if ($cat) array_push($feedlist['items'], $cat);\r
-\r
- $cat = $this->feedlist_init_cat($cat_id, $collapsed);\r
- }\r
-\r
- $updated = make_local_datetime($this->link, $line["updated_noms"], false);\r
-\r
- array_push($cat['items'], $this->feedlist_init_feed($feed_id,\r
- $feed, $unread, $line['last_error'], $updated));\r
- }\r
-\r
- if ($enable_cats) {\r
- array_push($feedlist['items'], $cat);\r
- } else {\r
- $feedlist['items'] = array_merge($feedlist['items'], $cat['items']);\r
- }\r
-\r
- } */\r
-\r
- return $feedlist;\r
- }\r
-\r
- private function feedlist_process_category($cat_id, &$feedlist) {\r
- $owner_uid = $_SESSION['uid'];\r
- $enable_cats = get_pref($this->link, 'ENABLE_FEED_CATS');\r
-\r
- if (get_pref($this->link, 'ENABLE_FEED_CATS')) {\r
- if (get_pref($this->link, "FEEDS_SORT_BY_UNREAD")) {\r
- $order_by_qpart = "order_id,category,unread DESC,title";\r
- } else {\r
- $order_by_qpart = "order_id,category,title";\r
- }\r
- } else {\r
- if (get_pref($this->link, "FEEDS_SORT_BY_UNREAD")) {\r
- $order_by_qpart = "unread DESC,title";\r
- } else {\r
- $order_by_qpart = "title";\r
- }\r
- }\r
-\r
- if ($enable_cats)\r
- $order_by_qpart = "ttrss_feed_categories.order_id,category,\r
- ttrss_feeds.order_id,title";\r
- else\r
- $order_by_qpart = "title";\r
-\r
- /* real feeds */\r
-\r
- if ($enable_cats)\r
- $order_by_qpart = "ttrss_feed_categories.order_id,category,\r
- ttrss_feeds.order_id,title";\r
- else\r
- $order_by_qpart = "title";\r
-\r
- if (!$enable_cats) {\r
- $parent_qpart = "true";\r
- } else if ($cat_id == 'root') {\r
- $parent_qpart = 'parent_cat IS NULL';\r
- } else {\r
- $parent_qpart = 'parent_cat = '.db_escape_string($cat_id);\r
- }\r
-\r
- $query = "SELECT ttrss_feeds.id, ttrss_feeds.title,\r
- ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated_noms,\r
- cat_id,last_error,\r
- COALESCE(ttrss_feed_categories.title, '".__('Uncategorized')."') AS category,\r
- ttrss_feed_categories.collapsed,\r
- value AS unread\r
- FROM ttrss_feeds LEFT JOIN ttrss_feed_categories\r
- ON (ttrss_feed_categories.id = cat_id)\r
- LEFT JOIN ttrss_counters_cache\r
- ON\r
- (ttrss_feeds.id = feed_id)\r
- WHERE\r
- ttrss_feeds.owner_uid = '$owner_uid' AND $parent_qpart\r
- ORDER BY $order_by_qpart";\r
-\r
- $result = db_query($this->link, $query);\r
-\r
- $actid = $_REQUEST["actid"];\r
-\r
- if (db_num_rows($result) > 0) {\r
-\r
- $category = "";\r
-\r
- if (!$enable_cats)\r
- $cat['items'] = array();\r
- else\r
- $cat = false;\r
-\r
- while ($line = db_fetch_assoc($result)) {\r
-\r
- $feed = htmlspecialchars(trim($line["title"]));\r
-\r
- if (!$feed) $feed = "[Untitled]";\r
-\r
- $feed_id = $line["id"];\r
- $unread = $line["unread"];\r
-\r
- $cat_id = $line["cat_id"];\r
- $tmp_category = $line["category"];\r
-\r
- if ($category != $tmp_category && $enable_cats) {\r
-\r
- $category = $tmp_category;\r
-\r
- $collapsed = sql_bool_to_bool($line["collapsed"]);\r
-\r
- // workaround for NULL category\r
- if ($category == __("Uncategorized")) {\r
- $collapsed = get_pref($this->link, "_COLLAPSED_UNCAT");\r
- }\r
-\r
- if ($cat) array_push($feedlist['items'], $cat);\r
-\r
- $cat = $this->feedlist_init_cat($cat_id, $collapsed);\r
-\r
- if ($cat_id) {\r
- $cat_items = $this->feedlist_process_category($cat_id, &$feedlist);\r
- if (count($cat_items) > 0) {\r
- array_push($cat['items'], $cat_items);\r
- }\r
- }\r
- }\r
-\r
- $updated = make_local_datetime($this->link, $line["updated_noms"], false);\r
-\r
- array_push($cat['items'], $this->feedlist_init_feed($feed_id,\r
- $feed, $unread, $line['last_error'], $updated));\r
- }\r
-\r
- if ($enable_cats) {\r
- array_push($feedlist['items'], $cat);\r
- } else {\r
- $feedlist['items'] = array_merge($feedlist['items'], $cat['items']);\r
- }\r
-\r
- }\r
-\r
- }\r
-\r
-\r
function catchupAll() {\r
db_query($this->link, "UPDATE ttrss_user_entries SET\r
last_read = NOW(),unread = false WHERE owner_uid = " . $_SESSION["uid"]);\r
$items = array();
- $result = db_query($this->link, "SELECT id, title FROM ttrss_feed_categories
+ $result = db_query($this->link, "SELECT id, title, collapsed FROM ttrss_feed_categories
WHERE owner_uid = " . $_SESSION["uid"] . " AND parent_cat = '$cat_id' ORDER BY order_id, title");
while ($line = db_fetch_assoc($result)) {
$cat = array();
$cat['id'] = 'CAT:' . $line['id'];
- $cat['bare_id'] = $feed_id;
+ $cat['bare_id'] = (int)$line['id'];
$cat['name'] = $line['title'];
$cat['items'] = array();
$cat['checkbox'] = false;
+ $cat['hidden'] = sql_bool_to_bool($line['collapsed']);
$cat['type'] = 'category';
+ $cat['unread'] = 0;
$cat['items'] = $this->get_category_items($line['id']);
while ($feed_line = db_fetch_assoc($feed_result)) {
$feed = array();
$feed['id'] = 'FEED:' . $feed_line['id'];
- $feed['bare_id'] = $feed_line['id'];
+ $feed['bare_id'] = (int)$feed_line['id'];
$feed['name'] = $feed_line['title'];
$feed['checkbox'] = false;
+ $feed['unread'] = 0;
$feed['error'] = $feed_line['last_error'];
$feed['icon'] = getFeedIcon($feed_line['id']);
$feed['param'] = make_local_datetime($this->link,
$root['items'] = array();
$root['type'] = 'category';
- if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
- $show_empty_cats = get_pref($this->link, '_PREFS_SHOW_EMPTY_CATS');
+ $enable_cats = get_pref($this->link, 'ENABLE_FEED_CATS');
+
+ if ($_REQUEST['mode'] == 2) {
+
+ if ($enable_cats) {
+ $cat_hidden = get_pref($this->link, "_COLLAPSED_SPECIAL");
+ $cat = $this->feedlist_init_cat(-1, $cat_hidden);
+ } else {
+ $cat['items'] = array();
+ }
+
+ foreach (array(-4, -3, -1, -2, 0) as $i) {
+ array_push($cat['items'], $this->feedlist_init_feed($i));
+ }
+
+ if ($enable_cats) {
+ array_push($root['items'], $cat);
+ } else {
+ $root['items'] = array_merge($root['items'], $cat['items']);
+ }
- $result = db_query($this->link, "SELECT id, title FROM ttrss_feed_categories
+ $result = db_query($this->link, "SELECT * FROM
+ ttrss_labels2 WHERE owner_uid = ".$_SESSION['uid']." ORDER by caption");
+
+ if (db_num_rows($result) > 0) {
+
+ if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
+ $cat_hidden = get_pref($this->link, "_COLLAPSED_LABELS");
+ $cat = $this->feedlist_init_cat(-2, $cat_hidden);
+ } else {
+ $cat['items'] = array();
+ }
+
+ while ($line = db_fetch_assoc($result)) {
+
+ $label_id = -$line['id'] - 11;
+ $count = getFeedUnread($this->link, $label_id);
+
+ $feed = $this->feedlist_init_feed($label_id, false, $count);
+
+ $feed['fg_color'] = $line['fg_color'];
+ $feed['bg_color'] = $line['bg_color'];
+
+ array_push($cat['items'], $feed);
+ }
+
+ if ($enable_cats) {
+ array_push($root['items'], $cat);
+ } else {
+ $root['items'] = array_merge($root['items'], $cat['items']);
+ }
+ }
+ }
+
+ if ($enable_cats) {
+ $show_empty_cats = $_REQUEST['mode'] != 2 &&
+ get_pref($this->link, '_PREFS_SHOW_EMPTY_CATS');
+
+ $result = db_query($this->link, "SELECT id, title, collapsed FROM ttrss_feed_categories
WHERE owner_uid = " . $_SESSION["uid"] . " AND parent_cat IS NULL ORDER BY order_id, title");
while ($line = db_fetch_assoc($result)) {
$cat = array();
$cat['id'] = 'CAT:' . $line['id'];
- $cat['bare_id'] = $feed_id;
+ $cat['bare_id'] = (int)$line['id'];
$cat['name'] = $line['title'];
$cat['items'] = array();
$cat['checkbox'] = false;
+ $cat['hidden'] = sql_bool_to_bool($line['collapsed']);
$cat['type'] = 'category';
+ $cat['unread'] = 0;
$cat['items'] = $this->get_category_items($line['id']);
$cat['bare_id'] = 0;
$cat['name'] = __("Uncategorized");
$cat['items'] = array();
+ $cat['hidden'] = get_pref($this->link, "_COLLAPSED_UNCAT");
$cat['type'] = 'category';
$cat['checkbox'] = false;
+ $cat['unread'] = 0;
$feed_result = db_query($this->link, "SELECT id, title,last_error,
".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
while ($feed_line = db_fetch_assoc($feed_result)) {
$feed = array();
$feed['id'] = 'FEED:' . $feed_line['id'];
- $feed['bare_id'] = $feed_line['id'];
+ $feed['bare_id'] = (int)$feed_line['id'];
$feed['name'] = $feed_line['title'];
$feed['checkbox'] = false;
$feed['error'] = $feed_line['last_error'];
$feed['icon'] = getFeedIcon($feed_line['id']);
$feed['param'] = make_local_datetime($this->link,
$feed_line['last_updated'], true);
+ $feed['unread'] = 0;
+ $feed['type'] = 'feed';
array_push($cat['items'], $feed);
}
while ($feed_line = db_fetch_assoc($feed_result)) {
$feed = array();
$feed['id'] = 'FEED:' . $feed_line['id'];
- $feed['bare_id'] = $feed_line['id'];
+ $feed['bare_id'] = (int)$feed_line['id'];
$feed['name'] = $feed_line['title'];
$feed['checkbox'] = false;
$feed['error'] = $feed_line['last_error'];
$feed['icon'] = getFeedIcon($feed_line['id']);
$feed['param'] = make_local_datetime($this->link,
$feed_line['last_updated'], true);
+ $feed['unread'] = 0;
+ $feed['type'] = 'feed';
array_push($root['items'], $feed);
}
$root['param'] = T_sprintf('(%d feeds)', count($root['items']));
-
}
$fl = array();
$fl['identifier'] = 'id';
$fl['label'] = 'name';
- $fl['items'] = array($root);
+
+ if ($_REQUEST['mode'] != 2) {
+ $fl['items'] = array($root);
+ } else {
+ $fl['items'] =& $root['items'];
+ }
print json_encode($fl);
return;
print "</div>"; #container
}
+
+ private function feedlist_init_cat($cat_id, $hidden = false) {
+ $obj = array();
+ $cat_id = (int) $cat_id;
+
+ if ($cat_id > 0) {
+ $cat_unread = ccache_find($this->link, $cat_id, $_SESSION["uid"], true);
+ } else if ($cat_id == 0 || $cat_id == -2) {
+ $cat_unread = getCategoryUnread($this->link, $cat_id);
+ }
+
+ $obj['id'] = 'CAT:' . $cat_id;
+ $obj['items'] = array();
+ $obj['name'] = getCategoryTitle($this->link, $cat_id);
+ $obj['type'] = 'category';
+ $obj['unread'] = (int) $cat_unread;
+ $obj['hidden'] = $hidden;
+ $obj['bare_id'] = $cat_id;
+
+ return $obj;
+ }
+
+ private function feedlist_init_feed($feed_id, $title = false, $unread = false, $error = '', $updated = '') {
+ $obj = array();
+ $feed_id = (int) $feed_id;
+
+ if (!$title)
+ $title = getFeedTitle($this->link, $feed_id, false);
+
+ if ($unread === false)
+ $unread = getFeedUnread($this->link, $feed_id, false);
+
+ $obj['id'] = 'FEED:' . $feed_id;
+ $obj['name'] = $title;
+ $obj['unread'] = (int) $unread;
+ $obj['type'] = 'feed';
+ $obj['error'] = $error;
+ $obj['updated'] = $updated;
+ $obj['icon'] = getFeedIcon($feed_id);
+ $obj['bare_id'] = $feed_id;
+
+ return $obj;
+ }
+
}
?>