Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Adminhtml_Rss_CatalogController
  • Mage_Adminhtml_Rss_OrderController
  • Mage_Rss_Block_Abstract
  • Mage_Rss_Block_Catalog_Abstract
  • Mage_Rss_Block_Catalog_Category
  • Mage_Rss_Block_Catalog_New
  • Mage_Rss_Block_Catalog_NotifyStock
  • Mage_Rss_Block_Catalog_Review
  • Mage_Rss_Block_Catalog_Salesrule
  • Mage_Rss_Block_Catalog_Special
  • Mage_Rss_Block_Catalog_Tag
  • Mage_Rss_Block_List
  • Mage_Rss_Block_Order_Details
  • Mage_Rss_Block_Order_New
  • Mage_Rss_Block_Order_Status
  • Mage_Rss_Block_Wishlist
  • Mage_Rss_CatalogController
  • Mage_Rss_Helper_Catalog
  • Mage_Rss_Helper_Data
  • Mage_Rss_Helper_Order
  • Mage_Rss_IndexController
  • Mage_Rss_Model_Mysql4_Order
  • Mage_Rss_Model_Observer
  • Mage_Rss_Model_Resource_Order
  • Mage_Rss_Model_Rss
  • Mage_Rss_Model_Session
  • Mage_Rss_Model_System_Config_Backend_Links
  • Mage_Rss_OrderController
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_Rss
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: /**
 28:  * Customer Shared Wishlist Rss Block
 29:  *
 30:  * @category   Mage
 31:  * @package    Mage_Rss
 32:  * @author     Magento Core Team <core@magentocommerce.com>
 33:  */
 34: class Mage_Rss_Block_Wishlist extends Mage_Wishlist_Block_Abstract
 35: {
 36:     /**
 37:      * Customer instance
 38:      *
 39:      * @var Mage_Customer_Model_Customer
 40:      */
 41:     protected $_customer;
 42: 
 43:     /**
 44:      * Default MAP renderer type
 45:      *
 46:      * @var string
 47:      */
 48:     protected $_mapRenderer = 'msrp_rss';
 49: 
 50:     /**
 51:      * Retrieve Wishlist model
 52:      *
 53:      * @return Mage_Wishlist_Model_Wishlist
 54:      */
 55:     protected function _getWishlist()
 56:     {
 57:         if (is_null($this->_wishlist)) {
 58:             $this->_wishlist = Mage::getModel('wishlist/wishlist');
 59:             $wishlistId = $this->getRequest()->getParam('wishlist_id');
 60:             if ($wishlistId) {
 61:                 $this->_wishlist->load($wishlistId);
 62:                 if ($this->_wishlist->getCustomerId() != $this->_getCustomer()->getId()) {
 63:                     $this->_wishlist->unsetData();
 64:                 }
 65:             } else {
 66:                 if($this->_getCustomer()->getId()) {
 67:                     $this->_wishlist->loadByCustomer($this->_getCustomer());
 68:                 }
 69:             }
 70:         }
 71:         return $this->_wishlist;
 72:     }
 73: 
 74:     /**
 75:      * Retrieve Customer instance
 76:      *
 77:      * @return Mage_Customer_Model_Customer
 78:      */
 79:     protected function _getCustomer()
 80:     {
 81:         if (is_null($this->_customer)) {
 82:             $this->_customer = Mage::getModel('customer/customer');
 83: 
 84:             $params = Mage::helper('core')->urlDecode($this->getRequest()->getParam('data'));
 85:             $data   = explode(',', $params);
 86:             $cId    = abs(intval($data[0]));
 87:             if ($cId && ($cId == Mage::getSingleton('customer/session')->getCustomerId()) ) {
 88:                 $this->_customer->load($cId);
 89:             }
 90:         }
 91: 
 92:         return $this->_customer;
 93:     }
 94: 
 95:     /**
 96:      * Build wishlist rss feed title
 97:      *
 98:      * @return string
 99:      */
100:     protected function _getTitle()
101:     {
102:         return Mage::helper('rss')->__('%s\'s Wishlist', $this->_getCustomer()->getName());
103:     }
104: 
105:     /**
106:      * Render block HTML
107:      *
108:      * @return string
109:      */
110:     protected function _toHtml()
111:     {
112:         /* @var $rssObj Mage_Rss_Model_Rss */
113:         $rssObj = Mage::getModel('rss/rss');
114: 
115:         if ($this->_getWishlist()->getId()) {
116:             $newUrl = Mage::getUrl('wishlist/shared/index', array(
117:                 'code'  => $this->_getWishlist()->getSharingCode()
118:             ));
119: 
120:             $title  = $this->_getTitle();
121:             $lang   = Mage::getStoreConfig('general/locale/code');
122: 
123:             $rssObj->_addHeader(array(
124:                 'title'         => $title,
125:                 'description'   => $title,
126:                 'link'          => $newUrl,
127:                 'charset'       => 'UTF-8',
128:                 'language'      => $lang
129:             ));
130: 
131:             /** @var $wishlistItem Mage_Wishlist_Model_Item*/
132:             foreach ($this->getWishlistItems() as $wishlistItem) {
133:                 /* @var $product Mage_Catalog_Model_Product */
134:                 $product = $wishlistItem->getProduct();
135:                 $productUrl = $this->getProductUrl($product);
136:                 $product->setAllowedInRss(true);
137:                 $product->setAllowedPriceInRss(true);
138:                 $product->setProductUrl($productUrl);
139:                 $args = array('product' => $product);
140: 
141:                 Mage::dispatchEvent('rss_wishlist_xml_callback', $args);
142: 
143:                 if (!$product->getAllowedInRss()) {
144:                     continue;
145:                 }
146: 
147:                 $description = '<table><tr><td><a href="' . $productUrl . '"><img src="'
148:                     . $this->helper('catalog/image')->init($product, 'thumbnail')->resize(75, 75)
149:                     . '" border="0" align="left" height="75" width="75"></a></td>'
150:                     . '<td style="text-decoration:none;">'
151:                     . $this->helper('catalog/output')
152:                         ->productAttribute($product, $product->getShortDescription(), 'short_description')
153:                     . '<p>';
154: 
155:                 if ($product->getAllowedPriceInRss()) {
156:                     $description .= $this->getPriceHtml($product,true);
157:                 }
158:                 $description .= '</p>';
159:                 if ($this->hasDescription($product)) {
160:                     $description .= '<p>' . Mage::helper('wishlist')->__('Comment:')
161:                         . ' ' . $this->helper('catalog/output')
162:                             ->productAttribute($product, $product->getDescription(), 'description')
163:                         . '<p>';
164:                 }
165: 
166:                 $description .= '</td></tr></table>';
167: 
168:                 $rssObj->_addEntry(array(
169:                     'title'         => $this->helper('catalog/output')
170:                         ->productAttribute($product, $product->getName(), 'name'),
171:                     'link'          => $productUrl,
172:                     'description'   => $description,
173:                 ));
174:             }
175:         }
176:         else {
177:             $rssObj->_addHeader(array(
178:                 'title'         => Mage::helper('rss')->__('Cannot retrieve the wishlist'),
179:                 'description'   => Mage::helper('rss')->__('Cannot retrieve the wishlist'),
180:                 'link'          => Mage::getUrl(),
181:                 'charset'       => 'UTF-8',
182:             ));
183:         }
184: 
185:         return $rssObj->createRssXml();
186:     }
187: 
188:     /**
189:      * Retrieve Product View URL
190:      *
191:      * @param Mage_Catalog_Model_Product $product
192:      * @param array $additional
193:      * @return string
194:      */
195:     public function getProductUrl($product, $additional = array())
196:     {
197:         $additional['_rss'] = true;
198:         return parent::getProductUrl($product, $additional);
199:     }
200: 
201:     /**
202:      * Adding customized price template for product type, used as action in layouts
203:      *
204:      * @param string $type Catalog Product Type
205:      * @param string $block Block Type
206:      * @param string $template Template
207:      */
208:     public function addPriceBlockType($type, $block = '', $template = '')
209:     {
210:         if ($type) {
211:             $this->_priceBlockTypes[$type] = array(
212:                 'block' => $block,
213:                 'template' => $template
214:             );
215:         }
216:     }
217: }
218: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0