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_Rss_Block_Catalog_Review extends Mage_Rss_Block_Abstract
00035 {
00036 protected function _construct()
00037 {
00038
00039
00040
00041 $this->setCacheKey('rss_catalog_review');
00042 $this->setCacheLifetime(600);
00043 }
00044
00045 protected function _toHtml()
00046 {
00047 $newurl = Mage::getUrl('rss/catalog/review');
00048 $title = Mage::helper('rss')->__('Pending product review(s)');
00049
00050 $rssObj = Mage::getModel('rss/rss');
00051 $data = array('title' => $title,
00052 'description' => $title,
00053 'link' => $newurl,
00054 'charset' => 'UTF-8',
00055 );
00056 $rssObj->_addHeader($data);
00057
00058 $reviewModel = Mage::getModel('review/review');
00059
00060 $collection = $reviewModel->getProductCollection()
00061 ->addStatusFilter($reviewModel->getPendingStatus())
00062 ->addAttributeToSelect('name', 'inner')
00063 ->setDateOrder();
00064
00065 Mage::getSingleton('core/resource_iterator')
00066 ->walk($collection->getSelect(), array(array($this, 'addReviewItemXmlCallback')), array('rssObj'=> $rssObj, 'reviewModel'=> $reviewModel));
00067 return $rssObj->createRssXml();
00068 }
00069
00070 public function addReviewItemXmlCallback($args)
00071 {
00072 $rssObj = $args['rssObj'];
00073 $reviewModel = $args['reviewModel'];
00074 $row = $args['row'];
00075
00076 $productUrl = Mage::getUrl('catalog/product/view',array('id'=>$row['entity_id']));
00077 $reviewUrl = Mage::helper('adminhtml')->getUrl('adminhtml/catalog_product_review/edit/', array('id'=>$row['review_id'],'_secure' => true,'_nosecret' => true));
00078 $storeName = Mage::app()->getStore($row['store_id'])->getName();
00079
00080 $description = '<p>'.
00081 $this->__('Product: <a href="%s">%s</a> <br/>',$productUrl,$row['name']).
00082 $this->__('Summary of review: %s <br/>',$row['title']).
00083 $this->__('Review: %s <br/>', $row['detail']).
00084 $this->__('Store: %s <br/>', $storeName ).
00085 $this->__('click <a href="%s">here</a> to view the review',$reviewUrl).
00086 '</p>'
00087 ;
00088 $data = array(
00089 'title' => $this->__('Product: "%s" review By: %s',$row['name'],$row['nickname']),
00090 'link' => 'test',
00091 'description' => $description,
00092 );
00093 $rssObj->_addEntry($data);
00094 }
00095 }