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 class Mage_Review_Block_Helper extends Mage_Core_Block_Template
00035 {
00036 private $_availableTemplates = array(
00037 'default' => 'review/helper/summary.phtml',
00038 'short' => 'review/helper/summary_short.phtml'
00039 );
00040
00041 public function getSummaryHtml($product, $templateType, $displayIfNoReviews)
00042 {
00043
00044 if (empty($this->_availableTemplates[$templateType])) {
00045 $templateType = 'default';
00046 }
00047 $this->setTemplate($this->_availableTemplates[$templateType]);
00048
00049 $this->setDisplayIfEmpty($displayIfNoReviews);
00050
00051 if (!$product->getRatingSummary()) {
00052 Mage::getModel('review/review')
00053 ->getEntitySummary($product, Mage::app()->getStore()->getId());
00054 }
00055 $this->setProduct($product);
00056
00057 return $this->toHtml();
00058 }
00059
00060 public function getRatingSummary()
00061 {
00062 return $this->getProduct()->getRatingSummary()->getRatingSummary();
00063 }
00064
00065 public function getReviewsCount()
00066 {
00067 return $this->getProduct()->getRatingSummary()->getReviewsCount();
00068 }
00069
00070 public function getReviewsUrl()
00071 {
00072 return Mage::getUrl('review/product/list', array(
00073 'id' => $this->getProduct()->getId(),
00074 'category' => $this->getProduct()->getCategoryId()
00075 ));
00076 }
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086 public function addTemplate($type, $template)
00087 {
00088 $this->_availableTemplates[$type] = $template;
00089 }
00090 }