From: Andrew Dolgov Date: Wed, 17 Jun 2015 18:40:44 +0000 (+0300) Subject: bayes: better prefs ui/stats X-Git-Tag: 16.3~293 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=308c55c0f1671525c804291bad7d0d853e0eb998;p=tt-rss.git bayes: better prefs ui/stats --- diff --git a/plugins/af_sort_bayes/init.js b/plugins/af_sort_bayes/init.js index e6523bc4..8043ee27 100644 --- a/plugins/af_sort_bayes/init.js +++ b/plugins/af_sort_bayes/init.js @@ -26,6 +26,7 @@ function bayesClearDatabase() { parameters: query, onComplete: function (transport) { notify(transport.responseText); + bayesUpdateUI(); } }); } @@ -35,3 +36,19 @@ function bayesClearDatabase() { } } +function bayesUpdateUI() { + try { + + var query = "backend.php?op=pluginhandler&plugin=af_sort_bayes&method=renderPrefsUI"; + + new Ajax.Request("backend.php", { + parameters: query, + onComplete: function (transport) { + dijit.byId("af_sort_bayes_prefs").attr("content", transport.responseText); + } + }); + + } catch (e) { + exception_error("showTrgmRelated", e); + } +} diff --git a/plugins/af_sort_bayes/init.php b/plugins/af_sort_bayes/init.php index f0a91009..7e34ceac 100644 --- a/plugins/af_sort_bayes/init.php +++ b/plugins/af_sort_bayes/init.php @@ -201,18 +201,16 @@ class Af_Sort_Bayes extends Plugin { $this->dbh->query("COMMIT"); } - function hook_prefs_tab($args) { - if ($args != "prefPrefs") return; - - print "
"; - + function renderPrefsUI() { $result = $this->dbh->query("SELECT category, probability, word_count, (SELECT COUNT(id) FROM {$this->sql_prefix}_references WHERE category_id = {$this->sql_prefix}_categories.id) as doc_count FROM {$this->sql_prefix}_categories WHERE owner_uid = " . $_SESSION["uid"]); + print "

" . __("Statistics") . "

"; + print ""; - print ""; + print ""; while ($line = $this->dbh->fetch_assoc($result)) { print ""; @@ -226,10 +224,35 @@ class Af_Sort_Bayes extends Plugin { print "
CategoryProbabilityWord countArticle count
CategoryProbabilityWordsArticles
"; + print "

" . __("Last matched articles") . "

"; + + $result = $this->dbh->query("SELECT te.title, category, tf.title AS feed_title + FROM ttrss_entries AS te, ttrss_user_entries AS tu, ttrss_feeds AS tf, {$this->sql_prefix}_references AS tr, {$this->sql_prefix}_categories AS tc + WHERE tf.id = tu.feed_id AND tu.ref_id = te.id AND tc.id = tr.category_id AND tr.document_id = te.guid ORDER BY te.id DESC LIMIT 20"); + + print ""; + + print " "; + print " "; // + } + + function hook_prefs_tab($args) { + if ($args != "prefPrefs") return; + + print "
"; + + $this->renderPrefsUI(); print "
"; }