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
- app/code/community/Flagbit/FactFinder/Block/Secondaryresult.php +12 -0
- app/code/community/Flagbit/FactFinder/Helper/Debug.php +26 -11
- app/code/community/Flagbit/FactFinder/Helper/Search.php +55 -51
- app/code/community/Flagbit/FactFinder/Model/Adapter.php +113 -3
- app/code/community/Flagbit/FactFinder/etc/config.xml +1 -1
- app/code/community/Flagbit/FactFinder/etc/system.xml +13 -4
- app/design/frontend/base/default/layout/factfinder.xml +4 -3
- app/design/frontend/base/default/template/factfinder/secondaryresult.phtml +41 -0
- app/locale/de_DE/Flagbit_FactFinder.csv +6 -2
- lib/FACTFinder/Abstract/Adapter.php +127 -117
- lib/FACTFinder/Abstract/CompareAdapter.php +60 -53
- lib/FACTFinder/Abstract/Configuration.php +158 -152
- lib/FACTFinder/Abstract/DataProvider.php +121 -111
- lib/FACTFinder/Abstract/ImportAdapter.php +55 -0
- lib/FACTFinder/Abstract/Logger.php +23 -0
- lib/FACTFinder/Abstract/ProductCampaignAdapter.php +72 -65
- lib/FACTFinder/Abstract/RecommendationAdapter.php +94 -87
- lib/FACTFinder/Abstract/ScicAdapter.php +158 -151
- lib/FACTFinder/Abstract/SearchAdapter.php +260 -252
- lib/FACTFinder/Abstract/SimilarRecordsAdapter.php +84 -77
- lib/FACTFinder/Abstract/SuggestAdapter.php +39 -32
- lib/FACTFinder/Abstract/TagCloudAdapter.php +36 -29
- lib/FACTFinder/AdvisorAnswer.php +27 -19
- lib/FACTFinder/AdvisorQuestion.php +18 -10
- lib/FACTFinder/Asn.php +36 -29
- lib/FACTFinder/AsnFilterItem.php +71 -64
- lib/FACTFinder/AsnGroup.php +134 -127
- lib/FACTFinder/AsnSliderFilter.php +130 -123
- lib/FACTFinder/BreadCrumbItem.php +74 -67
- lib/FACTFinder/Campaign.php +205 -197
- lib/FACTFinder/CampaignIterator.php +189 -181
- lib/FACTFinder/Configuration.php +332 -325
- lib/FACTFinder/EncodingHandler.php +218 -208
- lib/FACTFinder/Http/DataProvider.php +308 -290
- lib/FACTFinder/Http/DummyProvider.php +72 -66
- lib/FACTFinder/Http/ParallelDataProvider.php +139 -127
- lib/FACTFinder/Http/ScicAdapter.php +35 -28
- lib/FACTFinder/Http/SuggestAdapter.php +40 -34
- lib/FACTFinder/Item.php +54 -47
- lib/FACTFinder/Loader.php +191 -184
- lib/FACTFinder/Log4PhpLogger.php +86 -0
- lib/FACTFinder/Logger/BlackHole.php +0 -7
- lib/FACTFinder/Logger/LoggerInterface.php +0 -6
- lib/FACTFinder/NullLogger.php +24 -0
- lib/FACTFinder/Paging.php +177 -170
- lib/FACTFinder/Parameters.php +112 -105
- lib/FACTFinder/ParametersParser.php +378 -371
- lib/FACTFinder/ProductsPerPageOptions.php +85 -78
- lib/FACTFinder/Record.php +258 -251
- lib/FACTFinder/Result.php +40 -33
- lib/FACTFinder/SingleWordSearchItem.php +45 -38
- lib/FACTFinder/SuggestQuery.php +77 -70
- lib/FACTFinder/TagQuery.php +47 -40
- lib/FACTFinder/Util.php +56 -47
- lib/FACTFinder/Xml64/SearchAdapter.php +114 -110
- lib/FACTFinder/Xml65/ImportAdapter.php +84 -0
- lib/FACTFinder/Xml65/RecommendationAdapter.php +90 -83
- lib/FACTFinder/Xml65/SearchAdapter.php +479 -492
- lib/FACTFinder/Xml65/SuggestAdapter.php +64 -58
- lib/FACTFinder/Xml65/TagCloudAdapter.php +64 -61
- lib/FACTFinder/Xml66/CompareAdapter.php +26 -25
- lib/FACTFinder/Xml66/ImportAdapter.php +22 -0
- lib/FACTFinder/Xml66/RecommendationAdapter.php +22 -15
- lib/FACTFinder/Xml66/SearchAdapter.php +119 -114
- lib/FACTFinder/Xml66/SimilarRecordsAdapter.php +24 -23
- lib/FACTFinder/Xml66/SuggestAdapter.php +21 -14
- lib/FACTFinder/Xml66/TagCloudAdapter.php +22 -15
- lib/FACTFinder/Xml67/CompareAdapter.php +7 -0
- lib/FACTFinder/Xml67/ImportAdapter.php +19 -0
- lib/FACTFinder/Xml67/ProductCampaignAdapter.php +96 -93
- lib/FACTFinder/Xml67/RecommendationAdapter.php +27 -20
- lib/FACTFinder/Xml67/SearchAdapter.php +88 -83
- lib/FACTFinder/Xml67/SimilarRecordsAdapter.php +7 -0
- lib/FACTFinder/Xml67/SuggestAdapter.php +7 -0
- lib/FACTFinder/Xml67/TagCloudAdapter.php +7 -0
- 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
|
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 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
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 |
-
$
|
|
|
|
|
|
|
|
|
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
|
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
|
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.
|
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 |
-
|
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
|
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
|
|
|
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 |
-
*
|
5 |
-
*
|
6 |
-
*
|
7 |
-
*
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
*
|
71 |
-
*
|
72 |
-
* @return
|
73 |
-
**/
|
74 |
-
|
75 |
-
{
|
76 |
-
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
*
|
81 |
-
*
|
82 |
-
* @
|
83 |
-
|
84 |
-
|
85 |
-
{
|
86 |
-
$this->
|
87 |
-
}
|
88 |
-
|
89 |
-
/**
|
90 |
-
*
|
91 |
-
*
|
92 |
-
* @
|
93 |
-
|
94 |
-
|
95 |
-
{
|
96 |
-
|
97 |
-
}
|
98 |
-
|
99 |
-
/**
|
100 |
-
*
|
101 |
-
*
|
102 |
-
* @
|
103 |
-
|
104 |
-
|
105 |
-
{
|
106 |
-
$this->
|
107 |
-
}
|
108 |
-
|
109 |
-
/**
|
110 |
-
*
|
111 |
-
*
|
112 |
-
* @
|
113 |
-
|
114 |
-
|
115 |
-
{
|
116 |
-
|
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 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
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 |
-
|
60 |
-
|
61 |
$this->comparableAttributes = $this->createComparableAttributes();
|
62 |
-
|
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 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
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 |
-
*
|
5 |
-
*
|
6 |
-
* @
|
7 |
-
* @
|
8 |
-
*/
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
* @return string
|
19 |
-
*/
|
20 |
-
function
|
21 |
-
|
22 |
-
/**
|
23 |
-
* @
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
*
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
*
|
96 |
-
*
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
*
|
103 |
-
*
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
*
|
111 |
-
*
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
*
|
119 |
-
*
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
*
|
127 |
-
*
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
*
|
135 |
-
*
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
*
|
142 |
-
*
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
*
|
149 |
-
*
|
150 |
-
|
151 |
-
|
152 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
*
|
5 |
-
*
|
6 |
-
* @
|
7 |
-
* @
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
$this->
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
*
|
38 |
-
*
|
39 |
-
* @
|
40 |
-
**/
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
*
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
*
|
56 |
-
*
|
57 |
-
* @
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
*
|
68 |
-
*
|
69 |
-
* @
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
*
|
79 |
-
*
|
80 |
-
* @
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
* @param
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
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 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
{
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
return $this->getDataProvider()->getData();
|
29 |
}
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
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 |
-
|
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 |
-
*
|
5 |
-
*
|
6 |
-
* @
|
7 |
-
* @
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
protected $
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
*/
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
*
|
66 |
-
|
67 |
-
*
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
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 |
-
*
|
5 |
-
*
|
6 |
-
* @
|
7 |
-
* @
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
/**
|
20 |
-
*
|
21 |
-
*
|
22 |
-
*
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
*
|
49 |
-
*
|
50 |
-
* @param string $
|
51 |
-
* @param
|
52 |
-
* @param
|
53 |
-
* @
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
'
|
72 |
-
'
|
73 |
-
'
|
74 |
-
'
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
$
|
150 |
-
|
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 |
-
*
|
5 |
-
*
|
6 |
-
* @
|
7 |
-
* @
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
private $
|
20 |
-
private $
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
*
|
54 |
-
* was
|
55 |
-
*
|
56 |
-
* @return
|
57 |
-
**/
|
58 |
-
abstract public function
|
59 |
-
|
60 |
-
/**
|
61 |
-
* returns true
|
62 |
-
*
|
63 |
-
*
|
64 |