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_Review_Block_Customer_View extends Mage_Catalog_Block_Product_Abstract
00036 {
00037 public function __construct()
00038 {
00039 parent::__construct();
00040 $this->setTemplate('review/customer/view.phtml');
00041
00042 $this->setReviewId($this->getRequest()->getParam('id', false));
00043 }
00044
00045 public function getProductData()
00046 {
00047 if( $this->getReviewId() && !$this->getProductCacheData() ) {
00048 $product = Mage::getModel('catalog/product')
00049 ->setStoreId(Mage::app()->getStore()->getId())
00050 ->load($this->getReviewData()->getEntityPkValue());
00051 $this->setProductCacheData($product);
00052 }
00053 return $this->getProductCacheData();
00054 }
00055
00056 public function getReviewData()
00057 {
00058 if( $this->getReviewId() && !$this->getReviewCachedData() ) {
00059 $this->setReviewCachedData(Mage::getModel('review/review')->load($this->getReviewId()));
00060 }
00061 return $this->getReviewCachedData();
00062 }
00063
00064 public function getBackUrl()
00065 {
00066 return Mage::getUrl('review/customer');
00067 }
00068
00069 public function getRating()
00070 {
00071 if( !$this->getRatingCollection() ) {
00072 $ratingCollection = Mage::getModel('rating/rating_option_vote')
00073 ->getResourceCollection()
00074 ->setReviewFilter($this->getReviewId())
00075 ->addRatingInfo(Mage::app()->getStore()->getId())
00076 ->setStoreFilter(Mage::app()->getStore()->getId())
00077 ->load();
00078
00079 $this->setRatingCollection( ( $ratingCollection->getSize() ) ? $ratingCollection : false );
00080 }
00081
00082 return $this->getRatingCollection();
00083 }
00084
00085 public function getRatingSummary()
00086 {
00087 if( !$this->getRatingSummaryCache() ) {
00088 $this->setRatingSummaryCache(Mage::getModel('rating/rating')->getEntitySummary($this->getProductData()->getId()));
00089 }
00090 return $this->getRatingSummaryCache();
00091 }
00092
00093 public function getTotalReviews()
00094 {
00095 if( !$this->getTotalReviewsCache() ) {
00096 $this->setTotalReviewsCache(Mage::getModel('review/review')->getTotalReviews($this->getProductData()->getId()), false, Mage::app()->getStore()->getId());
00097 }
00098 return $this->getTotalReviewsCache();
00099 }
00100
00101 public function dateFormat($date)
00102 {
00103 return $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_LONG);
00104 }
00105 }