00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class Mage_Tag_Block_All extends Mage_Core_Block_Template
00036 {
00037
00038 protected $_tags;
00039 protected $_minPopularity;
00040 protected $_maxPopularity;
00041
00042 protected function _loadTags()
00043 {
00044 if (empty($this->_tags)) {
00045 $this->_tags = array();
00046 $tags = Mage::getModel('tag/tag')->getPopularCollection()
00047 ->joinFields(Mage::app()->getStore()->getId())
00048 ->limit(100)
00049 ->load()
00050 ->getItems();
00051
00052 if( count($tags) == 0 ) {
00053 return $this;
00054 }
00055
00056 $this->_maxPopularity = reset($tags)->getPopularity();
00057 $this->_minPopularity = end($tags)->getPopularity();
00058 $range = $this->_maxPopularity - $this->_minPopularity;
00059 $range = ( $range == 0 ) ? 1 : $range;
00060 foreach ($tags as $tag) {
00061 if( !$tag->getPopularity() ) {
00062 continue;
00063 }
00064 $tag->setRatio(($tag->getPopularity()-$this->_minPopularity)/$range);
00065 $this->_tags[$tag->getName()] = $tag;
00066 }
00067 ksort($this->_tags);
00068 }
00069 return $this;
00070 }
00071
00072 public function getTags()
00073 {
00074 $this->_loadTags();
00075 return $this->_tags;
00076 }
00077
00078 public function getMaxPopularity()
00079 {
00080 return $this->_maxPopularity;
00081 }
00082
00083 public function getMinPopularity()
00084 {
00085 return $this->_minPopularity;
00086 }
00087
00088 protected function _getHeadText()
00089 {
00090 return Mage::helper('tag')->__('All Tags');
00091 }
00092 }