pref-feeds: apply patch by gmargo@forum to show/hide empty categories
This commit is contained in:
parent
d50edb08ba
commit
5b7bd238ee
7 changed files with 46 additions and 5 deletions
|
@ -45,6 +45,7 @@ class Pref_Feeds extends Protected_Handler {
|
|||
$root['type'] = 'category';
|
||||
|
||||
if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
|
||||
$show_empty_cats = get_pref($this->link, '_PREFS_SHOW_EMPTY_CATS');
|
||||
|
||||
$result = db_query($this->link, "SELECT id, title FROM ttrss_feed_categories
|
||||
WHERE owner_uid = " . $_SESSION["uid"] . " ORDER BY order_id, title");
|
||||
|
@ -80,7 +81,7 @@ class Pref_Feeds extends Protected_Handler {
|
|||
|
||||
$cat['param'] = T_sprintf('(%d feeds)', count($cat['items']));
|
||||
|
||||
if (count($cat['items']) > 0)
|
||||
if (count($cat['items']) > 0 || $show_empty_cats)
|
||||
array_push($root['items'], $cat);
|
||||
|
||||
$root['param'] += count($cat['items']);
|
||||
|
@ -118,7 +119,7 @@ class Pref_Feeds extends Protected_Handler {
|
|||
|
||||
$cat['param'] = T_sprintf('(%d feeds)', count($cat['items']));
|
||||
|
||||
if (count($cat['items']) > 0)
|
||||
if (count($cat['items']) > 0 || $show_empty_cats)
|
||||
array_push($root['items'], $cat);
|
||||
|
||||
$root['param'] += count($cat['items']);
|
||||
|
@ -170,6 +171,11 @@ class Pref_Feeds extends Protected_Handler {
|
|||
return;
|
||||
}
|
||||
|
||||
function togglehiddenfeedcats() {
|
||||
set_pref($this->link, '_PREFS_SHOW_EMPTY_CATS',
|
||||
(get_pref($this->link, '_PREFS_SHOW_EMPTY_CATS') ? 'false' : 'true'));
|
||||
}
|
||||
|
||||
function savefeedorder() {
|
||||
$data = json_decode($_POST['payload'], true);
|
||||
|
||||
|
@ -1328,6 +1334,8 @@ class Pref_Feeds extends Protected_Handler {
|
|||
print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
|
||||
print "<div onclick=\"editFeedCats()\"
|
||||
dojoType=\"dijit.MenuItem\">".__('Edit categories')."</div>";
|
||||
print "<div onclick=\"toggleHiddenFeedCats()\"
|
||||
dojoType=\"dijit.MenuItem\">".__('(Un)hide empty categories')."</div>";
|
||||
print "<div onclick=\"resetCatOrder()\"
|
||||
dojoType=\"dijit.MenuItem\">".__('Reset sort order')."</div>";
|
||||
print "</div></div>";
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
} else {
|
||||
|
||||
define('EXPECTED_CONFIG_VERSION', 25);
|
||||
define('SCHEMA_VERSION', 89);
|
||||
define('SCHEMA_VERSION', 90);
|
||||
|
||||
require_once "config.php";
|
||||
require_once "sanity_config.php";
|
||||
|
|
15
js/prefs.js
15
js/prefs.js
|
@ -1635,6 +1635,21 @@ function resetCatOrder() {
|
|||
}
|
||||
}
|
||||
|
||||
function toggleHiddenFeedCats() {
|
||||
try {
|
||||
notify_progress("Loading, please wait...");
|
||||
|
||||
new Ajax.Request("backend.php", {
|
||||
parameters: "?op=pref-feeds&method=togglehiddenfeedcats",
|
||||
onComplete: function(transport) {
|
||||
updateFeedList();
|
||||
} });
|
||||
|
||||
} catch (e) {
|
||||
exception_error("toggleHiddenFeedCats");
|
||||
}
|
||||
}
|
||||
|
||||
function editCat(id, item, event) {
|
||||
try {
|
||||
var new_name = prompt(__('Rename category to:'), item.name);
|
||||
|
|
|
@ -260,7 +260,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 (89);
|
||||
insert into ttrss_version values (90);
|
||||
|
||||
create table ttrss_enclosures (id integer primary key auto_increment,
|
||||
content_url text not null,
|
||||
|
@ -394,6 +394,8 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_
|
|||
|
||||
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('DIGEST_PREFERRED_TIME', 2, '00:00', 'Try to send digests around specified time', 1, 'Uses UTC timezone');
|
||||
|
||||
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_PREFS_SHOW_EMPTY_CATS', 1, 'false', '', 1);
|
||||
|
||||
create table ttrss_user_prefs (
|
||||
owner_uid integer not null,
|
||||
pref_name varchar(250),
|
||||
|
|
|
@ -229,7 +229,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 (89);
|
||||
insert into ttrss_version values (90);
|
||||
|
||||
create table ttrss_enclosures (id serial not null primary key,
|
||||
content_url text not null,
|
||||
|
@ -356,6 +356,8 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_
|
|||
|
||||
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('DIGEST_PREFERRED_TIME', 2, '00:00', 'Try to send digests around specified time', 1, 'Uses UTC timezone');
|
||||
|
||||
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_PREFS_SHOW_EMPTY_CATS', 1, 'false', '', 1);
|
||||
|
||||
create table ttrss_user_prefs (
|
||||
owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
|
||||
pref_name varchar(250) not null references ttrss_prefs(pref_name) ON DELETE CASCADE,
|
||||
|
|
7
schema/versions/mysql/90.sql
Normal file
7
schema/versions/mysql/90.sql
Normal file
|
@ -0,0 +1,7 @@
|
|||
begin;
|
||||
|
||||
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_PREFS_SHOW_EMPTY_CATS', 1, 'false', '', 1);
|
||||
|
||||
update ttrss_version set schema_version = 90;
|
||||
|
||||
commit;
|
7
schema/versions/pgsql/90.sql
Normal file
7
schema/versions/pgsql/90.sql
Normal file
|
@ -0,0 +1,7 @@
|
|||
begin;
|
||||
|
||||
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_PREFS_SHOW_EMPTY_CATS', 1, 'false', '', 1);
|
||||
|
||||
update ttrss_version set schema_version = 90;
|
||||
|
||||
commit;
|
Loading…
Reference in a new issue