Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.0.0

Request #12417 Adding weighted limitation of elements
Submitted: 2007-11-10 19:00 UTC
From: bastianonken Assigned: bastianonken
Status: Closed Package: HTML_TagCloud (version 0.1.1)
PHP Version: Irrelevant OS: Irrelevant
Roadmaps: 0.1.3    
Subscription  


 [2007-11-10 19:00 UTC] bastianonken (Bastian Onken)
Description: ------------ At the moment a limitation of returned elements just cuts the stored values alphabetically, regardless of the weight of an element. This has been changed by the attached patch. The modified class returns a slightly different element set (see expected result). Instead of cutting the list of elements just after the n-th item, the new version considers the weight of each element before it cuts down the size (more weight comes first, items with less counts are getting cut). For the future version of the class, it would also be great to add a few configurable properties to set up the behaviour of the limitation of elements at constructor time or by extending the class members. Test script: --------------- $tags = new newHTML_TagCloud(); // add Element $tags->addElement('PHP(39)','http://www.php.net', 39, strtotime('-1 day')); $tags->addElement('XML(21)','http://www.xml.org', 21, strtotime('-2 week')); $tags->addElement('Perl(15)','http://www.xml.org', 15, strtotime('-1 month')); $tags->addElement('PEAR(32)','http://pear.php.net', 32, time()); $tags->addElement('MySQL(10)','http://www.mysql.com', 10, strtotime('-2 day')); $tags->addElement('PostgreSQL(6)','http://pgsql.com', 6, strtotime('-3 week')); // output HTML and CSS print $tags->buildAll(array('limit' => 3)); Expected result: ---------------- <a href="http://pear.php.net" style="font-size:26.4367649245px;" class="latest">PEAR(32)</a> <a href="http://www.php.net" style="font-size:26.4367649245px;" class="latest">PHP(39)</a> <a href="http://www.xml.org" style="font-size:12px;" class="earliest">XML(21)</a> Actual result: -------------- <a href="http://www.mysql.com" style="font-size:12px;" class="earliest">MySQL(10)</a> <a href="http://pear.php.net" style="font-size:27.570663159px;" class="latest">PEAR(32)</a> <a href="http://www.php.net" style="font-size:35.3559947385px;" class="earlier">PHP(39)</a>

Comments

 [2008-03-10 10:08 UTC] bastianonken (Bastian Onken)
Thank you for your bug report. This issue has been fixed in the latest released version of the package, which you can download at http://pear.php.net/get/HTML_TagCloud