diff options
-rw-r--r-- | classes/feeds.php | 2 | ||||
-rw-r--r-- | classes/pref/filters.php | 128 | ||||
-rw-r--r-- | include/functions.php | 4 | ||||
-rw-r--r-- | index.php | 12 | ||||
-rw-r--r-- | js/PrefFilterTree.js | 28 | ||||
-rw-r--r-- | js/prefs.js | 18 | ||||
-rw-r--r-- | js/viewfeed.js | 21 | ||||
-rw-r--r-- | schema/ttrss_schema_mysql.sql | 4 | ||||
-rw-r--r-- | schema/ttrss_schema_pgsql.sql | 4 | ||||
-rw-r--r-- | schema/versions/mysql/112.sql | 15 | ||||
-rw-r--r-- | schema/versions/pgsql/112.sql | 15 | ||||
-rw-r--r-- | tt-rss.css | 15 |
12 files changed, 201 insertions, 65 deletions
diff --git a/classes/feeds.php b/classes/feeds.php index 2b00b848d..0b46155cf 100644 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -133,7 +133,7 @@ class Feeds extends Handler_Protected { $reply .= "<option value=\"0\" disabled=\"1\">".__('Feed:')."</option>"; - $reply .= "<option value=\"catchupPage()\">".__('Mark as read')."</option>"; + //$reply .= "<option value=\"catchupPage()\">".__('Mark as read')."</option>"; $reply .= "<option value=\"displayDlg('generatedFeed', '$feed_id:$is_cat:$rss_link')\">".__('View as RSS')."</option>"; diff --git a/classes/pref/filters.php b/classes/pref/filters.php index 883ff0ebd..6ccff51d7 100644 --- a/classes/pref/filters.php +++ b/classes/pref/filters.php @@ -3,11 +3,47 @@ class Pref_Filters extends Handler_Protected { function csrf_ignore($method) { $csrf_ignored = array("index", "getfiltertree", "edit", "newfilter", "newrule", - "newaction"); + "newaction", "savefilterorder"); return array_search($method, $csrf_ignored) !== false; } + function filtersortreset() { + db_query($this->link, "UPDATE ttrss_filters2 + SET order_id = 0 WHERE owner_uid = " . $_SESSION["uid"]); + return; + } + + function savefilterorder() { + $data = json_decode($_POST['payload'], true); + + #file_put_contents("/tmp/saveorder.json", $_POST['payload']); + #$data = json_decode(file_get_contents("/tmp/saveorder.json"), true); + + if (!is_array($data['items'])) + $data['items'] = json_decode($data['items'], true); + + $index = 0; + + if (is_array($data) && is_array($data['items'])) { + foreach ($data['items'][0]['items'] as $item) { + $filter_id = (int) str_replace("FILTER:", "", $item['_reference']); + + if ($filter_id > 0) { + + db_query($this->link, "UPDATE ttrss_filters2 SET + order_id = $index WHERE id = '$filter_id' AND + owner_uid = " .$_SESSION["uid"]); + + ++$index; + } + } + } + + return; + } + + function testFilter() { $filter = array(); @@ -133,7 +169,7 @@ class Pref_Filters extends Handler_Protected { (SELECT reg_exp FROM ttrss_filters2_rules WHERE filter_id = ttrss_filters2.id ORDER BY id LIMIT 1) AS reg_exp FROM ttrss_filters2 WHERE - owner_uid = ".$_SESSION["uid"]." ORDER BY action_id,reg_exp"); + owner_uid = ".$_SESSION["uid"]." ORDER BY order_id"); $action_id = -1; @@ -142,7 +178,7 @@ class Pref_Filters extends Handler_Protected { while ($line = db_fetch_assoc($result)) { - if ($action_id != $line["action_id"]) { + /* if ($action_id != $line["action_id"]) { if (count($folder['items']) > 0) { array_push($root['items'], $folder); } @@ -152,7 +188,7 @@ class Pref_Filters extends Handler_Protected { $folder['name'] = __($line["action_name"]); $folder['items'] = array(); $action_id = $line["action_id"]; - } + } */ $name = $this->getFilterName($line["id"]); @@ -195,9 +231,11 @@ class Pref_Filters extends Handler_Protected { } } - if (count($folder['items']) > 0) { + /* if (count($folder['items']) > 0) { array_push($root['items'], $folder); - } + } */ + + $root['items'] = $folder['items']; $fl = array(); $fl['identifier'] = 'id'; @@ -218,6 +256,7 @@ class Pref_Filters extends Handler_Protected { $enabled = sql_bool_to_bool(db_fetch_result($result, 0, "enabled")); $match_any_rule = sql_bool_to_bool(db_fetch_result($result, 0, "match_any_rule")); $inverse = sql_bool_to_bool(db_fetch_result($result, 0, "inverse")); + $title = htmlspecialchars(db_fetch_result($result, 0, "title")); print "<form id=\"filter_edit_form\" onsubmit='return false'>"; @@ -226,6 +265,12 @@ class Pref_Filters extends Handler_Protected { print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"editSave\">"; print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"csrf_token\" value=\"".$_SESSION['csrf_token']."\">"; + print "<div class=\"dlgSec\">".__("Caption")."</div>"; + + print "<input dojoType=\"dijit.form.TextBox\" style=\"width : 20em;\" name=\"title\" value=\"$title\">"; + + print "</div>"; + print "<div class=\"dlgSec\">".__("Match")."</div>"; print "<div dojoType=\"dijit.Toolbar\">"; @@ -422,10 +467,12 @@ class Pref_Filters extends Handler_Protected { $enabled = checkbox_to_sql_bool(db_escape_string($this->link, $_REQUEST["enabled"])); $match_any_rule = checkbox_to_sql_bool(db_escape_string($this->link, $_REQUEST["match_any_rule"])); $inverse = checkbox_to_sql_bool(db_escape_string($this->link, $_REQUEST["inverse"])); + $title = db_escape_string($this->link, $_REQUEST["title"]); $result = db_query($this->link, "UPDATE ttrss_filters2 SET enabled = $enabled, match_any_rule = $match_any_rule, - inverse = $inverse + inverse = $inverse, + title = '$title' WHERE id = '$filter_id' AND owner_uid = ". $_SESSION["uid"]); @@ -539,14 +586,15 @@ class Pref_Filters extends Handler_Protected { $enabled = checkbox_to_sql_bool($_REQUEST["enabled"]); $match_any_rule = checkbox_to_sql_bool($_REQUEST["match_any_rule"]); + $title = db_escape_string($this->link, $_REQUEST["title"]); db_query($this->link, "BEGIN"); /* create base filter */ $result = db_query($this->link, "INSERT INTO ttrss_filters2 - (owner_uid, match_any_rule, enabled) VALUES - (".$_SESSION["uid"].",$match_any_rule,$enabled)"); + (owner_uid, match_any_rule, enabled, title) VALUES + (".$_SESSION["uid"].",$match_any_rule,$enabled, '$title')"); $result = db_query($this->link, "SELECT MAX(id) AS id FROM ttrss_filters2 WHERE owner_uid = ".$_SESSION["uid"]); @@ -611,6 +659,10 @@ class Pref_Filters extends Handler_Protected { print "<button dojoType=\"dijit.form.Button\" onclick=\"return editSelectedFilter()\">". __('Edit')."</button> "; + print "<button dojoType=\"dijit.form.Button\" onclick=\"return resetFilterOrder()\">". + __('Reset sort order')."</button> "; + + print "<button dojoType=\"dijit.form.Button\" onclick=\"return removeSelectedFilters()\">". __('Remove')."</button> "; @@ -627,14 +679,16 @@ class Pref_Filters extends Handler_Protected { <img src='images/indicator_tiny.gif'>". __("Loading, please wait...")."</div>"; - print "<div dojoType=\"dojo.data.ItemFileWriteStore\" jsId=\"filterStore\" + print "<div dojoType=\"fox.PrefFilterStore\" jsId=\"filterStore\" url=\"backend.php?op=pref-filters&method=getfiltertree\"> </div> <div dojoType=\"lib.CheckBoxStoreModel\" jsId=\"filterModel\" store=\"filterStore\" - query=\"{id:'root'}\" rootId=\"root\" rootLabel=\"Feeds\" + query=\"{id:'root'}\" rootId=\"root\" rootLabel=\"Filters\" childrenAttrs=\"items\" checkboxStrict=\"false\" checkboxAll=\"false\"> </div> <div dojoType=\"fox.PrefFilterTree\" id=\"filterTree\" + dndController=\"dijit.tree.dndSource\" + betweenThreshold=\"5\" model=\"filterModel\" openOnClick=\"true\"> <script type=\"dojo/method\" event=\"onLoad\" args=\"item\"> Element.hide(\"filterlistLoading\"); @@ -668,6 +722,10 @@ class Pref_Filters extends Handler_Protected { print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"add\">"; print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"csrf_token\" value=\"".$_SESSION['csrf_token']."\">"; + print "<div class=\"dlgSec\">".__("Caption")."</div>"; + + print "<input dojoType=\"dijit.form.TextBox\" style=\"width : 20em;\" name=\"title\" value=\"\">"; + print "<div class=\"dlgSec\">".__("Match")."</div>"; print "<div dojoType=\"dijit.Toolbar\">"; @@ -894,30 +952,42 @@ class Pref_Filters extends Handler_Protected { } private function getFilterName($id) { + $result = db_query($this->link, - "SELECT * FROM ttrss_filters2_rules WHERE filter_id = '$id' ORDER BY id - LIMIT 3"); + "SELECT title FROM ttrss_filters2 WHERE id = '$id'"); - $titles = array(); - $count = 0; + $title = db_fetch_result($result, 0, "title"); - while ($line = db_fetch_assoc($result)) { + if (!$title) { - if (sql_bool_to_bool($line["cat_filter"])) { - unset($line["cat_filter"]); - $line["feed_id"] = "CAT:" . (int)$line["cat_id"]; - unset($line["cat_id"]); - } + $result = db_query($this->link, + "SELECT * FROM ttrss_filters2_rules WHERE filter_id = '$id' ORDER BY id + LIMIT 3"); - if (!sql_bool_to_bool($line["inverse"])) unset($line["inverse"]); + $titles = array(); + $count = 0; - if ($count < 2) { - array_push($titles, $this->getRuleName($line)); - } else { - array_push($titles, "..."); - break; + while ($line = db_fetch_assoc($result)) { + + if (sql_bool_to_bool($line["cat_filter"])) { + unset($line["cat_filter"]); + $line["feed_id"] = "CAT:" . (int)$line["cat_id"]; + unset($line["cat_id"]); + } + + if (!sql_bool_to_bool($line["inverse"])) unset($line["inverse"]); + + if ($count < 2) { + array_push($titles, $this->getRuleName($line)); + } else { + array_push($titles, "..."); + break; + } + ++$count; } - ++$count; + + $title = truncate_string(join(", ", $titles), 64, "..."); + } $result = db_query($this->link, @@ -936,7 +1006,7 @@ class Pref_Filters extends Handler_Protected { ++$count; } - return array(join(", ", $titles), join(", ", $actions)); + return array($title, join(", ", $actions)); } function join() { diff --git a/include/functions.php b/include/functions.php index b9c30c6ce..9f75fc23a 100644 --- a/include/functions.php +++ b/include/functions.php @@ -1,6 +1,6 @@ <?php define('EXPECTED_CONFIG_VERSION', 26); - define('SCHEMA_VERSION', 111); + define('SCHEMA_VERSION', 112); define('LABEL_BASE_INDEX', -1024); define('PLUGIN_FEED_BASE_INDEX', -128); @@ -3192,7 +3192,7 @@ $cat_id = (int)getFeedCategory($link, $feed_id); $result = db_query($link, "SELECT * FROM ttrss_filters2 WHERE - owner_uid = $owner_uid AND enabled = true"); + owner_uid = $owner_uid AND enabled = true ORDER BY order_id, title"); $check_cats = join(",", array_merge( getParentCategories($link, $cat_id, $owner_uid), @@ -229,20 +229,20 @@ <div dojoType="dijit.MenuItem" disabled="1"><?php echo __('Feed actions:') ?></div> <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcAddFeed')"><?php echo __('Subscribe to feed...') ?></div> <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcEditFeed')"><?php echo __('Edit this feed...') ?></div> - <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcRescoreFeed')"><?php echo __('Rescore feed') ?></div> + <!-- <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcRescoreFeed')"><?php echo __('Rescore feed') ?></div> --> <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcRemoveFeed')"><?php echo __('Unsubscribe') ?></div> <div dojoType="dijit.MenuItem" disabled="1"><?php echo __('All feeds:') ?></div> <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcCatchupAll')"><?php echo __('Mark as read') ?></div> <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcShowOnlyUnread')"><?php echo __('(Un)hide read feeds') ?></div> <div dojoType="dijit.MenuItem" disabled="1"><?php echo __('Other actions:') ?></div> - <?php if ($pluginhost->get_plugin("digest")) { ?> + <!-- <?php if ($pluginhost->get_plugin("digest")) { ?> <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcDigest')"><?php echo __('Switch to digest...') ?></div> - <?php } ?> - <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcTagCloud')"><?php echo __('Show tag cloud...') ?></div> + <?php } ?> --> + <!-- <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcTagCloud')"><?php echo __('Show tag cloud...') ?></div> --> <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcToggleWidescreen')"><?php echo __('Toggle widescreen mode') ?></div> <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcTagSelect')"><?php echo __('Select by tags...') ?></div> - <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcAddLabel')"><?php echo __('Create label...') ?></div> - <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcAddFilter')"><?php echo __('Create filter...') ?></div> + <!-- <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcAddLabel')"><?php echo __('Create label...') ?></div> + <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcAddFilter')"><?php echo __('Create filter...') ?></div> --> <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcHKhelp')"><?php echo __('Keyboard shortcuts help') ?></div> <?php if (!$_SESSION["hide_logout"]) { ?> <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcLogout')"><?php echo __('Logout') ?></div> diff --git a/js/PrefFilterTree.js b/js/PrefFilterTree.js index afa2f445a..3546e30fb 100644 --- a/js/PrefFilterTree.js +++ b/js/PrefFilterTree.js @@ -1,6 +1,22 @@ dojo.provide("fox.PrefFilterTree"); dojo.require("lib.CheckBoxTree"); +dojo.require("dojo.data.ItemFileWriteStore"); + +dojo.declare("fox.PrefFilterStore", dojo.data.ItemFileWriteStore, { + + _saveEverything: function(saveCompleteCallback, saveFailedCallback, + newFileContentString) { + + dojo.xhrPost({ + url: "backend.php", + content: {op: "pref-filters", method: "savefilterorder", + payload: newFileContentString}, + error: saveFailedCallback, + load: saveCompleteCallback}); + }, + +}); dojo.declare("fox.PrefFilterTree", lib.CheckBoxTree, { _createTreeNode: function(args) { @@ -48,5 +64,17 @@ dojo.declare("fox.PrefFilterTree", lib.CheckBoxTree, { return (!item.error || item.error == '') ? "dijitTreeRow" : "dijitTreeRow Error"; }, + checkItemAcceptance: function(target, source, position) { + var item = dijit.getEnclosingWidget(target).item; + + // disable copying items + source.copyState = function() { return false; }; + + return position != 'over'; + }, + onDndDrop: function() { + this.inherited(arguments); + this.tree.model.store.save(); + }, }); diff --git a/js/prefs.js b/js/prefs.js index 7d12e4202..cc2246374 100644 --- a/js/prefs.js +++ b/js/prefs.js @@ -1563,6 +1563,24 @@ function clearArticleAccessKeys() { return false; } + +function resetFilterOrder() { + try { + notify_progress("Loading, please wait..."); + + new Ajax.Request("backend.php", { + parameters: "?op=pref-filters&method=filtersortreset", + onComplete: function(transport) { + updateFilterList(); + } }); + + + } catch (e) { + exception_error("resetFilterOrder"); + } +} + + function resetFeedOrder() { try { notify_progress("Loading, please wait..."); diff --git a/js/viewfeed.js b/js/viewfeed.js index caf40919e..27d0c01b4 100644 --- a/js/viewfeed.js +++ b/js/viewfeed.js @@ -941,23 +941,6 @@ function selectArticles(mode) { } } -function catchupPage() { - - var fn = getFeedName(getActiveFeedId(), activeFeedIsCat()); - - var str = __("Mark all visible articles in %s as read?"); - - str = str.replace("%s", fn); - - if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str)) { - return; - } - - selectArticles('all'); - selectionToggleUnread(false, 'viewCurrentFeed()', true); - selectArticles('none'); -} - function deleteSelection() { try { @@ -1170,11 +1153,11 @@ function postMouseIn(e, id) { if (_post_preview_timeout) window.clearTimeout(_post_preview_timeout); - if (!isCdmMode() || !getInitParam("cdm_expanded")) { + /* if (!isCdmMode() || !getInitParam("cdm_expanded")) { _post_preview_timeout = window.setTimeout(function() { displaySmallArticlePreview(e, id); }, 1000); - } + } */ } function displaySmallArticlePreview(e, id) { diff --git a/schema/ttrss_schema_mysql.sql b/schema/ttrss_schema_mysql.sql index dce3921d5..40d5c67f5 100644 --- a/schema/ttrss_schema_mysql.sql +++ b/schema/ttrss_schema_mysql.sql @@ -251,6 +251,8 @@ create table ttrss_filters2(id integer primary key auto_increment, match_any_rule boolean not null default false, enabled boolean not null default true, inverse bool not null default false, + title varchar(250) not null default '', + order_id integer not null default 0, index(owner_uid), foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=UTF8; @@ -291,7 +293,7 @@ create table ttrss_tags (id integer primary key auto_increment, create table ttrss_version (schema_version int not null) ENGINE=InnoDB DEFAULT CHARSET=UTF8; -insert into ttrss_version values (111); +insert into ttrss_version values (112); create table ttrss_enclosures (id integer primary key auto_increment, content_url text not null, diff --git a/schema/ttrss_schema_pgsql.sql b/schema/ttrss_schema_pgsql.sql index 8ef7f0805..711a35968 100644 --- a/schema/ttrss_schema_pgsql.sql +++ b/schema/ttrss_schema_pgsql.sql @@ -223,6 +223,8 @@ create table ttrss_filters2(id serial not null primary key, owner_uid integer not null references ttrss_users(id) on delete cascade, match_any_rule boolean not null default false, inverse boolean not null default false, + title varchar(250) not null default '', + order_id integer not null default 0, enabled boolean not null default true); create table ttrss_filters2_rules(id serial not null primary key, @@ -249,7 +251,7 @@ create index ttrss_tags_post_int_id_idx on ttrss_tags(post_int_id); create table ttrss_version (schema_version int not null); -insert into ttrss_version values (111); +insert into ttrss_version values (112); create table ttrss_enclosures (id serial not null primary key, content_url text not null, diff --git a/schema/versions/mysql/112.sql b/schema/versions/mysql/112.sql new file mode 100644 index 000000000..a6f0b200b --- /dev/null +++ b/schema/versions/mysql/112.sql @@ -0,0 +1,15 @@ +begin; + +alter table ttrss_filters2 add column order_id integer; +update ttrss_filters2 set order_id = 0; +alter table ttrss_filters2 change order_id order_id integer not null; +alter table ttrss_filters2 alter column order_id set default 0; + +alter table ttrss_filters2 add column title varchar(250); +update ttrss_filters2 set title = ''; +alter table ttrss_filters2 change title title varchar(250) not null; +alter table ttrss_filters2 alter column title set default ''; + +update ttrss_version set schema_version = 112; + +commit; diff --git a/schema/versions/pgsql/112.sql b/schema/versions/pgsql/112.sql new file mode 100644 index 000000000..a9d90d6d4 --- /dev/null +++ b/schema/versions/pgsql/112.sql @@ -0,0 +1,15 @@ +begin; + +alter table ttrss_filters2 add column order_id integer; +update ttrss_filters2 set order_id = 0; +alter table ttrss_filters2 alter column order_id set not null; +alter table ttrss_filters2 alter column order_id set default 0; + +alter table ttrss_filters2 add column title varchar(250); +update ttrss_filters2 set title = ''; +alter table ttrss_filters2 alter column title set not null; +alter table ttrss_filters2 alter column title set default ''; + +update ttrss_version set schema_version = 112; + +commit; diff --git a/tt-rss.css b/tt-rss.css index bdfeee3a3..e6c869ee5 100644 --- a/tt-rss.css +++ b/tt-rss.css @@ -32,11 +32,9 @@ div.postReply a:hover { div.postReply div.postHeader { border-width : 0px 0px 1px 0px; border-style : solid; - border-color : #88b0f0; - background-color : white; - background : url("images/toolbar.png"); - background-position : bottom left; - background-repeat : repeat-x; + border-color : #c0c0c0; + background : #fafafa; + box-shadow : 0px 0px 3px 0px #ccc; padding : 5px; color : #909090; } @@ -842,6 +840,11 @@ div.fatalError textarea { margin-right : 1em; } +.labelParam { + float : right; + margin-right : 1em; +} + .dijitTreeLabel.Disabled, .labelParam.Disabled { color : gray; } @@ -983,7 +986,7 @@ body#ttrssZoom div.postReply { box-shadow : 0px 0px 3px #ccc; } -body#ttrssZoom div.postContent, body#ttrssZoom div.postHeader { +body#ttrssZoom div.postContent { background-color : white; } |