improve filter overview display; replace ngettext with php gettext
This commit is contained in:
parent
4c2da34957
commit
1a293f10ab
|
@ -58,7 +58,7 @@ class Pref_Feeds extends Handler_Protected {
|
|||
|
||||
$cat['items'] = $this->get_category_items($line['id']);
|
||||
|
||||
$cat['param'] = vsprintf(ngettext('(%d feed)', '(%d feeds)', count($cat['items'])), count($cat['items']));
|
||||
$cat['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', count($cat['items'])), count($cat['items']));
|
||||
|
||||
if (count($cat['items']) > 0 || $show_empty_cats)
|
||||
array_push($items, $cat);
|
||||
|
@ -206,7 +206,7 @@ class Pref_Feeds extends Handler_Protected {
|
|||
|
||||
$cat['items'] = $this->get_category_items($line['id']);
|
||||
|
||||
$cat['param'] = vsprintf(ngettext('(%d feed)', '(%d feeds)', count($cat['items'])), count($cat['items']));
|
||||
$cat['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', count($cat['items'])), count($cat['items']));
|
||||
|
||||
if (count($cat['items']) > 0 || $show_empty_cats)
|
||||
array_push($root['items'], $cat);
|
||||
|
@ -248,13 +248,13 @@ class Pref_Feeds extends Handler_Protected {
|
|||
array_push($cat['items'], $feed);
|
||||
}
|
||||
|
||||
$cat['param'] = vsprintf(ngettext('(%d feed)', '(%d feeds)', count($cat['items'])), count($cat['items']));
|
||||
$cat['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', count($cat['items'])), count($cat['items']));
|
||||
|
||||
if (count($cat['items']) > 0 || $show_empty_cats)
|
||||
array_push($root['items'], $cat);
|
||||
|
||||
$root['param'] += count($cat['items']);
|
||||
$root['param'] = vsprintf(ngettext('(%d feed)', '(%d feeds)', count($cat['items'])), count($cat['items']));
|
||||
$root['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', count($cat['items'])), count($cat['items']));
|
||||
|
||||
} else {
|
||||
$feed_result = db_query($this->link, "SELECT id, title, last_error,
|
||||
|
@ -279,7 +279,7 @@ class Pref_Feeds extends Handler_Protected {
|
|||
array_push($root['items'], $feed);
|
||||
}
|
||||
|
||||
$root['param'] = vsprintf(ngettext('(%d feed)', '(%d feeds)', count($cat['items'])), count($cat['items']));
|
||||
$root['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', count($cat['items'])), count($cat['items']));
|
||||
}
|
||||
|
||||
$fl = array();
|
||||
|
|
|
@ -954,59 +954,36 @@ class Pref_Filters extends Handler_Protected {
|
|||
private function getFilterName($id) {
|
||||
|
||||
$result = db_query($this->link,
|
||||
"SELECT title FROM ttrss_filters2 WHERE id = '$id'");
|
||||
"SELECT title,COUNT(DISTINCT r.id) AS num_rules,COUNT(DISTINCT a.id) AS num_actions
|
||||
FROM ttrss_filters2 AS f LEFT JOIN ttrss_filters2_rules AS r
|
||||
ON (r.filter_id = f.id)
|
||||
LEFT JOIN ttrss_filters2_actions AS a
|
||||
ON (a.filter_id = f.id) WHERE f.id = '$id' GROUP BY f.title");
|
||||
|
||||
$title = db_fetch_result($result, 0, "title");
|
||||
$num_rules = db_fetch_result($result, 0, "num_rules");
|
||||
$num_actions = db_fetch_result($result, 0, "num_actions");
|
||||
|
||||
if (!$title) {
|
||||
if (!$title) $title = __("[No caption]");
|
||||
|
||||
$title = sprintf(_ngettext("%s (%d rule)", "%s (%d rules)", $num_rules), $title, $num_rules);
|
||||
|
||||
$result = db_query($this->link,
|
||||
"SELECT * FROM ttrss_filters2_rules WHERE filter_id = '$id' ORDER BY id
|
||||
LIMIT 3");
|
||||
"SELECT * FROM ttrss_filters2_actions WHERE filter_id = '$id' ORDER BY id LIMIT 1");
|
||||
|
||||
$titles = array();
|
||||
$count = 0;
|
||||
$actions = "";
|
||||
|
||||
while ($line = db_fetch_assoc($result)) {
|
||||
if (db_num_rows($result) > 0) {
|
||||
$line = db_fetch_assoc($result);
|
||||
$actions = $this->getActionName($line);
|
||||
|
||||
if (sql_bool_to_bool($line["cat_filter"])) {
|
||||
unset($line["cat_filter"]);
|
||||
$line["feed_id"] = "CAT:" . (int)$line["cat_id"];
|
||||
unset($line["cat_id"]);
|
||||
$num_actions -= 1;
|
||||
}
|
||||
|
||||
if (!sql_bool_to_bool($line["inverse"])) unset($line["inverse"]);
|
||||
if ($num_actions > 0)
|
||||
$actions = sprintf(_ngettext("%s (+%d action)", "%s (+%d actions)", $num_actions), $actions, $num_actions);
|
||||
|
||||
if ($count < 2) {
|
||||
array_push($titles, $this->getRuleName($line));
|
||||
} else {
|
||||
array_push($titles, "...");
|
||||
break;
|
||||
}
|
||||
++$count;
|
||||
}
|
||||
|
||||
$title = __("[No caption]") . " " . truncate_string(join(", ", $titles), 64, "...");
|
||||
|
||||
}
|
||||
|
||||
$result = db_query($this->link,
|
||||
"SELECT * FROM ttrss_filters2_actions WHERE filter_id = '$id' ORDER BY id LIMIT 3");
|
||||
|
||||
$actions = array();
|
||||
$count = 0;
|
||||
|
||||
while ($line = db_fetch_assoc($result)) {
|
||||
if ($count < 2) {
|
||||
array_push($actions, $this->getActionName($line));
|
||||
} else {
|
||||
array_push($actions, "...");
|
||||
break;
|
||||
}
|
||||
++$count;
|
||||
}
|
||||
|
||||
return array($title, join(", ", $actions));
|
||||
return array($title, $actions);
|
||||
}
|
||||
|
||||
function join() {
|
||||
|
|
Loading…
Reference in New Issue