Flagbit_Factfinder - Version 3.3.11

Version Notes

feature: Secondary FACT-Finder channels can be set up in the configuration, which are independent of Magento Data (to search through content pages for instance)

Download this release

Release Info

Developer Rudolf Batt
Extension Flagbit_Factfinder
Version 3.3.11
Comparing to
See all releases


Code changes from version 3.3.10 to 3.3.11

Files changed (76) hide show
  1. app/code/community/Flagbit/FactFinder/Block/Secondaryresult.php +12 -0
  2. app/code/community/Flagbit/FactFinder/Helper/Debug.php +26 -11
  3. app/code/community/Flagbit/FactFinder/Helper/Search.php +55 -51
  4. app/code/community/Flagbit/FactFinder/Model/Adapter.php +113 -3
  5. app/code/community/Flagbit/FactFinder/etc/config.xml +1 -1
  6. app/code/community/Flagbit/FactFinder/etc/system.xml +13 -4
  7. app/design/frontend/base/default/layout/factfinder.xml +4 -3
  8. app/design/frontend/base/default/template/factfinder/secondaryresult.phtml +41 -0
  9. app/locale/de_DE/Flagbit_FactFinder.csv +6 -2
  10. lib/FACTFinder/Abstract/Adapter.php +127 -117
  11. lib/FACTFinder/Abstract/CompareAdapter.php +60 -53
  12. lib/FACTFinder/Abstract/Configuration.php +158 -152
  13. lib/FACTFinder/Abstract/DataProvider.php +121 -111
  14. lib/FACTFinder/Abstract/ImportAdapter.php +55 -0
  15. lib/FACTFinder/Abstract/Logger.php +23 -0
  16. lib/FACTFinder/Abstract/ProductCampaignAdapter.php +72 -65
  17. lib/FACTFinder/Abstract/RecommendationAdapter.php +94 -87
  18. lib/FACTFinder/Abstract/ScicAdapter.php +158 -151
  19. lib/FACTFinder/Abstract/SearchAdapter.php +260 -252
  20. lib/FACTFinder/Abstract/SimilarRecordsAdapter.php +84 -77
  21. lib/FACTFinder/Abstract/SuggestAdapter.php +39 -32
  22. lib/FACTFinder/Abstract/TagCloudAdapter.php +36 -29
  23. lib/FACTFinder/AdvisorAnswer.php +27 -19
  24. lib/FACTFinder/AdvisorQuestion.php +18 -10
  25. lib/FACTFinder/Asn.php +36 -29
  26. lib/FACTFinder/AsnFilterItem.php +71 -64
  27. lib/FACTFinder/AsnGroup.php +134 -127
  28. lib/FACTFinder/AsnSliderFilter.php +130 -123
  29. lib/FACTFinder/BreadCrumbItem.php +74 -67
  30. lib/FACTFinder/Campaign.php +205 -197
  31. lib/FACTFinder/CampaignIterator.php +189 -181
  32. lib/FACTFinder/Configuration.php +332 -325
  33. lib/FACTFinder/EncodingHandler.php +218 -208
  34. lib/FACTFinder/Http/DataProvider.php +308 -290
  35. lib/FACTFinder/Http/DummyProvider.php +72 -66
  36. lib/FACTFinder/Http/ParallelDataProvider.php +139 -127
  37. lib/FACTFinder/Http/ScicAdapter.php +35 -28
  38. lib/FACTFinder/Http/SuggestAdapter.php +40 -34
  39. lib/FACTFinder/Item.php +54 -47
  40. lib/FACTFinder/Loader.php +191 -184
  41. lib/FACTFinder/Log4PhpLogger.php +86 -0
  42. lib/FACTFinder/Logger/BlackHole.php +0 -7
  43. lib/FACTFinder/Logger/LoggerInterface.php +0 -6
  44. lib/FACTFinder/NullLogger.php +24 -0
  45. lib/FACTFinder/Paging.php +177 -170
  46. lib/FACTFinder/Parameters.php +112 -105
  47. lib/FACTFinder/ParametersParser.php +378 -371
  48. lib/FACTFinder/ProductsPerPageOptions.php +85 -78
  49. lib/FACTFinder/Record.php +258 -251
  50. lib/FACTFinder/Result.php +40 -33
  51. lib/FACTFinder/SingleWordSearchItem.php +45 -38
  52. lib/FACTFinder/SuggestQuery.php +77 -70
  53. lib/FACTFinder/TagQuery.php +47 -40
  54. lib/FACTFinder/Util.php +56 -47
  55. lib/FACTFinder/Xml64/SearchAdapter.php +114 -110
  56. lib/FACTFinder/Xml65/ImportAdapter.php +84 -0
  57. lib/FACTFinder/Xml65/RecommendationAdapter.php +90 -83
  58. lib/FACTFinder/Xml65/SearchAdapter.php +479 -492
  59. lib/FACTFinder/Xml65/SuggestAdapter.php +64 -58
  60. lib/FACTFinder/Xml65/TagCloudAdapter.php +64 -61
  61. lib/FACTFinder/Xml66/CompareAdapter.php +26 -25
  62. lib/FACTFinder/Xml66/ImportAdapter.php +22 -0
  63. lib/FACTFinder/Xml66/RecommendationAdapter.php +22 -15
  64. lib/FACTFinder/Xml66/SearchAdapter.php +119 -114
  65. lib/FACTFinder/Xml66/SimilarRecordsAdapter.php +24 -23
  66. lib/FACTFinder/Xml66/SuggestAdapter.php +21 -14
  67. lib/FACTFinder/Xml66/TagCloudAdapter.php +22 -15
  68. lib/FACTFinder/Xml67/CompareAdapter.php +7 -0
  69. lib/FACTFinder/Xml67/ImportAdapter.php +19 -0
  70. lib/FACTFinder/Xml67/ProductCampaignAdapter.php +96 -93
  71. lib/FACTFinder/Xml67/RecommendationAdapter.php +27 -20
  72. lib/FACTFinder/Xml67/SearchAdapter.php +88 -83
  73. lib/FACTFinder/Xml67/SimilarRecordsAdapter.php +7 -0
  74. lib/FACTFinder/Xml67/SuggestAdapter.php +7 -0
  75. lib/FACTFinder/Xml67/TagCloudAdapter.php +7 -0
  76. package.xml +5 -5
app/code/community/Flagbit/FactFinder/Block/Secondaryresult.php ADDED
@@ -0,0 +1,12 @@
1
+ <?php
2
+ class Flagbit_FactFinder_Block_Secondaryresult extends Mage_Core_Block_Template
3
+ {
4
+ protected function getSecondaryResult($channel)
5
+ {
6
+ $adapter = Mage::getSingleton('factfinder/adapter');
7
+
8
+ $result = $adapter->getSecondarySearchResult($channel);
9
+
10
+ return $result;
11
+ }
12
+ }
app/code/community/Flagbit/FactFinder/Helper/Debug.php CHANGED
@@ -20,7 +20,7 @@
20
* @version $Id$
21
*/
22
class Flagbit_FactFinder_Helper_Debug extends Mage_Core_Helper_Abstract
23
- implements FACTFinder_Logger_LoggerInterface
24
{
25
/**
26
* Module Configuration File
@@ -64,16 +64,31 @@ class Flagbit_FactFinder_Helper_Debug extends Mage_Core_Helper_Abstract
64
65
return $this;
66
}
67
-
68
- public function error($error)
69
- {
70
- return $this->log('ERROR: ' . $error);
71
- }
72
-
73
- public function info($message)
74
- {
75
- return $this->log('INFO: ' . $message);
76
- }
77
78
/**
79
* get Class Rewrite Conflicts for the current Modul
20
* @version $Id$
21
*/
22
class Flagbit_FactFinder_Helper_Debug extends Mage_Core_Helper_Abstract
23
+ implements FACTFinder_Abstract_Logger
24
{
25
/**
26
* Module Configuration File
64
65
return $this;
66
}
67
+
68
+ public function trace($message)
69
+ {
70
+ return $this->log('TRACE: ' . $message);
71
+ }
72
+ public function debug($message)
73
+ {
74
+ return $this->log('DEBUG: ' . $message);
75
+ }
76
+ public function info($message)
77
+ {
78
+ return $this->log('INFO: ' . $message);
79
+ }
80
+ public function warn($message)
81
+ {
82
+ return $this->log('WARNING: ' . $message);
83
+ }
84
+ public function error($message)
85
+ {
86
+ return $this->log('ERROR: ' . $message);
87
+ }
88
+ public function fatal($message)
89
+ {
90
+ return $this->log('FATAL ERROR: ' . $message);
91
+ }
92
93
/**
94
* get Class Rewrite Conflicts for the current Modul
app/code/community/Flagbit/FactFinder/Helper/Search.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
/**
3
* Flagbit_FactFinder
4
*
@@ -9,10 +9,10 @@
9
10
/**
11
* Helper class
12
- *
13
- * This helper class provides some Methods which allows us
14
- * to get default und current Values from Toolbar block.
15
- *
16
* @category Mage
17
* @package Flagbit_FactFinder
18
* @copyright Copyright (c) 2010 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
@@ -20,24 +20,24 @@
20
* @version $Id$
21
*/
22
class Flagbit_FactFinder_Helper_Search extends Mage_Core_Helper_Abstract {
23
-
24
/**
25
* XML Config Path to Product Identifier Setting
26
- *
27
* @var string
28
*/
29
- const XML_CONFIG_PATH_PRODUCT_IDENTIFIER = 'factfinder/config/identifier';
30
-
31
/**
32
* XML Config Path to Product Identifier Setting
33
- *
34
* @var string
35
*/
36
- const XML_CONFIG_PATH_USE_PROXY = 'factfinder/config/proxy';
37
-
38
/**
39
* if FACT-Finder enabled?
40
- *
41
* @return boolean
42
*/
43
public function getIsEnabled($searchPageCheck = true, $functionality = '')
@@ -47,9 +47,9 @@ class Flagbit_FactFinder_Helper_Search extends Mage_Core_Helper_Abstract {
47
|| ($searchPageCheck == true && !$this->getIsOnSearchPage() && !Mage::getStoreConfigFlag('factfinder/activation/navigation'))) {
48
return false;
49
}
50
-
51
$result = true;
52
-
53
if ($functionality) {
54
switch ($functionality) {
55
case 'suggest':
@@ -74,35 +74,35 @@ class Flagbit_FactFinder_Helper_Search extends Mage_Core_Helper_Abstract {
74
break;
75
}
76
}
77
-
78
return $result;
79
}
80
-
81
/**
82
* get Module Status depending on Module
83
- *
84
* @return boolean
85
*/
86
public function getIsOnSearchPage()
87
{
88
- return Mage::app()->getRequest()->getModuleName() == 'catalogsearch' || Mage::app()->getRequest()->getModuleName() == 'xmlconnect';
89
}
90
-
91
-
92
/**
93
* get Toolbar Block
94
- *
95
* @return Mage_Catalog_Block_Product_List_Toolbar
96
*/
97
protected function _getToolbarBlock()
98
- {
99
$mainBlock = Mage::app()->getLayout()->getBlock('search.result');
100
if($mainBlock instanceof Mage_CatalogSearch_Block_Result){
101
$toolbarBlock = $mainBlock->getListBlock()->getToolbarBlock();
102
}else{
103
$toolbarBlock = Mage::app()->getLayout()->createBlock('catalog/product_list_toolbar');
104
}
105
-
106
return $toolbarBlock;
107
}
108
@@ -114,11 +114,11 @@ class Flagbit_FactFinder_Helper_Search extends Mage_Core_Helper_Abstract {
114
public function getDefaultPerPageValue()
115
{
116
return $this->_getToolbarBlock()->getDefaultPerPageValue();
117
- }
118
-
119
/**
120
* get Entity ID Field Name by Configuration or via Entity
121
- *
122
* @return string
123
*/
124
public function getIdFieldName()
@@ -126,69 +126,73 @@ class Flagbit_FactFinder_Helper_Search extends Mage_Core_Helper_Abstract {
126
$idFieldName = Mage::getStoreConfig(self::XML_CONFIG_PATH_PRODUCT_IDENTIFIER);
127
if(!$idFieldName){
128
$idFieldName = $this->getEntity()->getIdFieldName();
129
- }
130
return $idFieldName;
131
}
132
-
133
/**
134
* get FACT-Finder Suggest URL
135
- *
136
* @return string
137
*/
138
public function getSuggestUrl()
139
{
140
$url = Mage::getSingleton('factfinder/adapter')->getSuggestUrl();
141
- if(Mage::getStoreConfig(self::XML_CONFIG_PATH_USE_PROXY)){
142
- $url = $this->_getUrl('factfinder/proxy/suggest');
143
}
144
return $url;
145
}
146
-
147
148
/**
149
* get current Order
150
- *
151
* @return string
152
*/
153
public function getCurrentOrder()
154
{
155
return $this->_getToolbarBlock()->getCurrentOrder();
156
}
157
-
158
/**
159
* get current Order Direction
160
- *
161
* @return string
162
*/
163
public function getCurrentDirection()
164
{
165
return $this->_getToolbarBlock()->getCurrentDirection();
166
}
167
-
168
/**
169
* get Page Limit
170
- *
171
* @return int
172
*/
173
public function getPageLimit()
174
{
175
- $limit = $this->_getToolbarBlock()->getLimit();
176
if ($limit == 'all') {
177
$limit = 2*3*4*5*6; //a lot of products working for each layout
178
}
179
return $limit;
180
}
181
-
182
/**
183
* get current Page Number
184
- *
185
* @return int
186
*/
187
public function getCurrentPage()
188
{
189
- return $this->_getToolbarBlock()->getCurrentPage();
190
}
191
-
192
/**
193
* Retrieve query model object
194
*
@@ -198,7 +202,7 @@ class Flagbit_FactFinder_Helper_Search extends Mage_Core_Helper_Abstract {
198
{
199
return Mage::helper('catalogsearch')->getQuery();
200
}
201
-
202
/**
203
* Retrieve query model object
204
*
@@ -208,11 +212,11 @@ class Flagbit_FactFinder_Helper_Search extends Mage_Core_Helper_Abstract {
208
{
209
return Mage::helper('catalogsearch')->getQueryText();
210
}
211
-
212
-
213
/**
214
* return product campaings
215
- *
216
* @param array $productIds
217
* @return FACTFinder_CampaignIterator
218
*/
@@ -220,13 +224,13 @@ class Flagbit_FactFinder_Helper_Search extends Mage_Core_Helper_Abstract {
220
{
221
try {
222
// get productcampaign adapter and set product id or sku array
223
- $productCampaignAdapter = Mage::getModel('factfinder/adapter')->getProductCampaignAdapter();
224
- $productCampaignAdapter->setProductIds($productIds);
225
$productCampaignAdapter->makeProductCampaign();
226
-
227
return $productCampaignAdapter->getCampaigns();
228
} catch(Exception $e) {
229
return array();
230
- }
231
}
232
}
1
+ <?php
2
/**
3
* Flagbit_FactFinder
4
*
9
10
/**
11
* Helper class
12
+ *
13
+ * This helper class provides some Methods which allows us
14
+ * to get default und current Values from Toolbar block.
15
+ *
16
* @category Mage
17
* @package Flagbit_FactFinder
18
* @copyright Copyright (c) 2010 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
20
* @version $Id$
21
*/
22
class Flagbit_FactFinder_Helper_Search extends Mage_Core_Helper_Abstract {
23
+
24
/**
25
* XML Config Path to Product Identifier Setting
26
+ *
27
* @var string
28
*/
29
+ const XML_CONFIG_PATH_PRODUCT_IDENTIFIER = 'factfinder/config/identifier';
30
+
31
/**
32
* XML Config Path to Product Identifier Setting
33
+ *
34
* @var string
35
*/
36
+ const XML_CONFIG_PATH_USE_PROXY = 'factfinder/config/proxy';
37
+
38
/**
39
* if FACT-Finder enabled?
40
+ *
41
* @return boolean
42
*/
43
public function getIsEnabled($searchPageCheck = true, $functionality = '')
47
|| ($searchPageCheck == true && !$this->getIsOnSearchPage() && !Mage::getStoreConfigFlag('factfinder/activation/navigation'))) {
48
return false;
49
}
50
+
51
$result = true;
52
+
53
if ($functionality) {
54
switch ($functionality) {
55
case 'suggest':
74
break;
75
}
76
}
77
+
78
return $result;
79
}
80
+
81
/**
82
* get Module Status depending on Module
83
+ *
84
* @return boolean
85
*/
86
public function getIsOnSearchPage()
87
{
88
+ return Mage::app()->getRequest()->getModuleName() == 'catalogsearch' || Mage::app()->getRequest()->getModuleName() == 'xmlconnect';
89
}
90
+
91
+
92
/**
93
* get Toolbar Block
94
+ *
95
* @return Mage_Catalog_Block_Product_List_Toolbar
96
*/
97
protected function _getToolbarBlock()
98
+ {
99
$mainBlock = Mage::app()->getLayout()->getBlock('search.result');
100
if($mainBlock instanceof Mage_CatalogSearch_Block_Result){
101
$toolbarBlock = $mainBlock->getListBlock()->getToolbarBlock();
102
}else{
103
$toolbarBlock = Mage::app()->getLayout()->createBlock('catalog/product_list_toolbar');
104
}
105
+
106
return $toolbarBlock;
107
}
108
114
public function getDefaultPerPageValue()
115
{
116
return $this->_getToolbarBlock()->getDefaultPerPageValue();
117
+ }
118
+
119
/**
120
* get Entity ID Field Name by Configuration or via Entity
121
+ *
122
* @return string
123
*/
124
public function getIdFieldName()
126
$idFieldName = Mage::getStoreConfig(self::XML_CONFIG_PATH_PRODUCT_IDENTIFIER);
127
if(!$idFieldName){
128
$idFieldName = $this->getEntity()->getIdFieldName();
129
+ }
130
return $idFieldName;
131
}
132
+
133
/**
134
* get FACT-Finder Suggest URL
135
+ *
136
* @return string
137
*/
138
public function getSuggestUrl()
139
{
140
$url = Mage::getSingleton('factfinder/adapter')->getSuggestUrl();
141
+ if (Mage::getStoreConfig(self::XML_CONFIG_PATH_USE_PROXY)) {
142
+ $params = array();
143
+ if (Mage::app()->getStore()->isCurrentlySecure()) {
144
+ $params['_secure'] = true;
145
+ }
146
+ $url = $this->_getUrl('factfinder/proxy/suggest', $params);
147
}
148
return $url;
149
}
150
+
151
152
/**
153
* get current Order
154
+ *
155
* @return string
156
*/
157
public function getCurrentOrder()
158
{
159
return $this->_getToolbarBlock()->getCurrentOrder();
160
}
161
+
162
/**
163
* get current Order Direction
164
+ *
165
* @return string
166
*/
167
public function getCurrentDirection()
168
{
169
return $this->_getToolbarBlock()->getCurrentDirection();
170
}
171
+
172
/**
173
* get Page Limit
174
+ *
175
* @return int
176
*/
177
public function getPageLimit()
178
{
179
+ $limit = $this->_getToolbarBlock()->getLimit();
180
if ($limit == 'all') {
181
$limit = 2*3*4*5*6; //a lot of products working for each layout
182
}
183
return $limit;
184
}
185
+
186
/**
187
* get current Page Number
188
+ *
189
* @return int
190
*/
191
public function getCurrentPage()
192
{
193
+ return $this->_getToolbarBlock()->getCurrentPage();
194
}
195
+
196
/**
197
* Retrieve query model object
198
*
202
{
203
return Mage::helper('catalogsearch')->getQuery();
204
}
205
+
206
/**
207
* Retrieve query model object
208
*
212
{
213
return Mage::helper('catalogsearch')->getQueryText();
214
}
215
+
216
+
217
/**
218
* return product campaings
219
+ *
220
* @param array $productIds
221
* @return FACTFinder_CampaignIterator
222
*/
224
{
225
try {
226
// get productcampaign adapter and set product id or sku array
227
+ $productCampaignAdapter = Mage::getModel('factfinder/adapter')->getProductCampaignAdapter();
228
+ $productCampaignAdapter->setProductIds($productIds);
229
$productCampaignAdapter->makeProductCampaign();
230
+
231
return $productCampaignAdapter->getCampaigns();
232
} catch(Exception $e) {
233
return array();
234
+ }
235
}
236
}
app/code/community/Flagbit/FactFinder/Model/Adapter.php CHANGED
@@ -84,25 +84,39 @@ class Flagbit_FactFinder_Model_Adapter
84
protected $_afterSearchNavigation = null;
85
86
/**
87
- * FACT-Finder Searchadapter
88
* @var array
89
*/
90
protected $_searchResultProductIds = null;
91
92
/**
93
* current FACT-Finder Category Path
94
* @var array
95
*/
96
protected $_currentFactfinderCategoryPath = null;
97
98
99
public function __construct($arg = null)
100
{
101
- if ($arg != null && $arg instanceof FACTFinder_Logger_LoggerInterface) {
102
FF::setLogger($arg);
103
} else {
104
$logger = Mage::helper('factfinder/debug');
105
FF::setLogger($logger);
106
}
107
}
108
@@ -730,6 +744,102 @@ class Flagbit_FactFinder_Model_Adapter
730
731
return $this->_searchResultProductIds;
732
}
733
734
/**
735
* set single parameter, which will be looped through to the FACT-Finder request
@@ -756,7 +866,7 @@ class Flagbit_FactFinder_Model_Adapter
756
if ($this->_dataProvider == null) {
757
$config = $this->_getConfiguration();
758
$params = $this->_getParamsParser()->getServerRequestParams();
759
-
760
$this->_dataProvider = FF::getInstance('http/dataProvider', $params, $config);
761
}
762
return $this->_dataProvider;
84
protected $_afterSearchNavigation = null;
85
86
/**
87
+ * FACT-Finder product IDs of primary search result
88
* @var array
89
*/
90
protected $_searchResultProductIds = null;
91
92
+ /**
93
+ * FACT-Finder secondary search results
94
+ * @var array
95
+ */
96
+ protected $_secondarySearchResults = null;
97
+
98
+
99
/**
100
* current FACT-Finder Category Path
101
* @var array
102
*/
103
protected $_currentFactfinderCategoryPath = null;
104
105
+ /**
106
+ * logger object to log all module interna
107
+ * @var FACTFinder_Abstract_Logger
108
+ */
109
+ protected $_logger = null;
110
111
public function __construct($arg = null)
112
{
113
+ if ($arg != null && $arg instanceof FACTFinder_Abstract_Logger) {
114
FF::setLogger($arg);
115
+ $this->_logger = $arg;
116
} else {
117
$logger = Mage::helper('factfinder/debug');
118
FF::setLogger($logger);
119
+ $this->_logger = $logger;
120
}
121
}
122
744
745
return $this->_searchResultProductIds;
746
}
747
+
748
+ /**
749
+ * get secondary Search Results
750
+ *
751
+ * @return array Products Ids
752
+ */
753
+ public function getSecondarySearchResult($channel)
754
+ {
755
+ // array_filter() is used to turn a one-element array into an empty array in the case of an empty config-string
756
+ $channels = array_filter(explode(';', Mage::getStoreConfig('factfinder/search/secondary_channels')));
757
+
758
+ if(!in_array($channel, $channels))
759
+ {
760
+ Mage::logException(new Exception("Tried to query a channel that was not configured as a secondary channel."));
761
+ return array();
762
+ }
763
+
764
+ if($this->_secondarySearchResults == null)
765
+ {
766
+ $this->_secondarySearchResults = array();
767
+
768
+ $query = Mage::helper('factfinder/search')->getQueryText();
769
+
770
+ $searchAdapters = array();
771
+
772
+ foreach($channels AS $currentChannel)
773
+ {
774
+ try {
775
+ $searchAdapters[$currentChannel] = $this->_getSecondarySearchAdapter($currentChannel, $query);
776
+ }
777
+ catch (Exception $e) {
778
+ Mage::logException($e);
779
+ }
780
+ }
781
+
782
+ FACTFinder_Http_ParallelDataProvider::loadAllData();
783
+
784
+ foreach($searchAdapters AS $currentChannel => $searchAdapter)
785
+ {
786
+ try {
787
+ $this->_secondarySearchResults[$currentChannel] = $searchAdapter->getResult();
788
+ }
789
+ catch (Exception $e) {
790
+ Mage::logException($e);
791
+ }
792
+ }
793
+ }
794
+
795
+ if(!array_key_exists($channel, $this->_secondarySearchResults))
796
+ {
797
+ Mage::logException(new Exception("Result for channel '".$channel."' could not be retrieved."));
798
+ return array();
799
+ }
800
+
801
+ return $this->_secondarySearchResults[$channel];
802
+ }
803
+
804
+ /**
805
+ * get a (new) FactFinder SearchAdapter for a secondary channel
806
+ *
807
+ * @return FACTFinder_Abstract_SearchAdapter
808
+ */
809
+ protected function _getSecondarySearchAdapter($channel, $query)
810
+ {
811
+ $config = $this->_getConfiguration();
812
+ $encodingHandler = FF::getSingleton('encodingHandler', $config);
813
+ $dataProvider = $this->_getParallelDataProvider($channel);
814
+
815
+ // Overwrite the channel set by the configuration
816
+ $dataProvider->setParam('channel', $channel);
817
+ $dataProvider->setParam('query', $query);
818
+
819
+ $searchAdapter = FF::getInstance(
820
+ 'xml'.Mage::getStoreConfig('factfinder/search/ffversion').'/searchAdapter',
821
+ $dataProvider,
822
+ $this->_getParamsParser(),
823
+ $encodingHandler
824
+ );
825
+
826
+ return $searchAdapter;
827
+ }
828
+
829
+ /**
830
+ * get a (new) FactFinder DataProvider that works in parallel
831
+ *
832
+ * @return FACTFinder_Abstract_Dataprovider
833
+ **/
834
+ protected function _getParallelDataProvider()
835
+ {
836
+ $config = $this->_getConfiguration();
837
+ $params = $this->_getParamsParser()->getServerRequestParams();
838
+
839
+ $dp = FACTFinder_Http_ParallelDataProvider::getDataProvider($params, $config);
840
+
841
+ return $dp;
842
+ }
843
844
/**
845
* set single parameter, which will be looped through to the FACT-Finder request
866
if ($this->_dataProvider == null) {
867
$config = $this->_getConfiguration();
868
$params = $this->_getParamsParser()->getServerRequestParams();
869
+
870
$this->_dataProvider = FF::getInstance('http/dataProvider', $params, $config);
871
}
872
return $this->_dataProvider;
app/code/community/Flagbit/FactFinder/etc/config.xml CHANGED
@@ -22,7 +22,7 @@
22
<modules>
23
<Flagbit_FactFinder>
24
<active>true</active>
25
- <version>3.3.9</version>
26
</Flagbit_FactFinder>
27
</modules>
28
<global>
22
<modules>
23
<Flagbit_FactFinder>
24
<active>true</active>
25
+ <version>3.3.11</version>
26
</Flagbit_FactFinder>
27
</modules>
28
<global>
app/code/community/Flagbit/FactFinder/etc/system.xml CHANGED
@@ -99,14 +99,23 @@
99
<show_in_store>1</show_in_store>
100
</auth_password>
101
<channel translate="label comment">
102
- <label>Channel</label>
103
- <comment>FACT-Finder can provide multiple search indexes, each represented by a "channel". Leave empty to use the default channel.</comment>
104
<frontend_type>text</frontend_type>
105
<sort_order>70</sort_order>
106
<show_in_default>1</show_in_default>
107
<show_in_website>1</show_in_website>
108
<show_in_store>1</show_in_store>
109
</channel>
110
<language translate="label comment">
111
<label>Language</label>
112
<comment>Some text strings come directly from FACT-Finder. Enter the language code here. Leave empty to use the language specified by the user's browser.</comment>
@@ -197,7 +206,7 @@
197
<show_in_website>0</show_in_website>
198
<show_in_store>1</show_in_store>
199
</attributes>
200
- <export_url translate="label">
201
<label></label>
202
<frontend_model>factfinder/adminhtml_exportlink</frontend_model>
203
<sort_order>60</sort_order>
@@ -244,7 +253,7 @@
244
</proxy>
245
<internal_ip translate="label">
246
<label>Internal IPs</label>
247
- <comment>Enter your internal ip addresses. Multiple ip addresses can be entered divided by semicolon.</comment>
248
<frontend_type>text</frontend_type>
249
<sort_order>40</sort_order>
250
<show_in_default>1</show_in_default>
99
<show_in_store>1</show_in_store>
100
</auth_password>
101
<channel translate="label comment">
102
+ <label>Primary Channel</label>
103
+ <comment>FACT-Finder can provide multiple search indexes, each represented by a "channel". Enter the channel that will be filled with your Magento export. Leave empty to use the default channel.</comment>
104
<frontend_type>text</frontend_type>
105
<sort_order>70</sort_order>
106
<show_in_default>1</show_in_default>
107
<show_in_website>1</show_in_website>
108
<show_in_store>1</show_in_store>
109
</channel>
110
+ <secondary_channels translate="label">
111
+ <label>Secondary Channels</label>
112
+ <comment>Enter any secondary channels you want to search. Multiple channels can be separated by semicolons.</comment>
113
+ <frontend_type>text</frontend_type>
114
+ <sort_order>75</sort_order>
115
+ <show_in_default>1</show_in_default>
116
+ <show_in_website>1</show_in_website>
117
+ <show_in_store>1</show_in_store>
118
+ </secondary_channels>
119
<language translate="label comment">
120
<label>Language</label>
121
<comment>Some text strings come directly from FACT-Finder. Enter the language code here. Leave empty to use the language specified by the user's browser.</comment>
206
<show_in_website>0</show_in_website>
207
<show_in_store>1</show_in_store>
208
</attributes>
209
+ <export_url translate="label">
210
<label></label>
211
<frontend_model>factfinder/adminhtml_exportlink</frontend_model>
212
<sort_order>60</sort_order>
253
</proxy>
254
<internal_ip translate="label">
255
<label>Internal IPs</label>
256
+ <comment>Enter your internal IP addresses. Multiple IP addresses can be separated by semicolons.</comment>
257
<frontend_type>text</frontend_type>
258
<sort_order>40</sort_order>
259
<show_in_default>1</show_in_default>
app/design/frontend/base/default/layout/factfinder.xml CHANGED
@@ -37,24 +37,25 @@
37
</block>
38
<block type="factfinder/campaign_advisory" after="factfinder.campaign.feedback" template="factfinder/campaign/advisory.phtml" />
39
<block type="core/template" name="factfinder.logo" template="factfinder/logo.phtml"/>
40
</reference>
41
</catalogsearch_result_index>
42
43
<catalog_product_view>
44
<reference name="content">
45
- <!-- <block type="factfinder/campaign_product_advisory" before="product.info" template="factfinder/campaign/product/advisory.phtml" /-->
46
<block type="factfinder/campaign_product_feedback" before="product.info" template="factfinder/campaign/product/feedback.phtml" />
47
</reference>
48
<reference>
49
<block name="product.info.upsell">
50
<action method="setItemLimit"><type>upsell</type><limit>20</limit></action>
51
- </block>
52
</reference>
53
</catalog_product_view>
54
55
<checkout_cart_index>
56
<reference name="checkout.cart.form.before">
57
- <!-- <block type="factfinder/campaign_cart_advisory" before="-" template="factfinder/campaign/cart/advisory.phtml" /-->
58
<block type="factfinder/campaign_cart_feedback" before="-" template="factfinder/campaign/cart/feedback.phtml" />
59
</reference>
60
</checkout_cart_index>
37
</block>
38
<block type="factfinder/campaign_advisory" after="factfinder.campaign.feedback" template="factfinder/campaign/advisory.phtml" />
39
<block type="core/template" name="factfinder.logo" template="factfinder/logo.phtml"/>
40
+ <block type="factfinder/secondaryresult" after="search.result" name="factfinder.secondaryresult" template="factfinder/secondaryresult.phtml" />
41
</reference>
42
</catalogsearch_result_index>
43
44
<catalog_product_view>
45
<reference name="content">
46
+ <!-- <block type="factfinder/campaign_product_advisory" before="product.info" template="factfinder/campaign/product/advisory.phtml" /-->
47
<block type="factfinder/campaign_product_feedback" before="product.info" template="factfinder/campaign/product/feedback.phtml" />
48
</reference>
49
<reference>
50
<block name="product.info.upsell">
51
<action method="setItemLimit"><type>upsell</type><limit>20</limit></action>
52
+ </block>
53
</reference>
54
</catalog_product_view>
55
56
<checkout_cart_index>
57
<reference name="checkout.cart.form.before">
58
+ <!-- <block type="factfinder/campaign_cart_advisory" before="-" template="factfinder/campaign/cart/advisory.phtml" /-->
59
<block type="factfinder/campaign_cart_feedback" before="-" template="factfinder/campaign/cart/feedback.phtml" />
60
</reference>
61
</checkout_cart_index>
app/design/frontend/base/default/template/factfinder/secondaryresult.phtml ADDED
@@ -0,0 +1,41 @@
1
+ <?php
2
+ /**
3
+ * Flagbit_FactFinder
4
+ *
5
+ * @category Mage
6
+ * @package Flagbit_FactFinder
7
+ * @copyright Copyright (c) 2010 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
8
+ */
9
+
10
+ /**
11
+ * Add a list of secondary results to Search Result
12
+ *
13
+ * @category Mage
14
+ * @package Flagbit_FactFinder
15
+ * @copyright Copyright (c) 2010 Flagbit GmbH & Co. KG (http://www.flagbit.de/)
16
+ * @author Joerg Weller <weller@flagbit.de>
17
+ * @version $Id$
18
+ */
19
+ ?>
20
+ <?php
21
+
22
+ // array_filter() is used to turn a one-element array into an empty array in the case of an empty config-string
23
+ $channels = array_filter(explode(';', Mage::getStoreConfig('factfinder/search/secondary_channels')));
24
+
25
+ if(Mage::helper('factfinder/search')->getIsEnabled() && !empty($channels)):
26
+
27
+ ?>
28
+
29
+ <div>
30
+ <?php echo $this->__('Secondary Result'); ?>:
31
+ <br><br>
32
+ <?php
33
+ $result = $this->getSecondaryResult($channels[0]);
34
+ foreach($result AS $record)
35
+ {
36
+ echo $record->getValue("Title")."<br/>";
37
+ }
38
+ ?>
39
+ </div>
40
+
41
+ <?php endif;?>
app/locale/de_DE/Flagbit_FactFinder.csv CHANGED
@@ -8,12 +8,13 @@
8
"Debug Log", "Debug Log"
9
"Download export", "Export herunterladen"
10
"Enabled", "Aktiviert"
11
- "Enter your internal ip addresses. Multiple ip addresses can be entered divided by semicolon.", "Geben Sie hier Ihre internen IP-Adressen ein. Mehrere IP-Adressen werden mit Semikolon getrennt."
12
"Export Images and Deeplinks", "Bilder und Deeplinks exportieren"
13
"FACT-Finder", "FACT-Finder"
14
"FACT-Finder Access Data", "FACT-Finder Zugangsdaten"
15
"FACT-Finder Business User Cockpit", "FACT-Finder Business User Cockpit"
16
- "FACT-Finder can provide multiple search indexes, each represented by a ""channel"". Leave empty to use the default channel.", "FACT-Finder kann mehrere Such-Indizes zur Verfügung stellen. Jeder Index wird durch einen ""Channel"" dargestellt. Wenn kein Wert angegeben ist, wird der Standard-Channel genutzt."
17
"FACT-Finder cannot be activated:", "FACT-Finder konnte nicht aktiviert werden:"
18
"FACT-Finder Config Data", "FACT-Finder Konfigurationsdaten"
19
"FACT-Finder Export Configuration", "FACT-Finder Export-Konfiguration"
@@ -24,13 +25,16 @@
24
"Name of the FACT-Finder application", "Name der FACT-Finder-Applikation"
25
"No", "Nein"
26
"Password", "Passwort"
27
"Product ID (default)", "Produkt-ID (Standard)"
28
"Product Identifier", "Produkt Identifizierung"
29
"Product SKU", "Produkt-SKU (Artikelnummer)"
30
"Redirect to product page if single result", "Bei eindeutigem Resultat auf Produkt-Detailseite weiterleiten"
31
"Search", "Suche"
32
"Search entire store here...", "Den gesamten Shop durchsuchen..."
33
"Search:", "Suche:"
34
"Server Port", "Servers-Port"
35
"Server URL", "Server-URL"
36
"servername should only contain the IP address or the domain - no ""http://"" or any slashes!", "Der Servername sollte ausschließlih die IP-Adresse oder die Domain enthalten - kein ""http://"" und keine Slashes (\)!"
8
"Debug Log", "Debug Log"
9
"Download export", "Export herunterladen"
10
"Enabled", "Aktiviert"
11
+ "Enter your internal IP addresses. Multiple IP addresses can be separated by semicolons.", "Geben Sie hier Ihre internen IP-Adressen ein. Mehrere IP-Adressen werden mit Semikolon getrennt."
12
+ "Enter any secondary channels you want to search. Multiple channels can be separated by semicolons.", "Geben Sie hier weitere Channel an, die Sie durchsuchen wollen. Mehrere Channel werden mit Semikolon getrennt."
13
"Export Images and Deeplinks", "Bilder und Deeplinks exportieren"
14
"FACT-Finder", "FACT-Finder"
15
"FACT-Finder Access Data", "FACT-Finder Zugangsdaten"
16
"FACT-Finder Business User Cockpit", "FACT-Finder Business User Cockpit"
17
+ "FACT-Finder can provide multiple search indexes, each represented by a ""channel"". Enter the channel that will be filled with your Magento export. Leave empty to use the default channel.", "FACT-Finder kann mehrere Such-Indizes zur Verfügung stellen. Jeder Index wird durch einen ""Channel"" dargestellt. Tragen Sie den Channel ein, der mit Ihrem Magento-Export gefüllt wird. Wenn kein Wert angegeben ist, wird der Standard-Channel genutzt."
18
"FACT-Finder cannot be activated:", "FACT-Finder konnte nicht aktiviert werden:"
19
"FACT-Finder Config Data", "FACT-Finder Konfigurationsdaten"
20
"FACT-Finder Export Configuration", "FACT-Finder Export-Konfiguration"
25
"Name of the FACT-Finder application", "Name der FACT-Finder-Applikation"
26
"No", "Nein"
27
"Password", "Passwort"
28
+ "Primary Channel", "Primärer Channel"
29
"Product ID (default)", "Produkt-ID (Standard)"
30
"Product Identifier", "Produkt Identifizierung"
31
"Product SKU", "Produkt-SKU (Artikelnummer)"
32
"Redirect to product page if single result", "Bei eindeutigem Resultat auf Produkt-Detailseite weiterleiten"
33
+ "Secondary Result", "Sekundäre Ergebnisse"
34
"Search", "Suche"
35
"Search entire store here...", "Den gesamten Shop durchsuchen..."
36
"Search:", "Suche:"
37
+ "Secondary Channels", "Sekundäre Channel"
38
"Server Port", "Servers-Port"
39
"Server URL", "Server-URL"
40
"servername should only contain the IP address or the domain - no ""http://"" or any slashes!", "Der Servername sollte ausschließlih die IP-Adresse oder die Domain enthalten - kein ""http://"" und keine Slashes (\)!"
lib/FACTFinder/Abstract/Adapter.php CHANGED
@@ -1,118 +1,128 @@
1
- <?php
2
-
3
- /**
4
- * handles the issue to create useable object from the data delivered by the dataprovider.
5
- * this class can also be seen as a factory, but it is rather an adapter, because it converst the responded objects into
6
- * the useable, unique objects
7
- *
8
- * @author Rudolf Batt <rb@omikron.net>
9
- * @version $Id: Adapter.php 25893 2010-06-29 08:19:43Z rb $
10
- * @package FACTFinder\Abstract
11
- */
12
- abstract class FACTFinder_Abstract_Adapter
13
- {
14
- protected $paramsParser;
15
- protected $dataProvider;
16
- protected $encodingHandler;
17
-
18
- protected $log;
19
-
20
- protected $data;
21
-
22
- final public function __construct(FACTFinder_Abstract_DataProvider $dataProvider, FACTFinder_ParametersParser $paramsParser,
23
- FACTFinder_EncodingHandler $encodingHandler)
24
- {
25
- $this->log = FF::getLogger();
26
- $this->setDataProvider($dataProvider);
27
- $this->setParamsParser($paramsParser);
28
- $this->setEncodingHandler($encodingHandler);
29
- $this->init();
30
- }
31
-
32
- /**
33
- * can be overwritten to do initialising issues, that would normaly done by the constructor. it will be called at
34
- * the end of the constructor
35
- *
36
- * @return void
37
- */
38
- protected function init(){}
39
-
40
- /**
41
- * returns the data lazily. if it isn't available yet, it will be requested from the dataprovider.
42
- * decorates the dataprovider::getData method so a inheriting class does not have to use the dataprovider
43
- */
44
- protected function getData()
45
- {
46
- if(!isset($this->data)) {
47
- $this->data = $this->getDataProvider()->getData();
48
- }
49
- return $this->data;
50
- }
51
-
52
- protected function reloadData()
53
- {
54
- $this->data = $this->getDataProvider()->getData();
55
- return $this->data;
56
- }
57
-
58
- /**
59
- * set data provider
60
- *
61
- * @param FACTFinder_Abstract_DataProvider
62
- * @return void
63
- **/
64
- public function setDataProvider(FACTFinder_Abstract_DataProvider $dataProvider)
65
- {
66
- $this->dataProvider = $dataProvider;
67
- }
68
-
69
- /**
70
- * get data provider
71
- *
72
- * @return FACTFinder_Abstract_DataProvider
73
- **/
74
- protected function getDataProvider()
75
- {
76
- return $this->dataProvider;
77
- }
78
-
79
- /**
80
- * set parameter parser
81
- *
82
- * @param FACTFinder_ParametersParser $paramsParser
83
- */
84
- public function setParamsParser(FACTFinder_ParametersParser $paramsParser)
85
- {
86
- $this->paramsParser = $paramsParser;
87
- }
88
-
89
- /**
90
- * returns the used factfinder params object.
91
- *
92
- * @return FACTFinder_ParametersParser
93
- **/
94
- protected function getParamsParser()
95
- {
96
- return $this->paramsParser;
97
- }
98
-
99
- /**
100
- * set encoding handler
101
- *
102
- * @param FACTFinder_EncodingHandler $encodingHandler
103
- */
104
- public function setEncodingHandler(FACTFinder_EncodingHandler $encodingHandler)
105
- {
106
- $this->encodingHandler = $encodingHandler;
107
- }
108
-
109
- /**
110
- * returns the used encoding handler
111
- *
112
- * @return FACTFinder_EncodingHandler
113
- **/
114
- protected function getEncodingHandler()
115
- {
116
- return $this->encodingHandler;
117
- }
118
}
1
+ <?php
2
+ /**
3
+ * FACT-Finder PHP Framework
4
+ *
5
+ * @category Library
6
+ * @package FACTFinder\Abstract
7
+ * @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
8
+ */
9
+
10
+ /**
11
+ * handles the issue to create useable object from the data delivered by the dataprovider.
12
+ * this class can also be seen as a factory, but it is rather an adapter, because it converst the responded objects into
13
+ * the useable, unique objects
14
+ *
15
+ * @author Rudolf Batt <rb@omikron.net>
16
+ * @version $Id: Adapter.php 25893 2010-06-29 08:19:43Z rb $
17
+ * @package FACTFinder\Abstract
18
+ */
19
+ abstract class FACTFinder_Abstract_Adapter
20
+ {
21
+ protected $paramsParser;
22
+ protected $dataProvider;
23
+ protected $encodingHandler;
24
+
25
+ protected $log;
26
+
27
+ protected $data;
28
+
29
+ final public function __construct(FACTFinder_Abstract_DataProvider $dataProvider, FACTFinder_ParametersParser $paramsParser,
30
+ FACTFinder_EncodingHandler $encodingHandler, FACTFinder_Abstract_Logger $log = null)
31
+ {
32
+ if(isset($log))
33
+ $this->log = $log;
34
+ else
35
+ $this->log = FF::getSingleton('nullLogger');
36
+ $this->setDataProvider($dataProvider);
37
+ $this->setParamsParser($paramsParser);
38
+ $this->setEncodingHandler($encodingHandler);
39
+ $this->init();
40
+ }
41
+
42
+ /**
43
+ * can be overwritten to do initialising issues, that would normaly done by the constructor. it will be called at
44
+ * the end of the constructor
45
+ *
46
+ * @return void
47
+ */
48
+ protected function init(){}
49
+
50
+ /**
51
+ * returns the data lazily. if it isn't available yet, it will be requested from the dataprovider.
52
+ * decorates the dataprovider::getData method so a inheriting class does not have to use the dataprovider
53
+ */
54
+ protected function getData()
55
+ {
56
+ if(!isset($this->data)) {
57
+ $this->data = $this->getDataProvider()->getData();
58
+ }
59
+ return $this->data;
60
+ }
61
+
62
+ protected function reloadData()
63
+ {
64
+ $this->data = $this->getDataProvider()->getData();
65
+ return $this->data;
66
+ }
67
+
68
+ /**
69
+ * set data provider
70
+ *
71
+ * @param FACTFinder_Abstract_DataProvider
72
+ * @return void
73
+ **/
74
+ public function setDataProvider(FACTFinder_Abstract_DataProvider $dataProvider)
75
+ {
76
+ $this->dataProvider = $dataProvider;
77
+ }
78
+
79
+ /**
80
+ * get data provider
81
+ *
82
+ * @return FACTFinder_Abstract_DataProvider
83
+ **/
84
+ protected function getDataProvider()
85
+ {
86
+ return $this->dataProvider;
87
+ }
88
+
89
+ /**
90
+ * set parameter parser
91
+ *
92
+ * @param FACTFinder_ParametersParser $paramsParser
93
+ */
94
+ public function setParamsParser(FACTFinder_ParametersParser $paramsParser)
95
+ {
96
+ $this->paramsParser = $paramsParser;
97
+ }
98
+
99
+ /**
100
+ * returns the used factfinder params object.
101
+ *
102
+ * @return FACTFinder_ParametersParser
103
+ **/
104
+ protected function getParamsParser()
105
+ {
106
+ return $this->paramsParser;
107
+ }
108
+
109
+ /**
110
+ * set encoding handler
111
+ *
112
+ * @param FACTFinder_EncodingHandler $encodingHandler
113
+ */
114
+ public function setEncodingHandler(FACTFinder_EncodingHandler $encodingHandler)
115
+ {
116
+ $this->encodingHandler = $encodingHandler;
117
+ }
118
+
119
+ /**
120
+ * returns the used encoding handler
121
+ *
122
+ * @return FACTFinder_EncodingHandler
123
+ **/
124
+ protected function getEncodingHandler()
125
+ {
126
+ return $this->encodingHandler;
127
+ }
128
}
lib/FACTFinder/Abstract/CompareAdapter.php CHANGED
@@ -1,4 +1,11 @@
1
<?php
2
3
/**
4
* adapter for the factfinder "product comparison" data
@@ -10,78 +17,78 @@
10
abstract class FACTFinder_Abstract_CompareAdapter extends FACTFinder_Abstract_Adapter
11
{
12
protected $productIds = array();
13
-
14
- protected $comparableAttributes = array();
15
- protected $comparedRecords = array();
16
- protected $attributesUpToDate = false;
17
- protected $recordsUpToDate = false;
18
-
19
- protected $idsOnly = false;
20
-
21
- /**
22
- * Set ids of products to be compared
23
- *
24
- * @param array $productIds list of integers
25
- **/
26
- public function setProductIds($productIds) {
27
- $this->productIds = $productIds;
28
- $this->getDataProvider()->setParam('ids', implode(';',$this->productIds));
29
- $this->attributesUpToDate = false;
30
- $this->recordsUpToDate = false;
31
- }
32
-
33
- /**
34
- * Set the idsOnly request parameter
35
- *
36
- * @param bool $idsOnly
37
- **/
38
- public function setIdsOnly($idsOnly) {
39
- $this->idsOnly = $idsOnly;
40
- $this->getDataProvider()->setParam('idsOnly', $idsOnly ? 'true' : 'false');
41
- }
42
-
43
- /**
44
- * Adds an id to the list of products to be compared
45
- *
46
- * @param int $productId
47
- **/
48
- public function addProductId($productId) {
49
- $this->productIds[] = $productId;
50
- $this->attributesUpToDate = false;
51
- $this->recordsUpToDate = false;
52
- }
53
-
54
- /**
55
* returns the comparable attributes for products to be compared
56
*
57
* @return array $comparableAttributes of strings (field names as keys, hasDifferences as values)
58
**/
59
- public function getComparableAttributes() {
60
- if (!$this->attributesUpToDate || !isset($this->comparableAttributes) || $this->comparableAttributes == null) {
61
$this->comparableAttributes = $this->createComparableAttributes();
62
- $this->attributesUpToDate == true;
63
}
64
return $this->comparableAttributes;
65
}
66
-
67
/**
68
* returns the Record objects or record ids for products to be compared (depending on the value of idsOnly)
69
*
70
* @return array $comparedRecords list of FACTFinder_Record objects
71
**/
72
public function getComparedRecords() {
73
- if (!$this->recordsUpToDate || !isset($this->comparedRecords) || $this->comparedRecords == null) {
74
- $this->comparedRecords = $this->createComparedRecords();
75
- $this->recordsUpToDate == true;
76
- }
77
- return $this->comparedRecords;
78
}
79
-
80
/**
81
* @return array $comparableAttributes of strings (field names as keys, hasDifferences as values)
82
*/
83
abstract protected function createComparableAttributes();
84
-
85
/**
86
* @return array $comparedRecords list of FACTFinder_Record objects or integers (depending on the value of idsOnly)
87
*/
1
<?php
2
+ /**
3
+ * FACT-Finder PHP Framework
4
+ *
5
+ * @category Library
6
+ * @package FACTFinder\Abstract
7
+ * @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
8
+ */
9
10
/**
11
* adapter for the factfinder "product comparison" data
17
abstract class FACTFinder_Abstract_CompareAdapter extends FACTFinder_Abstract_Adapter
18
{
19
protected $productIds = array();
20
+
21
+ protected $comparableAttributes = array();
22
+ protected $comparedRecords = array();
23
+ protected $attributesUpToDate = false;
24
+ protected $recordsUpToDate = false;
25
+
26
+ protected $idsOnly = false;
27
+
28
+ /**
29
+ * Set ids of products to be compared
30
+ *
31
+ * @param array $productIds list of integers
32
+ **/
33
+ public function setProductIds($productIds) {
34
+ $this->productIds = $productIds;
35
+ $this->getDataProvider()->setParam('ids', implode(';',$this->productIds));
36
+ $this->attributesUpToDate = false;
37
+ $this->recordsUpToDate = false;
38
+ }
39
+
40
+ /**
41
+ * Set the idsOnly request parameter
42
+ *
43
+ * @param bool $idsOnly
44
+ **/
45
+ public function setIdsOnly($idsOnly) {
46
+ $this->idsOnly = $idsOnly;
47
+ $this->getDataProvider()->setParam('idsOnly', $idsOnly ? 'true' : 'false');
48
+ }
49
+
50
+ /**
51
+ * Adds an id to the list of products to be compared
52
+ *
53
+ * @param int $productId
54
+ **/
55
+ public function addProductId($productId) {
56
+ $this->productIds[] = $productId;
57
+ $this->attributesUpToDate = false;
58
+ $this->recordsUpToDate = false;
59
+ }
60
+
61
+ /**
62
* returns the comparable attributes for products to be compared
63
*
64
* @return array $comparableAttributes of strings (field names as keys, hasDifferences as values)
65
**/
66
+ public function getComparableAttributes() {
67
+ if (!$this->attributesUpToDate || !isset($this->comparableAttributes) || $this->comparableAttributes == null) {
68
$this->comparableAttributes = $this->createComparableAttributes();
69
+ $this->attributesUpToDate == true;
70
}
71
return $this->comparableAttributes;
72
}
73
+
74
/**
75
* returns the Record objects or record ids for products to be compared (depending on the value of idsOnly)
76
*
77
* @return array $comparedRecords list of FACTFinder_Record objects
78
**/
79
public function getComparedRecords() {
80
+ if (!$this->recordsUpToDate || !isset($this->comparedRecords) || $this->comparedRecords == null) {
81
+ $this->comparedRecords = $this->createComparedRecords();
82
+ $this->recordsUpToDate == true;
83
+ }
84
+ return $this->comparedRecords;
85
}
86
+
87
/**
88
* @return array $comparableAttributes of strings (field names as keys, hasDifferences as values)
89
*/
90
abstract protected function createComparableAttributes();
91
+
92
/**
93
* @return array $comparedRecords list of FACTFinder_Record objects or integers (depending on the value of idsOnly)
94
*/
lib/FACTFinder/Abstract/Configuration.php CHANGED
@@ -1,153 +1,159 @@
1
- <?php
2
-
3
- /**
4
- * interface to access the needed configuration values
5
- *
6
- * @category FACTFinderLib
7
- * @package FACTFinder\Abstract
8
- */
9
- interface FACTFinder_Abstract_Configuration
10
- {
11
- /**
12
- * @return string
13
- */
14
- function getVersion();
15
-
16
- /**
17
- * @param string name
18
- * @return string value
19
- */
20
- function getCustomValue($name);
21
-
22
- /**
23
- * @return string
24
- */
25
- function getRequestProtocol();
26
-
27
- /**
28
- * @return string
29
- */
30
- function getServerAddress();
31
-
32
- /**
33
- * @return int
34
- */
35
- function getServerPort();
36
-
37
- /**
38
- * @return string
39
- */
40
- function getContext();
41
-
42
- /**
43
- * @return string
44
- */
45
- function getChannel();
46
-
47
- /**
48
- * @return string
49
- */
50
- function getLanguage();
51
-
52
- /**
53
- * @return string
54
- */
55
- function getAuthUser();
56
-
57
- /**
58
- * @return string
59
- */
60
- function getAuthPasswort();
61
-
62
- /**
63
- * @return boolean
64
- */
65
- function isHttpAuthenticationType();
66
-
67
- /**
68
- * @return boolean
69
- */
70
- function isSimpleAuthenticationType();
71
-
72
- /**
73
- * @return boolean
74
- */
75
- function isAdvancedAuthenticationType();
76
-
77
- /**
78
- * @return string
79
- */
80
- function getAdvancedAuthPrefix();
81
-
82
- /**
83
- * @return string
84
- */
85
- function getAdvancedAuthPostfix();
86
-
87
- /**
88
- * get mapping rules to map params for the page
89
- *
90
- * @return array
91
- */
92
- function getPageMappings();
93
-
94
- /**
95
- * get mapping rules to map params for the server
96
- *
97
- * @return array
98
- */
99
- function getServerMappings();
100
-
101
- /**
102
- * returns an array of parameter names as array keys with the boolean value true. this are the ignored page
103
- * parameters from the configuration
104
- *
105
- * @return array with string as key and boolean true as value for each of them
106
- */
107
- function getIgnoredPageParams();
108
-
109
- /**
110
- * returns an array of parameter names as array keys with the boolean value true. this are the ignored server
111
- * parameters from the configuration
112
- *
113
- * @return array with string as key and boolean true as value for each of them
114
- */
115
- function getIgnoredServerParams();
116
-
117
- /**
118
- * returns an array of the required parameters for the page. The array-keys are the parameter names and the array
119
- * values are the default values of each parameter
120
- *
121
- * @return array string to string map (param-name as array-key; default value as array-value)
122
- */
123
- function getRequiredPageParams();
124
-
125
- /**
126
- * returns an array of the required parameters for the server. The array-keys are the parameter names and the array
127
- * values are the default values of each parameter
128
- *
129
- * @return array string to string map (param-name as array-key; default value as array-value)
130
- */
131
- function getRequiredServerParams();
132
-
133
- /**
134
- * get encoding of the page content
135
- *
136
- * @return string
137
- */
138
- function getPageContentEncoding();
139
-
140
- /**
141
- * get encoding of the page url
142
- *
143
- * @return string
144
- */
145
- function getPageUrlEncoding();
146
-
147
- /**
148
- * get encoding of the server url
149
- *
150
- * @return string
151
- */
152
- function getServerUrlEncoding();
153
}
1
+ <?php
2
+ /**
3
+ * FACT-Finder PHP Framework
4
+ *
5
+ * @category Library
6
+ * @package FACTFinder\Abstract
7
+ * @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
8
+ */
9
+
10
+ /**
11
+ * interface to access the needed configuration values
12
+ *
13
+ * @package FACTFinder\Abstract
14
+ */
15
+ interface FACTFinder_Abstract_Configuration
16
+ {
17
+ /**
18
+ * @return string
19
+ */
20
+ function getVersion();
21
+
22
+ /**
23
+ * @param string name
24
+ * @return string value
25
+ */
26
+ function getCustomValue($name);
27
+
28
+ /**
29
+ * @return string
30
+ */
31
+ function getRequestProtocol();
32
+
33
+ /**
34
+ * @return string
35
+ */
36
+ function getServerAddress();
37
+
38
+ /**
39
+ * @return int
40
+ */
41
+ function getServerPort();
42
+
43
+ /**
44
+ * @return string
45
+ */
46
+ function getContext();
47
+
48
+ /**
49
+ * @return string
50
+ */
51
+ function getChannel();
52
+
53
+ /**
54
+ * @return string
55
+ */
56
+ function getLanguage();
57
+
58
+ /**
59
+ * @return string
60
+ */
61
+ function getAuthUser();
62
+
63
+ /**
64
+ * @return string
65
+ */
66
+ function getAuthPasswort();
67
+
68
+ /**
69
+ * @return boolean
70
+ */
71
+ function isHttpAuthenticationType();
72
+
73
+ /**
74
+ * @return boolean
75
+ */
76
+ function isSimpleAuthenticationType();
77
+
78
+ /**
79
+ * @return boolean
80
+ */
81
+ function isAdvancedAuthenticationType();
82
+
83
+ /**
84
+ * @return string
85
+ */
86
+ function getAdvancedAuthPrefix();
87
+
88
+ /**
89
+ * @return string
90
+ */
91
+ function getAdvancedAuthPostfix();
92
+
93
+ /**
94
+ * get mapping rules to map params for the page
95
+ *
96
+ * @return array
97
+ */
98
+ function getPageMappings();
99
+
100
+ /**
101
+ * get mapping rules to map params for the server
102
+ *
103
+ * @return array
104
+ */
105
+ function getServerMappings();
106
+
107
+ /**
108
+ * returns an array of parameter names as array keys with the boolean value true. this are the ignored page
109
+ * parameters from the configuration
110
+ *
111
+ * @return array with string as key and boolean true as value for each of them
112
+ */
113
+ function getIgnoredPageParams();
114
+
115
+ /**
116
+ * returns an array of parameter names as array keys with the boolean value true. this are the ignored server
117
+ * parameters from the configuration
118
+ *
119
+ * @return array with string as key and boolean true as value for each of them
120
+ */
121
+ function getIgnoredServerParams();
122
+
123
+ /**
124
+ * returns an array of the required parameters for the page. The array-keys are the parameter names and the array
125
+ * values are the default values of each parameter
126
+ *
127
+ * @return array string to string map (param-name as array-key; default value as array-value)
128
+ */
129
+ function getRequiredPageParams();
130
+
131
+ /**
132
+ * returns an array of the required parameters for the server. The array-keys are the parameter names and the array
133
+ * values are the default values of each parameter
134
+ *
135
+ * @return array string to string map (param-name as array-key; default value as array-value)
136
+ */
137
+ function getRequiredServerParams();
138
+
139
+ /**
140
+ * get encoding of the page content
141
+ *
142
+ * @return string
143
+ */
144
+ function getPageContentEncoding();
145
+
146
+ /**
147
+ * get encoding of the page url
148
+ *
149
+ * @return string
150
+ */
151
+ function getPageUrlEncoding();
152
+
153
+ /**
154
+ * get encoding of the server url
155
+ *
156
+ * @return string
157
+ */
158
+ function getServerUrlEncoding();
159
}
lib/FACTFinder/Abstract/DataProvider.php CHANGED
@@ -1,112 +1,122 @@
1
- <?php
2
-
3
- /**
4
- * abstract data provider
5
- *
6
- * @author Rudolf Batt <rb@omikron.net>
7
- * @version $Id: DataProvider.php 25893 2010-06-29 08:19:43Z rb $
8
- * @package FACTFinder\Abstract
9
- */
10
- abstract class FACTFinder_Abstract_DataProvider
11
- {
12
- protected $params = array();
13
- protected $config = array();
14
- protected $type;
15
-
16
- protected $log;
17
-
18
- public function __construct(array $params = null, FACTFinder_Abstract_Configuration $config = null)
19
- {
20
- $this->log = FF::getLogger();
21
- $this->log->info("Initializing data provider.");
22
- if ($params != null) $this->setParams($params);
23
- if ($config != null) $this->setConfig($config);
24
- }
25
-
26
- /**
27
- * set type to identify which data should be loaded. that could be a request path or any source identifier
28
- *
29
- * @param mixed target
30
- **/
31
- public function setType($type)
32
- {
33
- $this->type = $type;
34
- }
35
-
36
- /**
37
- * return the data for the current config and params; the return type depends on the implementation
38
- *
39
- * @return mixed data
40
- **/
41
- abstract public function getData();
42
-
43
- /**
44
- * sets factfinder params object
45
- *
46
- * @param array params
47
- * @return void
48
- **/
49
- public function setParams(array $params)
50
- {
51
- $this->params = $params;
52
- }
53
-
54
- /**
55
- * set single param
56
- *
57
- * @param string name
58
- * @param string value
59
- * @return void
60
- **/
61
- public function setParam($name, $value)
62
- {
63
- $this->params[$name] = $value;
64
- }
65
-
66
- /**
67
- * unset single param
68
- *
69
- * @param string name
70
- * @return void
71
- **/
72
- public function unsetParam($name)
73
- {
74
- unset($this->params[$name]);
75
- }
76
-
77
- /**
78
- * set single param with multiple values
79
- *
80
- * @param string name
81
- * @param array of strings values
82
- * @return void
83
- **/
84
- public function setArrayParam($name, $values)
85
- {
86
- $this->params[$name] = $values;
87
- }
88
-
89
- /**
90
- * @param FACTFinder_Abstract_IConfiguration config
91
- **/
92
- public function setConfig(FACTFinder_Abstract_Configuration $config)
93
- {
94
- $this->config = $config;
95
- }
96
-
97
- /**
98
- * @return array
99
- **/
100
- public function getParams()
101
- {
102
- return $this->params;
103
- }
104
-
105
- /**
106
- * @return FACTFinder_Abstract_IConfiguration
107
- **/
108
- protected function getConfig()
109
- {
110
- return $this->config;
111
- }
112
}
1
+ <?php
2
+ /**
3
+ * FACT-Finder PHP Framework
4
+ *
5
+ * @category Library
6
+ * @package FACTFinder\Abstract
7
+ * @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
8
+ */
9
+
10
+ /**
11
+ * abstract data provider
12
+ *
13
+ * @author Rudolf Batt <rb@omikron.net>
14
+ * @version $Id: DataProvider.php 25893 2010-06-29 08:19:43Z rb $
15
+ * @package FACTFinder\Abstract
16
+ */
17
+ abstract class FACTFinder_Abstract_DataProvider
18
+ {
19
+ protected $params = array();
20
+ protected $config = array();
21
+ protected $type;
22
+
23
+ protected $log;
24
+
25
+ public function __construct(array $params = null, FACTFinder_Abstract_Configuration $config = null, FACTFinder_Abstract_Logger $log = null)
26
+ {
27
+ if(isset($log))
28
+ $this->log = $log;
29
+ else
30
+ $this->log = FF::getSingleton('nullLogger');
31
+ $this->log->info("Initializing data provider.");
32
+ if ($params != null) $this->setParams($params);
33
+ if ($config != null) $this->setConfig($config);
34
+ }
35
+
36
+ /**
37
+ * set type to identify which data should be loaded. that could be a request path or any source identifier
38
+ *
39
+ * @param mixed target
40
+ **/
41
+ public function setType($type)
42
+ {
43
+ $this->type = $type;
44
+ }
45
+
46
+ /**
47
+ * return the data for the current config and params; the return type depends on the implementation
48
+ *
49
+ * @return mixed data
50
+ **/
51
+ abstract public function getData();
52
+
53
+ /**
54
+ * sets factfinder params object
55
+ *
56
+ * @param array params
57
+ * @return void
58
+ **/
59
+ public function setParams(array $params)
60
+ {
61
+ $this->params = $params;
62
+ }
63
+
64
+ /**
65
+ * set single param
66
+ *
67
+ * @param string name
68
+ * @param string value
69
+ * @return void
70
+ **/
71
+ public function setParam($name, $value)
72
+ {
73
+ $this->params[$name] = $value;
74
+ }
75
+
76
+ /**
77
+ * unset single param
78
+ *
79
+ * @param string name
80
+ * @return void
81
+ **/
82
+ public function unsetParam($name)
83
+ {
84
+ unset($this->params[$name]);
85
+ }
86
+
87
+ /**
88
+ * set single param with multiple values
89
+ *
90
+ * @param string name
91
+ * @param array of strings values
92
+ * @return void
93
+ **/
94
+ public function setArrayParam($name, $values)
95
+ {
96
+ $this->params[$name] = $values;
97
+ }
98
+
99
+ /**
100
+ * @param FACTFinder_Abstract_IConfiguration config
101
+ **/
102
+ public function setConfig(FACTFinder_Abstract_Configuration $config)
103
+ {
104
+ $this->config = $config;
105
+ }
106
+
107
+ /**
108
+ * @return array
109
+ **/
110
+ public function getParams()
111
+ {
112
+ return $this->params;
113
+ }
114
+
115
+ /**
116
+ * @return FACTFinder_Abstract_IConfiguration
117
+ **/
118
+ protected function getConfig()
119
+ {
120
+ return $this->config;
121
+ }
122
}
lib/FACTFinder/Abstract/ImportAdapter.php ADDED
@@ -0,0 +1,55 @@
1
+ <?php
2
+ /**
3
+ * FACT-Finder PHP Framework
4
+ *
5
+ * @category Library
6
+ * @package FACTFinder\Abstract
7
+ * @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
8
+ */
9
+
10
+ /**
11
+ * adapter to trigger an import in factfinder
12
+ *
13
+ * @author Rudolf Batt <rb@omikron.net>
14
+ * @version $Id: TagCloudAdapter.php 25893 2010-06-29 08:19:43Z rb $
15
+ * @package FACTFinder\Abstract
16
+ */
17
+ abstract class FACTFinder_Abstract_ImportAdapter extends FACTFinder_Abstract_Adapter
18
+ {
19
+ /**
20
+ * trigger a data import
21
+ *
22
+ * @param bool $download import files will also be updated if true
23
+ * @return object $report import report in xml format
24
+ */
25
+ public function triggerDataImport($download = false) {
26
+ return $this->triggerImport($download, 'data');
27
+ }
28
+
29
+ /**
30
+ * trigger a suggest import
31
+ *
32
+ * @param bool $download import files will also be updated if true
33
+ * @return object $report import report in xml format
34
+ */
35
+ public function triggerSuggestImport($download = false) {
36
+ return $this->triggerImport($download, 'suggest');
37
+ }
38
+
39
+ /**
40
+ * trigger a recommendation import
41
+ *
42
+ * @param bool $download import files will also be updated if true
43
+ * @return object $report import report in xml format
44
+ */
45
+ public function triggerRecommendationImport($download = false) {
46
+ return $this->triggerImport($download, 'recommendation');
47
+ }
48
+
49
+ /**
50
+ * @param bool $download import files will also be updated if true
51
+ * @param string $type determines which import will be triggered. can be 'data', 'suggest' or 'recommendation'
52
+ * @return object $report import report in xml format
53
+ */
54
+ abstract protected function triggerImport($download, $type);
55
+ }
lib/FACTFinder/Abstract/Logger.php ADDED
@@ -0,0 +1,23 @@
1
+ <?php
2
+ /**
3
+ * FACT-Finder PHP Framework
4
+ *
5
+ * @category Library
6
+ * @package FACTFinder\Abstract
7
+ * @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
8
+ */
9
+
10
+ /**
11
+ * interface to access a logger if needed
12
+ *
13
+ * @package FACTFinder\Abstract
14
+ */
15
+ interface FACTFinder_Abstract_Logger
16
+ {
17
+ public function trace($message);
18
+ public function debug($message);
19
+ public function info($message);
20
+ public function warn($message);
21
+ public function error($message);
22
+ public function fatal($message);
23
+ }
lib/FACTFinder/Abstract/ProductCampaignAdapter.php CHANGED
@@ -1,4 +1,11 @@
1
<?php
2
3
/**
4
* adapter for the factfinder product campaign data
@@ -10,74 +17,74 @@
10
abstract class FACTFinder_Abstract_ProductCampaignAdapter extends FACTFinder_Abstract_Adapter
11
{
12
protected $productIds = array();
13
- protected $isShoppingCartCampaign = false;
14
- protected $campaignsUpToDate = false;
15
-
16
- protected $campaigns;
17
-
18
- /**
19
- * @throws Exception if there is no query or no catalog-parameter set at the dataprovider
20
- */
21
- protected function getData()
22
{
23
- $params = $this->getDataProvider()->getParams();
24
- if (empty($params['productNumber'])) {
25
- $this->log->error("No product number was set.");
26
- throw new Exception("No product number was set.");
27
- }
28
return $this->getDataProvider()->getData();
29
}
30
-
31
- /**
32
- * Set ids of products to be compared
33
- *
34
- * @param array $productIds list of integers
35
- **/
36
- public function setProductIds($productIds) {
37
- $this->productIds = $productIds;
38
- $this->campaignsUpToDate = false;
39
- if($this->isShoppingCartCampaign) {
40
- $this->getDataProvider()->setArrayParam('productNumber',$this->productIds);
41
- } else {
42
- $this->getDataProvider()->setParam('productNumber', $this->productIds[0]);
43
- }
44
- }
45
46
- /**
47
- * Adds an id to the list of products to be compared
48
- *
49
- * @param int $productId
50
- **/
51
- public function addProductId($productId) {
52
- $this->productIds[] = $productId;
53
- $this->campaignsUpToDate = false;
54
- if($this->isShoppingCartCampaign) {
55
- $this->getDataProvider()->setArrayParam('productNumber',$this->productIds);
56
- } else {
57
- $this->getDataProvider()->setParam('productNumber', $this->productIds[0]);
58
- }
59
- }
60
-
61
- /**
62
- * Sets the adapter up for fetching campaigns on product detail pages
63
- **/
64
- public function makeProductCampaign() {
65
- $this->isShoppingCartCampaign = false;
66
- $this->campaignsUpToDate = false;
67
- $this->getDataProvider()->setParam('do', 'getProductCampaigns');
68
- $this->getDataProvider()->setParam('productNumber', $this->productIds[0]);
69
- }
70
-
71
- /**
72
- * Sets the adapter up for fetching campaigns on shopping cart pages
73
- **/
74
- public function makeShoppingCartCampaign() {
75
- $this->isShoppingCartCampaign = true;
76
- $this->campaignsUpToDate = false;
77
- $this->getDataProvider()->setParam('do', 'getShoppingCartCampaigns');
78
- $this->getDataProvider()->setArrayParam('productNumber',$this->productIds);
79
- }
80
-
81
/**
82
* returns the campaigns
83
*
@@ -86,7 +93,7 @@ abstract class FACTFinder_Abstract_ProductCampaignAdapter extends FACTFinder_Abs
86
public function getCampaigns() {
87
if (!$this->campaigns || $this->campaigns == null) {
88
$this->campaigns = $this->createCampaigns();
89
- $this->campaignsUpToDate == true;
90
}
91
return $this->campaigns;
92
}
1
<?php
2
+ /**
3
+ * FACT-Finder PHP Framework
4
+ *
5
+ * @category Library
6
+ * @package FACTFinder\Abstract
7
+ * @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
8
+ */
9
10
/**
11
* adapter for the factfinder product campaign data
17
abstract class FACTFinder_Abstract_ProductCampaignAdapter extends FACTFinder_Abstract_Adapter
18
{
19
protected $productIds = array();
20
+ protected $isShoppingCartCampaign = false;
21
+ protected $campaignsUpToDate = false;
22
+
23
+ protected $campaigns;
24
+
25
+ /**
26
+ * @throws Exception if there is no query or no catalog-parameter set at the dataprovider
27
+ */
28
+ protected function getData()
29
{
30
+ $params = $this->getDataProvider()->getParams();
31
+ if (empty($params['productNumber'])) {
32
+ $this->log->error("No product number was set.");
33
+ throw new Exception("No product number was set.");
34
+ }
35
return $this->getDataProvider()->getData();
36
}
37
+
38
+ /**
39
+ * Set ids of products to be compared
40
+ *
41
+ * @param array $productIds list of integers
42
+ **/
43
+ public function setProductIds($productIds) {
44
+ $this->productIds = $productIds;
45
+ $this->campaignsUpToDate = false;
46
+ if($this->isShoppingCartCampaign) {
47
+ $this->getDataProvider()->setArrayParam('productNumber',$this->productIds);
48
+ } else {
49
+ $this->getDataProvider()->setParam('productNumber', $this->productIds[0]);
50
+ }
51
+ }
52
53
+ /**
54
+ * Adds an id to the list of products to be compared
55
+ *
56
+ * @param int $productId
57
+ **/
58
+ public function addProductId($productId) {
59
+ $this->productIds[] = $productId;
60
+ $this->campaignsUpToDate = false;
61
+ if($this->isShoppingCartCampaign) {
62
+ $this->getDataProvider()->setArrayParam('productNumber',$this->productIds);
63
+ } else {
64
+ $this->getDataProvider()->setParam('productNumber', $this->productIds[0]);
65
+ }
66
+ }
67
+
68
+ /**
69
+ * Sets the adapter up for fetching campaigns on product detail pages
70
+ **/
71
+ public function makeProductCampaign() {
72
+ $this->isShoppingCartCampaign = false;
73
+ $this->campaignsUpToDate = false;
74
+ $this->getDataProvider()->setParam('do', 'getProductCampaigns');
75
+ $this->getDataProvider()->setParam('productNumber', $this->productIds[0]);
76
+ }
77
+
78
+ /**
79
+ * Sets the adapter up for fetching campaigns on shopping cart pages
80
+ **/
81
+ public function makeShoppingCartCampaign() {
82
+ $this->isShoppingCartCampaign = true;
83
+ $this->campaignsUpToDate = false;
84
+ $this->getDataProvider()->setParam('do', 'getShoppingCartCampaigns');
85
+ $this->getDataProvider()->setArrayParam('productNumber',$this->productIds);
86
+ }
87
+
88
/**
89
* returns the campaigns
90
*
93
public function getCampaigns() {
94
if (!$this->campaigns || $this->campaigns == null) {
95
$this->campaigns = $this->createCampaigns();
96
+ $this->campaignsUpToDate == true;
97
}
98
return $this->campaigns;
99
}
lib/FACTFinder/Abstract/RecommendationAdapter.php CHANGED
@@ -1,87 +1,94 @@
1
- <?php
2
-
3
- /**
4
- * adapter for the factfinder recommendation engine
5
- *
6
- * @author Rudolf Batt <rb@omikron.net>
7
- * @version $Id$
8
- * @package FACTFinder\Abstract
9
- */
10
- abstract class FACTFinder_Abstract_RecommendationAdapter extends FACTFinder_Abstract_Adapter
11
- {
12
- protected $productIds = array();
13
- protected $recommendation;
14
- protected $recommendationUpToDate = false;
15
-
16
- protected $idsOnly = false;
17
- /*
18
- * Option for XML query. 0 means "no maximum".
19
- */
20
- protected $maxResults = 0;
21
-
22
- /*
23
- * @return int $maxResults
24
- */
25
- public function getMaxResults() {
26
- return $this->maxResults;
27
- }
28
-
29
- /*
30
- * @param int $count positive integer (negative will be treated as 0)
31
- */
32
- public function setMaxResults($count) {
33
- $this->maxResults = $count < 1 ? 0 : $count;
34
- if($count > 0) $this->getDataProvider()->setParam('maxResults', $count);
35
- else $this->getDataProvder()->unsetParam('maxResults');
36
- }
37
-
38
- /**
39
- * Set id of product to base recommendation on
40
- *
41
- * @param int $productId
42
- **/
43
- public function setProductId($productId) {
44
- $this->productIds = array($productId);
45
- $this->getDataProvider()->setParam('id', $productId);
46
- $this->recommendationUpToDate = false;
47
- }
48
-
49
- public function setIdsOnly($idsOnly) {
50
- // Reset the recommendations, if more detail is wanted than before
51
- if($this->idsOnly && !$idsOnly) $recommendationUpToDate = false;
52
- $this->idsOnly = $idsOnly;
53
- $this->getDataProvider()->setParam('idsOnly', $idsOnly ? 'true' : 'false');
54
- }
55
-
56
- /**
57
- * creates the recommendation-records
58
- *
59
- * @param string id
60
- * @return array of FACTFinder_Record objects
61
- **/
62
- abstract protected function createRecommendations();
63
-
64
- /**
65
- * returns recommendations for specified id. if no id is set, try to fetch parameter 'id'.
66
- * if no id is available, there will be a warning raised and returning an empty array
67
- *
68
- * @return FACTFinder_Result
69
- **/
70
- public function getRecommendations() {
71
- if (empty($this->productIds)) {
72
- $requestParams = $this->getParamsParser()->getRequestParams();
73
- if (isset($requestParams['id'])) {
74
- $this->productIds = array($requestParams['id']);
75
- }
76
- if (empty($this->productIds)) {
77
- trigger_error('recommendations can not be loaded without id. could not load id from request', E_USER_WARNING);
78
- return array();
79
- }
80
- }
81
- if (!$this->recommendationUpToDate || !isset($this->recommendation) || $this->recommendation == null) {
82
- $this->recommendation = $this->createRecommendations();
83
- $this->recommendationUpToDate = true;
84
- }
85
- return $this->recommendation;
86
- }
87
- }
1
+ <?php
2
+ /**
3
+ * FACT-Finder PHP Framework
4
+ *
5
+ * @category Library
6
+ * @package FACTFinder\Abstract
7
+ * @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
8
+ */
9
+
10
+ /**
11
+ * adapter for the factfinder recommendation engine
12
+ *
13
+ * @author Rudolf Batt <rb@omikron.net>
14
+ * @version $Id$
15
+ * @package FACTFinder\Abstract
16
+ */
17
+ abstract class FACTFinder_Abstract_RecommendationAdapter extends FACTFinder_Abstract_Adapter
18
+ {
19
+ protected $productIds = array();
20
+ protected $recommendation;
21
+ protected $recommendationUpToDate = false;
22
+
23
+ protected $idsOnly = false;
24
+ /*
25
+ * Option for XML query. 0 means "no maximum".
26
+ */
27
+ protected $maxResults = 0;
28
+
29
+ /*
30
+ * @return int $maxResults
31
+ */
32
+ public function getMaxResults() {
33
+ return $this->maxResults;
34
+ }
35
+
36
+ /*
37
+ * @param int $count positive integer (negative will be treated as 0)
38
+ */
39
+ public function setMaxResults($count) {
40
+ $this->maxResults = $count < 1 ? 0 : $count;
41
+ if($count > 0) $this->getDataProvider()->setParam('maxResults', $count);
42
+ else $this->getDataProvder()->unsetParam('maxResults');
43
+ }
44
+
45
+ /**
46
+ * Set id of product to base recommendation on
47
+ *
48
+ * @param int $productId
49
+ **/
50
+ public function setProductId($productId) {
51
+ $this->productIds = array($productId);
52
+ $this->getDataProvider()->setParam('id', $productId);
53
+ $this->recommendationUpToDate = false;
54
+ }
55
+
56
+ public function setIdsOnly($idsOnly) {
57
+ // Reset the recommendations, if more detail is wanted than before
58
+ if($this->idsOnly && !$idsOnly) $recommendationUpToDate = false;
59
+ $this->idsOnly = $idsOnly;
60
+ $this->getDataProvider()->setParam('idsOnly', $idsOnly ? 'true' : 'false');
61
+ }
62
+
63
+ /**
64
+ * creates the recommendation-records
65
+ *
66
+ * @param string id
67
+ * @return array of FACTFinder_Record objects
68
+ **/
69
+ abstract protected function createRecommendations();
70
+
71
+ /**
72
+ * returns recommendations for specified id. if no id is set, try to fetch parameter 'id'.
73
+ * if no id is available, there will be a warning raised and returning an empty array
74
+ *
75
+ * @return FACTFinder_Result
76
+ **/
77
+ public function getRecommendations() {
78
+ if (empty($this->productIds)) {
79
+ $requestParams = $this->getParamsParser()->getRequestParams();
80
+ if (isset($requestParams['id'])) {
81
+ $this->productIds = array($requestParams['id']);
82
+ }
83
+ if (empty($this->productIds)) {
84
+ trigger_error('recommendations can not be loaded without id. could not load id from request', E_USER_WARNING);
85
+ return array();
86
+ }
87
+ }
88
+ if (!$this->recommendationUpToDate || !isset($this->recommendation) || $this->recommendation == null) {
89
+ $this->recommendation = $this->createRecommendations();
90
+ $this->recommendationUpToDate = true;
91
+ }
92
+ return $this->recommendation;
93
+ }
94
+ }
lib/FACTFinder/Abstract/ScicAdapter.php CHANGED
@@ -1,152 +1,159 @@
1
- <?php
2
-
3
- /**
4
- * abstract adapter for the shopping cart information collector tracking
5
- *
6
- * @author Rudolf Batt <rb@omikron.net>
7
- * @version $Id: ScicAdapter.php 25896 2010-06-29 08:34:06Z rb $
8
- * @package FACTFinder\Abstract
9
- */
10
- abstract class FACTFinder_Abstract_ScicAdapter extends FACTFinder_Abstract_Adapter
11
- {
12
- /**
13
- * let the data provider save the tracking params
14
- *
15
- * @return boolean $success
16
- */
17
- abstract protected function applyTracking();
18
-
19
- /**
20
- * if all needed parameters are available at the request like described in the documentation, just use this method to
21
- * fetch the needed parameters and track them
22
- * insure to set a session id if there is no parameter "sid". if this argument is not set or empty and the parameter
23
- * "sid" is not available, it will try to use session_id() to fetch one.
24
- *
25
- * @param string $sid session id
26
- * @return boolean $success
27
- */
28
- public function doTrackingFromRequest($sid = null)
29
- {
30
- $params = $this->getParamsParser()->getServerRequestParams();
31
- if (!empty($sid)) {
32
- $params['sid'] = $sid;
33
- } else if (empty($params['sid'])) {
34
- $params['sid'] = session_id();
35
- }
36
- $this->getDataProvider()->setParams($params);
37
- return $this->applyTracking();
38
- }
39
-
40
- /**
41
- * track a detail click on a product
42
- *
43
- * @param string $id id of product
44
- * @param string $sid session id (if empty, then try to set using the function session_id() )
45
- * @param string $query query which led to the product
46
- * @param int $pos position of product in the search result
47
- * @param int $origPos original position of product in the search result. this data is delivered by FACT-Finder (optional - is set equals to $position by default)
48
- * @param int $page page number where the product was clicked (optional - is 1 by default)
49
- * @param double $simi similiarity of the product (optional - is 100.00 by default)
50
- * @param string $title title of product (optional - is empty by default)
51
- * @param int $pageSize size of the page where the product was found (optional - is 12 by default)
52
- * @param int $origPageSize original size of the page before the user could have changed it (optional - is set equals to $page by default)
53
- * @return boolean $success
54
- */
55
- public function trackClick($id, $sid = null, $query, $pos, $origPos = -1, $page = 1, $simi = 100.0, $title = '',
56
- $pageSize = 12, $origPageSize = -1)
57
- {
58
- if (empty($sid)) $sid = session_id();
59
- if ($origPos == -1) $origPos = $pos;
60
- if ($origPageSize == -1) $origPageSize = $pageSize;
61
-
62
- $this->getDataProvider()->setParams(
63
- array(
64
- 'query' => $query,
65
- 'id' => $id,
66
- 'pos' => $pos,
67
- 'origPos' => $origPos,
68
- 'page' => $page,
69
- 'simi' => $simi,
70
- 'sid' => $sid,
71
- 'title' => $title,
72
- 'event' => 'click',
73
- 'pageSize' => $pageSize,
74
- 'origPageSize' => $origPageSize
75
- )
76
- );
77
- return $this->applyTracking();
78
- }
79
-
80
- /**
81
- * track a product which was added to the cart
82
- *
83
- * @param string $id id of product
84
- * @param string $sid session id (if empty, then try to set using the function session_id() )
85
- * @param int $count number of items purchased for each product (optional - default 1)
86
- * @param double $price this is the single unit price (optional)
87
- * @return boolean $success
88
- */
89
- public function trackCart($id, $sid = null, $count = 1, $price = null, $userid = null)
90
- {
91
- if (empty($sid)) $sid = session_id();
92
- $params = array(
93
- 'id' => $id,
94
- 'sid' => $sid,
95
- 'count' => $count,
96
- 'event' => 'cart'
97
- );
98
-
99
- if (!empty($price)) $params['price'] = $price;
100
- if (!empty($userid)) $params['userid'] = $userid;
101
-
102
- $this->getDataProvider()->setParams($params);
103
- return $this->applyTracking();
104
- }
105
-
106
- /**
107
- * track a product which was purchased
108
- *
109
- * @param string $id id of product
110
- * @param string $sid session id (if empty, then try to set using the function session_id() )
111
- * @param int $count number of items purchased for each product (optional - default 1)
112
- * @param double $price this is the single unit price (optional)
113
- * @return boolean $success
114
- */
115
- public function trackCheckout($id, $sid = null, $count = 1, $price = null, $userid = null)
116
- {
117
- if (empty($sid)) $sid = session_id();
118
- $params = array(
119
- 'id' => $id,
120
- 'sid' => $sid,
121
- 'count' => $count,
122
- 'event' => 'checkout'
123
- );
124
-
125
- if (!empty($price)) $params['price'] = $price;
126
- if (!empty($userid)) $params['userid'] = $userid;
127
-
128
- $this->getDataProvider()->setParams($params);
129
- return $this->applyTracking();
130
- }
131
-
132
- /**
133
- * track a click on a recommended product
134
- *
135
- * @param string $id id of product
136
- * @param string $sid session id (if empty, then try to set using the function session_id() )
137
- * @param int $mainId ID of the product for which the clicked-upon item was recommended
138
- * @return boolean $success
139
- */
140
- public function trackRecommendationClick($id, $sid = null, $mainId)
141
- {
142
- if (empty($sid)) $sid = session_id();
143
- $params = array(
144
- 'id' => $id,
145
- 'sid' => $sid,
146
- 'mainId' => $mainId,
147
- 'event' => 'recommendationClick'
148
- );
149
- $this->getDataProvider()->setParams($params);
150
- return $this->applyTracking();
151
- }
152
}
1
+ <?php
2
+ /**
3
+ * FACT-Finder PHP Framework
4
+ *
5
+ * @category Library
6
+ * @package FACTFinder\Abstract
7
+ * @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
8
+ */
9
+
10
+ /**
11
+ * abstract adapter for the shopping cart information collector tracking
12
+ *
13
+ * @author Rudolf Batt <rb@omikron.net>
14
+ * @version $Id: ScicAdapter.php 25896 2010-06-29 08:34:06Z rb $
15
+ * @package FACTFinder\Abstract
16
+ */
17
+ abstract class FACTFinder_Abstract_ScicAdapter extends FACTFinder_Abstract_Adapter
18
+ {
19
+ /**
20
+ * let the data provider save the tracking params
21
+ *
22
+ * @return boolean $success
23
+ */
24
+ abstract protected function applyTracking();
25
+
26
+ /**
27
+ * if all needed parameters are available at the request like described in the documentation, just use this method to
28
+ * fetch the needed parameters and track them
29
+ * insure to set a session id if there is no parameter "sid". if this argument is not set or empty and the parameter
30
+ * "sid" is not available, it will try to use session_id() to fetch one.
31
+ *
32
+ * @param string $sid session id
33
+ * @return boolean $success
34
+ */
35
+ public function doTrackingFromRequest($sid = null)
36
+ {
37
+ $params = $this->getParamsParser()->getServerRequestParams();
38
+ if (strlen($sid) > 0) {
39
+ $params['sid'] = $sid;
40
+ } else if (!isset($params['sid']) || strlen($params['sid']) == 0) {
41
+ $params['sid'] = session_id();
42
+ }
43
+ $this->getDataProvider()->setParams($params);
44
+ return $this->applyTracking();
45
+ }
46
+
47
+ /**
48
+ * track a detail click on a product
49
+ *
50
+ * @param string $id id of product
51
+ * @param string $sid session id (if empty, then try to set using the function session_id() )
52
+ * @param string $query query which led to the product
53
+ * @param int $pos position of product in the search result
54
+ * @param int $origPos original position of product in the search result. this data is delivered by FACT-Finder (optional - is set equals to $position by default)
55
+ * @param int $page page number where the product was clicked (optional - is 1 by default)
56
+ * @param double $simi similiarity of the product (optional - is 100.00 by default)
57
+ * @param string $title title of product (optional - is empty by default)
58
+ * @param int $pageSize size of the page where the product was found (optional - is 12 by default)
59
+ * @param int $origPageSize original size of the page before the user could have changed it (optional - is set equals to $page by default)
60
+ * @return boolean $success
61
+ */
62
+ public function trackClick($id, $sid = null, $query, $pos, $origPos = -1, $page = 1, $simi = 100.0, $title = '',
63
+ $pageSize = 12, $origPageSize = -1)
64
+ {
65
+ if (strlen($sid) == 0) $sid = session_id();
66
+ if ($origPos == -1) $origPos = $pos;
67
+ if ($origPageSize == -1) $origPageSize = $pageSize;
68
+
69
+ $this->getDataProvider()->setParams(
70
+ array(
71
+ 'query' => $query,
72
+ 'id' => $id,
73
+ 'pos' => $pos,
74
+ 'origPos' => $origPos,
75
+ 'page' => $page,
76
+ 'simi' => $simi,
77
+ 'sid' => $sid,
78
+ 'title' => $title,
79
+ 'event' => 'click',
80
+ 'pageSize' => $pageSize,
81
+ 'origPageSize' => $origPageSize
82
+ )
83
+ );
84
+ return $this->applyTracking();
85
+ }
86
+
87
+ /**
88
+ * track a product which was added to the cart
89
+ *
90
+ * @param string $id id of product
91
+ * @param string $sid session id (if empty, then try to set using the function session_id() )
92
+ * @param int $count number of items purchased for each product (optional - default 1)
93
+ * @param double $price this is the single unit price (optional)
94
+ * @return boolean $success
95
+ */
96
+ public function trackCart($id, $sid = null, $count = 1, $price = null, $userid = null)
97
+ {
98
+ if (strlen($sid) == 0) $sid = session_id();
99
+ $params = array(
100
+ 'id' => $id,
101
+ 'sid' => $sid,
102
+ 'count' => $count,
103
+ 'event' => 'cart'
104
+ );
105
+
106
+ if (strlen($price) > 0) $params['price'] = $price;
107
+ if (strlen($userid) > 0) $params['userid'] = $userid;
108
+
109
+ $this->getDataProvider()->setParams($params);
110
+ return $this->applyTracking();
111
+ }
112
+
113
+ /**
114
+ * track a product which was purchased
115
+ *
116
+ * @param string $id id of product
117
+ * @param string $sid session id (if empty, then try to set using the function session_id() )
118
+ * @param int $count number of items purchased for each product (optional - default 1)
119
+ * @param double $price this is the single unit price (optional)
120
+ * @return boolean $success
121
+ */
122
+ public function trackCheckout($id, $sid = null, $count = 1, $price = null, $userid = null)
123
+ {
124
+ if (strlen($sid) == 0) $sid = session_id();
125
+ $params = array(
126
+ 'id' => $id,
127
+ 'sid' => $sid,
128
+ 'count' => $count,
129
+ 'event' => 'checkout'
130
+ );
131
+
132
+ if (strlen($price) > 0) $params['price'] = $price;
133
+ if (strlen($userid) > 0) $params['userid'] = $userid;
134
+
135
+ $this->getDataProvider()->setParams($params);
136
+ return $this->applyTracking();
137
+ }
138
+
139
+ /**
140
+ * track a click on a recommended product
141
+ *
142
+ * @param string $id id of product
143
+ * @param string $sid session id (if empty, then try to set using the function session_id() )
144
+ * @param int $mainId ID of the product for which the clicked-upon item was recommended
145
+ * @return boolean $success
146
+ */
147
+ public function trackRecommendationClick($id, $sid = null, $mainId)
148
+ {
149
+ if (strlen($sid) == 0) $sid = session_id();
150
+ $params = array(
151
+ 'id' => $id,
152
+ 'sid' => $sid,
153
+ 'mainId' => $mainId,
154
+ 'event' => 'recommendationClick'
155
+ );
156
+ $this->getDataProvider()->setParams($params);
157
+ return $this->applyTracking();
158
+ }
159
}
lib/FACTFinder/Abstract/SearchAdapter.php CHANGED
@@ -1,252 +1,260 @@
1
- <?php
2
-
3
- /**
4
- * adapter for the factfinder search
5
- *
6
- * @author Rudolf Batt <rb@omikron.net>
7
- * @version $Id: SearchAdapter.php 25935 2010-06-29 15:04:45Z rb $
8
- * @package FACTFinder\Abstract
9
- */
10
- abstract class FACTFinder_Abstract_SearchAdapter extends FACTFinder_Abstract_Adapter
11
- {
12
- private $searchParams;
13
- private $result;
14
- private $asn;
15
- private $sorting;
16
- private $paging;
17
- private $productsPerPageOptions;
18
- private $breadCrumbTrail;
19
- private $campaigns;
20
- private $singleWordSearch;
21
-
22
- const NO_QUERY = 'noQuery';
23
- const NO_RESULT = 'noResult';
24
- const RESULTS_FOUND = 'resultsFound';
25
- const NOTHING_FOUND = 'nothingFound';
26
-
27
- /**
28
- * @throws Exception if there is no query or no catalog-parameter set at the dataprovider
29
- */
30
- protected function getData()
31
- {
32
- $params = $this->getDataProvider()->getParams();
33
- if (empty($params['query']) && empty($params['seoPath'])
34
- && (empty($params['catalog']) || $params['catalog'] != 'true')) {
35
- $this->log->error("No query was set.");
36
- throw new Exception(self::NO_QUERY);
37
- }
38
- return $this->getDataProvider()->getData();
39
- }
40
-
41
- /**
42
- * returns the search status of the article number search, which is one of this class constants:
43
- * NO_RESULT it was not an article number search
44
- * NOTHING_FOUND is article number search, but nothing found
45
- * RESULTS_FOUND found article by article number
46
- * returns null, if no article number search was done
47
- *
48
- * @return string status
49
- **/
50
- abstract public function getArticleNumberSearchStatus();
51
-
52
- /**
53
- * returns true if the query matches the article number search regex, else false. also returns false, when there
54
- * was any error
55
- *
56
- * @return boolean isArticleNumberSearch
57
- **/
58
- abstract public function isArticleNumberSearch();
59
-
60
- /**
61
- * returns true when search timed out. even if true, nevertheless result records may exist
62
- *
63
- * @return boolean
64