diff options
Diffstat (limited to 'classes/pref')
| -rwxr-xr-x | classes/pref/feeds.php | 51 | ||||
| -rwxr-xr-x | classes/pref/filters.php | 12 | ||||
| -rw-r--r-- | classes/pref/prefs.php | 33 | ||||
| -rw-r--r-- | classes/pref/system.php | 88 |
4 files changed, 137 insertions, 47 deletions
diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index 8b9099007..e1e88ddc0 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -74,7 +74,7 @@ class Pref_Feeds extends Handler_Protected { $cat['items'] = $this->get_category_items($line['id']); $num_children = $this->calculate_children_count($cat); - $cat['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', (int) $num_children), $num_children); + $cat['param'] = sprintf(_ngettext('(%d feed)', '(%d feeds)', (int) $num_children), $num_children); if ($num_children > 0 || $show_empty_cats) array_push($items, $cat); @@ -126,6 +126,7 @@ class Pref_Feeds extends Handler_Protected { $root['id'] = 'root'; $root['name'] = __('Feeds'); $root['items'] = array(); + $root['param'] = 0; $root['type'] = 'category'; $enable_cats = get_pref('ENABLE_FEED_CATS'); @@ -229,7 +230,7 @@ class Pref_Feeds extends Handler_Protected { $cat['items'] = $this->get_category_items($line['id']); $num_children = $this->calculate_children_count($cat); - $cat['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', (int) $num_children), $num_children); + $cat['param'] = sprintf(_ngettext('(%d feed)', '(%d feeds)', (int) $num_children), $num_children); if ($num_children > 0 || $show_empty_cats) array_push($root['items'], $cat); @@ -277,13 +278,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'] = sprintf(_ngettext('(%d feed)', '(%d feeds)', count($cat['items'])), count($cat['items'])); if (count($cat['items']) > 0 || $show_empty_cats) array_push($root['items'], $cat); $num_children = $this->calculate_children_count($root); - $root['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', (int) $num_children), $num_children); + $root['param'] = sprintf(_ngettext('(%d feed)', '(%d feeds)', (int) $num_children), $num_children); } else { $fsth = $this->pdo->prepare("SELECT id, title, last_error, @@ -312,7 +313,7 @@ class Pref_Feeds extends Handler_Protected { array_push($root['items'], $feed); } - $root['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', count($root['items'])), count($root['items'])); + $root['param'] = sprintf(_ngettext('(%d feed)', '(%d feeds)', count($root['items'])), count($root['items'])); } $fl = array(); @@ -509,7 +510,6 @@ class Pref_Feeds extends Handler_Protected { global $purge_intervals; global $update_intervals; - $feed_id = clean($_REQUEST["id"]); $sth = $this->pdo->prepare("SELECT * FROM ttrss_feeds WHERE id = ? AND @@ -620,7 +620,10 @@ class Pref_Feeds extends Handler_Protected { print "<label>".__("Interval:")."</label> "; - print_select_hash("update_interval", $update_interval, $update_intervals, + $local_update_intervals = $update_intervals; + $local_update_intervals[0] .= sprintf(" (%s)", $update_intervals[get_pref("DEFAULT_UPDATE_INTERVAL")]); + + print_select_hash("update_interval", $update_interval, $local_update_intervals, 'dojoType="fox.form.Select"'); print "</fieldset>"; @@ -633,7 +636,21 @@ class Pref_Feeds extends Handler_Protected { print "<label>" . __('Article purging:') . "</label> "; - print_select_hash("purge_interval", $purge_interval, $purge_intervals, + if (FORCE_ARTICLE_PURGE == 0) { + $local_purge_intervals = $purge_intervals; + $default_purge_interval = get_pref("PURGE_OLD_DAYS"); + + if ($default_purge_interval > 0) + $local_purge_intervals[0] .= " " . T_nsprintf('(%d day)', '(%d days)', $default_purge_interval, $default_purge_interval); + else + $local_purge_intervals[0] .= " " . sprintf("(%s)", __("Disabled")); + + } else { + $purge_interval = FORCE_ARTICLE_PURGE; + $local_purge_intervals = [ T_nsprintf('%d day', '%d days', $purge_interval, $purge_interval) ]; + } + + print_select_hash("purge_interval", $purge_interval, $local_purge_intervals, 'dojoType="fox.form.Select" ' . ((FORCE_ARTICLE_PURGE == 0) ? "" : 'disabled="1"')); @@ -859,7 +876,10 @@ class Pref_Feeds extends Handler_Protected { print "<label>".__("Interval:")."</label> "; - print_select_hash("update_interval", "", $update_intervals, + $local_update_intervals = $update_intervals; + $local_update_intervals[0] .= sprintf(" (%s)", $update_intervals[get_pref("DEFAULT_UPDATE_INTERVAL")]); + + print_select_hash("update_interval", "", $local_update_intervals, 'disabled="1" dojoType="fox.form.Select"'); $this->batch_edit_cbox("update_interval"); @@ -874,7 +894,15 @@ class Pref_Feeds extends Handler_Protected { print "<label>" . __('Article purging:') . "</label> "; - print_select_hash("purge_interval", "", $purge_intervals, + $local_purge_intervals = $purge_intervals; + $default_purge_interval = get_pref("PURGE_OLD_DAYS"); + + if ($default_purge_interval > 0) + $local_purge_intervals[0] .= " " . T_sprintf("(%d days)", $default_purge_interval); + else + $local_purge_intervals[0] .= " " . sprintf("(%s)", __("Disabled")); + + print_select_hash("purge_interval", "", $local_purge_intervals, 'disabled="1" dojoType="fox.form.Select"'); $this->batch_edit_cbox("purge_interval"); @@ -1187,10 +1215,11 @@ class Pref_Feeds extends Handler_Protected { } if ($num_errors > 0) { - $error_button = "<button dojoType=\"dijit.form.Button\" onclick=\"CommonDialogs.showFeedsWithErrors()\" id=\"errorButton\">" . __("Feeds with errors") . "</button>"; + } else { + $error_button = ""; } $inactive_button = "<button dojoType=\"dijit.form.Button\" diff --git a/classes/pref/filters.php b/classes/pref/filters.php index 1113f251e..70b7d0326 100755 --- a/classes/pref/filters.php +++ b/classes/pref/filters.php @@ -552,7 +552,7 @@ class Pref_Filters extends Handler_Protected { return "<span class='filterRule $inverse'>" . T_sprintf("%s on %s in %s %s", htmlspecialchars($rule["reg_exp"]), - $filter_type, $feed, isset($rule["inverse"]) ? __("(inverse)") : "") . "</span>"; + "<span class='field'>$filter_type</span>", "<span class='feed'>$feed</span>", isset($rule["inverse"]) ? __("(inverse)") : "") . "</span>"; } function printRuleName() { @@ -736,10 +736,8 @@ class Pref_Filters extends Handler_Protected { } function index() { - - $filter_search = clean($_REQUEST["search"]); - if (array_key_exists("search", $_REQUEST)) { + $filter_search = clean($_REQUEST["search"]); $_SESSION["prefs_filter_search"] = $filter_search; } else { $filter_search = $_SESSION["prefs_filter_search"]; @@ -749,12 +747,6 @@ class Pref_Filters extends Handler_Protected { print "<div style='padding : 0px' dojoType='dijit.layout.ContentPane' region='top'>"; print "<div dojoType='fox.Toolbar'>"; - if (array_key_exists("search", $_REQUEST)) { - $_SESSION["prefs_filter_search"] = $filter_search; - } else { - $filter_search = $_SESSION["prefs_filter_search"]; - } - print "<div style='float : right; padding-right : 4px;'> <input dojoType=\"dijit.form.TextBox\" id=\"filter_search\" size=\"20\" type=\"search\" value=\"$filter_search\"> diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index d7b486cbb..bce3c171b 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -66,9 +66,13 @@ class Pref_Prefs extends Handler_Protected { ] ]; + $this->pref_help_bottom = [ + "BLACKLISTED_TAGS" => __("Never apply these tags automatically (comma-separated list)."), + ]; + $this->pref_help = [ "ALLOW_DUPLICATE_POSTS" => array(__("Allow duplicate articles"), ""), - "BLACKLISTED_TAGS" => array(__("Blacklisted tags"), __("Never apply these tags automatically (comma-separated list).")), + "BLACKLISTED_TAGS" => array(__("Blacklisted tags"), ""), "DEFAULT_SEARCH_LANGUAGE" => array(__("Default language"), __("Used for full-text search")), "CDM_AUTO_CATCHUP" => array(__("Mark read on scroll"), __("Mark articles as read as you scroll past them")), "CDM_EXPANDED" => array(__("Always expand articles")), @@ -192,6 +196,12 @@ class Pref_Prefs extends Handler_Protected { case 'USER_CSS_THEME': if (!$need_reload) $need_reload = get_pref($pref_name) != $value; break; + + case 'BLACKLISTED_TAGS': + $cats = FeedItem_Common::normalize_categories(explode(",", $value)); + asort($cats); + $value = implode(", ", $cats); + break; } set_pref($pref_name, $value); @@ -671,6 +681,19 @@ class Pref_Prefs extends Handler_Protected { $timezones = explode("\n", file_get_contents("lib/timezones.txt")); print_select($pref_name, $value, $timezones, 'dojoType="dijit.form.FilteringSelect"'); + + } else if ($pref_name == "BLACKLISTED_TAGS") { # TODO: other possible <textarea> prefs go here + + print "<div>"; + + print "<textarea dojoType='dijit.form.SimpleTextarea' rows='4' + style='width: 500px; font-size : 12px;' + name='$pref_name'>$value</textarea><br/>"; + + print "<div class='help-text-bottom text-muted'>" . $this->pref_help_bottom[$pref_name] . "</div>"; + + print "</div>"; + } else if ($pref_name == "USER_CSS_THEME") { $themes = array_merge(glob("themes/*.php"), glob("themes/*.css"), glob("themes.local/*.css")); @@ -725,8 +748,8 @@ class Pref_Prefs extends Handler_Protected { print "<input type='checkbox' name='$pref_name' $checked $disabled dojoType='dijit.form.CheckBox' id='CB_$pref_name' value='1'>"; - } else if (array_search($pref_name, array('FRESH_ARTICLE_MAX_AGE', - 'PURGE_OLD_DAYS', 'LONG_DATE_FORMAT', 'SHORT_DATE_FORMAT')) !== false) { + } else if (in_array($pref_name, ['FRESH_ARTICLE_MAX_AGE', + 'PURGE_OLD_DAYS', 'LONG_DATE_FORMAT', 'SHORT_DATE_FORMAT'])) { $regexp = ($type_name == 'integer') ? 'regexp="^\d*$"' : ''; @@ -1271,14 +1294,14 @@ class Pref_Prefs extends Handler_Protected { } private function getShortDesc($pref_name) { - if (isset($this->pref_help[$pref_name])) { + if (isset($this->pref_help[$pref_name][0])) { return $this->pref_help[$pref_name][0]; } return ""; } private function getHelpText($pref_name) { - if (isset($this->pref_help[$pref_name])) { + if (isset($this->pref_help[$pref_name][1])) { return $this->pref_help[$pref_name][1]; } return ""; diff --git a/classes/pref/system.php b/classes/pref/system.php index 7e9aa44a1..89052c6e3 100644 --- a/classes/pref/system.php +++ b/classes/pref/system.php @@ -25,27 +25,43 @@ class Pref_System extends Handler_Protected { function index() { - print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">"; - print "<div dojoType=\"dijit.layout.AccordionPane\" - title=\"<i class='material-icons'>report</i> ".__('Event Log')."\">"; + $severity = isset($_REQUEST["severity"]) ? (int) clean($_REQUEST["severity"]) : E_USER_WARNING; + + print "<div dojoType='dijit.layout.AccordionContainer' region='center'>"; + print "<div dojoType='dijit.layout.AccordionPane' style='padding : 0' + title='<i class=\"material-icons\">report</i> ".__('Event Log')."'>"; if (LOG_DESTINATION == "sql") { - $res = $this->pdo->query("SELECT errno, errstr, filename, lineno, - created_at, login, context FROM ttrss_error_log - LEFT JOIN ttrss_users ON (owner_uid = ttrss_users.id) - ORDER BY ttrss_error_log.id DESC - LIMIT 100"); + print "<div dojoType='dijit.layout.BorderContainer' gutters='false'>"; + + print "<div region='top' dojoType='fox.Toolbar'>"; + + print "<button dojoType='dijit.form.Button' + onclick='Helpers.updateEventLog()'>".__('Refresh')."</button>"; + + print "<button dojoType='dijit.form.Button' + onclick='Helpers.clearEventLog()'>".__('Clear')."</button>"; - print "<button dojoType=\"dijit.form.Button\" - onclick=\"Helpers.updateEventLog()\">".__('Refresh')."</button> "; + print "<div class='pull-right'>"; - print " <button dojoType=\"dijit.form.Button\" - class=\"alt-danger\" onclick=\"Helpers.clearEventLog()\">".__('Clear')."</button> "; + print __("Severity:") . " "; + print_select_hash("severity", $severity, + [ + E_USER_ERROR => __("Errors"), + E_USER_WARNING => __("Warnings"), + E_USER_NOTICE => __("Everything") + ], 'dojoType="fox.form.Select" onchange="Helpers.updateEventLog()"'); - print "<p><table width=\"100%\" cellspacing=\"10\" class=\"prefErrorLog\">"; + print "</div>"; # pull-right - print "<tr class=\"title\"> + print "</div>"; # toolbar + + print '<div style="padding : 0px" dojoType="dijit.layout.ContentPane" region="center">'; + + print "<table width='100%' cellspacing='10' class='prefErrorLog'>"; + + print "<tr class='title'> <td width='5%'>".__("Error")."</td> <td>".__("Filename")."</td> <td>".__("Message")."</td> @@ -53,7 +69,37 @@ class Pref_System extends Handler_Protected { <td width='5%'>".__("Date")."</td> </tr>"; - while ($line = $res->fetch()) { + $errno_values = []; + + switch ($severity) { + case E_USER_ERROR: + $errno_values = [ E_ERROR, E_USER_ERROR, E_PARSE ]; + break; + case E_USER_WARNING: + $errno_values = [ E_ERROR, E_USER_ERROR, E_PARSE, E_WARNING, E_USER_WARNING, E_DEPRECATED, E_USER_DEPRECATED ]; + break; + } + + if (count($errno_values) > 0) { + $errno_qmarks = arr_qmarks($errno_values); + $errno_filter_qpart = "errno IN ($errno_qmarks)"; + } else { + $errno_filter_qpart = "true"; + } + + $sth = $this->pdo->prepare("SELECT + errno, errstr, filename, lineno, created_at, login, context + FROM + ttrss_error_log LEFT JOIN ttrss_users ON (owner_uid = ttrss_users.id) + WHERE + $errno_filter_qpart + ORDER BY + ttrss_error_log.id DESC + LIMIT 100"); + + $sth->execute($errno_values); + + while ($line = $sth->fetch()) { print "<tr>"; foreach ($line as $k => $v) { @@ -73,15 +119,15 @@ class Pref_System extends Handler_Protected { print "</table>"; } else { - print_notice("Please set LOG_DESTINATION to 'sql' in config.php to enable database logging."); - } - print "</div>"; + print "</div>"; # content pane + print "</div>"; # container + print "</div>"; # accordion pane - print "<div dojoType=\"dijit.layout.AccordionPane\" - title=\"<i class='material-icons'>info</i> ".__('PHP Information')."\">"; + print "<div dojoType='dijit.layout.AccordionPane' + title='<i class=\"material-icons\">info</i> ".__('PHP Information')."'>"; ob_start(); phpinfo(); @@ -92,7 +138,7 @@ class Pref_System extends Handler_Protected { print preg_replace( '%^.*<body>(.*)</body>.*$%ms','$1', $info); print "</div>"; - print "</div>"; + print "</div>"; # accordion pane PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, "hook_prefs_tab", "prefSystem"); |