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_Form extends Mage_Core_Block_Template
00035 {
00036 public function __construct()
00037 {
00038 parent::__construct();
00039
00040 $data = Mage::getSingleton('review/session')->getFormData(true);
00041 $data = new Varien_Object($data);
00042
00043
00044 if (!$data->getNickname()) {
00045 $customer = Mage::getSingleton('customer/session')->getCustomer();
00046 if ($customer && $customer->getId()) {
00047 $data->setNickname($customer->getFirstname());
00048 }
00049 }
00050
00051 $this->setTemplate('review/form.phtml')
00052 ->assign('data', $data)
00053 ->assign('messages', Mage::getSingleton('review/session')->getMessages(true));
00054 }
00055
00056 public function getProductInfo()
00057 {
00058 $product = Mage::getModel('catalog/product');
00059 return $product->load($this->getRequest()->getParam('id'));
00060 }
00061
00062 public function getAction()
00063 {
00064 $productId = Mage::app()->getRequest()->getParam('id', false);
00065 return Mage::getUrl('review/product/post', array('id' => $productId));
00066 }
00067
00068 public function getRatings()
00069 {
00070 $ratingCollection = Mage::getModel('rating/rating')
00071 ->getResourceCollection()
00072 ->addEntityFilter('product')
00073 ->setPositionOrder()
00074 ->addRatingPerStoreName(Mage::app()->getStore()->getId())
00075 ->setStoreFilter(Mage::app()->getStore()->getId())
00076 ->load()
00077 ->addOptionToItems();
00078 return $ratingCollection;
00079 }
00080 }