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