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_Customer_Tags extends Mage_Customer_Block_Account_Dashboard
00036 {
00037 protected $_tags;
00038 protected $_minPopularity;
00039 protected $_maxPopularity;
00040
00041 protected function _loadTags()
00042 {
00043 if (empty($this->_tags)) {
00044 $this->_tags = array();
00045
00046 $tags = Mage::getResourceModel('tag/tag_collection')
00047 ->addPopularity()
00048 ->setOrder('popularity', 'DESC')
00049 #->addStatusFilter(Mage_Tag_Model_Tag::STATUS_APPROVED)
00050 ->addCustomerFilter(Mage::getSingleton('customer/session')->getCustomerId())
00051 ->setActiveFilter()
00052 ->load()
00053 ->getItems();
00054 } else {
00055 return;
00056 }
00057
00058 if( isset($tags) && count($tags) == 0 ) {
00059 return;
00060 }
00061
00062 $this->_maxPopularity = reset($tags)->getPopularity();
00063 $this->_minPopularity = end($tags)->getPopularity();
00064 $range = $this->_maxPopularity - $this->_minPopularity;
00065 $range = ( $range == 0 ) ? 1 : $range;
00066
00067 foreach ($tags as $tag) {
00068 $tag->setRatio(($tag->getPopularity()-$this->_minPopularity)/$range);
00069 $this->_tags[$tag->getName()] = $tag;
00070 }
00071 ksort($this->_tags);
00072 }
00073
00074 public function getTags()
00075 {
00076 $this->_loadTags();
00077 return $this->_tags;
00078 }
00079
00080 public function getMaxPopularity()
00081 {
00082 return $this->_maxPopularity;
00083 }
00084
00085 public function getMinPopularity()
00086 {
00087 return $this->_minPopularity;
00088 }
00089 }