ZF-6578: Zend_Tag: Bug in Zend_Tag_Cloud_Decorator_HtmlTag->setClassList()

Issue Type: Bug Created: 2009-05-08T09:12:57.000+0000 Last Updated: 2009-05-08T11:50:46.000+0000 Status: Resolved Fix version(s): - 1.8.1 (12/May/09)

Reporter: Canio Sileo (codeswitch) Assignee: Ben Scholzen (dasprid) Tags: - Zend_Tag

Related issues: Attachments:


When using Zend_Tag_Cloud_Decorator_HtmlTag->setClassList(), instead of assigning the className, I'm getting the weightValue of a Zend_Tag_Item.

I have this code in my viewscript:

// Create the item list $list = new Zend_Tag_ItemList();

// Assign tags to it $list[] = new Zend_Tag_Item(array('title' => 'Code', 'weight' => 50, 'params' => array('url' => WEBHOST))); $list[] = new Zend_Tag_Item(array('title' => 'Zend Framework', 'weight' => 1)); $list[] = new Zend_Tag_Item(array('title' => 'PHP', 'weight' => 5));

// Spread absolute values on the items $list->spreadWeightValues(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));

$cloud = new Zend_Tag_Cloud(); $cloud->setItemList($list); // Cloud-Decorator $cloudDecorator = new Zend_Tag_Cloud_Decorator_HtmlCloud(); $cloudDecorator->setHtmlTags(array('div' => array('class' => 'tagcloud'))); $cloud->setCloudDecorator($cloudDecorator); // Tag-Decorator $tagDecorator = new Zend_Tag_Cloud_Decorator_HtmlTag(); $tagDecorator->setHtmlTags(array()); $tagDecorator->setMaxFontSize(26); $tagDecorator->setMinFontSize(10); $tagDecorator->setFontSizeUnit('px'); $tagDecorator->setClassList(array('text-color-theme')); $cloud->setTagDecorator($tagDecorator);

By using $tagDecorator->setClassList(array('text-color-theme')); I get this html-code:

Code Zend Framework PHP

As you see, the second a-tag is correct, but the other two have numbers as classNames.

I tracked it down to Zend\Tag\Cloud\Decorator\HtmlTag.php in Line 251, where the className should be assigned, not the weightValue.

Here is a var_dump of one tag-item:

object(Zend_Tag_Item)[434] protected '_title' => string 'Code' (length=4) protected '_weight' => float 50 protected '_params' => array 'url' => string 'http://localhost/testpage' (length=27) 'weightValue' => int 10 protected '_skipOptions' => array 0 => string 'options' (length=7) 1 => string 'param' (length=5)


Posted by Ben Scholzen (dasprid) on 2009-05-08T09:37:54.000+0000

This is actually no bug of the decorator but of Zend_Tag_ItemList. I currently generates a "division by zero"-warning when just a single value is supplied. By the way:

a) you don't have to spread weight values yourself when using a standard decorator b) When you set font-size settings first and then a class list, the font size settings are overriden.

Posted by Canio Sileo (codeswitch) on 2009-05-08T10:33:05.000+0000

Thanks for the fix.

But isn't what you wrote to b) in your comment another bug?

I know that font-size settings are overwritten by setClassList(), but exactly the same happens vice versa. That means, I can either set font-size settings without being able to set classes (example 1), or I can use classes overwriting my font-size settings (example 2). :(

example 1 $tagDecorator->setClassList(array('text-color-theme')); $tagDecorator->setMaxFontSize(26); $tagDecorator->setMinFontSize(10); $tagDecorator->setFontSizeUnit('px');

example 2 $tagDecorator->setMaxFontSize(26); $tagDecorator->setMinFontSize(10); $tagDecorator->setFontSizeUnit('px'); $tagDecorator->setClassList(array('text-color-theme'));

Or did I miss something?

Posted by Ben Scholzen (dasprid) on 2009-05-08T11:50:44.000+0000

Yes, you are missing the fact, that it is about spreading either font-sizes or css-classes for the relative values ;)

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.