From 82aea97816774e3410eb4137b80dd0497547eb96 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 18 Nov 2010 14:20:43 +0300 Subject: [PATCH] support feed icons in PrefFeedTree; code cleanup --- PrefFeedTree.js | 15 +++ modules/pref-feeds.php | 232 +++-------------------------------------- prefs.js | 2 +- 3 files changed, 32 insertions(+), 217 deletions(-) diff --git a/PrefFeedTree.js b/PrefFeedTree.js index 511f4faf..bb0d77bc 100644 --- a/PrefFeedTree.js +++ b/PrefFeedTree.js @@ -19,10 +19,25 @@ dojo.declare("fox.PrefFeedStore", dojo.data.ItemFileWriteStore, { }); dojo.declare("fox.PrefFeedTree", lib.CheckBoxTree, { + _createTreeNode: function(args) { + var tnode = this.inherited(arguments); + + if (args.item.icon) + tnode.iconNode.src = args.item.icon[0]; + + return tnode; + }, onDndDrop: function() { this.inherited(arguments); this.tree.model.store.save(); }, + getRowClass: function (item, opened) { + return (!item.error || item.error == '') ? "dijitTreeRow" : + "dijitTreeRow Error"; + }, + getIconClass: function (item, opened) { + return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "feedIcon"; + }, checkItemAcceptance: function(target, source, position) { var item = dijit.getEnclosingWidget(target).item; diff --git a/modules/pref-feeds.php b/modules/pref-feeds.php index f6776e20..67adeb66 100644 --- a/modules/pref-feeds.php +++ b/modules/pref-feeds.php @@ -45,7 +45,8 @@ $cat['name'] = $line['title']; $cat['items'] = array(); - $feed_result = db_query($link, "SELECT id, title FROM ttrss_feeds + $feed_result = db_query($link, "SELECT id, title, last_error + FROM ttrss_feeds WHERE cat_id = '".$line['id']."' AND owner_uid = ".$_SESSION["uid"]. " ORDER BY order_id, title"); @@ -55,6 +56,9 @@ $feed['bare_id'] = $feed_line['id']; $feed['name'] = $feed_line['title']; $feed['checkbox'] = false; + $feed['error'] = $feed_line['last_error']; + $feed['icon'] = getFeedIcon($feed_line['id']); + array_push($cat['items'], $feed); } @@ -69,7 +73,8 @@ $cat['name'] = __("Uncategorized"); $cat['items'] = array(); - $feed_result = db_query($link, "SELECT id, title FROM ttrss_feeds + $feed_result = db_query($link, "SELECT id, title,last_error + FROM ttrss_feeds WHERE cat_id IS NULL AND owner_uid = ".$_SESSION["uid"]. " ORDER BY order_id, title"); @@ -79,12 +84,16 @@ $feed['bare_id'] = $feed_line['id']; $feed['name'] = $feed_line['title']; $feed['checkbox'] = false; + $feed['error'] = $feed_line['last_error']; + $feed['icon'] = getFeedIcon($feed_line['id']); + array_push($cat['items'], $feed); } array_push($root['items'], $cat); } else { - $feed_result = db_query($link, "SELECT id, title FROM ttrss_feeds + $feed_result = db_query($link, "SELECT id, title, last_error + FROM ttrss_feeds WHERE owner_uid = ".$_SESSION["uid"]. " ORDER BY order_id, title"); @@ -94,6 +103,9 @@ $feed['bare_id'] = $feed_line['id']; $feed['name'] = $feed_line['title']; $feed['checkbox'] = false; + $feed['error'] = $feed_line['last_error']; + $feed['icon'] = getFeedIcon($feed_line['id']); + array_push($root['items'], $feed); } } @@ -1163,7 +1175,7 @@ print "
".__('Subscribe to feed')."
"; print "
".__('Edit feeds')."
"; + dojoType=\"dijit.MenuItem\">".__('Edit selected feeds').""; print "
".__('Reset sort order')."
"; print ""; @@ -1235,218 +1247,6 @@ "; - /* - $feeds_sort = db_escape_string($_REQUEST["sort"]); - - if (!$feeds_sort || $feeds_sort == "undefined") { - $feeds_sort = $_SESSION["pref_sort_feeds"]; - if (!$feeds_sort) $feeds_sort = "title"; - } - - $_SESSION["pref_sort_feeds"] = $feeds_sort; - - if ($feed_search) { - - $feed_search = split(" ", $feed_search); - $tokens = array(); - - foreach ($feed_search as $token) { - - $token = trim($token); - - array_push($tokens, "(UPPER(F1.title) LIKE UPPER('%$token%') OR - UPPER(C1.title) LIKE UPPER('%$token%') OR - UPPER(F1.feed_url) LIKE UPPER('%$token%'))"); - } - - $search_qpart = "(" . join($tokens, " AND ") . ") AND "; - - } else { - $search_qpart = ""; - } - - $show_last_article_info = false; - $show_last_article_checked = ""; - $show_last_article_qpart = ""; - - if ($_REQUEST["slat"] == "true") { - $show_last_article_info = true; - $show_last_article_checked = "checked"; - $show_last_article_qpart = ", (SELECT ".SUBSTRING_FOR_DATE."(MAX(updated),1,16) FROM ttrss_user_entries, - ttrss_entries WHERE ref_id = ttrss_entries.id - AND feed_id = F1.id) AS last_article"; - } else if ($feeds_sort == "last_article") { - $feeds_sort = "title"; - } - - if (get_pref($link, 'ENABLE_FEED_CATS')) { - $order_by_qpart = "category,$feeds_sort,title"; - } else { - $order_by_qpart = "$feeds_sort,title"; - } - - $result = db_query($link, "SELECT - F1.id, - F1.title, - F1.feed_url, - ".SUBSTRING_FOR_DATE."(F1.last_updated,1,16) AS last_updated, - F1.update_interval, - F1.last_error, - F1.purge_interval, - F1.cat_id, - C1.title AS category, - F1.include_in_digest - $show_last_article_qpart - FROM - ttrss_feeds AS F1 - LEFT JOIN ttrss_feed_categories AS C1 - ON (F1.cat_id = C1.id) - WHERE - $search_qpart F1.owner_uid = '".$_SESSION["uid"]."' - ORDER by $order_by_qpart"); - - if (db_num_rows($result) != 0) { - - print "

"; - print " - "; - - print ""; - - print ""; - - if ($show_last_article_info) { - print ""; - } - - print ""; - } - - $lnum = 0; - - $cur_cat_id = -1; - - while ($line = db_fetch_assoc($result)) { - - $feed_id = $line["id"]; - $cat_id = $line["cat_id"]; - - $edit_title = htmlspecialchars($line["title"]); - $edit_cat = htmlspecialchars($line["category"]); - - $last_error = $line["last_error"]; - - if (!$edit_cat) $edit_cat = __("Uncategorized"); - - $last_updated = $line["last_updated"]; - - if (!$last_updated) { - $last_updated = "—"; - } else { - $last_updated = make_local_datetime($link, $last_updated, false); - } - - $last_article = $line["last_article"]; - - if (!$last_article) { - $last_article = "—"; - } else { - $last_article = make_local_datetime($link, $last_article, false); - } - - if (get_pref($link, 'ENABLE_FEED_CATS') && $cur_cat_id != $cat_id) { - $lnum = 0; - - print ""; - - print " - "; - - print ""; - - print ""; - - if ($show_last_article_info) { - print ""; - } - - print ""; - - $cur_cat_id = $cat_id; - } - - $class = ($lnum % 2) ? "even" : "odd"; - $this_row_id = "id=\"FEEDR-$feed_id\""; - - print ""; - - $icon_file = ICONS_DIR . "/$feed_id.ico"; - - if (file_exists($icon_file) && filesize($icon_file) > 0) { - $feed_icon = ""; - } else { - $feed_icon = ""; - } - - print ""; - - $onclick = "onclick='editFeed($feed_id, event)' title='".__('Click to edit')."'"; - - print ""; - - if ($last_error) { - $edit_title = "$edit_title"; - $last_updated = "$last_updated"; - $last_article = "$last_article"; - } - - print ""; - - if ($show_last_article_info) { - print ""; - } - - print ""; - - print ""; - - ++$lnum; - } - - print "
". - "
". - "
". - __('Select:')." - ".__('All').", - ".__('None')." - "; - - if (!get_pref($link, 'ENABLE_FEED_CATS')) { - print "
  ".__('Title')."".__('Last Article')."".__('Updated')."
$edit_cat
  ".__('Title')." - ".__('Last Article')." - ".__('Updated')."
$feed_icon" . $edit_title . "" . - "$last_article$last_updated
"; - - print "

"; - - } else { - - print "

"; - - if (!$feed_search) { - print_warning(__("You don't have any subscribed feeds.")); - } else { - print_warning(__('No matching feeds found.')); - } - print "

"; - - } */ - print ""; # feeds pane print "
"; diff --git a/prefs.js b/prefs.js index 35633860..0e77118d 100644 --- a/prefs.js +++ b/prefs.js @@ -957,7 +957,7 @@ function editSelectedFeeds() { notify(""); - notify_progress("Loading, please wait..."); + notify_progress("Loading, please wait...", true); var query = "?op=pref-feeds&subop=editfeeds&ids=" + param_escape(rows.toString()); -- 2.39.5