1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31: 32:
33:
34: class extends Mage_Core_Controller_Front_Action
35: {
36: 37: 38: 39: 40:
41: protected $_wishlist;
42:
43: 44: 45: 46: 47:
48: protected $_customer;
49:
50: 51: 52:
53: public function indexAction()
54: {
55: if (Mage::getStoreConfig('rss/config/active')) {
56: $this->loadLayout();
57: $this->renderLayout();
58: } else {
59: $this->getResponse()->setHeader('HTTP/1.1','404 Not Found');
60: $this->getResponse()->setHeader('Status','404 File not found');
61: $this->_forward('defaultNoRoute');
62: }
63: }
64:
65: 66: 67:
68: public function nofeedAction()
69: {
70: $this->getResponse()->setHeader('HTTP/1.1','404 Not Found');
71: $this->getResponse()->setHeader('Status','404 File not found');
72: $this->loadLayout(false);
73: $this->renderLayout();
74: }
75:
76: 77: 78: 79: 80: 81:
82: public function wishlistAction()
83: {
84: if (!Mage::getStoreConfig('rss/wishlist/active')) {
85: $this->getResponse()->setHeader('HTTP/1.1','404 Not Found');
86: $this->getResponse()->setHeader('Status','404 File not found');
87: $this->_forward('nofeed','index','rss');
88: return;
89: }
90:
91: $wishlist = $this->_getWishlist();
92: if (!$wishlist) {
93: $this->_forward('nofeed','index','rss');
94: return;
95: }
96:
97: if ($wishlist->getVisibility()) {
98: $this->_showWishlistRss();
99: return ;
100: } else if (Mage::getSingleton('customer/session')->authenticate($this)
101: && $wishlist->getCustomerId() == $this->_getCustomer()->getId()
102: ) {
103: $this->_showWishlistRss();
104: } else {
105: $this->_forward('nofeed','index','rss');
106: }
107: }
108:
109: 110: 111:
112: protected function ()
113: {
114: $this->getResponse()->setHeader('Content-type', 'text/xml; charset=UTF-8');
115: $this->loadLayout(false);
116: $this->renderLayout();
117: }
118:
119: 120: 121: 122: 123:
124: protected function _getWishlist()
125: {
126: if (is_null($this->_wishlist)) {
127: $this->_wishlist = Mage::getModel('wishlist/wishlist');
128: $wishlistId = $this->getRequest()->getParam('wishlist_id');
129: if ($wishlistId) {
130: $this->_wishlist->load($wishlistId);
131: } else {
132: if($this->_getCustomer()->getId()) {
133: $this->_wishlist->loadByCustomer($this->_getCustomer());
134: }
135: }
136: }
137: return $this->_wishlist;
138: }
139:
140: 141: 142: 143: 144:
145: protected function _getCustomer()
146: {
147: if (is_null($this->_customer)) {
148: $this->_customer = Mage::getModel('customer/customer');
149:
150: $params = Mage::helper('core')->urlDecode($this->getRequest()->getParam('data'));
151: $data = explode(',', $params);
152: $customerId = abs(intval($data[0]));
153: if ($customerId && ($customerId == Mage::getSingleton('customer/session')->getCustomerId()) ) {
154: $this->_customer->load($customerId);
155: }
156: }
157:
158: return $this->_customer;
159: }
160: }
161: