From 0979b696e4d770f5461057f406dfe8a8f3d3d48c Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 17 May 2007 12:58:38 +0100 Subject: [PATCH] show tag cloud instead of flat tag list --- feedlist.js | 2 ++ functions.php | 48 ++++++++++++++++++++++++++++++++++++++++ modules/popup-dialog.php | 24 ++++++++++++++++++++ tt-rss.css | 10 +++++++++ tt-rss.js | 23 ++++++++++++------- tt-rss.php | 2 +- 6 files changed, 100 insertions(+), 9 deletions(-) diff --git a/feedlist.js b/feedlist.js index 740020e63..9bfd9a235 100644 --- a/feedlist.js +++ b/feedlist.js @@ -46,6 +46,8 @@ function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) { enableHotkeys(); + closeInfoBox(); + /* if (!skip_history) { history_push('FEED:' + feed + ':' + subop + ':' + is_cat + ':' + subop_param); diff --git a/functions.php b/functions.php index 17712ebce..0bcbc5e47 100644 --- a/functions.php +++ b/functions.php @@ -3852,4 +3852,52 @@ return $topmost_article_ids; } + +// from here: http://www.roscripts.com/Create_tag_cloud-71.html + + function printTagCloud($link) { + + $query = "SELECT tag_name, COUNT(post_int_id) AS count + FROM ttrss_tags WHERE owner_uid = ".$_SESSION["uid"]." + GROUP BY tag_name ORDER BY count DESC LIMIT 50"; + + $result = db_query($link, $query); + + $tags = array(); + + while ($line = db_fetch_assoc($result)) { + $tags[$line["tag_name"]] = $line["count"]; + } + + ksort($tags); + + $max_size = 32; // max font size in pixels + $min_size = 9; // min font size in pixels + + // largest and smallest array values + $max_qty = max(array_values($tags)); + $min_qty = min(array_values($tags)); + + // find the range of values + $spread = $max_qty - $min_qty; + if ($spread == 0) { // we don't want to divide by zero + $spread = 1; + } + + // set the font-size increment + $step = ($max_size - $min_size) / ($spread); + + // loop through the tag array + foreach ($tags as $key => $value) { + // calculate font-size + // find the $value in excess of $min_qty + // multiply by the font-size increment ($size) + // and add the $min_size set above + $size = round($min_size + (($value - $min_qty) * $step)); + + echo "' . $key . ' '; + } + } ?> diff --git a/modules/popup-dialog.php b/modules/popup-dialog.php index 0403b6231..3011f8c1b 100644 --- a/modules/popup-dialog.php +++ b/modules/popup-dialog.php @@ -412,6 +412,30 @@ return; } + if ($id == "printTagCloud") { + print "
".__('Tag Cloud')."
"; + print "
"; + + print "Showing top 50 most popular tags (show all):
"; + + print "
"; + + printTagCloud($link); + + print "
"; + + print "
"; + print ""; + print "
"; + + print "
"; + + return; + } + print "
Internal Error

Unknown dialog $id

diff --git a/tt-rss.css b/tt-rss.css index 69f191cda..47152d2b6 100644 --- a/tt-rss.css +++ b/tt-rss.css @@ -921,6 +921,16 @@ span.groupPrompt { color : #4684ff; } +div.tagCloudContainer { +/* height : 300px; + overflow : auto; */ + border : 1px solid #99d67a; + background-color : white; + margin : 5px 0px 5px 0px; + padding : 10px; + text-align : center; +} + ul.feedErrorsList { height : 300px; overflow : auto; diff --git a/tt-rss.js b/tt-rss.js index 861c9abb8..56351332e 100644 --- a/tt-rss.js +++ b/tt-rss.js @@ -27,20 +27,26 @@ function tagsAreDisplayed() { return display_tags; } -function toggleTags() { - display_tags = !display_tags; +function toggleTags(show_all) { var p = document.getElementById("dispSwitchPrompt"); - if (display_tags) { + if (!show_all && !display_tags) { + displayDlg("printTagCloud"); + } else if (show_all) { + closeInfoBox(); + display_tags = true; p.innerHTML = __("display feeds"); - } else { - p.innerHTML = __("display tags"); + notify_progress("Loading, please wait..."); + updateFeedList(); + } else if (display_tags) { + display_tags = false; + p.innerHTML = __("tag cloud"); + notify_progress("Loading, please wait..."); + updateFeedList(); } - - notify_progress("Loading, please wait..."); - updateFeedList(); + return false; } function dlg_frefresh_callback() { @@ -514,6 +520,7 @@ function quickMenuGo(opid) { if (opid == "qmcAddFilter") { displayDlg("quickAddFilter", getActiveFeedId()); } + } catch (e) { exception_error("quickMenuGo", e); } diff --git a/tt-rss.php b/tt-rss.php index 6ab331611..968f9cfeb 100644 --- a/tt-rss.php +++ b/tt-rss.php @@ -122,7 +122,7 @@ window.onload = init;
+ href="javascript:toggleTags()">