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_Adminhtml_Block_Review_Rating_Detailed extends Mage_Adminhtml_Block_Template
00036 {
00037 protected $_voteCollection = false;
00038 public function __construct()
00039 {
00040 parent::__construct();
00041 $this->setTemplate('rating/detailed.phtml');
00042 if( Mage::registry('review_data') ) {
00043 $this->setReviewId(Mage::registry('review_data')->getReviewId());
00044 }
00045 }
00046
00047 public function getRating()
00048 {
00049 if( !$this->getRatingCollection() ) {
00050 if( Mage::registry('review_data') ) {
00051 $stores = Mage::registry('review_data')->getStores();
00052
00053 $stores = array_diff($stores, array(0));
00054
00055 $ratingCollection = Mage::getModel('rating/rating')
00056 ->getResourceCollection()
00057 ->addEntityFilter('product')
00058 ->setStoreFilter($stores)
00059 ->setPositionOrder()
00060 ->load()
00061 ->addOptionToItems();
00062
00063 $this->_voteCollection = Mage::getModel('rating/rating_option_vote')
00064 ->getResourceCollection()
00065 ->setReviewFilter($this->getReviewId())
00066 ->addOptionInfo()
00067 ->load()
00068 ->addRatingOptions();
00069
00070 } elseif (!$this->getIsIndependentMode()) {
00071 $ratingCollection = Mage::getModel('rating/rating')
00072 ->getResourceCollection()
00073 ->addEntityFilter('product')
00074 ->setStoreFilter(null)
00075 ->setPositionOrder()
00076 ->load()
00077 ->addOptionToItems();
00078 } else {
00079 $ratingCollection = Mage::getModel('rating/rating')
00080 ->getResourceCollection()
00081 ->addEntityFilter('product')
00082 ->setStoreFilter($this->getRequest()->getParam('select_stores') ? $this->getRequest()->getParam('select_stores') : $this->getRequest()->getParam('stores'))
00083 ->setPositionOrder()
00084 ->load()
00085 ->addOptionToItems();
00086
00087
00088 }
00089 $this->setRatingCollection( ( $ratingCollection->getSize() ) ? $ratingCollection : false );
00090 }
00091 return $this->getRatingCollection();
00092 }
00093
00094 public function setIndependentMode()
00095 {
00096 $this->setIsIndependentMode(true);
00097 return $this;
00098 }
00099
00100 public function isSelected($option, $rating)
00101 {
00102 if($this->getIsIndependentMode()) {
00103 $ratings = $this->getRequest()->getParam('ratings');
00104
00105 if(isset($ratings[$option->getRatingId()])) {
00106 return $option->getId() == $ratings[$option->getRatingId()];
00107 }
00108
00109 return false;
00110 }
00111
00112 if($this->_voteCollection) {
00113 foreach($this->_voteCollection as $vote) {
00114 if($option->getId() == $vote->getOptionId()) {
00115 return true;
00116 }
00117 }
00118 }
00119
00120 return false;
00121 }
00122 }