Mage_Tag_Block_Popular Class Reference

Inheritance diagram for Mage_Tag_Block_Popular:

Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object

List of all members.

Public Member Functions

 getTags ()
 getMaxPopularity ()
 getMinPopularity ()

Protected Member Functions

 _loadTags ()
 _toHtml ()

Protected Attributes

 $_tags
 $_minPopularity
 $_maxPopularity


Detailed Description

Definition at line 35 of file Popular.php.


Member Function Documentation

_loadTags (  )  [protected]

Definition at line 42 of file Popular.php.

00043     {
00044         if (empty($this->_tags)) {
00045             $this->_tags = array();
00046 
00047             $tags = Mage::getModel('tag/tag')->getPopularCollection()
00048                 ->joinFields(Mage::app()->getStore()->getId())
00049                 ->limit(20)
00050                 ->load()
00051                 ->getItems();
00052 
00053             if( count($tags) == 0 ) {
00054                 return $this;
00055             }
00056 
00057 
00058             $this->_maxPopularity = reset($tags)->getPopularity();
00059             $this->_minPopularity = end($tags)->getPopularity();
00060             $range = $this->_maxPopularity - $this->_minPopularity;
00061             $range = ( $range == 0 ) ? 1 : $range;
00062             foreach ($tags as $tag) {
00063                 if( !$tag->getPopularity() ) {
00064                     continue;
00065                 }
00066                 $tag->setRatio(($tag->getPopularity()-$this->_minPopularity)/$range);
00067                 $this->_tags[$tag->getName()] = $tag;
00068             }
00069             ksort($this->_tags);
00070         }
00071         return $this;
00072     }

_toHtml (  )  [protected]

Render block HTML

Returns:
string

Reimplemented from Mage_Core_Block_Template.

Definition at line 90 of file Popular.php.

00091     {
00092         if (count($this->getTags()) > 0) {
00093             return parent::_toHtml();
00094         }
00095         return '';
00096     }

getMaxPopularity (  ) 

Definition at line 80 of file Popular.php.

00081     {
00082         return $this->_maxPopularity;
00083     }

getMinPopularity (  ) 

Definition at line 85 of file Popular.php.

00086     {
00087         return $this->_minPopularity;
00088     }

getTags (  ) 

Definition at line 74 of file Popular.php.

00075     {
00076         $this->_loadTags();
00077         return $this->_tags;
00078     }


Member Data Documentation

$_maxPopularity [protected]

Definition at line 40 of file Popular.php.

$_minPopularity [protected]

Definition at line 39 of file Popular.php.

$_tags [protected]

Definition at line 38 of file Popular.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:52 2009 for Magento by  doxygen 1.5.8