IREUS_Recommendation_Engine_Interface - Version 2.2.4

Version Notes

Log out and log in after install to get access to the configuration interface! You will find it in the menu [System -> Configuration -> IREUS Recommendation Engine]

Download this release

Release Info

Developer Magento Core Team
Extension IREUS_Recommendation_Engine_Interface
Version 2.2.4
Comparing to
See all releases


Version 2.2.4

app/code/community/Netresearch/Ireus/Block/Catalog/Product/List/Upsell.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * IREUS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0).
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to obtain the license through the world-wide-web,
11
+ * please send an email to support@ireus.net so we can send you a copy.
12
+ *
13
+ * DISCLAIMER
14
+ *
15
+ * Do not edit or add to this file if you wish to upgrade Ireus to newer
16
+ * versions in the future. If you wish to customize Ireus for your
17
+ * needs please refer to http://www.ireus.net for more information.
18
+ *
19
+ * @category IREUS Recommendation Engine
20
+ * @package Ireus
21
+ * @copyright Copyright (c) 2010 prudsys AG (http://www.prudsys.com)
22
+ * @author Stephan Hoyer, Germany
23
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
24
+ *
25
+ * $Id$
26
+ */
27
+
28
+
29
+ class Netresearch_Ireus_Block_Catalog_Product_List_Upsell
30
+ extends Mage_Catalog_Block_Product_List_Upsell
31
+ {
32
+ public function getItemCollection()
33
+ {
34
+ if (
35
+ Mage::getStoreConfig('ireus/settings/active') &&
36
+ Mage::getStoreConfig('ireus/settings/disable_magento_upsell')
37
+ ) {
38
+ return new Varien_Object();
39
+ }
40
+ return parent::getItemCollection();
41
+ }
42
+ }
app/code/community/Netresearch/Ireus/Block/Checkout/Multishipping/Success.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * IREUS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0).
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to obtain the license through the world-wide-web,
11
+ * please send an email to support@ireus.net so we can send you a copy.
12
+ *
13
+ * DISCLAIMER
14
+ *
15
+ * Do not edit or add to this file if you wish to upgrade Ireus to newer
16
+ * versions in the future. If you wish to customize Ireus for your
17
+ * needs please refer to http://www.ireus.net for more information.
18
+ *
19
+ * @category IREUS Recommendation Engine
20
+ * @package Ireus
21
+ * @copyright Copyright (c) 2010 prudsys AG (http://www.prudsys.com)
22
+ * @author Stephan Hoyer, Germany
23
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
24
+ *
25
+ * $Id$
26
+ */
27
+
28
+
29
+ class Netresearch_Ireus_Block_Checkout_Multishipping_Success extends Mage_Checkout_Block_Multishipping_Success
30
+ {
31
+ public function getOrderIds()
32
+ {
33
+ $ids = Mage::getSingleton('core/session')->getOrderIds(false);
34
+ if ($ids && is_array($ids)) {
35
+ return $ids;
36
+ return implode(', ', $ids);
37
+ }
38
+ return false;
39
+ }
40
+
41
+ public function getViewOrderUrl($orderId)
42
+ {
43
+ return $this->getUrl('sales/order/view/', array('order_id' => $orderId, '_secure' => true));
44
+ }
45
+
46
+ public function getContinueUrl()
47
+ {
48
+ return Mage::getBaseUrl();
49
+ }
50
+ }
app/code/community/Netresearch/Ireus/Block/Data.php ADDED
@@ -0,0 +1,407 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * IREUS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0).
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to obtain the license through the world-wide-web,
11
+ * please send an email to support@ireus.net so we can send you a copy.
12
+ *
13
+ * DISCLAIMER
14
+ *
15
+ * Do not edit or add to this file if you wish to upgrade Ireus to newer
16
+ * versions in the future. If you wish to customize Ireus for your
17
+ * needs please refer to http://www.ireus.net for more information.
18
+ *
19
+ * @category IREUS Recommendation Engine
20
+ * @package Ireus
21
+ * @copyright Copyright (c) 2010 prudsys AG (http://www.prudsys.com)
22
+ * @author Stephan Hoyer, Germany
23
+ * @author Silvio Steiger, Germany
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ *
26
+ * $Id$
27
+ */
28
+
29
+
30
+ // Register IREUS PHP Framework
31
+ require_once('IreusAutoloader.php');
32
+ IreusAutoloader::getInstance()->register();
33
+
34
+
35
+ class Netresearch_Ireus_Block_Data extends Mage_Core_Block_Template
36
+ {
37
+ var $isIreusCallActive;
38
+ var $lastIreusEvent;
39
+ var $latestAddedProduct;
40
+ var $latestOrder;
41
+ var $latestOrderedProducts;
42
+ var $latestMultishippingOrderIds;
43
+
44
+
45
+ /**
46
+ * returns current product id
47
+ *
48
+ * @return int
49
+ */
50
+ protected function getProductId()
51
+ {
52
+ return Mage::registry('product')->getId();
53
+ }
54
+
55
+
56
+ /**
57
+ * returns debug mode
58
+ *
59
+ * @return bool
60
+ */
61
+ protected function isDebugMode()
62
+ {
63
+ return Mage::getStoreConfig('ireus/settings/debug');
64
+ }
65
+
66
+
67
+ /**
68
+ * returns ireus-customer related Recommendation Engine ID
69
+ *
70
+ * @return string
71
+ */
72
+ protected function getEngineId()
73
+ {
74
+ return Mage::getStoreConfig('ireus/settings/re_id');
75
+ }
76
+
77
+
78
+ /**
79
+ * returns current session id
80
+ *
81
+ * @return string
82
+ */
83
+ protected function getSessionId()
84
+ {
85
+ return Mage::getSingleton("customer/session")->getSessionId();
86
+ }
87
+
88
+
89
+ /**
90
+ * returns current user id
91
+ *
92
+ * @return string
93
+ */
94
+ protected function getUserId()
95
+ {
96
+ return Mage::getSingleton("customer/session")->getCustomer()->getId();
97
+ }
98
+
99
+
100
+ /**
101
+ * returns current category id
102
+ *
103
+ * @return int
104
+ */
105
+ protected function getCategoryId()
106
+ {
107
+ return Mage::registry('current_category')->getId();
108
+ }
109
+
110
+
111
+ /**
112
+ * determines, whether it has been ordered something by current visitor
113
+ *
114
+ * @return bool
115
+ */
116
+ protected function hasRecentlyOrdered()
117
+ {
118
+ $this->latestMultishippingOrderIds = Mage::getSingleton('core/session')->getOrderIds(true);
119
+
120
+ //Multishipping
121
+ if(count($this->latestMultishippingOrderIds)) {
122
+ return true;
123
+ }
124
+
125
+ //OnePageCheckout
126
+ if(Mage::getSingleton('checkout/session')->getLastQuoteId()) {
127
+ return true;
128
+ }
129
+
130
+ return false;
131
+ }
132
+
133
+
134
+ /**
135
+ * returns last ordered quote
136
+ *
137
+ * @return Mage_Sales_Quote
138
+ */
139
+ protected function getLatestQuote()
140
+ {
141
+ if(!isset($this->latestQuote)) {
142
+ $this->latestQuote =
143
+ Mage::getModel('sales/quote')
144
+ ->load(Mage::getSingleton('checkout/session')->getLastQuoteId());
145
+ }
146
+ return $this->latestQuote;
147
+ }
148
+
149
+
150
+ /**
151
+ * returns an array of products and theirs ordered qtys like
152
+ *
153
+ * array(
154
+ * 'ids' => array(123, 321, 435),
155
+ * 'qtys'=> array(1,2,2)
156
+ * )
157
+ *
158
+ * @return array
159
+ */
160
+ protected function getLatestOrderedProducts()
161
+ {
162
+ if(!isset($this->latestOrderedProducts)) {
163
+ $ids = $qtys = array();
164
+ $items = array();
165
+ if(isset($this->latestMultishippingOrderIds)) {
166
+ foreach($this->latestMultishippingOrderIds as $orderId=>$orderNumber) {
167
+ $items = array_merge($items, Mage::getModel('sales/order')->load($orderId)->getAllItems());
168
+ }
169
+ }
170
+ else {
171
+ $items = $this->getLatestQuote()->getAllItems();
172
+ }
173
+ foreach($items as $item) {
174
+ $ids[] = $item->getProductId();
175
+ $qtys[] = !is_null($item->getQty()) ? $item->getQty() : $item->getQtyOrdered();
176
+ }
177
+ $this->latestOrderedProducts = array('ids' => $ids, 'qtys' => $qtys);
178
+ }
179
+ return $this->latestOrderedProducts;
180
+ }
181
+
182
+
183
+ /**
184
+ * returns array of last ordered product ids
185
+ *
186
+ * @return array
187
+ */
188
+ protected function getLatestOrderedProductIds()
189
+ {
190
+ $products = $this->getLatestOrderedProducts();
191
+ return $products['ids'];
192
+ }
193
+
194
+
195
+ /**
196
+ * returns array of last ordered product qtys
197
+ *
198
+ * @return array
199
+ */
200
+ protected function getLatestOrderedQtys()
201
+ {
202
+ $products = $this->getLatestOrderedProducts();
203
+ return $products['qtys'];
204
+ }
205
+
206
+
207
+ /**
208
+ * returns id of latest product added to cart
209
+ *
210
+ * @return int
211
+ */
212
+ protected function getLatestAddedProductId()
213
+ {
214
+ if(!isset($this->latestAddedProduct)) {
215
+ $this->latestAddedProduct = Mage::getSingleton('checkout/session')->getData('latestAddedProductsId');
216
+ Mage::getSingleton('checkout/session')->unsetData('latestAddedProductsId');
217
+ }
218
+ return $this->latestAddedProduct;
219
+ }
220
+
221
+
222
+ /**
223
+ * determines whether the current visitor has puted something to cart
224
+ *
225
+ * @return bool
226
+ */
227
+ protected function hasRecentlyAddedSomethingToCart()
228
+ {
229
+ if(!isset($this->latestAddedProduct)) {
230
+ $this->getLatestAddedProductId();
231
+ }
232
+ return isset($this->latestAddedProduct);
233
+ }
234
+
235
+
236
+ /**
237
+ * determines where Ireus should display something on the current page
238
+ *
239
+ * @return bool
240
+ */
241
+ protected function isActive()
242
+ {
243
+ if(!Mage::getStoreConfig('ireus/settings/active')) {
244
+ return false;
245
+ }
246
+
247
+ switch(Mage::app()->getRequest()->getControllerName())
248
+ {
249
+ case 'product': // show product
250
+ if ($this->getNameInLayout() == 'ireus_databasket'
251
+ && !$this->hasRecentlyAddedSomethingToCart()
252
+ ) {
253
+ return false;
254
+ }
255
+ else
256
+ {
257
+ return true;
258
+ }
259
+ case 'category': // show category
260
+ return true;
261
+ case 'cart': // added product to cart
262
+ if (Mage::app()->getRequest()->getActionName() !== 'index'
263
+ || (
264
+ $this->getNameInLayout() == 'ireus_databasket'
265
+ && !$this->hasRecentlyAddedSomethingToCart()
266
+ )
267
+ ) {
268
+ return false;
269
+ }
270
+ else
271
+ {
272
+ return true;
273
+ }
274
+ case 'multishipping': // order successfull
275
+ case 'onepage': // order successfull
276
+ if(
277
+ Mage::app()->getRequest()->getActionName() === 'success' &&
278
+ $this->hasRecentlyOrdered()
279
+ ) {
280
+ return true;
281
+ }
282
+ case 'index': // show homepage
283
+ if(
284
+ Mage::app()->getRequest()->getModuleName() === 'cms' &&
285
+ Mage::app()->getRequest()->getActionName() === 'index'
286
+ ) {
287
+ return true;
288
+ }
289
+ }
290
+ return false;
291
+ }
292
+
293
+
294
+ /**
295
+ * generates JSON data of parameters needed by Ireus
296
+ *
297
+ * @return string
298
+ */
299
+ protected function getJsonData()
300
+ {
301
+ if(!Mage::getStoreConfig('ireus/settings/active')) {
302
+ return "";
303
+ }
304
+
305
+ $return = array (
306
+ 'reid' => $this->getEngineId(),
307
+ 'sid' => $this->getSessionId(),
308
+ 'uid' => $this->getUserId()
309
+ );
310
+
311
+ if($this->isDebugMode()) {
312
+ $return['debug'] = 1;
313
+ }
314
+
315
+ switch(Mage::app()->getRequest()->getControllerName())
316
+ {
317
+ case 'product':
318
+ if ($this->getNameInLayout() == 'ireus_databasket'
319
+ && $this->hasRecentlyAddedSomethingToCart()
320
+ ) {
321
+ $return['pid'] = $this->getLatestAddedProductId();
322
+ $return['e'] = 'basket';
323
+ }
324
+ else
325
+ {
326
+ $return['pid'] = $this->getProductId();
327
+ $return['e'] = 'product';
328
+ }
329
+ break;
330
+ case 'category':
331
+ $return['cid'] = $this->getCategoryId();
332
+ $return['e'] = 'user';
333
+ break;
334
+ case 'index':
335
+ $return['cid'] = "";
336
+ $return['e'] = 'home';
337
+ break;
338
+ case 'cart':
339
+ if ($this->getNameInLayout() == 'ireus_databasket'
340
+ && $this->hasRecentlyAddedSomethingToCart()
341
+ ) {
342
+ $return['pid'] = $this->getLatestAddedProductId();
343
+ $return['e'] = 'basket';
344
+ }
345
+ else
346
+ {
347
+ $return['cid'] = "";
348
+ $return['e'] = 'home';
349
+ }
350
+ break;
351
+ case 'multishipping':
352
+ case 'onepage':
353
+ $return['pids'] = implode(',', $this->getLatestOrderedProductIds());
354
+ $return['qty'] = implode(',', $this->getLatestOrderedQtys());
355
+ $return['e'] = 'order';
356
+ break;
357
+ }
358
+ return Zend_Json::encode($return);
359
+ }
360
+
361
+
362
+ /**
363
+ * Gets cached data for noscript fallback
364
+ *
365
+ * @return string
366
+ */
367
+ protected function getCachedRecomms()
368
+ {
369
+ if(!Mage::getStoreConfig('ireus/settings/active')) {
370
+ return '';
371
+ }
372
+
373
+ $sidparam = Mage::getSingleton('core/session')->getSessionIdQueryParam();
374
+
375
+ switch(Mage::app()->getRequest()->getControllerName())
376
+ {
377
+ case 'product':
378
+ $event = 'product';
379
+ $id = $this->getProductId();
380
+ break;
381
+
382
+ case 'category':
383
+ $event = 'user';
384
+ $id = $this->getCategoryId();
385
+ break;
386
+
387
+ case 'index':
388
+ default:
389
+ $event = 'home';
390
+ $id = '';
391
+ break;
392
+ }
393
+
394
+ return Ireus_Controller_Cache::getContent(
395
+ $this->getEngineId(),
396
+ $this->getSessionId(),
397
+ $event,
398
+ $id,
399
+ Mage::getBaseDir('cache') . DIRECTORY_SEPARATOR . 'ireus',
400
+ array(
401
+ '&'.$sidparam.'=%SID%',
402
+ $sidparam.'=%SID%'
403
+ ),
404
+ 'UTF-8'
405
+ );
406
+ }
407
+ }
app/code/community/Netresearch/Ireus/Helper/Data.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * IREUS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0).
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to obtain the license through the world-wide-web,
11
+ * please send an email to support@ireus.net so we can send you a copy.
12
+ *
13
+ * DISCLAIMER
14
+ *
15
+ * Do not edit or add to this file if you wish to upgrade Ireus to newer
16
+ * versions in the future. If you wish to customize Ireus for your
17
+ * needs please refer to http://www.ireus.net for more information.
18
+ *
19
+ * @category IREUS Recommendation Engine
20
+ * @package Ireus
21
+ * @copyright Copyright (c) 2010 prudsys AG (http://www.prudsys.com)
22
+ * @author Silvio Steiger, Germany
23
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
24
+ *
25
+ * $Id$
26
+ */
27
+
28
+
29
+ class Netresearch_Ireus_Helper_Data extends Mage_Core_Helper_Abstract
30
+ {
31
+ }
app/code/community/Netresearch/Ireus/Model/Observer.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * IREUS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0).
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to obtain the license through the world-wide-web,
11
+ * please send an email to support@ireus.net so we can send you a copy.
12
+ *
13
+ * DISCLAIMER
14
+ *
15
+ * Do not edit or add to this file if you wish to upgrade Ireus to newer
16
+ * versions in the future. If you wish to customize Ireus for your
17
+ * needs please refer to http://www.ireus.net for more information.
18
+ *
19
+ * @category IREUS Recommendation Engine
20
+ * @package Ireus
21
+ * @copyright Copyright (c) 2010 prudsys AG (http://www.prudsys.com)
22
+ * @author Stephan Hoyer, Germany
23
+ * @author Silvio Steiger, Germany
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ *
26
+ * $Id$
27
+ */
28
+
29
+
30
+ class Netresearch_Ireus_Model_Observer
31
+ {
32
+ public function saveLatestAddedProduct($observer)
33
+ {
34
+ Mage::getSingleton('checkout/session')
35
+ ->setData('latestAddedProductsId', $observer['product']->getId());
36
+ return $this;
37
+ }
38
+ }
app/code/community/Netresearch/Ireus/controllers/ExportController.php ADDED
@@ -0,0 +1,380 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * IREUS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0).
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to obtain the license through the world-wide-web,
11
+ * please send an email to support@ireus.net so we can send you a copy.
12
+ *
13
+ * DISCLAIMER
14
+ *
15
+ * Do not edit or add to this file if you wish to upgrade Ireus to newer
16
+ * versions in the future. If you wish to customize Ireus for your
17
+ * needs please refer to http://www.ireus.net for more information.
18
+ *
19
+ * @category IREUS Recommendation Engine
20
+ * @package Ireus
21
+ * @copyright Copyright (c) 2010 prudsys AG (http://www.prudsys.com)
22
+ * @author Stephan Hoyer, Germany
23
+ * @author Silvio Steiger, Germany
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ *
26
+ * $Id$
27
+ */
28
+
29
+
30
+ // Register IREUS PHP Framework
31
+ require_once('IreusAutoloader.php');
32
+ IreusAutoloader::getInstance()->register();
33
+
34
+
35
+ class Netresearch_Ireus_ExportController extends Mage_Core_Controller_Front_Action
36
+ {
37
+ const CONFIG_SECURITY_CODE = 'ireus/settings/security_code';
38
+ const CONFIG_EXPORT_DISABLED_CATEGORIES = 'ireus/settings/export_disabled_categories';
39
+ const CONFIG_IMAGE_WIDTH = 'ireus/settings/image_width';
40
+ const CONFIG_IMAGE_HEIGHT = 'ireus/settings/image_height';
41
+ const PAGE_SIZE = 500;
42
+
43
+ var $_storeId ='admin';
44
+
45
+ var $_ordersColumns = array(
46
+ 'tid' => 'order_id',
47
+ 'pid' => 'product_id'
48
+ );
49
+
50
+ var $_productsColumns = array(
51
+ 'pid' => 'entity_id',
52
+ 'sku' => 'sku',
53
+ 'name' => 'name',
54
+ 'brand' => 'brand',
55
+ 'manufacturer' => 'manufacturer',
56
+ 'description' => 'short_description',
57
+ 'param1' => 'add_to_cart_url',
58
+ 'URL' => 'url',
59
+ 'imageURL' => 'images_url',
60
+ 'netUnitPrice' => 'price',
61
+ 'onlineFlag' => 'is_salable',
62
+ 'quantity' => 'qty',
63
+ 'strikeOutPrice' => 'special_price'
64
+ );
65
+
66
+ static $_sessionId;
67
+
68
+ static $_sessionIdQueryParam;
69
+
70
+ static $_ireusplaceholder = '%SID%';
71
+
72
+
73
+ /**
74
+ * Check security code and redirect to 404 if not given or wrong
75
+ *
76
+ * @return Netresearch_Ireus_ExportController
77
+ */
78
+ public function preDispatch()
79
+ {
80
+ parent::preDispatch();
81
+ $security_code = Mage::App()->getRequest()->getParam('code');
82
+ if(
83
+ is_null($security_code) or
84
+ $security_code != Mage::getStoreConfig(self::CONFIG_SECURITY_CODE)
85
+ ) {
86
+ $this->_redirect('noroute');
87
+ $this->setFlag('',self::FLAG_NO_DISPATCH,true);
88
+ }
89
+
90
+ if ($this->getRequest()->getParam('store')
91
+ ) {
92
+ $this->_setActiveStore($this->getRequest()->getParam('store'));
93
+ }
94
+
95
+ $this->_storeId = Mage::App()->getStore()->getCode();
96
+ self::$_sessionId = Mage::getSingleton('core/session')->getSessionId();
97
+ self::$_sessionIdQueryParam = Mage::getSingleton('core/session')->getSessionIdQueryParam();
98
+
99
+ return $this;
100
+ }
101
+
102
+
103
+ /**
104
+ * Output a CSV of all products with their
105
+ * categories and all parent categories,
106
+ *
107
+ * @return null
108
+ */
109
+ public function categoriesAction()
110
+ {
111
+ // Change maximum execution time
112
+ set_time_limit(0);
113
+
114
+ $product = Mage::getModel('catalog/product');
115
+
116
+ foreach(Mage::getModel('Catalog/Category')
117
+ ->getCollection()
118
+ ->addFieldToFilter('is_active', 1)
119
+ ->addFieldToFilter('level', array('gt' => 1))
120
+ ->addAttributeToSelect('name') as $category
121
+ ) {
122
+ if($category->getProductCount()
123
+ ) {
124
+ $productcategories = Mage::getModel('Catalog/Category')
125
+ ->getCollection()
126
+ ->addFieldToFilter('entity_id', array(
127
+ 'in' => $category->getPathIds()))
128
+ ->addAttributeToSelect('entity_id')
129
+ ->addAttributeToSelect('name');
130
+
131
+ $collection = $category->getProductCollection()
132
+ ->joinField('qty', 'cataloginventory/stock_item', '*',
133
+ 'product_id=entity_id', '{{table}}.stock_id=1', 'left')
134
+ ->addAttributeToFilter('status',
135
+ Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
136
+ ->addAttributeToFilter('visibility', array('in'=>array(
137
+ Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
138
+ Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
139
+ )))
140
+ ->addAttributeToFilter('price', array('gt' => 0));
141
+
142
+ Mage::getSingleton('core/resource_iterator')
143
+ ->walk(
144
+ $collection->getSelect(),
145
+ array(
146
+ array(
147
+ $this,
148
+ 'callbackCategoriesAction'
149
+ )
150
+ ),
151
+ array(
152
+ 'product' => $product,
153
+ 'productcategories' => $productcategories
154
+ )
155
+ );
156
+ }
157
+ }
158
+
159
+ exit;
160
+ }
161
+
162
+
163
+ /**
164
+ * Callback function for the resource iterator of the categories Action
165
+ *
166
+ * @param array $args
167
+ * @return void
168
+ */
169
+ public function callbackCategoriesAction ($args)
170
+ {
171
+ $product = $args['product'];
172
+ $productcategories = $args['productcategories'];
173
+ $product->setData($args['row']);
174
+
175
+ $productsWithCategories = array();
176
+ $pid = $product->getId();
177
+ foreach ($productcategories as $currentcategory
178
+ ) {
179
+ $cid = $currentcategory->getId();
180
+ $productsWithCategories[$pid.$cid] = array(
181
+ 'pid' => $pid,
182
+ 'cid' => $cid,
183
+ 'cidparent' => $currentcategory->getParentId(),
184
+ 'cname' => $currentcategory->getName()
185
+ );
186
+ }
187
+
188
+ // Stream output product wise
189
+ echo Ireus_Controller_Export::getInstance()
190
+ ->createCategoriesCsv($productsWithCategories);
191
+ flush();
192
+ }
193
+
194
+
195
+ /**
196
+ * Output a CSV of all orders
197
+ *
198
+ * @return null
199
+ */
200
+ public function ordersAction()
201
+ {
202
+ // Change maximum execution time
203
+ set_time_limit(0);
204
+
205
+ echo Ireus_Controller_Export::getInstance()
206
+ ->setOrderColumns($this->_ordersColumns)
207
+ ->exportOrdersCsv(Mage::getModel('Sales/Order_Item')->getCollection()->getData());
208
+
209
+ exit;
210
+ }
211
+
212
+
213
+ /**
214
+ * Output a CSV of all products with their attributes
215
+ *
216
+ * @return null
217
+ */
218
+ public function productsAction()
219
+ {
220
+ // Change maximum execution time
221
+ set_time_limit(0);
222
+
223
+ // Prepare the prudsys IREUS Export Controller
224
+ Ireus_Controller_Export::getInstance()
225
+ ->setProductColumns($this->_productsColumns);
226
+
227
+ // Get products from database
228
+ $collection = Mage::getModel('Catalog/Product')
229
+ ->getCollection()
230
+ ->joinField('qty', 'cataloginventory/stock_item', '*',
231
+ 'product_id=entity_id', '{{table}}.stock_id=1', 'left')
232
+ ->addAttributeToFilter('status',
233
+ Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
234
+ ->addAttributeToFilter('price', array('gt' => 0))
235
+ ->addAttributeToFilter(
236
+ 'visibility',
237
+ array(
238
+ 'in' => array(
239
+ Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
240
+ Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
241
+ )
242
+ )
243
+ )
244
+ ->addAttributeToSelect('small_image');
245
+ foreach($this->_productsColumns as $value
246
+ ) {
247
+ $collection->addAttributeToSelect($value);
248
+ }
249
+
250
+ // Walk through collection page wise
251
+ $countCollection = clone $collection;
252
+ $count = $countCollection->count();
253
+ unset ($countCollection);
254
+ $i=0;
255
+ do {
256
+ $i++;
257
+ $products = array();
258
+ $pageCollection = clone $collection;
259
+ $pageCollection->setPage($i, self::PAGE_SIZE);
260
+ foreach ($pageCollection as $product
261
+ ) {
262
+ $product_url = $product->getProductUrl();
263
+ $product->setManufacturer($product->getAttributeText('manufacturer'));
264
+ $product->setUrl(self::setSidPlaceholder($product_url));
265
+ $product->setImagesUrl(Mage::helper('Catalog/Image')
266
+ ->init($product,'small_image')
267
+ ->resize(
268
+ Mage::getStoreConfig(self::CONFIG_IMAGE_WIDTH),
269
+ Mage::getStoreConfig(self::CONFIG_IMAGE_HEIGHT)
270
+ )
271
+ ->__toString());
272
+ $product->setAddToCartUrl(self::getAddToCartUrl($product, $product_url));
273
+
274
+ // Stream result in parts of 10
275
+ $products[] = $product->getData();
276
+ if (count($products) > 9
277
+ ) {
278
+ echo Ireus_Controller_Export::getInstance()
279
+ ->createProductsCsv($products);
280
+ flush();
281
+ $products = array();
282
+ }
283
+ }
284
+
285
+ // Stream remaining items
286
+ if (count($products) > 0
287
+ ) {
288
+ echo Ireus_Controller_Export::getInstance()
289
+ ->createProductsCsv($products);
290
+ flush();
291
+ }
292
+
293
+ $count -= $pageCollection->count();
294
+
295
+ } while($count > 0);
296
+
297
+ // Delete cached recommendations
298
+ Ireus_Controller_Cache::deleteCache(Mage::getBaseDir('cache') . DIRECTORY_SEPARATOR . 'ireus');
299
+
300
+ exit;
301
+ }
302
+
303
+
304
+ /**
305
+ * Create "add this product to cart" url
306
+ *
307
+ * @param object $collection
308
+ * @param array $additional
309
+ * @return array
310
+ */
311
+ protected static function getAddToCartUrl($product, $product_url, $additional = array())
312
+ {
313
+ if ($product->getTypeInstance(true)->hasRequiredOptions($product)
314
+ ) {
315
+ $url = $product_url;
316
+ $link = (strpos($url, '?') !== false) ? '&' : '?';
317
+ $result = $url . $link . 'options=cart';
318
+ }
319
+ else
320
+ {
321
+ $result = Mage::helper('checkout/cart')->getAddUrl($product, $additional);
322
+ }
323
+
324
+ return self::setSidPlaceholder($result);
325
+ }
326
+
327
+
328
+ /**
329
+ * Sets SessionID placeholder in urls for dynamic SessionID adjustments done by IREUS
330
+ *
331
+ * @param string $url
332
+ * @return string
333
+ */
334
+ protected static function setSidPlaceholder ($url)
335
+ {
336
+ if (strpos($url, self::$_sessionId)
337
+ ) {
338
+ $url = str_replace(self::$_sessionId, self::$_ireusplaceholder, $url);
339
+ }
340
+ else
341
+ {
342
+ $url .= ((strpos($url, '?') !== false) ? '&' : '?')
343
+ . self::$_sessionIdQueryParam
344
+ . '='
345
+ . self::$_ireusplaceholder;
346
+ }
347
+
348
+ return $url;
349
+ }
350
+
351
+
352
+ /**
353
+ * Sets a different store if needed
354
+ *
355
+ * @param Mixed $storeCode can be either storeId or storeCode of store to set
356
+ * @return Mage_Core_Controller_Front_Action
357
+ */
358
+ protected function _setActiveStore($storeCode)
359
+ {
360
+ if (!$storeCode
361
+ ) {
362
+ $storeCode = $this->_storeCode;
363
+ }
364
+
365
+ // if storeId is used convert to storeCode
366
+ if (is_numeric($storeCode)) {
367
+ $storeCode = Mage::app()->getStore($storeCode)->getCode();
368
+ }
369
+
370
+ // if current store is ok return
371
+ if (Mage::app()->getStore()->getCode() == $storeCode) {
372
+ return $this;
373
+ }
374
+
375
+ // set active store
376
+ Mage::app()->setCurrentStore($storeCode);
377
+
378
+ return $this;
379
+ }
380
+ }
app/code/community/Netresearch/Ireus/etc/config.xml ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * IREUS
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0).
9
+ * It is available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you are unable to obtain the license through the world-wide-web,
12
+ * please send an email to support@ireus.net so we can send you a copy.
13
+ *
14
+ * DISCLAIMER
15
+ *
16
+ * Do not edit or add to this file if you wish to upgrade Ireus to newer
17
+ * versions in the future. If you wish to customize Ireus for your
18
+ * needs please refer to http://www.ireus.net for more information.
19
+ *
20
+ * @category IREUS Recommendation Engine
21
+ * @package Ireus
22
+ * @copyright Copyright (c) 2010 prudsys AG (http://www.prudsys.com)
23
+ * @author Stephan Hoyer, Germany
24
+ * @author Silvio Steiger, Germany
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ *
27
+ * $Id$
28
+ */
29
+ -->
30
+ <config>
31
+ <modules>
32
+ <Netresearch_Ireus>
33
+ <version>1.5.0.0</version>
34
+ </Netresearch_Ireus>
35
+ </modules>
36
+
37
+ <admin>
38
+ </admin>
39
+
40
+ <global>
41
+ <blocks>
42
+ <ireus><class>Netresearch_Ireus_Block</class></ireus>
43
+ <catalog>
44
+ <rewrite>
45
+ <product_list_upsell>Netresearch_Ireus_Block_Catalog_Product_List_Upsell</product_list_upsell>
46
+ </rewrite>
47
+ </catalog>
48
+ <checkout>
49
+ <rewrite>
50
+ <multishipping_success>Netresearch_Ireus_Block_Checkout_Multishipping_Success</multishipping_success>
51
+ </rewrite>
52
+ </checkout>
53
+ </blocks>
54
+ <models>
55
+ <ireus>
56
+ <class>Netresearch_Ireus_Model</class>
57
+ </ireus>
58
+ </models>
59
+ <helpers>
60
+ <ireus>
61
+ <class>Netresearch_Ireus_Helper</class>
62
+ </ireus>
63
+ </helpers>
64
+ </global>
65
+
66
+ <adminhtml>
67
+ <translate>
68
+ <modules>
69
+ <Netresearch_Ireus>
70
+ <files>
71
+ <default>Netresearch_Ireus.csv</default>
72
+ </files>
73
+ </Netresearch_Ireus>
74
+ </modules>
75
+ </translate>
76
+ <acl>
77
+ <resources>
78
+ <all>
79
+ <title>Allow Everything</title>
80
+ </all>
81
+ <admin>
82
+ <children>
83
+ <system>
84
+ <children>
85
+ <config>
86
+ <children>
87
+ <ireus translate="title" module="ireus">
88
+ <title>IREUS Recommendation Engine</title>
89
+ <sort_order>50</sort_order>
90
+ </ireus>
91
+ </children>
92
+ </config>
93
+ </children>
94
+ </system>
95
+ </children>
96
+ </admin>
97
+ </resources>
98
+ </acl>
99
+ </adminhtml>
100
+
101
+ <frontend>
102
+ <routers>
103
+ <ireus>
104
+ <use>standard</use>
105
+ <args>
106
+ <module>Netresearch_Ireus</module>
107
+ <frontName>ireus</frontName>
108
+ </args>
109
+ </ireus>
110
+ </routers>
111
+ <translate>
112
+ <modules>
113
+ <Netresearch_Ireus>
114
+ <files>
115
+ <default>Netresearch_Ireus.csv</default>
116
+ </files>
117
+ </Netresearch_Ireus>
118
+ </modules>
119
+ </translate>
120
+ <layout>
121
+ <updates>
122
+ <ireus>
123
+ <file>ireus.xml</file>
124
+ </ireus>
125
+ </updates>
126
+ </layout>
127
+ <events>
128
+ <checkout_cart_add_product_complete>
129
+ <observers>
130
+ <ireus>
131
+ <type>singleton</type>
132
+ <class>ireus/observer</class>
133
+ <method>saveLatestAddedProduct</method>
134
+ </ireus>
135
+ </observers>
136
+ </checkout_cart_add_product_complete>
137
+ </events>
138
+ </frontend>
139
+ </config>
app/code/community/Netresearch/Ireus/etc/system.xml ADDED
@@ -0,0 +1,277 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * IREUS
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0).
9
+ * It is available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you are unable to obtain the license through the world-wide-web,
12
+ * please send an email to support@ireus.net so we can send you a copy.
13
+ *
14
+ * DISCLAIMER
15
+ *
16
+ * Do not edit or add to this file if you wish to upgrade Ireus to newer
17
+ * versions in the future. If you wish to customize Ireus for your
18
+ * needs please refer to http://www.ireus.net for more information.
19
+ *
20
+ * @category IREUS Recommendation Engine
21
+ * @package Ireus
22
+ * @copyright Copyright (c) 2010 prudsys AG (http://www.prudsys.com)
23
+ * @author Stephan Hoyer, Germany
24
+ * @author Silvio Steiger, Germany
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ *
27
+ * $Id$
28
+ */
29
+ -->
30
+ <config>
31
+ <sections>
32
+ <ireus translate="label" model="ireus">
33
+ <label>IREUS Recommendation Engine</label>
34
+ <tab>catalog</tab>
35
+ <frontend_type>text</frontend_type>
36
+ <sort_order>70</sort_order>
37
+ <show_in_default>1</show_in_default>
38
+ <show_in_website>1</show_in_website>
39
+ <show_in_store>1</show_in_store>
40
+ <groups>
41
+ <settings translate="label comment">
42
+ <label>Basic Settings</label>
43
+ <frontend_type>text</frontend_type>
44
+ <sort_order>100</sort_order>
45
+ <show_in_default>1</show_in_default>
46
+ <show_in_website>1</show_in_website>
47
+ <show_in_store>1</show_in_store>
48
+ <fields>
49
+ <active translate="label comment">
50
+ <label>Activate IREUS connector:</label>
51
+ <frontend_type>select</frontend_type>
52
+ <comment><![CDATA[For the use of IREUS you also need to activate your IREUS Recommendation Engine on <a href="http://www.ireus.net/rp/setLanguage.do?ref=index.do&locale=en" target="_blank">www.ireus.net</a>.]]></comment>
53
+ <source_model>adminhtml/system_config_source_yesno</source_model>
54
+ <sort_order>100</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>1</show_in_store>
58
+ </active>
59
+ <re_id translate="label comment">
60
+ <label>Recommendation Engine ID:</label>
61
+ <frontend_type>text</frontend_type>
62
+ <comment><![CDATA[Get your own REID on <a href="http://www.ireus.net/rp/setLanguage.do?ref=registration.do&locale=en" target="_blank">www.ireus.net</a> for free.]]></comment>
63
+ <sort_order>200</sort_order>
64
+ <show_in_default>1</show_in_default>
65
+ <show_in_website>1</show_in_website>
66
+ <show_in_store>1</show_in_store>
67
+ </re_id>
68
+ <security_code translate="label comment">
69
+ <label>Security code:</label>
70
+ <frontend_type>text</frontend_type>
71
+ <comment>Enter an arbitrary key.</comment>
72
+ <sort_order>300</sort_order>
73
+ <show_in_default>1</show_in_default>
74
+ <show_in_website>1</show_in_website>
75
+ <show_in_store>1</show_in_store>
76
+ </security_code>
77
+ <image_width translate="label comment">
78
+ <label>Image width (pixel) *:</label>
79
+ <frontend_type>text</frontend_type>
80
+ <comment><![CDATA[Width of images shown in recommendations.<sup>*</sup>]]></comment>
81
+ <sort_order>400</sort_order>
82
+ <show_in_default>1</show_in_default>
83
+ <show_in_website>1</show_in_website>
84
+ <show_in_store>1</show_in_store>
85
+ </image_width>
86
+ <image_height translate="label comment">
87
+ <label>Image height (pixel) *:</label>
88
+ <frontend_type>text</frontend_type>
89
+ <comment><![CDATA[Height of images shown in recommendations.<sup>*</sup>]]></comment>
90
+ <sort_order>500</sort_order>
91
+ <show_in_default>1</show_in_default>
92
+ <show_in_website>1</show_in_website>
93
+ <show_in_store>1</show_in_store>
94
+ </image_height>
95
+ <disable_magento_upsell translate="label comment">
96
+ <label>Disable Magento Upsell:</label>
97
+ <frontend_type>select</frontend_type>
98
+ <source_model>adminhtml/system_config_source_yesno</source_model>
99
+ <sort_order>600</sort_order>
100
+ <show_in_default>1</show_in_default>
101
+ <show_in_website>1</show_in_website>
102
+ <show_in_store>1</show_in_store>
103
+ </disable_magento_upsell>
104
+ </fields>
105
+ <comment><![CDATA[<p style="font-size: 90%">Changes of settings maked with * will be effective first after rerun of your product data upload to IREUS. You may start the rerun manually in the IREUS customer area on <a href="http://www.ireus.net" target="_blank">www.ireus.net</a>.</p><br />]]></comment>
106
+ </settings>
107
+ <dataupload translate="label comment">
108
+ <label>Data Upload</label>
109
+ <comment>
110
+ <![CDATA[
111
+ <p>For the use of IREUS you need to upload your product catalogs data to your IREUS recommendation engine. You can do this as follows:<p>
112
+ <ol><li>Go to <a href="http://www.ireus.net/rp/setLanguage.do?ref=index.do&locale=en" target="_blank">www.ireus.net</a> and access the customer area.<li>
113
+ <li>Choose the button 'Product Data' and the option 'Http-Upload'.</li>
114
+ <li>Copy following URLs to the appropriate fields of the product upload page and the category upload page.
115
+ Replace <em>{{BaseUrl}}</em> by the base url of your Magento shop including hostname and the storecode if any
116
+ and replace <em>{{SecurityCode}}</em> by the Secutity code you entered above in the basic settings section.</li></ol>
117
+ <br>
118
+ <table>
119
+ <tr>
120
+ <td>
121
+ <label for="ireusproducts">Products: </label>
122
+ </td>
123
+ <td>
124
+ <input id="ireusproducts" type="text" size="90" class="editinput" name="ireusproducts" value="{{BaseUrl}}/ireus/export/products/code/{{SecurityCode}}" readonly>
125
+ </td>
126
+ </tr>
127
+ <tr>
128
+ <td>
129
+ <label for="ireuscategories">Categories: </label>
130
+ </td>
131
+ <td>
132
+ <input id="ireuscategories" type="text" size="90" class="editinput" name="ireuscategories" value="{{BaseUrl}}/ireus/export/categories/code/{{SecurityCode}}" readonly>
133
+ </td>
134
+ </tr>
135
+ </table>
136
+ ]]>
137
+ </comment>
138
+ <frontend_type>text</frontend_type>
139
+ <sort_order>200</sort_order>
140
+ <show_in_default>1</show_in_default>
141
+ <show_in_website>1</show_in_website>
142
+ <show_in_store>1</show_in_store>
143
+ </dataupload>
144
+ <transactions translate="label comment">
145
+ <label>Transaction Data</label>
146
+ <comment>
147
+ <![CDATA[
148
+ <p>Display recommendations immediatelly with uploading transaction data to your IREUS recommendation engine.
149
+ For downloading the needed CSV file open the following url in an internet browser after
150
+ replacing <em>{{BaseUrl}}</em> by the base url of your Magento shop including hostname and the storecode if any and
151
+ replacing <em>{{SecurityCode}}</em> by the Secutity code you entered above in the basic settings section.<p>
152
+ <p>This step is optional but recommended.</p>
153
+ <br>
154
+ <table>
155
+ <tr>
156
+ <td>
157
+ <label for="ireusorders">Orders: </label>
158
+ </td>
159
+ <td>
160
+ <input id="ireusorders" type="text" size="90" class="editinput" name="ireusorders" value="{{BaseUrl}}/ireus/export/orders/code/{{SecurityCode}}" readonly>
161
+ </td>
162
+ </tr>
163
+ </table>
164
+ ]]>
165
+ </comment>
166
+ <frontend_type>text</frontend_type>
167
+ <sort_order>300</sort_order>
168
+ <show_in_default>1</show_in_default>
169
+ <show_in_website>1</show_in_website>
170
+ <show_in_store>1</show_in_store>
171
+ </transactions>
172
+ <recommtemplates translate="label comment">
173
+ <label>Recommendation Templates</label>
174
+ <comment>
175
+ <![CDATA[
176
+ <p>You may create templates for your IREUS recommendations that fit to the design of your shop.
177
+ In the textbox below you find an example. Copy it and use it on the IREUS customer area -> designer -> own Html-Code.
178
+ There you may change these examples to your needs.</p>
179
+ <br>
180
+ <table>
181
+ <tr>
182
+ <td>
183
+ <label for="ireusrecommtemplate">Example template - product detail page:</label>
184
+
185
+ </td>
186
+ <td>
187
+ <textarea id="ireusrecommtemplate" name="ireusrecommtemplate" cols="90" rows="10" wrap="off" readonly="readonly">
188
+ #set ($locale = $conversion.toLocale("de_DE"))
189
+ #if($recommendations.size()>0)
190
+ <div class="box-collateral box-up-sell">
191
+ <h2>What other customers are interested in actually</h2>
192
+ <table cellspacing="0" id="upsell-product-table" class="products-grid">
193
+ <tbody>
194
+ <tr class="first last odd">
195
+ #foreach($recommendation in $recommendations)
196
+ <td>
197
+ <p class="product-image">
198
+ <a href="$recommendation.URL"><img alt="$recommendation.name" src="$recommendation.imageURL" /></a>
199
+ </p>
200
+ <h5><a href="$recommendation.URL">$recommendation.name</a></h5>
201
+ <div class="price-box">
202
+ <span id="product-price-25" class="regular-price"><span class="price">$number.format("currency", $recommendation.netUnitPrice, $locale)</span></span>
203
+ </div>
204
+ </td>
205
+ #end
206
+ </tr>
207
+ </tbody>
208
+ </table>
209
+ </div>
210
+ #end</textarea>
211
+ </td>
212
+ </tr>
213
+ <tr>
214
+ <td>
215
+ <label for="ireusrecommtemplate">Example template - start &amp; category pages:</label>
216
+
217
+ </td>
218
+ <td>
219
+ <textarea id="ireusrecommtemplate" name="ireusrecommtemplate" cols="90" rows="10" wrap="off" readonly="readonly">
220
+ #set ($locale = $conversion.toLocale("de_DE"))
221
+ #if($recommendations.size()>0)
222
+ <div class="block block-related">
223
+ <div class="block-title">
224
+ <strong><span>Choosen for you:</span></strong>
225
+ </div>
226
+ <div class="block-content">
227
+ <p class="block-subtitle">Items that might be of special interest for you:</p>
228
+ <ol class="mini-products-list" id="block-related">
229
+ #foreach($recommendation in $recommendations)
230
+ <li class="item odd">
231
+ <div class="product">
232
+ <a href="$recommendation.URL" title="$recommendation.name" class="product-image"><img src="$recommendation.imageURL" alt="$recommendation.name" height="50" width="50"></a>
233
+ <div class="product-details">
234
+ <p class="product-name"><a href="$recommendation.URL">$recommendation.name</a></p>
235
+ <div class="price-box">
236
+ <span class="regular-price" id="product-price-52-related">
237
+ <span class="price">$number.format("currency", $recommendation.netUnitPrice, $locale)</span>
238
+ </span>
239
+ </div>
240
+ <a href="$recommendation.param1" class="link-wishlist">Add to Wishlist</a>
241
+ </div>
242
+ </div>
243
+ </li>
244
+ #end
245
+ </ol>
246
+ </div>
247
+ </div>
248
+ #end</textarea>
249
+ </td>
250
+ </tr>
251
+
252
+ </table>
253
+ ]]>
254
+ </comment>
255
+ <frontend_type>text</frontend_type>
256
+ <sort_order>400</sort_order>
257
+ <show_in_default>1</show_in_default>
258
+ <show_in_website>1</show_in_website>
259
+ <show_in_store>1</show_in_store>
260
+ </recommtemplates>
261
+ <shoptemplates translate="label comment">
262
+ <label>Shop Template Integration</label>
263
+ <comment>
264
+ <![CDATA[
265
+ <p>Change the reference block names in the file ireus.xml for displaying IREUS recommendations in customized shop templates or for changing the position of the IREUS recommendations. You find this file in the folder: <em>/app/design/frontend/default/default/layout/</em>.</p>
266
+ ]]>
267
+ </comment>
268
+ <frontend_type>text</frontend_type>
269
+ <sort_order>500</sort_order>
270
+ <show_in_default>1</show_in_default>
271
+ <show_in_website>1</show_in_website>
272
+ <show_in_store>1</show_in_store>
273
+ </shoptemplates>
274
+ </groups>
275
+ </ireus>
276
+ </sections>
277
+ </config>
app/design/frontend/default/default/layout/ireus.xml ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * IREUS
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0).
9
+ * It is available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you are unable to obtain the license through the world-wide-web,
12
+ * please send an email to support@ireus.net so we can send you a copy.
13
+ *
14
+ * DISCLAIMER
15
+ *
16
+ * Do not edit or add to this file if you wish to upgrade Ireus to newer
17
+ * versions in the future. If you wish to customize Ireus for your
18
+ * needs please refer to http://www.ireus.net for more information.
19
+ *
20
+ * @category IREUS Recommendation Engine
21
+ * @package Ireus
22
+ * @copyright Copyright (c) 2010 prudsys AG (http://www.prudsys.com)
23
+ * @author Stephan Hoyer, Germany
24
+ * @author Silvio Steiger, Germany
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ *
27
+ * $Id$
28
+ */
29
+ -->
30
+
31
+
32
+ <layout version="0.1.0">
33
+ <catalog_product_view>
34
+ <reference name="product.info.additional">
35
+ <block type="ireus/data" name="ireus_products" before="product_tag_list" as="ireus_products" template="ireus/recomm.phtml"/>
36
+ </reference>
37
+ <reference name="before_body_end">
38
+ <block type="ireus/data" name="ireus_dataproduct" before="ireus_footer" as="ireus_dataproduct" template="ireus/data.phtml"/>
39
+ <block type="ireus/data" name="ireus_databasket" before="ireus_dataproduct" as="ireus_databasket" template="ireus/data.phtml"/>
40
+ <block type="ireus/data" name="ireus_footer" after="-" as="ireus_footer" template="ireus/footer.phtml"/>
41
+ </reference>
42
+ </catalog_product_view>
43
+
44
+ <catalog_category_layered>
45
+ <reference name="right">
46
+ <block type="ireus/data" name="ireus_products" before="right.reports.product.viewed" as="ireus_products" template="ireus/userrecomm.phtml"/>
47
+ </reference>
48
+ <reference name="before_body_end">
49
+ <block type="ireus/data" name="ireus_data" before="ireus_footer" as="ireus_data" template="ireus/data.phtml"/>
50
+ <block type="ireus/data" name="ireus_footer" after="-" as="ireus_footer" template="ireus/footer.phtml"/>
51
+ </reference>
52
+ </catalog_category_layered>
53
+
54
+ <catalog_category_default>
55
+ <reference name="right">
56
+ <block type="ireus/data" name="ireus_products" before="right.reports.product.viewed" as="ireus_products" template="ireus/userrecomm.phtml"/>
57
+ </reference>
58
+ <reference name="before_body_end">
59
+ <block type="ireus/data" name="ireus_data" before="ireus_footer" as="ireus_data" template="ireus/data.phtml"/>
60
+ <block type="ireus/data" name="ireus_footer" after="-" as="ireus_footer" template="ireus/footer.phtml"/>
61
+ </reference>
62
+ </catalog_category_default>
63
+
64
+ <checkout_cart_index>
65
+ <reference name="content">
66
+ <block type="ireus/data" name="ireus_products" after="-" as="ireus_products" template="ireus/userrecomm.phtml"/>
67
+ </reference>
68
+ <reference name="before_body_end">
69
+ <block type="ireus/data" name="ireus_databasket" before="ireus_datauser" as="ireus_databasket" template="ireus/data.phtml"/>
70
+ <block type="ireus/data" name="ireus_datauser" before="ireus_footer" as="ireus_datauser" template="ireus/data.phtml"/>
71
+ <block type="ireus/data" name="ireus_footer" after="-" as="ireus_footer" template="ireus/footer.phtml"/>
72
+ </reference>
73
+ </checkout_cart_index>
74
+
75
+ <cms_index_index>
76
+ <reference name="right">
77
+ <block type="ireus/data" name="ireus_products" before="right.reports.product.viewed" as="ireus_products" template="ireus/userrecomm.phtml"/>
78
+ </reference>
79
+ <reference name="before_body_end">
80
+ <block type="ireus/data" name="ireus_data" before="ireus_footer" as="ireus_data" template="ireus/data.phtml"/>
81
+ <block type="ireus/data" name="ireus_footer" after="-" as="ireus_footer" template="ireus/footer.phtml"/>
82
+ </reference>
83
+ </cms_index_index>
84
+
85
+ <checkout_onepage_success>
86
+ <reference name="before_body_end">
87
+ <block type="ireus/data" name="ireus_data" before="ireus_footer" as="ireus_data" template="ireus/data.phtml"/>
88
+ <block type="ireus/data" name="ireus_footer" after="-" as="ireus_footer" template="ireus/footer.phtml"/>
89
+ </reference>
90
+ </checkout_onepage_success>
91
+
92
+ <checkout_multishipping_success>
93
+ <reference name="before_body_end">
94
+ <block type="ireus/data" name="ireus_data" before="ireus_footer" as="ireus_data" template="ireus/data.phtml"/>
95
+ <block type="ireus/data" name="ireus_footer" after="-" as="ireus_footer" template="ireus/footer.phtml"/>
96
+ </reference>
97
+ </checkout_multishipping_success>
98
+
99
+ </layout>
app/design/frontend/default/default/template/ireus/data.phtml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * IREUS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0).
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to obtain the license through the world-wide-web,
11
+ * please send an email to support@ireus.net so we can send you a copy.
12
+ *
13
+ * DISCLAIMER
14
+ *
15
+ * Do not edit or add to this file if you wish to upgrade Ireus to newer
16
+ * versions in the future. If you wish to customize Ireus for your
17
+ * needs please refer to http://www.ireus.net for more information.
18
+ *
19
+ * @category IREUS Recommendation Engine
20
+ * @package Ireus
21
+ * @copyright Copyright (c) 2010 prudsys AG (http://www.prudsys.com)
22
+ * @author Stephan Hoyer, Germany
23
+ * @author Silvio Steiger, Germany
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ *
26
+ * $Id$
27
+ */
28
+ ?>
29
+
30
+
31
+ <?php if($this->isActive()): ?>
32
+ <script type="text/javascript">
33
+ //<![CDATA[
34
+ if(typeof(ireus_events) == 'undefined') var ireus_events = new Array();
35
+ var ireus = new Object(<?php echo $this->getJsonData()?>);
36
+ ireus_events.push(ireus);
37
+ //]]>
38
+ </script>
39
+ <?php endif; ?>
app/design/frontend/default/default/template/ireus/footer.phtml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * IREUS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0).
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to obtain the license through the world-wide-web,
11
+ * please send an email to support@ireus.net so we can send you a copy.
12
+ *
13
+ * DISCLAIMER
14
+ *
15
+ * Do not edit or add to this file if you wish to upgrade Ireus to newer
16
+ * versions in the future. If you wish to customize Ireus for your
17
+ * needs please refer to http://www.ireus.net for more information.
18
+ *
19
+ * @category IREUS Recommendation Engine
20
+ * @package Ireus
21
+ * @copyright Copyright (c) 2010 prudsys AG (http://www.prudsys.com)
22
+ * @author Stephan Hoyer, Germany
23
+ * @author Silvio Steiger, Germany
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ *
26
+ * $Id$
27
+ */
28
+ ?>
29
+
30
+
31
+ <?php if($this->isActive()): ?>
32
+ <script type="text/javascript">
33
+ //<![CDATA[
34
+ if ((typeof ireus_events) == 'object') {
35
+ document.write('<' + 'script type="text/javascript" async="async" src ="' + window.location.protocol + '//www.ireus.net/rp/js/ireus_v1-2.js"' + '><' + '/script' + '>');
36
+ }
37
+ //]]>
38
+ </script>
39
+ <?php endif; ?>
app/design/frontend/default/default/template/ireus/recomm.phtml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * IREUS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0).
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to obtain the license through the world-wide-web,
11
+ * please send an email to support@ireus.net so we can send you a copy.
12
+ *
13
+ * DISCLAIMER
14
+ *
15
+ * Do not edit or add to this file if you wish to upgrade Ireus to newer
16
+ * versions in the future. If you wish to customize Ireus for your
17
+ * needs please refer to http://www.ireus.net for more information.
18
+ *
19
+ * @category IREUS Recommendation Engine
20
+ * @package Ireus
21
+ * @copyright Copyright (c) 2010 prudsys AG (http://www.prudsys.com)
22
+ * @author Stephan Hoyer, Germany
23
+ * @author Silvio Steiger, Germany
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ *
26
+ * $Id$
27
+ */
28
+ ?>
29
+
30
+
31
+ <?php if($this->isActive()): ?>
32
+ <div id="ireus_recomm">
33
+ <noscript>
34
+ <?php echo $this->getCachedRecomms()?>
35
+ </noscript>
36
+ </div>
37
+ <?php endif; ?>
app/design/frontend/default/default/template/ireus/userrecomm.phtml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * IREUS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0).
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to obtain the license through the world-wide-web,
11
+ * please send an email to support@ireus.net so we can send you a copy.
12
+ *
13
+ * DISCLAIMER
14
+ *
15
+ * Do not edit or add to this file if you wish to upgrade Ireus to newer
16
+ * versions in the future. If you wish to customize Ireus for your
17
+ * needs please refer to http://www.ireus.net for more information.
18
+ *
19
+ * @category IREUS Recommendation Engine
20
+ * @package Ireus
21
+ * @copyright Copyright (c) 2010 prudsys AG (http://www.prudsys.com)
22
+ * @author Stephan Hoyer, Germany
23
+ * @author Silvio Steiger, Germany
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ *
26
+ * $Id$
27
+ */
28
+ ?>
29
+
30
+
31
+ <?php if($this->isActive()): ?>
32
+ <div id="ireus_userrecomm">
33
+ <noscript>
34
+ <?php echo $this->getCachedRecomms()?>
35
+ </noscript>
36
+ </div>
37
+ <?php endif; ?>
app/etc/modules/Netresearch_Ireus.xml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ * @category Debug
4
+ * @package Netresearch_Debug
5
+ * @author Stephan Hoyer <stephan.hoyer@netresearch.de>
6
+ * @copyright Copyright (c) 2009 Netresearch GmbH & Co.KG <http://www.netresearch.de/>
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ -->
9
+
10
+ <config>
11
+ <modules>
12
+ <Netresearch_Ireus>
13
+ <active>true</active>
14
+ <codePool>community</codePool>
15
+ </Netresearch_Ireus>
16
+ </modules>
17
+ </config>
lib/Ireus/Controller/Cache.php ADDED
@@ -0,0 +1,257 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * IREUS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0).
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to obtain the license through the world-wide-web,
11
+ * please send an email to support@ireus.net so we can send you a copy.
12
+ *
13
+ * DISCLAIMER
14
+ *
15
+ * Do not edit or add to this file if you wish to upgrade Ireus to newer
16
+ * versions in the future. If you wish to customize Ireus for your
17
+ * needs please refer to http://www.ireus.net for more information.
18
+ *
19
+ * @category IREUS Recommendation Engine
20
+ * @package Ireus_Cache
21
+ * @copyright Copyright (c) 2010 prudsys AG (http://www.prudsys.com)
22
+ * @author Silvio Steiger, Germany
23
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
24
+ *
25
+ *
26
+ * INFORMATION ABOUT CACHING IREUS CONTENT
27
+ *
28
+ * Caching of IREUS Recommendations may used ONLY for presenting content for SEARCH ENGINE CRAWLERS
29
+ * and as backup for users without JavaScript enabled. DO NOT USE THIS AS YOUR DEFAULT METHOD!
30
+ *
31
+ * If you use caching as proposed (recommended cache lifetime of some hours) you indeed don't have
32
+ * personalization features on cached content but you don't increase the response time of your shop server.
33
+ * If you decrease the cache lifetime to 0 seconds for enabling personalization features you'll
34
+ * increase the response time of your shop server because then your shop script needs to wait for response
35
+ * from ireus.net with each request for a shop page.
36
+ *
37
+ * Therefore for preseting personalized IREUS Recommendations the prefered method is client side JavaScript
38
+ * with backup from cached static IREUS Recommendations (cache lifetime = 7200 seconds is recommended).
39
+ *
40
+ */
41
+
42
+
43
+ class Ireus_Controller_Cache extends Ireus_Object
44
+ {
45
+ /**
46
+ * Cache lifetime (seconds)
47
+ * Recommended: 86400, Minimum: 7200 (not to decrease shop performance)
48
+ *
49
+ * @var int
50
+ */
51
+ protected static $_cachelifetime = 86400;
52
+
53
+
54
+ /**
55
+ * Complete cache deletion interval (days)
56
+ *
57
+ * Deleting the cache may take some seconds.
58
+ * Don't do it too often.
59
+ *
60
+ * @var int
61
+ */
62
+ protected static $_deletioninterval = 30;
63
+
64
+
65
+ /**
66
+ * Base URL for IREUS Recommendation Service
67
+ *
68
+ * @var string
69
+ */
70
+ protected static $_servleturl = 'http://www.ireus.net/ireus-server';
71
+
72
+
73
+ /**
74
+ * Gets recommendations either from cache or the Ireus Online Service
75
+ *
76
+ * @param string $reid
77
+ * @param string $event
78
+ * @param string $id
79
+ * @param string $cachepath
80
+ * @return string
81
+ */
82
+ public static function getContent ($reid, $sid, $event, $id='', $cachepath, $sidparam, $charset='UTF-8')
83
+ {
84
+ $displayerrors = ini_set("display_errors", false);
85
+
86
+ $output = '';
87
+
88
+ if (!$reid
89
+ || !$event
90
+ ) {
91
+ trigger_error('No reid/event given for caching.', E_USER_ERROR);
92
+ return false;
93
+ }
94
+
95
+ $filename = md5($event.$id).'.txt';
96
+ $file = $cachepath
97
+ . DIRECTORY_SEPARATOR
98
+ . implode(
99
+ DIRECTORY_SEPARATOR,
100
+ str_split(
101
+ substr(
102
+ $filename,
103
+ 0,
104
+ 3
105
+ )
106
+ )
107
+ )
108
+ . DIRECTORY_SEPARATOR
109
+ . $filename;
110
+
111
+ if (!is_readable($file)
112
+ || (time() - filemtime($file)) > self::$_cachelifetime
113
+ || !($output = file_get_contents($file))
114
+ ) {
115
+ // Get content from IREUS
116
+ $output = self::requestRecomms($reid, $sid, $event, $id, $output, $file, $charset);
117
+ $output = str_replace($sidparam, '', $output);
118
+
119
+ // Cache content to disk
120
+ Ireus_Model_File::writeFile($file, $output);
121
+ }
122
+
123
+ ini_set("display_errors", $displayerrors);
124
+
125
+ return $output;
126
+ }
127
+
128
+
129
+ /**
130
+ * Deletes cache completely
131
+ *
132
+ * @param string $cachepath
133
+ * @return void
134
+ */
135
+ public static function deleteCache ($cachepath)
136
+ {
137
+ $file = $cachepath
138
+ . DIRECTORY_SEPARATOR
139
+ . 'lastdeletion.txt';
140
+
141
+ if (!is_readable($file)
142
+ || (time() - filemtime($file)) > (self::$_deletioninterval * 86400)
143
+ ) {
144
+ // Delete cache
145
+ Ireus_Model_File::deleteDirectory($cachepath);
146
+
147
+ // Create lastdeletion info
148
+ Ireus_Model_File::writeFile($file, date('r', time()));
149
+ }
150
+ }
151
+
152
+
153
+ /**
154
+ * Get recommendations from IREUS Online Service or use cached recomms on error
155
+ *
156
+ * @param string $reid
157
+ * @param string $event
158
+ * @param string $id
159
+ * @param string $output
160
+ * @param string $file
161
+ * @return string
162
+ */
163
+ protected static function requestRecomms($reid, $sid, $event, $id, $output='', $file='', $charset='UTF-8')
164
+ {
165
+ $sid = md5($sid);
166
+
167
+ $requesturlpart = '/res/'.trim($reid)
168
+ . '/recomm/'.$event.'_cache'
169
+ . '/sid/'.$sid
170
+ . '';
171
+
172
+ $requestParameters = 'userID='.$sid.'&';
173
+ if ($event == 'product'
174
+ ) {
175
+ $requestParameters .= 'itemid='.$id.'&';
176
+ }
177
+ elseif ($event == 'user'
178
+ && $id
179
+ ) {
180
+ $requestParameters .= 'categoryid='.$id.'&';
181
+ }
182
+
183
+ $uri = self::$_servleturl
184
+ . $requesturlpart
185
+ . '?'
186
+ . $requestParameters
187
+ . '';
188
+
189
+ $context = stream_context_create(
190
+ array(
191
+ 'http' => array(
192
+ 'timeout' => 1.5 // seconds
193
+ )
194
+ )
195
+ );
196
+
197
+ // Get and check recomms from ireus.net
198
+ try {
199
+ $request = file_get_contents($uri, false, $context);
200
+ } catch (Exception $e) {
201
+ $request = false;
202
+ }
203
+
204
+ if ($request
205
+ ) {
206
+ if (strpos($request, 'if((typeof IreusHandler') === 0
207
+ && ($start = strpos($request, '(\'') + 2) > 2
208
+ && ($end = strpos($request, '\')', $start)) > $start
209
+ ) {
210
+ $output = str_replace(
211
+ array('\\\''),
212
+ array('\''),
213
+ iconv(
214
+ "UTF-8",
215
+ $charset,
216
+ self::decodeUnicode(
217
+ substr(
218
+ $request,
219
+ $start,
220
+ $end - $start
221
+ )
222
+ )
223
+ )
224
+ );
225
+ }
226
+ }
227
+
228
+ // Use cached output on errors
229
+ if (!$output
230
+ ) {
231
+ try {
232
+ $output = file_get_contents($file);
233
+ } catch (Exception $e) {
234
+ $output = false;
235
+ }
236
+
237
+ if (!$output
238
+ ) {
239
+ $output = '<!-- No Recommendations -->';
240
+ }
241
+ }
242
+
243
+ return $output;
244
+ }
245
+
246
+
247
+ /**
248
+ * Decodes an unicode (\uXXXX) string to utf8
249
+ *
250
+ * @param string $value
251
+ * @return string
252
+ */
253
+ protected static function decodeUnicode ($value)
254
+ {
255
+ return preg_replace("/\\\u([0-9A-F]{4})/ie", "utf8_encode(chr(hexdec('\\1')))", $value);
256
+ }
257
+ }
lib/Ireus/Controller/Export.php ADDED
@@ -0,0 +1,647 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * IREUS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0).
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to obtain the license through the world-wide-web,
11
+ * please send an email to support@ireus.net so we can send you a copy.
12
+ *
13
+ * DISCLAIMER
14
+ *
15
+ * Do not edit or add to this file if you wish to upgrade Ireus to newer
16
+ * versions in the future. If you wish to customize Ireus for your
17
+ * needs please refer to http://www.ireus.net for more information.
18
+ *
19
+ * @category IREUS Recommendation Engine
20
+ * @package Ireus_Export
21
+ * @copyright Copyright (c) 2010 prudsys AG (http://www.prudsys.com)
22
+ * @author Silvio Steiger, Germany
23
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
24
+ *
25
+ * $Id: Export.php 1555 2010-02-05 09:28:52Z sist $
26
+ */
27
+
28
+
29
+ class Ireus_Controller_Export extends Ireus_Object
30
+ {
31
+ /**
32
+ * Class constants
33
+ *
34
+ * @var mixed
35
+ */
36
+ const _QUOTING = '"';
37
+ const _COLUMNSEPARATOR = '|';
38
+ const _LINESEPARATOR = "\r\n";
39
+
40
+
41
+ /**
42
+ * Class instance
43
+ *
44
+ * @var object
45
+ */
46
+ protected static $_instance;
47
+
48
+
49
+ /**
50
+ * Key map for renaming product array keys
51
+ *
52
+ * @var array
53
+ */
54
+ protected $_productColumns;
55
+
56
+
57
+ /**
58
+ * Key map for renaming category array keys
59
+ *
60
+ * @var array
61
+ */
62
+ protected $_categoryColumns;
63
+
64
+
65
+ /**
66
+ * Key map for renaming order array keys
67
+ *
68
+ * @var array
69
+ */
70
+ protected $_orderColumns;
71
+
72
+
73
+ /**
74
+ * Key map for renaming order array keys
75
+ *
76
+ * @var array
77
+ */
78
+ protected $_sendCsvHeader = true;
79
+
80
+
81
+ /**
82
+ * Length map for Ireus product array keys
83
+ *
84
+ * @var array
85
+ */
86
+ protected $_productLengths = array(
87
+ 'pid' => array(0, 'string'),
88
+ 'netUnitPrice' => array(0, 'float'),
89
+ 'sku' => array(0, 'string'),
90
+ 'name' => array(400, 'string'),
91
+ 'masterUID' => array(0, 'string'),
92
+ 'brand' => array(60, 'string'),
93
+ 'manufacturer' => array(60, 'string'),
94
+ 'quantityUnit' => array(10, 'string'),
95
+ 'quantity' => array(0, 'integer'),
96
+ 'netPurchasePrice' => array(0, 'float'),
97
+ 'strikeOutPrice' => array(0, 'float'),
98
+ 'reward' => array(0, 'float'),
99
+ 'description' => array(2000, 'string'),
100
+ 'URL' => array(0, 'string'),
101
+ 'imageURL' => array(0, 'string'),
102
+ 'onlineFlag' => array(0, 'string'),
103
+ 'param1' => array(2000, 'string'),
104
+ 'param2' => array(2000, 'string'),
105
+ 'param3' => array(2000, 'string'),
106
+ 'param4' => array(2000, 'string'),
107
+ 'param5' => array(2000, 'string'),
108
+ //'stock' => array(0, 'integer'),
109
+ //'type' => array(0, 'string'),
110
+ //'rank' => array(0, 'float'),
111
+ //'initstock' => array(0, 'float')
112
+ );
113
+
114
+
115
+ /**
116
+ * Length map for Ireus category array keys
117
+ *
118
+ * @var array
119
+ */
120
+ protected $_categoryLengths = array(
121
+ 'pid' => array(0, 'string'),
122
+ 'cid' => array(0, 'string'),
123
+ 'cidparent' => array(0, 'string'),
124
+ 'cname' => array(200, 'string')
125
+ );
126
+
127
+
128
+ /**
129
+ * Base directory set in <base> header tag
130
+ *
131
+ * @var string
132
+ */
133
+ protected $_base;
134
+
135
+
136
+ /**
137
+ * reduce urls to url path
138
+ *
139
+ * @var string
140
+ */
141
+ protected $_removehostname = true;
142
+
143
+
144
+ /**
145
+ * reduce urls to url path
146
+ *
147
+ * @var string
148
+ */
149
+ private $_setimagedimensions = false;
150
+
151
+
152
+ /**
153
+ * Singleton pattern implementation
154
+ *
155
+ * @return Ireus_Controller_Export
156
+ */
157
+ public static function getInstance()
158
+ {
159
+ if (!self::$_instance) {
160
+ self::$_instance = new self;
161
+ }
162
+ return self::$_instance;
163
+ }
164
+
165
+
166
+ /**
167
+ * Creates CSV string with products data in Ireus format Vers. 1.0
168
+ *
169
+ * @param array $products
170
+ * @param string $baseurl
171
+ * @return string
172
+ */
173
+ public function createProductsCsv ($products)
174
+ {
175
+ $this->renameKeys($products, $this->getProductColumns());
176
+ $this->checkReward($products);
177
+ $this->cropStrings($products, $this->_productLengths);
178
+ if ($this->_setimagedimensions
179
+ ) {
180
+ $this->createImageDimensions($products);
181
+ }
182
+
183
+ $output = Ireus_Model_Csv::writeString($products, self::_QUOTING, self::_COLUMNSEPARATOR, self::_LINESEPARATOR, $this->_sendCsvHeader);
184
+ $this->_sendCsvHeader = false;
185
+
186
+ return $output;
187
+ }
188
+
189
+
190
+ /**
191
+ * Creates CSV string with categories data in Ireus format Vers. 1.0
192
+ *
193
+ * @param array $products
194
+ * @param string $baseurl
195
+ * @return string
196
+ */
197
+ public function createCategoriesCsv ($categories)
198
+ {
199
+ $this->renameKeys($categories, $this->getCategoryColumns());
200
+ $this->cropStrings($categories, $this->_categoryLengths);
201
+
202
+ $output = Ireus_Model_Csv::writeString($categories, self::_QUOTING, self::_COLUMNSEPARATOR, self::_LINESEPARATOR, $this->_sendCsvHeader);
203
+ $this->_sendCsvHeader = false;
204
+
205
+ return $output;
206
+ }
207
+
208
+
209
+ /**
210
+ * Export CSV file with historic order data
211
+ *
212
+ * @param array $orders
213
+ * @param bool $sendheader
214
+ * @return string
215
+ */
216
+ public function exportOrdersCsv ($orders, $sendheader = false)
217
+ {
218
+ $this->renameKeys($orders, $this->getOrderColumns());
219
+ $this->sortLines($orders, 'tid');
220
+
221
+ if ($sendheader) {
222
+ // send header to directly output file for download
223
+ header('Content-Type: text/csv');
224
+ header('Content-disposition: attachment; filename=HistoricOrders.csv');
225
+
226
+ echo Ireus_Model_Csv::writeString($orders, self::_QUOTING, self::_COLUMNSEPARATOR, self::_LINESEPARATOR);
227
+ }
228
+ else {
229
+
230
+ $output = Ireus_Model_Csv::writeString($orders, self::_QUOTING, self::_COLUMNSEPARATOR, self::_LINESEPARATOR, $this->_sendCsvHeader);
231
+ $this->_sendCsvHeader= false;
232
+
233
+ return $output;
234
+ }
235
+ }
236
+
237
+
238
+ /**
239
+ * Set $_base property
240
+ *
241
+ * @param string $base
242
+ * @return this
243
+ */
244
+ public function setBase($base)
245
+ {
246
+ $this->_base = $base;
247
+ return $this;
248
+ }
249
+
250
+
251
+ /**
252
+ * Set $_removehostname property, for changing urls into relative urls (default = true)
253
+ *
254
+ * @param bool $value
255
+ * @return this
256
+ */
257
+ public function disableRemoveHostname($value = true)
258
+ {
259
+ $this->_removehostname = !$value;
260
+ return $this;
261
+ }
262
+
263
+
264
+ /**
265
+ * Set $_setimagedimensions property, for filling param5 with image dimensions (default = false)
266
+ *
267
+ * @param bool $value
268
+ * @return this
269
+ */
270
+ public function setImageDimensions($value = true)
271
+ {
272
+ $this->_setimagedimensions = $value;
273
+ return $this;
274
+ }
275
+
276
+
277
+ /**
278
+ * Creates BaseURL without protocol servername and $_base directory
279
+ *
280
+ * @param string $shopurl (http://{shopdomain}/{basedir}/otherstuff
281
+ * @param string $basedir
282
+ * @return string
283
+ */
284
+ public function getPath ($shopurl)
285
+ {
286
+ if (preg_match('/^((https?)\:\/\/)/', $shopurl)) {
287
+
288
+ return preg_replace(
289
+ '/^\/*/',
290
+ '/',
291
+ preg_replace(
292
+ array('/^((https?)\:\/\/)(([a-z0-9-.]*)\.([a-z]{2,3})|localhost)/', '/'.$this->_base.'/'),
293
+ '',
294
+ $shopurl,
295
+ 1
296
+ )
297
+ );
298
+ }
299
+ elseif (preg_match('/^(([a-z0-9-.]*)\.([a-z]{2,3})|localhost)/', $shopurl)) {
300
+
301
+ return preg_replace(
302
+ '/^\/*/',
303
+ '/',
304
+ preg_replace(
305
+ array('/^(([a-z0-9-.]*)\.([a-z]{2,3})|localhost)/', '/'.$this->_base.'/'),
306
+ '',
307
+ $shopurl,
308
+ 1
309
+ )
310
+ );
311
+ }
312
+ else {
313
+
314
+ return preg_replace(
315
+ '/^\/*/',
316
+ '/',
317
+ str_replace(array($this->_base, 'localhost'), '', $shopurl));
318
+ }
319
+ }
320
+
321
+
322
+ /**
323
+ * Get product columns keymap
324
+ *
325
+ * @return array
326
+ */
327
+ protected function getProductColumns()
328
+ {
329
+ $basecolumns = array(
330
+ 'pid' => 'pid',
331
+ 'netUnitPrice' => 'netUnitPrice',
332
+ 'sku' => 'sku',
333
+ 'name' => 'name',
334
+ 'masterUID' => 'masterUID',
335
+ 'brand' => 'brand',
336
+ 'manufacturer' => 'manufacturer',
337
+ 'quantityUnit' => 'quantityUnit',
338
+ 'quantity' => 'quantity',
339
+ 'netPurchasePrice' => 'netPurchasePrice',
340
+ 'strikeOutPrice' => 'strikeOutPrice',
341
+ 'reward' => 'reward',
342
+ 'description' => 'description',
343
+ 'URL' => 'URL',
344
+ 'imageURL' => 'imageURL',
345
+ 'onlineFlag' => 'onlineFlag',
346
+ 'param1' => 'param1',
347
+ 'param2' => 'param2',
348
+ 'param3' => 'param3',
349
+ 'param4' => 'param4',
350
+ 'param5' => 'param5',
351
+ //'stock' => 'stock',
352
+ //'type' => 'type',
353
+ //'rank' => 'rank',
354
+ //'initstock' => 'initstock'
355
+ );
356
+
357
+ if (!$this->_productColumns) {
358
+ $this->_productColumns = array();
359
+ }
360
+
361
+ return array_merge($basecolumns, $this->_productColumns);
362
+ }
363
+
364
+ /**
365
+ * Set $_productColumns array
366
+ *
367
+ * @param array $keymap
368
+ * @return Ireus_Controller_Export
369
+ */
370
+ public function setProductColumns($keymap)
371
+ {
372
+ $this->_productColumns = $keymap;
373
+
374
+ return $this;
375
+ }
376
+
377
+
378
+ /**
379
+ * Get category columns keymap
380
+ *
381
+ * @return array
382
+ */
383
+ protected function getCategoryColumns()
384
+ {
385
+ $basecolumns = array(
386
+ 'pid' => 'pid',
387
+ 'cid' => 'cid',
388
+ 'cidparent' => 'cidparent',
389
+ 'cname' => 'cname'
390
+ );
391
+
392
+ if (!$this->_categoryColumns) {
393
+ $this->_categoryColumns = array();
394
+ }
395
+
396
+ return array_merge($basecolumns, $this->_categoryColumns);
397
+ }
398
+
399
+
400
+ /**
401
+ * Set $_categoryColumns array
402
+ *
403
+ * @param array $keymap
404
+ * @return Ireus_Controller_Export
405
+ */
406
+ public function setCategoryColumns($keymap)
407
+ {
408
+ $this->_categoryColumns = $keymap;
409
+
410
+ return $this;
411
+ }
412
+
413
+
414
+ /**
415
+ * Get order columns keymap
416
+ *
417
+ * @return array
418
+ */
419
+ protected function getOrderColumns()
420
+ {
421
+ $basecolumns = array(
422
+ 'tid' => 'tid',
423
+ 'pid' => 'pid',
424
+ );
425
+
426
+ if (!$this->_orderColumns) {
427
+ $this->_orderColumns = array();
428
+ }
429
+
430
+ return array_merge($basecolumns, $this->_orderColumns);
431
+ }
432
+
433
+
434
+ /**
435
+ * Set $_orderColumns array
436
+ *
437
+ * @param array $keymap
438
+ * @return Ireus_Controller_Export
439
+ */
440
+ public function setOrderColumns($keymap)
441
+ {
442
+ $this->_orderColumns = $keymap;
443
+
444
+ return $this;
445
+ }
446
+
447
+
448
+ /**
449
+ * Renames keys of given data array according to the keymap
450
+ *
451
+ * @param array $lines
452
+ * @param array $keymap
453
+ * @return null
454
+ */
455
+ protected function renameKeys(&$lines, $keymap)
456
+ {
457
+ foreach($lines as $linekey => $line) {
458
+ $array = array();
459
+ foreach ($keymap as $key => $value) {
460
+ $array[$key] = array_key_exists($value, $line) ? $line[$value] : '';
461
+ }
462
+ $lines[$linekey] = $array;
463
+ }
464
+ }
465
+
466
+
467
+ /**
468
+ * Checks reward
469
+ *
470
+ * @param array $lines
471
+ * @return null
472
+ */
473
+ protected function checkReward (&$lines)
474
+ {
475
+ $reward = false;
476
+
477
+ foreach ($lines as $key => $line
478
+ ) {
479
+ $lines[$key]['reward'] = floatval($lines[$key]['reward']);
480
+ if (!$reward) {
481
+ $reward = ($lines[$key]['reward'] == 0 ? false : true);
482
+ }
483
+ }
484
+
485
+ if (!$reward
486
+ ) {
487
+ foreach ($lines as $key => $line
488
+ ) {
489
+ $lines[$key]['reward'] = $lines[$key]['netUnitPrice'];
490
+ }
491
+ }
492
+ }
493
+
494
+
495
+ /**
496
+ * Crops and encodes given data values according to the lengthsmap
497
+ *
498
+ * @param array $lines
499
+ * @param array $lengthsmap
500
+ * @return null
501
+ */
502
+ protected function cropStrings (&$lines, $lengthsmap)
503
+ {
504
+ foreach ($lines as $linekey => $line) {
505
+ reset($lengthsmap);
506
+ while (list($key, $val) = each($lengthsmap)) {
507
+ $line[$key] = strip_tags($line[$key]);
508
+
509
+ // cast values
510
+ if (!settype($line[$key], $val[1])
511
+ ) {
512
+ trigger_error('Couldn\'t cconvert '.$key.'='.$line[$key].' into '.$val[1].'!');
513
+ }
514
+
515
+ if (!is_string($line[$key])
516
+ ) {
517
+ continue;
518
+ }
519
+ else
520
+ {
521
+ $line[$key] = str_replace(array("\n", "\r\n", "\r"), '', $line[$key]);
522
+ $line[$key] = str_replace('\'', '&#39;', $line[$key]);
523
+ }
524
+
525
+ // reduce urls by servername and basedir
526
+ if ($this->_removehostname
527
+ && ($key == 'url'
528
+ || $key == 'imageurl'
529
+ || strpos($key, 'param') !== false)
530
+ && $line[$key]
531
+ ) {
532
+ $line[$key] = $this->getPath($line[$key]);
533
+ }
534
+
535
+ // prepare fields and numbers that should be alpanumeric
536
+ if ($val[0] == 0) {
537
+ if (htmlentities($line[$key], ENT_COMPAT, 'UTF-8', false) != NULL) {
538
+ // $line[$key] = $line[$key];
539
+ }
540
+ else {
541
+ $line[$key] = utf8_encode($line[$key]);
542
+ }
543
+ }
544
+
545
+ // prepare fields that may contain everything
546
+ else {
547
+ if (($field = htmlentities($line[$key], ENT_COMPAT, 'UTF-8', false)) != NULL) {
548
+ $line[$key] = $field;
549
+ }
550
+ elseif (($field = htmlentities($line[$key], ENT_COMPAT, 'cp1252', false)) != NULL) {
551
+ $line[$key] = utf8_encode($field);
552
+ }
553
+ else {
554
+ $line[$key] = utf8_encode(htmlentities($line[$key], ENT_COMPAT, 'iso-8859-15', false));
555
+ }
556
+
557
+ // crop fields if needed
558
+ if (strlen($line[$key]) > $val[0]) {
559
+ if ($val[0] > 100) {
560
+ $line[$key] = substr($line[$key], 0, strripos(substr($line[$key], 0, $val[0]-4), ' ')).' ...';
561
+ }
562
+ elseif (($amppos = strrpos(substr($line[$key], 0, $val[0]-3), '&')) > ($val[0] - 11)) {
563
+ $line[$key] = substr($line[$key], 0, $amppos).'...';
564
+ }
565
+ else {
566
+ $line[$key] = substr($line[$key], 0, $val[0]-3).'...';
567
+ }
568
+ }
569
+ }
570
+ }
571
+ $lines[$linekey] = $line;
572
+ }
573
+ }
574
+
575
+
576
+ /**
577
+ * Sort 2-dimensional array
578
+ *
579
+ * @param array $lines (data array)
580
+ * @param string $sortkey (data key to sort)
581
+ * @return void
582
+ */
583
+ protected function sortLines (& $lines, $sortkey)
584
+ {
585
+ if (!empty($lines)
586
+ ) {
587
+ foreach ($lines as $key =>$line
588
+ ) {
589
+ $sort[$key] = $line[$sortkey];
590
+ }
591
+ array_multisort($sort, SORT_ASC, $lines);
592
+ }
593
+ }
594
+
595
+
596
+ /**
597
+ * Set param4 and param5 to image dimensions (look at PHP function: getimagesize()))
598
+ *
599
+ * @param array $products
600
+ * @return $products
601
+ */
602
+ protected function createImageDimensions (&$products)
603
+ {
604
+ // Check for free parameter 5
605
+ foreach ($products as $product
606
+ ) {
607
+ if ($product['param4'] != ''
608
+ || $product['param5'] != ''
609
+ ) {
610
+ trigger_error('Parameters 4 and 5 not empty! Can\'t save image dimensions!', E_USER_WARNING);
611
+ return;
612
+ }
613
+ }
614
+
615
+ // Get image dimensions
616
+ foreach ($products as $key => $product
617
+ ) {
618
+ if ($this->_removehostname
619
+ ) {
620
+ $file = $_SERVER['DOCUMENT_ROOT'].$this->_base.$this->getPath($product['imageURL']);
621
+ if (is_readable($file)
622
+ ) {
623
+ $is_readable = true;
624
+ }
625
+ else
626
+ {
627
+ $is_readable = false;
628
+ }
629
+ }
630
+ else
631
+ {
632
+ $file = $product['imageURL'];
633
+ $is_readable = true;
634
+ }
635
+
636
+ if ($is_readable
637
+ ) {
638
+ $imgdimensions = getimagesize($file);
639
+ if ($imgdimensions[3]
640
+ ) {
641
+ $products[$key]['param4'] = $imgdimensions[0];
642
+ $products[$key]['param5'] = $imgdimensions[1];
643
+ }
644
+ }
645
+ }
646
+ }
647
+ }
lib/Ireus/Model/Csv.php ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * IREUS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0).
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to obtain the license through the world-wide-web,
11
+ * please send an email to support@ireus.net so we can send you a copy.
12
+ *
13
+ * DISCLAIMER
14
+ *
15
+ * Do not edit or add to this file if you wish to upgrade Ireus to newer
16
+ * versions in the future. If you wish to customize Ireus for your
17
+ * needs please refer to http://www.ireus.net for more information.
18
+ *
19
+ * @category IREUS Recommendation Engine
20
+ * @package Ireus_Csv
21
+ * @copyright Copyright (c) 2010 prudsys AG (http://www.prudsys.com)
22
+ * @author Silvio Steiger, Germany
23
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
24
+ *
25
+ * $Id: Csv.php 1555 2010-02-05 09:28:52Z sist $
26
+ */
27
+
28
+
29
+ class Ireus_Model_Csv extends Ireus_Object
30
+ {
31
+ /**
32
+ * Read CSV from file
33
+ *
34
+ * @param string $filename
35
+ * @return array
36
+ */
37
+ public static function readFile ($file, $quoting = '"', $delimiter = '|', $lineending = "\r\n")
38
+ {
39
+ # Check file
40
+ if (!file_exists($file)) {
41
+ trigger_error('File does not exist: '.$file, E_USER_ERROR);
42
+ return;
43
+ }
44
+
45
+ # open the file for reading
46
+ $handle = fopen($file, "r");
47
+
48
+ # Read first line of csv file to catch the header
49
+ $header = fgetcsv($handle, 0, $delimiter);
50
+
51
+ # Read the rest of the csv file to catch the data
52
+ while (!feof($handle)) {
53
+ $line = fgetcsv($handle, 0, $delimiter, $quoting);
54
+
55
+ # built array
56
+ $array = array();
57
+ foreach ($header as $key => $val) {
58
+ $array[$val] = $line[$key];
59
+ }
60
+ $data[] = $array;
61
+ }
62
+
63
+ # Close the handle
64
+ fclose($handle);
65
+
66
+ return $data;
67
+ }
68
+
69
+
70
+ /**
71
+ * Write array to file in Csv format
72
+ *
73
+ * @param string $file
74
+ * @return array
75
+ */
76
+ public static function writeFile ($lines, $file, $quoting = '"', $delimiter = '|', $lineending = "\r\n")
77
+ {
78
+ # Check, if file is writable first.
79
+ if ($handle = fopen($file, 'w')) {
80
+
81
+ # get content as string
82
+ $content = self::writeString($lines, $quoting, $delimiter, $lineending, true);
83
+
84
+ if (fwrite($handle, $content) === FALSE) {
85
+ trigger_error('Can\'t write to file: '.$file, E_USER_ERROR);
86
+ return;
87
+ }
88
+ fclose($handle);
89
+ }
90
+ else {
91
+ trigger_error('Can\'t create or open file: '.$file, E_USER_ERROR);
92
+ }
93
+ }
94
+
95
+
96
+ /**
97
+ * Write array to string in Csv format
98
+ *
99
+ * @param string $file
100
+ * @return array
101
+ */
102
+ public static function writeString ($lines, $quoting = '"', $delimiter = '|', $lineending = "\r\n", $sendCsvHeader = true)
103
+ {
104
+ # Check parameter
105
+ if (!is_array(reset($lines))
106
+ ){
107
+ return false;
108
+ }
109
+
110
+ $string = '';
111
+
112
+ # write header
113
+ if ($sendCsvHeader
114
+ ) {
115
+ $string = implode(array_keys(reset($lines)), $delimiter) . $lineending;
116
+ }
117
+
118
+ # write data
119
+ foreach ($lines as $line
120
+ ) {
121
+ foreach ($line as $key => $value
122
+ ) {
123
+ if (is_string($value)
124
+ ) {
125
+ $string .= $quoting . $value . $quoting . $delimiter;
126
+ }
127
+ else
128
+ {
129
+ $string .= $value . $delimiter;
130
+ }
131
+ }
132
+ $string = rtrim($string, $delimiter);
133
+ $string .= $lineending;
134
+ }
135
+
136
+ return $string;
137
+ }
138
+ }
lib/Ireus/Model/File.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * IREUS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0).
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to obtain the license through the world-wide-web,
11
+ * please send an email to support@ireus.net so we can send you a copy.
12
+ *
13
+ * DISCLAIMER
14
+ *
15
+ * Do not edit or add to this file if you wish to upgrade Ireus to newer
16
+ * versions in the future. If you wish to customize Ireus for your
17
+ * needs please refer to http://www.ireus.net for more information.
18
+ *
19
+ * @category IREUS Recommendation Engine
20
+ * @package Ireus_File
21
+ * @copyright Copyright (c) 2010 prudsys AG (http://www.prudsys.com)
22
+ * @author Silvio Steiger, Germany
23
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
24
+ *
25
+ */
26
+
27
+
28
+ class Ireus_Model_File extends Ireus_Object
29
+ {
30
+ /**
31
+ * Deletes directory recursively
32
+ *
33
+ * @param string $dir
34
+ * @return void
35
+ */
36
+ public static function deleteDirectory ($dir)
37
+ {
38
+ if (is_dir($dir)
39
+ && substr($dir, -1) !== '/'
40
+ ) {
41
+ $dir .= '/';
42
+ }
43
+
44
+ $files = glob($dir . '*', GLOB_MARK);
45
+ foreach ($files as $file)
46
+ {
47
+ if (is_dir($file)
48
+ ) {
49
+ self::deleteDirectory($file);
50
+ }
51
+ else
52
+ {
53
+ unlink($file);
54
+ }
55
+ }
56
+
57
+ if (is_dir($dir)
58
+ ) {
59
+ rmdir($dir);
60
+ }
61
+ }
62
+
63
+
64
+ /**
65
+ * Write file to disk
66
+ *
67
+ * @param string $file
68
+ * @param string $content
69
+ * @return array
70
+ */
71
+ public static function writeFile ($file, $content)
72
+ {
73
+ $path = dirname($file);
74
+ if (!is_writable($path)
75
+ ) {
76
+ if (!mkdir($path, 0777, true)
77
+ ) {
78
+ trigger_error('Can\t create or write to directory: '.$path, E_USER_ERROR);
79
+ return false;
80
+ };
81
+ }
82
+
83
+ if ($handle = fopen($file, 'w')
84
+ ) {
85
+ if (fwrite($handle, $content) === false
86
+ ) {
87
+ trigger_error('Can\'t write to file: '.$file, E_USER_ERROR);
88
+ return;
89
+ }
90
+ fclose($handle);
91
+ }
92
+ else
93
+ {
94
+ trigger_error('Can\'t create or open file: '.$file, E_USER_ERROR);
95
+ }
96
+ }
97
+ }
lib/Ireus/Object.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * IREUS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0).
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to obtain the license through the world-wide-web,
11
+ * please send an email to support@ireus.net so we can send you a copy.
12
+ *
13
+ * DISCLAIMER
14
+ *
15
+ * Do not edit or add to this file if you wish to upgrade Ireus to newer
16
+ * versions in the future. If you wish to customize Ireus for your
17
+ * needs please refer to http://www.ireus.net for more information.
18
+ *
19
+ * @category IREUS Recommendation Engine
20
+ * @package Ireus
21
+ * @copyright Copyright (c) 2010 prudsys AG (http://www.prudsys.com)
22
+ * @author Silvio Steiger, Germany
23
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
24
+ *
25
+ * $Id: Object.php 1555 2010-02-05 09:28:52Z sist $
26
+ */
27
+
28
+ // load manually all first level classes if no autoloading
29
+ if (class_exists('IreusAutoloader') && !IreusAutoloader::getInstance()->_autoload) {
30
+ IreusAutoloader::getInstance()->autoload('Ireus_Controller_Export');
31
+ IreusAutoloader::getInstance()->autoload('Ireus_Controller_Cache');
32
+ IreusAutoloader::getInstance()->autoload('Ireus_Model_Csv');
33
+ IreusAutoloader::getInstance()->autoload('Ireus_Model_File');
34
+ IreusAutoloader::getInstance()->autoload('Ireus_View_Client');
35
+ }
36
+
37
+
38
+ abstract class Ireus_Object
39
+ {
40
+ }
lib/Ireus/View/Client.php ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * IREUS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0).
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to obtain the license through the world-wide-web,
11
+ * please send an email to support@ireus.net so we can send you a copy.
12
+ *
13
+ * DISCLAIMER
14
+ *
15
+ * Do not edit or add to this file if you wish to upgrade Ireus to newer
16
+ * versions in the future. If you wish to customize Ireus for your
17
+ * needs please refer to http://www.ireus.net for more information.
18
+ *
19
+ * @category IREUS Recommendation Engine
20
+ * @package Ireus_Client
21
+ * @copyright Copyright (c) 2010 prudsys AG (http://www.prudsys.com)
22
+ * @author Silvio Steiger, Germany
23
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
24
+ *
25
+ * $Id: Client.php 1555 2010-02-05 09:28:52Z sist $
26
+ */
27
+
28
+
29
+ class Ireus_View_Client extends Ireus_Object
30
+ {
31
+
32
+ /**
33
+ * Returns an html chunk with Ireus event definitions
34
+ *
35
+ * @param string $event
36
+ * @param array $params
37
+ * @return string
38
+ */
39
+ public static function getEvent($event, $params, $cachedrecomms='')
40
+ {
41
+ switch ($event) {
42
+ case 'home':
43
+ case 'user':
44
+ $output = self::getView($event);
45
+ $output .= self::getView('event');
46
+ break;
47
+
48
+ case 'product':
49
+ $output = self::getView('product');
50
+ $output .= self::getView('event');
51
+ break;
52
+
53
+ case 'basket':
54
+ case 'order':
55
+ default:
56
+ $output = self::getView('event');
57
+ }
58
+
59
+ $placeholdervalues = array(
60
+ 'IreusEventParams' => json_encode($params),
61
+ 'IreusCachedRecomms' => $cachedrecomms
62
+ );
63
+
64
+ return self::fillView($output, $placeholdervalues);
65
+ }
66
+
67
+
68
+ /**
69
+ * Returns an html chunk with Ireus call definition
70
+ *
71
+ * @return string
72
+ */
73
+ public static function getCall()
74
+ {
75
+ return self::getView('call');
76
+ }
77
+
78
+
79
+ /**
80
+ * Loads view template
81
+ *
82
+ * @param string $tpl
83
+ * @return string
84
+ */
85
+ protected static function getView($tpl)
86
+ {
87
+ $filename = dirname(__FILE__). DIRECTORY_SEPARATOR . 'Client' . DIRECTORY_SEPARATOR . $tpl . '.tpl.php';
88
+ if (!is_file($filename)) {
89
+ echo 'Errortest: '.trigger_error($filename.' not found.', E_USER_WARNING);
90
+ return false;
91
+ }
92
+
93
+ try {
94
+ $contents = file_get_contents($filename);
95
+ } catch (Exception $e) {
96
+ trigger_error('Can\'t read file: '.$filename, E_USER_WARNING);
97
+ return false;
98
+ }
99
+
100
+ return $contents;
101
+ }
102
+
103
+
104
+ /**
105
+ * Fills an html chunk with values
106
+ *
107
+ * @param string $view (html chunk with placeholders)
108
+ * @param array $params (array of 'placeholdername' => 'value')
109
+ * @return string
110
+ */
111
+ protected static function fillView($view, $params)
112
+ {
113
+ foreach ($params as $key => $val) {
114
+ $view = str_replace('[[+'.$key.']]', $val, $view);
115
+ }
116
+
117
+ // Clean
118
+ $view = preg_replace('/\[\[\+.+?\]\]/', '', $view);
119
+
120
+ return $view;
121
+ }
122
+ }
lib/Ireus/View/Client/call.tpl.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <script type="text/javascript">
2
+ //<![CDATA[
3
+ if ((typeof ireus_events) == 'object') {
4
+ document.write('<' + 'script type="text/javascript" async="async" src ="' + window.location.protocol + '//www.ireus.net/rp/js/ireus_v1-2.js"' + '><' + '/script' + '>');
5
+ }
6
+ //]]>
7
+ </script>
lib/Ireus/View/Client/event.tpl.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <script type="text/javascript">
2
+ //<![CDATA[
3
+ if(typeof(ireus_events) == 'undefined') var ireus_events = new Array();
4
+ var ireus = new Object([[+IreusEventParams]]);
5
+ ireus_events.push(ireus);
6
+ //]]>
7
+ </script>
lib/Ireus/View/Client/home.tpl.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <div id="ireus_userrecomm">
2
+ <noscript>
3
+ [[+IreusCachedRecomms]]
4
+ </noscript>
5
+ </div>
lib/Ireus/View/Client/product.tpl.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <div id="ireus_recomm">
2
+ <noscript>
3
+ [[+IreusCachedRecomms]]
4
+ </noscript>
5
+ </div>
lib/Ireus/View/Client/user.tpl.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <div id="ireus_userrecomm">
2
+ <noscript>
3
+ [[+IreusCachedRecomms]]
4
+ </noscript>
5
+ </div>
lib/IreusAutoloader.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * IREUS
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0).
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to obtain the license through the world-wide-web,
11
+ * please send an email to support@ireus.net so we can send you a copy.
12
+ *
13
+ * DISCLAIMER
14
+ *
15
+ * Do not edit or add to this file if you wish to upgrade Ireus to newer
16
+ * versions in the future. If you wish to customize Ireus for your
17
+ * needs please refer to http://www.ireus.net for more information.
18
+ *
19
+ * @category IREUS Recommendation Engine
20
+ * @package IreusAutoloader
21
+ * @copyright Copyright (c) 2010 prudsys AG (http://www.prudsys.com)
22
+ * @author Silvio Steiger, Germany
23
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
24
+ */
25
+
26
+
27
+ // Activate IREUS PHP Framework autoloading
28
+ // via SPL autoload stack.
29
+ // Zend compatible autoloaders load IREUS automatically
30
+ // if includepath to IREUS is correctly set.
31
+ #IreusAutoloader::getInstance()->register();
32
+
33
+ // load manually if no autoloading (loads classes if used or not)
34
+ #if (!IreusAutoloader::getInstance()->_autoload) {
35
+ # IreusAutoloader::getInstance()->autoload('Ireus_Object');
36
+ #}
37
+
38
+
39
+ final class IreusAutoloader
40
+ {
41
+ /**
42
+ * Class instance
43
+ *
44
+ * @var object
45
+ */
46
+ public static $_instance;
47
+
48
+
49
+ /**
50
+ * Use autoload marker
51
+ *
52
+ * @var bool
53
+ */
54
+ public $_autoload;
55
+
56
+
57
+ /**
58
+ * Singleton pattern implementation
59
+ *
60
+ * @return IreusAutoloader
61
+ */
62
+ public static function getInstance()
63
+ {
64
+ if (!self::$_instance) {
65
+ self::$_instance = new self;
66
+ }
67
+ return self::$_instance;
68
+ }
69
+
70
+
71
+ /**
72
+ * Register SPL autoload function
73
+ *
74
+ * @return Null
75
+ */
76
+ public function register()
77
+ {
78
+ spl_autoload_register(array(self::getInstance(), 'autoload'));
79
+ if (strpos(get_include_path(), dirname(__FILE__)) === false
80
+ ) {
81
+ set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__));
82
+ }
83
+ $this->_autoload = true;
84
+
85
+ // for compatibility reasons
86
+ if (function_exists('__autoload')) {
87
+ spl_autoload_register('__autoload');
88
+ }
89
+ }
90
+
91
+
92
+ /**
93
+ * Load class source code
94
+ *
95
+ * @param string $class
96
+ * @return included file or false
97
+ */
98
+ public function autoload($class)
99
+ {
100
+ $classFile = str_replace(' ', DIRECTORY_SEPARATOR, ucwords(str_replace('_', ' ', $class))).'.php';
101
+
102
+ foreach (explode(PATH_SEPARATOR, get_include_path()) as $path) {
103
+ if (file_exists($path . DIRECTORY_SEPARATOR . $classFile)) {
104
+ return include_once $classFile;
105
+ }
106
+ }
107
+ return false;
108
+ }
109
+ }
package.xml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>IREUS_Recommendation_Engine_Interface</name>
4
+ <version>2.2.4</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL V3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Impoves caching of static recommendations for SEO and recommendation statistics; Decreases the download time of product and catalog data;</summary>
10
+ <description>With prudsys IREUS - the real-time recommendation engine of the Data Mining specialist prudsys - you can customise the product recommendations in your online shop. Using the click behaviour prudsys IREUS can determine each visitor's current buying interest in real-time and recommend products that are highly relevant based on this.
11
+
12
+ Your benefit: Increasing the conversion rate and revenue from your online shop.
13
+
14
+ Additionally prudsys IREUS optimises the quality of the recommendations on an ongoing basis in real-time by analysing the responses of the users to the recommendations. Integrated statistics show the acceptance of the recommendations and the revenue thus generated.
15
+
16
+ prudsys IREUS is based on the prudsys Realtime Decisioning Engine (prudsys RDE), the leading real-time analytics application in Germany. With the prudsys IREUS Magento connector you benefit from the easy integration of the prudsys IREUS recommendation engine in your own online shop.
17
+
18
+ The registration for prudsys IREUS is free of charge at: www.ireus.net.</description>
19
+ <notes>Log out and log in after install to get access to the configuration interface! You will find it in the menu [System -&gt; Configuration -&gt; IREUS Recommendation Engine]</notes>
20
+ <authors><author><name>prudsys IREUS Support Team</name><user>auto-converted</user><email>support@ireus.net</email></author></authors>
21
+ <date>2010-11-30</date>
22
+ <time>12:54:58</time>
23
+ <contents><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="ireus.xml" hash="d2a0f76c8917d6891423029acd1db2a4"/></dir><dir name="template"><dir name="ireus"><file name="data.phtml" hash="914c75fc9f1f09b3ec914a5aa12e1a71"/><file name="footer.phtml" hash="4f8718b50744c98cec9d1ffce31e2242"/><file name="recomm.phtml" hash="c56c8aa10531782cb0237a5cd7a715ad"/><file name="userrecomm.phtml" hash="879f8c79109f82ceff8a3c03d0c3ce1b"/></dir></dir></dir></dir></dir></target><target name="mage"><dir name="lib"><dir name="Ireus"><file name="Object.php" hash="cf2c29389d0ae7c04858d763e074e4f3"/><dir name="Controller"><file name="Cache.php" hash="3df552a3caf67a320e7088f499bf3534"/><file name="Export.php" hash="389b64cb5ae302090f07f71ff937dd86"/></dir><dir name="Model"><file name="Csv.php" hash="925df2eec3f91eef4916ec8b40c01253"/><file name="File.php" hash="24afa81bbeabf0261eaae12ccda94193"/></dir><dir name="View"><file name="Client.php" hash="c1739c7d943f63863a2bd7b546db3a6a"/><dir name="Client"><file name="call.tpl.php" hash="75da798d5fd4d21208fe636a12b3085c"/><file name="event.tpl.php" hash="d3ae7d342b6805f94e61b10aff601c10"/><file name="home.tpl.php" hash="966b74dae389541a20366d54fb8cb63c"/><file name="product.tpl.php" hash="ceba16f08b72b43f84378cdc22094492"/><file name="user.tpl.php" hash="966b74dae389541a20366d54fb8cb63c"/></dir></dir></dir><file name="IreusAutoloader.php" hash="4c6d6bec65a2d8f196e3a9d3b94114b8"/></dir></target><target name="mageetc"><dir name="modules"><file name="Netresearch_Ireus.xml" hash="51f0d7dfc505541ad5bbd81cac334a4c"/></dir></target><target name="magecommunity"><dir name="Netresearch"><dir name="Ireus"><dir name="Block"><file name="Data.php" hash="3ff307908696c365004c97da627fd70d"/><dir name="Catalog"><dir name="Product"><dir name="List"><file name="Upsell.php" hash="2063a8463153a5e74ab11333f6112c74"/></dir></dir></dir><dir name="Checkout"><dir name="Multishipping"><file name="Success.php" hash="72495e9ef43ab32d78ac9b225ad25e7b"/></dir></dir></dir><dir name="controllers"><file name="ExportController.php" hash="b4ee2c7737a2977d042b3ce64785898d"/></dir><dir name="etc"><file name="config.xml" hash="7f84d0b692e329b9c3b9bedbad2af2b9"/><file name="system.xml" hash="e16445be0775c0d7928080f6a8f20c12"/></dir><dir name="Helper"><file name="Data.php" hash="166807c6ae52889ee30ae9d5d9760f06"/></dir><dir name="Model"><file name="Observer.php" hash="1722435a09f1ec005ea85831f1efd9b8"/></dir></dir></dir></target></contents>
24
+ <compatible/>
25
+ <dependencies/>
26
+ </package>