From 308c55c0f1671525c804291bad7d0d853e0eb998 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 17 Jun 2015 21:40:44 +0300 Subject: [PATCH] bayes: better prefs ui/stats --- plugins/af_sort_bayes/init.js | 17 +++++++++++++++++ plugins/af_sort_bayes/init.php | 35 ++++++++++++++++++++++++++++------ 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/plugins/af_sort_bayes/init.js b/plugins/af_sort_bayes/init.js index e6523bc4f..8043ee277 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 f0a910092..7e34ceac4 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 "
"; }