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 |
-
$
|
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 |
-
|
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 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 search
|
12 |
+
*
|
13 |
+
* @author Rudolf Batt <rb@omikron.net>
|
14 |
+
* @version $Id: SearchAdapter.php 25935 2010-06-29 15:04:45Z rb $
|
15 |
+
* @package FACTFinder\Abstract
|
16 |
+
*/
|
17 |
+
abstract class FACTFinder_Abstract_SearchAdapter extends FACTFinder_Abstract_Adapter
|
18 |
+
{
|
19 |
+
private $searchParams;
|
20 |
+
private $result;
|
21 |
+
private $asn;
|
22 |
+
private $sorting;
|
23 |
+
private $paging;
|
24 |
+
private $productsPerPageOptions;
|
25 |
+
private $breadCrumbTrail;
|
26 |
+
private $campaigns;
|
27 |
+
private $singleWordSearch;
|
28 |
+
|
29 |
+
const NO_QUERY = 'noQuery';
|
30 |
+
const NO_RESULT = 'noResult';
|
31 |
+
const RESULTS_FOUND = 'resultsFound';
|
32 |
+
const NOTHING_FOUND = 'nothingFound';
|
33 |
+
|
34 |
+
/**
|
35 |
+
* @throws Exception if there is no query or no catalog-parameter set at the dataprovider
|
36 |
+
*/
|
37 |
+
protected function getData()
|
38 |
+
{
|
39 |
+
$params = $this->getDataProvider()->getParams();
|
40 |
+
if ((!isset($params['query']) || strlen($params['query']) == 0)
|
41 |
+
&& (!isset($params['seoPath']) || strlen($params['seoPath']) == 0)
|
42 |
+
&& (!isset($params['catalog']) || $params['catalog'] != 'true')) {
|
43 |
+
$this->log->error("No query was set.");
|
44 |
+
throw new Exception(self::NO_QUERY);
|
45 |
+
}
|
46 |
+
return $this->getDataProvider()->getData();
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* returns the search status of the article number search, which is one of this class constants:
|
51 |
+
* NO_RESULT it was not an article number search
|
52 |
+
* NOTHING_FOUND is article number search, but nothing found
|
53 |
+
* RESULTS_FOUND found article by article number
|
54 |
+
* returns null, if no article number search was done
|
55 |
+
*
|
56 |
+
* @return string status
|
57 |
+
**/
|
58 |
+
abstract public function getArticleNumberSearchStatus();
|
59 |
+
|
60 |
+
/**
|
61 |
+
* returns true if the query matches the article number search regex, else false. also returns false, when there
|
62 |
+
* was any error
|
63 |
+
*
|
64 |
+
* @return boolean isArticleNumberSearch
|
65 |
+
**/
|
66 |
+
abstract public function isArticleNumberSearch();
|
67 |
+
|
68 |
+
/**
|
69 |
+
* returns true when search timed out. even if true, nevertheless result records may exist
|
70 |
+
*
|
71 |
+
* @return boolean
|
72 |
+
**/
|
73 |
+
abstract public function isSearchTimedOut();
|
74 |
+
|
75 |
+
/**
|
76 |
+
* returns the search status of the search, which is one of this class constants:
|
77 |
+
* NO_RESULT: there seems to be any error. no search done
|
78 |
+
* NOTHING_FOUND: search done, but nothing found; maybe campaigns are available
|
79 |
+
* RESULTS_FOUND: results found
|
80 |
+
* returns null, if no article number search was done
|
81 |
+
*
|
82 |
+
* @return string status
|
83 |
+
**/
|
84 |
+
abstract public function getStatus();
|
85 |
+
|
86 |
+
/**
|
87 |
+
* creates the result object
|
88 |
+
*
|
89 |
+
* @return FACTFinder_Result
|
90 |
+
**/
|
91 |
+
abstract protected function createResult();
|
92 |
+
|
93 |
+
/**
|
94 |
+
* creates the asn object
|
95 |
+
*
|
96 |
+
* @return FACTFinder_Asn
|
97 |
+
**/
|
98 |
+
abstract protected function createAsn();
|
99 |
+
|
100 |
+
/**
|
101 |
+
* creates the sorting object
|
102 |
+
*
|
103 |
+
* @return array of FACTFinder_Item objects
|
104 |
+
**/
|
105 |
+
abstract protected function createSorting();
|
106 |
+
|
107 |
+
/**
|
108 |
+
* creates the paging object
|
109 |
+
*
|
110 |
+
* @return FACTFinder_Paging object
|
111 |
+
**/
|
112 |
+
abstract protected function createPaging();
|
113 |
+
|
114 |
+
/**
|
115 |
+
* creates the paging object
|
116 |
+
*
|
117 |
+
* @return FACTFinder_ProductsPerPageOptions object
|
118 |
+
**/
|
119 |
+
abstract protected function createProductsPerPageOptions();
|
120 |
+
|
121 |
+
/**
|
122 |
+
* create breadcrumbtrail
|
123 |
+
*
|
124 |
+
* @return array of FACTFinder_BreadCrumbItem objects
|
125 |
+
*/
|
126 |
+
abstract protected function createBreadCrumbTrail();
|
127 |
+
|
128 |
+
/**
|
129 |
+
* create campaigns
|
130 |
+
*
|
131 |
+
* @return FACTFinder_CampaignIterator
|
132 |
+
*/
|
133 |
+
abstract protected function createCampaigns();
|
134 |
+
|
135 |
+
/**
|
136 |
+
* create sindle word search
|
137 |
+
*
|
138 |
+
* @return array of FACTFinder_SuggestQuery objects
|
139 |
+
*/
|
140 |
+
abstract protected function createSingleWordSearch();
|
141 |
+
|
142 |
+
/**
|
143 |
+
* returns the search params object
|
144 |
+
*
|
145 |
+
* @return FACTFinder_Parameters result
|
146 |
+
**/
|
147 |
+
abstract protected function createSearchParams();
|
148 |
+
|
149 |
+
/**
|
150 |
+
* returns the search params object
|
151 |
+
*
|
152 |
+
* @return FACTFinder_Parameters result
|
153 |
+
**/
|
154 |
+
public function getSearchParams() {
|
155 |
+
if ($this->searchParams == null) {
|
156 |
+
$this->searchParams = $this->createSearchParams();
|
157 |
+
}
|
158 |
+
return $this->searchParams;
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* returns the result object
|
163 |
+
*
|
164 |
+
* @return FACTFinder_Result result
|
165 |
+
**/
|
166 |
+
public function getResult() {
|
167 |
+
if ($this->result == null) {
|
168 |
+
$this->result = $this->createResult();
|
169 |
+
}
|
170 |
+
return $this->result;
|
171 |
+
}
|
172 |
+
|
173 |
+
/**
|
174 |
+
* returns the asn object
|
175 |
+
*
|
176 |
+
* @return FACTFinder_Asn
|
177 |
+
**/
|
178 |
+
public function getAsn() {
|
179 |
+
if ($this->asn == null) {
|
180 |
+
$this->asn = $this->createAsn();
|
181 |
+
}
|
182 |
+
return $this->asn;
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* returns the sorting
|
187 |
+
*
|
188 |
+
* @return array of FACTFinder_SortItem objects
|
189 |
+
**/
|
190 |
+
public function getSorting() {
|
191 |
+
if ($this->sorting == null) {
|
192 |
+
$this->sorting = $this->createSorting();
|
193 |
+
}
|
194 |
+
return $this->sorting;
|
195 |
+
}
|
196 |
+
|
197 |
+
/**
|
198 |
+
* returns the paging
|
199 |
+
*
|
200 |
+
* @return FACTFinder_Paging object
|
201 |
+
**/
|
202 |
+
public function getPaging() {
|
203 |
+
if ($this->paging == null) {
|
204 |
+
$this->paging = $this->createPaging();
|
205 |
+
}
|
206 |
+
return $this->paging;
|
207 |
+
}
|
208 |
+
|
209 |
+
/**
|
210 |
+
* return products-per-page-options
|
211 |
+
*
|
212 |
+
* @return FACTFinder_ProductsPerPageOptions object
|
213 |
+
*/
|
214 |
+
public function getProductsPerPageOptions() {
|
215 |
+
if ($this->productsPerPageOptions == null) {
|
216 |
+
$this->productsPerPageOptions = $this->createProductsPerPageOptions();
|
217 |
+
}
|
218 |
+
return $this->productsPerPageOptions;
|
219 |
+
}
|
220 |
+
|
221 |
+
/**
|
222 |
+
* returns the breadcrumbtrail
|
223 |
+
*
|
224 |
+
* @return array of FACTFinder_BreadCrumbItem objects
|
225 |
+
*/
|
226 |
+
public function getBreadCrumbTrail() {
|
227 |
+
if ($this->breadCrumbTrail == null) {
|
228 |
+
$this->breadCrumbTrail = $this->createBreadCrumbTrail();
|
229 |
+
}
|
230 |
+
return $this->breadCrumbTrail;
|
231 |
+
}
|
232 |
+
|
233 |
+
/**
|
234 |
+
* returns the campaigns
|
235 |
+
*
|
236 |
+
* @return FACTFinder_CampaignIterator
|
237 |
+
*/
|
238 |
+
public function getCampaigns() {
|
239 |
+
if ($this->campaigns == null) {
|
240 |
+
$this->campaigns = $this->createCampaigns();
|
241 |
+
}
|
242 |
+
return $this->campaigns;
|
243 |
+
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* if the result was not good and there are more than one queries used for it, this method will return an array of
|
247 |
+
* FACTFinder_SuggestQuery objects, for each word a single item. by clicking at a singleWordSearch item, the result
|
248 |
+
* will get better
|
249 |
+
* please notice, that this feature has to be actived in the FACT-Finder search environment, so this method returns
|
250 |
+
* an empty array, if there are no singleWordSearch items
|
251 |
+
*
|
252 |
+
* @return array of FACTFinder_SuggestQuery objects
|
253 |
+
*/
|
254 |
+
public function getSingleWordSearch() {
|
255 |
+
if ($this->singleWordSearch == null) {
|
256 |
+
$this->singleWordSearch = $this->createSingleWordSearch();
|
257 |
+
}
|
258 |
+
return $this->singleWordSearch;
|
259 |
+
}
|
260 |
+
}
|
lib/FACTFinder/Abstract/SimilarRecordsAdapter.php
CHANGED
@@ -1,4 +1,11 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
/**
|
4 |
* adapter for the factfinder "similar records" data
|
@@ -9,81 +16,81 @@
|
|
9 |
*/
|
10 |
abstract class FACTFinder_Abstract_SimilarRecordsAdapter extends FACTFinder_Abstract_Adapter
|
11 |
{
|
12 |
-
|
13 |
private $similarAttributes;
|
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 |
-
public function setMaxRecordCount($count) {
|
48 |
-
$this->maxRecordCount = $count < 1 ? 0 : $count;
|
49 |
-
if($count > 0) $this->getDataProvider()->setParam('maxRecordCount', $count);
|
50 |
-
else $this->getDataProvder()->unsetParam('maxRecordCount');
|
51 |
-
}
|
52 |
-
|
53 |
-
public function setIdsOnly($idsOnly) {
|
54 |
-
// Reset the similar records, if more detail is wanted than before
|
55 |
-
if($this->idsOnly && !$idsOnly) $this->recordsUpToDate = false;
|
56 |
-
$this->idsOnly = $idsOnly;
|
57 |
-
if($idsOnly)
|
58 |
-
$this->getDataProvider()->setParam('idsOnly','true');
|
59 |
-
else
|
60 |
-
$this->getDataProvider()->unsetParam('idsOnly');
|
61 |
-
}
|
62 |
-
|
63 |
/**
|
64 |
* returns similar attributes for previously specified id. if no id is set, try to fetch parameter 'id'.
|
65 |
* if no id is available, there will be a warning raised and returning an empty array
|
66 |
-
|
67 |
* @return array $similarAttributes of strings (field names as keys)
|
68 |
*/
|
69 |
public function getSimilarAttributes() {
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
$this->similarAttributes = $this->createSimilarAttributes();
|
82 |
-
|
83 |
}
|
84 |
return $this->similarAttributes;
|
85 |
}
|
86 |
-
|
87 |
/**
|
88 |
* returns similar records for specified id. if no id is set, try to fetch parameter 'id'.
|
89 |
* if no id is available, there will be a warning raised and returning an empty array.
|
@@ -92,28 +99,28 @@ abstract class FACTFinder_Abstract_SimilarRecordsAdapter extends FACTFinder_Abst
|
|
92 |
* @return array $similarRecords list of FACTFinder_Record objects
|
93 |
*/
|
94 |
public function getSimilarRecords() {
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
$this->similarRecords = $this->createSimilarRecords();
|
107 |
-
|
108 |
}
|
109 |
return $this->similarRecords;
|
110 |
}
|
111 |
-
|
112 |
/**
|
113 |
* @return array $similarAttributes of strings (field names as keys)
|
114 |
*/
|
115 |
abstract protected function createSimilarAttributes();
|
116 |
-
|
117 |
/**
|
118 |
* @return array $similarRecords list of FACTFinder_Record objects
|
119 |
*/
|
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 "similar records" data
|
16 |
*/
|
17 |
abstract class FACTFinder_Abstract_SimilarRecordsAdapter extends FACTFinder_Abstract_Adapter
|
18 |
{
|
19 |
+
protected $productId;
|
20 |
private $similarAttributes;
|
21 |
+
private $similarRecords;
|
22 |
+
protected $attributesUpToDate = false;
|
23 |
+
protected $recordsUpToDate = false;
|
24 |
+
|
25 |
+
protected $idsOnly = false;
|
26 |
+
|
27 |
+
/*
|
28 |
+
* Option for XML query. 0 means "no maximum".
|
29 |
+
*/
|
30 |
+
private $maxRecordCount = 0;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Set id of product to get similar records for
|
34 |
+
*
|
35 |
+
* @param int $productId
|
36 |
+
**/
|
37 |
+
public function setProductId($productId) {
|
38 |
+
$this->productId = $productId;
|
39 |
+
$this->getDataProvider()->setParam('id', $productId);
|
40 |
+
$this->attributesUpToDate = false;
|
41 |
+
$this->recordsUpToDate = false;
|
42 |
+
}
|
43 |
+
|
44 |
+
/*
|
45 |
+
* @return int $maxRecordCount
|
46 |
*/
|
47 |
+
public function getMaxRecordCount() {
|
48 |
+
return $this->maxRecordCount;
|
49 |
+
}
|
50 |
+
|
51 |
+
/*
|
52 |
+
* @param int $count positive integer (negative will be treated as 0)
|
53 |
+
*/
|
54 |
+
public function setMaxRecordCount($count) {
|
55 |
+
$this->maxRecordCount = $count < 1 ? 0 : $count;
|
56 |
+
if($count > 0) $this->getDataProvider()->setParam('maxRecordCount', $count);
|
57 |
+
else $this->getDataProvder()->unsetParam('maxRecordCount');
|
58 |
+
}
|
59 |
+
|
60 |
+
public function setIdsOnly($idsOnly) {
|
61 |
+
// Reset the similar records, if more detail is wanted than before
|
62 |
+
if($this->idsOnly && !$idsOnly) $this->recordsUpToDate = false;
|
63 |
+
$this->idsOnly = $idsOnly;
|
64 |
+
if($idsOnly)
|
65 |
+
$this->getDataProvider()->setParam('idsOnly','true');
|
66 |
+
else
|
67 |
+
$this->getDataProvider()->unsetParam('idsOnly');
|
68 |
+
}
|
69 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
/**
|
71 |
* returns similar attributes for previously specified id. if no id is set, try to fetch parameter 'id'.
|
72 |
* if no id is available, there will be a warning raised and returning an empty array
|
73 |
+
|
74 |
* @return array $similarAttributes of strings (field names as keys)
|
75 |
*/
|
76 |
public function getSimilarAttributes() {
|
77 |
+
if (strlen($this->productId) == 0) {
|
78 |
+
$requestParams = $this->getParamsParser()->getRequestParams();
|
79 |
+
if (isset($requestParams['id'])) {
|
80 |
+
$this->productId = $requestParams['id'];
|
81 |
+
}
|
82 |
+
if (strlen($this->productId) == 0) {
|
83 |
+
trigger_error('recommendations can not be loaded without id. could not load id from request', E_USER_WARNING);
|
84 |
+
return array();
|
85 |
+
}
|
86 |
+
}
|
87 |
+
if (!$this->attributesUpToDate || !isset($this->similarAttributes) || $this->similarAttributes == null) {
|
88 |
$this->similarAttributes = $this->createSimilarAttributes();
|
89 |
+
$this->attributesUpToDate = true;
|
90 |
}
|
91 |
return $this->similarAttributes;
|
92 |
}
|
93 |
+
|
94 |
/**
|
95 |
* returns similar records for specified id. if no id is set, try to fetch parameter 'id'.
|
96 |
* if no id is available, there will be a warning raised and returning an empty array.
|
99 |
* @return array $similarRecords list of FACTFinder_Record objects
|
100 |
*/
|
101 |
public function getSimilarRecords() {
|
102 |
+
if (strlen($this->productId) == 0) {
|
103 |
+
$requestParams = $this->getParamsParser()->getRequestParams();
|
104 |
+
if (isset($requestParams['id'])) {
|
105 |
+
$this->productId = $requestParams['id'];
|
106 |
+
}
|
107 |
+
if (strlen($this->productId) == 0) {
|
108 |
+
trigger_error('similar records can not be loaded without id. could not load id from request', E_USER_WARNING);
|
109 |
+
return array();
|
110 |
+
}
|
111 |
+
}
|
112 |
+
if (!$this->recordsUpToDate || !isset($this->similarRecords) || $this->similarRecords == null) {
|
113 |
$this->similarRecords = $this->createSimilarRecords();
|
114 |
+
$this->recordsUpToDate = true;
|
115 |
}
|
116 |
return $this->similarRecords;
|
117 |
}
|
118 |
+
|
119 |
/**
|
120 |
* @return array $similarAttributes of strings (field names as keys)
|
121 |
*/
|
122 |
abstract protected function createSimilarAttributes();
|
123 |
+
|
124 |
/**
|
125 |
* @return array $similarRecords list of FACTFinder_Record objects
|
126 |
*/
|
lib/FACTFinder/Abstract/SuggestAdapter.php
CHANGED
@@ -1,33 +1,40 @@
|
|
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 |
}
|
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 factfinder's suggest
|
12 |
+
*
|
13 |
+
* @author Rudolf Batt <rb@omikron.net>
|
14 |
+
* @version $Id: SuggestAdapter.php 25893 2010-06-29 08:19:43Z rb $
|
15 |
+
* @package FACTFinder\Abstract
|
16 |
+
*/
|
17 |
+
abstract class FACTFinder_Abstract_SuggestAdapter extends FACTFinder_Abstract_Adapter
|
18 |
+
{
|
19 |
+
private $suggestions;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* get suggestions created by createSuggesions()
|
23 |
+
*
|
24 |
+
* @return mixed
|
25 |
+
*/
|
26 |
+
public function getSuggestions()
|
27 |
+
{
|
28 |
+
if ($this->suggestions == null) {
|
29 |
+
$this->suggestions = $this->createSuggestions();
|
30 |
+
}
|
31 |
+
return $this->suggestions;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* create and return suggestions. dependend to the implementation this can be any type
|
36 |
+
*
|
37 |
+
* @return mixed
|
38 |
+
*/
|
39 |
+
abstract protected function createSuggestions();
|
40 |
}
|
lib/FACTFinder/Abstract/TagCloudAdapter.php
CHANGED
@@ -1,30 +1,37 @@
|
|
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 |
}
|
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 tagcloud data
|
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_TagCloudAdapter extends FACTFinder_Abstract_Adapter
|
18 |
+
{
|
19 |
+
private $tagCloud;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* get tag cloud
|
23 |
+
*
|
24 |
+
* @return array $tagCloud list of FACTFinder_Tag objects
|
25 |
+
*/
|
26 |
+
public function getTagCloud() {
|
27 |
+
if ($this->tagCloud == null) {
|
28 |
+
$this->tagCloud = $this->createTagCloud();
|
29 |
+
}
|
30 |
+
return $this->tagCloud;
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @return array $tagCloud list of FACTFinder_Tag objects
|
35 |
+
*/
|
36 |
+
abstract protected function createTagCloud();
|
37 |
}
|
lib/FACTFinder/AdvisorAnswer.php
CHANGED
@@ -1,4 +1,12 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
/**
|
3 |
* represents an answer to a question of an advisor campaign (see FACTFinder_AdvisorQuestion)
|
4 |
* relevant for FF versions >= 6.7
|
@@ -11,35 +19,35 @@ class FACTFinder_AdvisorAnswer
|
|
11 |
{
|
12 |
private $text;
|
13 |
private $params;
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
* @param string text
|
19 |
-
|
20 |
* @param array subquestions; array of FACTFinder_AdvisorQuestion objects
|
21 |
*/
|
22 |
-
|
23 |
$this->text = trim($text);
|
24 |
-
|
25 |
$this->addSubquestions($subquestions);
|
26 |
}
|
27 |
-
|
28 |
-
|
29 |
* @return string text
|
30 |
*/
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
* @return string params
|
37 |
*/
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
* add follow-up questions to this answer
|
44 |
*
|
45 |
* @param array of FACTFinder_AdvisorQuestion objects
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Common
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
/**
|
11 |
* represents an answer to a question of an advisor campaign (see FACTFinder_AdvisorQuestion)
|
12 |
* relevant for FF versions >= 6.7
|
19 |
{
|
20 |
private $text;
|
21 |
private $params;
|
22 |
+
|
23 |
+
private $subquestions = array();
|
24 |
+
|
25 |
+
/**
|
26 |
* @param string text
|
27 |
+
* @param string params
|
28 |
* @param array subquestions; array of FACTFinder_AdvisorQuestion objects
|
29 |
*/
|
30 |
+
public function __construct($text = '', $params = '', $subquestions = array()) {
|
31 |
$this->text = trim($text);
|
32 |
+
$this->params = trim($params);
|
33 |
$this->addSubquestions($subquestions);
|
34 |
}
|
35 |
+
|
36 |
+
/**
|
37 |
* @return string text
|
38 |
*/
|
39 |
+
public function getText() {
|
40 |
+
return $this->text;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
* @return string params
|
45 |
*/
|
46 |
+
public function getParams() {
|
47 |
+
return $this->params;
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
* add follow-up questions to this answer
|
52 |
*
|
53 |
* @param array of FACTFinder_AdvisorQuestion objects
|
lib/FACTFinder/AdvisorQuestion.php
CHANGED
@@ -1,4 +1,12 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
/**
|
3 |
* represents a question of an advisor campaign
|
4 |
* relevant for FF versions >= 6.7
|
@@ -12,24 +20,24 @@ class FACTFinder_AdvisorQuestion
|
|
12 |
private $text;
|
13 |
|
14 |
private $answers = array();
|
15 |
-
|
16 |
-
|
17 |
* @param string question text
|
18 |
* @param array answers; array of FACTFinder_AdvisorAnswer objects
|
19 |
*/
|
20 |
-
|
21 |
$this->text = trim($text);
|
22 |
$this->addAnswers($answers);
|
23 |
}
|
24 |
-
|
25 |
-
|
26 |
* @return string text
|
27 |
*/
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
* add answers to this question
|
34 |
*
|
35 |
* @param array of FACTFinder_AdvisorAnswer objects
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Common
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
/**
|
11 |
* represents a question of an advisor campaign
|
12 |
* relevant for FF versions >= 6.7
|
20 |
private $text;
|
21 |
|
22 |
private $answers = array();
|
23 |
+
|
24 |
+
/**
|
25 |
* @param string question text
|
26 |
* @param array answers; array of FACTFinder_AdvisorAnswer objects
|
27 |
*/
|
28 |
+
public function __construct($text = '', $answers = array()) {
|
29 |
$this->text = trim($text);
|
30 |
$this->addAnswers($answers);
|
31 |
}
|
32 |
+
|
33 |
+
/**
|
34 |
* @return string text
|
35 |
*/
|
36 |
+
public function getText() {
|
37 |
+
return $this->text;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
* add answers to this question
|
42 |
*
|
43 |
* @param array of FACTFinder_AdvisorAnswer objects
|
lib/FACTFinder/Asn.php
CHANGED
@@ -1,30 +1,37 @@
|
|
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 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Common
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* represents a group in the ASN which contains several filters. By iterating over an ASN object, you will
|
12 |
+
* get FACTFinder_AsnGroup objects in the loop.
|
13 |
+
*
|
14 |
+
* @author Rudolf Batt <rb@omikron.net>
|
15 |
+
* @version $Id: Asn.php 25893 2010-06-29 08:19:43Z rb $
|
16 |
+
* @package FACTFinder\Common
|
17 |
+
*/
|
18 |
+
class FACTFinder_Asn extends ArrayIterator
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* decorates the FACTFinder_AsnGroup::hasPreviewImages() method for each group in the asn. so if one group has
|
22 |
+
* preview images, this method returns true
|
23 |
+
*
|
24 |
+
* @return boolean
|
25 |
+
*/
|
26 |
+
public function hasPreviewImages()
|
27 |
+
{
|
28 |
+
$hasPreviewImages = false;
|
29 |
+
foreach ($this AS $group) {
|
30 |
+
if ($group->hasPreviewImages()) {
|
31 |
+
$hasPreviewImages = true;
|
32 |
+
break;
|
33 |
+
}
|
34 |
+
}
|
35 |
+
return $hasPreviewImages;
|
36 |
+
}
|
37 |
}
|
lib/FACTFinder/AsnFilterItem.php
CHANGED
@@ -1,65 +1,72 @@
|
|
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 |
-
* @return
|
38 |
-
*/
|
39 |
-
public function
|
40 |
-
return $this->
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* @return int
|
45 |
-
*/
|
46 |
-
public function
|
47 |
-
return $this->
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* return
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
* @return
|
61 |
-
*/
|
62 |
-
public function
|
63 |
-
return
|
64 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Common
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* represents an filterable item from the after search navigation
|
12 |
+
*
|
13 |
+
* @author Rudolf Batt <rb@omikron.net>
|
14 |
+
* @version $Id: AsnFilterItem.php 25893 2010-06-29 08:19:43Z rb $
|
15 |
+
* @package FACTFinder\Common
|
16 |
+
*/
|
17 |
+
class FACTFinder_AsnFilterItem extends FACTFinder_Item
|
18 |
+
{
|
19 |
+
private $matchCount;
|
20 |
+
private $clusterLevel;
|
21 |
+
private $previewImage = null;
|
22 |
+
private $field;
|
23 |
+
|
24 |
+
public function __construct($value, $url, $isSelected = false, $matchCount = 0, $clusterLevel = 0, $previewImage = null, $field = ''){
|
25 |
+
parent::__construct($value, $url, $isSelected);
|
26 |
+
$this->matchCount = intval($matchCount);
|
27 |
+
$this->clusterLevel = intval($clusterLevel);
|
28 |
+
$this->previewImage = strval($previewImage);
|
29 |
+
$this->field = strval($field);
|
30 |
+
}
|
31 |
+
|
32 |
+
public function getType() {
|
33 |
+
return 'item';
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* @return String
|
38 |
+
*/
|
39 |
+
public function getField() {
|
40 |
+
return $this->field;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @return int
|
45 |
+
*/
|
46 |
+
public function getMatchCount() {
|
47 |
+
return $this->matchCount;
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @return int
|
52 |
+
*/
|
53 |
+
public function getClusterLevel() {
|
54 |
+
return $this->clusterLevel;
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* return url of a preview image or null if there is no set
|
59 |
+
*
|
60 |
+
* @return string image url or null if none exists
|
61 |
+
*/
|
62 |
+
public function getPreviewImage() {
|
63 |
+
return $this->previewImage;
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* @return boolean
|
68 |
+
*/
|
69 |
+
public function hasPreviewImage() {
|
70 |
+
return strlen($this->previewImage) > 0;
|
71 |
+
}
|
72 |
}
|
lib/FACTFinder/AsnGroup.php
CHANGED
@@ -1,128 +1,135 @@
|
|
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 |
-
* @return boolean
|
51 |
-
*/
|
52 |
-
public function
|
53 |
-
return $this->style == '
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* @return boolean
|
58 |
-
*/
|
59 |
-
public function
|
60 |
-
return
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* return boolean
|
65 |
-
*/
|
66 |
-
public function
|
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 |
-
* @return string
|
117 |
-
*/
|
118 |
-
public function
|
119 |
-
return $this->
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* @return
|
124 |
-
*/
|
125 |
-
public function
|
126 |
-
return $this->
|
127 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Common
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* represents a group in the ASN which contains several filters. By iterating over an AsnGroup object, you will
|
12 |
+
* get AsnFilterItem objects in the loop.
|
13 |
+
*
|
14 |
+
* @author Rudolf Batt <rb@omikron.net>
|
15 |
+
* @version $Id: AsnGroup.php 25893 2010-06-29 08:19:43Z rb $
|
16 |
+
* @category Collection
|
17 |
+
* @package FACTFinder\Common
|
18 |
+
*/
|
19 |
+
class FACTFinder_AsnGroup extends ArrayIterator
|
20 |
+
{
|
21 |
+
private $name;
|
22 |
+
private $detailedLinkCount;
|
23 |
+
private $unit;
|
24 |
+
private $hasPreviewImages = false;
|
25 |
+
private $hasSelectedItems = false;
|
26 |
+
private $isSliderStyle = false;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* constructor
|
30 |
+
*
|
31 |
+
* @param array asn filters to add to this group (default: empty array)
|
32 |
+
* @param string name of the group (default: empty string)
|
33 |
+
* @param int number of detail links to show (default: 0)
|
34 |
+
* @param string untit character of the group (default: empty string)
|
35 |
+
* @param string style; possible values: DEFAULT|SLIDER|COLOR (default: DEFAULT)
|
36 |
+
*/
|
37 |
+
public function __construct(array $asnFilters = array(), $name = '', $detailedLinkCount = 0, $unit = '', $style = 'DEFAULT') {
|
38 |
+
$this->name = strval($name);
|
39 |
+
$this->detailedLinkCount = intval($detailedLinkCount);
|
40 |
+
$this->unit = strval($unit);
|
41 |
+
$this->style = $style;
|
42 |
+
|
43 |
+
parent::__construct();
|
44 |
+
$this->addFilters($asnFilters);
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* return true if group filtering should be done in slider style
|
49 |
+
*
|
50 |
+
* @return boolean
|
51 |
+
*/
|
52 |
+
public function isSliderStyle() {
|
53 |
+
return $this->style == 'SLIDER';
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* @return boolean
|
58 |
+
*/
|
59 |
+
public function isColorStyle() {
|
60 |
+
return $this->style == 'COLOR';
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* @return boolean
|
65 |
+
*/
|
66 |
+
public function isDefaultStyle() {
|
67 |
+
return !$this->isSliderStyle() && !$this->isColorStyle();
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* return boolean true if one or more items has a preview image
|
72 |
+
*/
|
73 |
+
public function hasPreviewImages()
|
74 |
+
{
|
75 |
+
return $this->hasPreviewImages;
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* return boolean true if one or more items are selected
|
80 |
+
*/
|
81 |
+
public function hasSelectedItems()
|
82 |
+
{
|
83 |
+
return $this->hasSelectedItems;
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* add every filter from the given array to this group
|
88 |
+
*
|
89 |
+
* @param array of filter objects
|
90 |
+
* @return void
|
91 |
+
*/
|
92 |
+
public function addFilters(array $filters)
|
93 |
+
{
|
94 |
+
foreach($filters AS $filter) {
|
95 |
+
$this->addFilter($filter);
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* @param filter object
|
101 |
+
* @return void
|
102 |
+
*/
|
103 |
+
public function addFilter($filter)
|
104 |
+
{
|
105 |
+
if ($filter instanceof FACTFinder_AsnFilterItem) {
|
106 |
+
if ($filter->hasPreviewImage()) {
|
107 |
+
$this->hasPreviewImages = true;
|
108 |
+
} else if ($filter->isSelected()) {
|
109 |
+
$this->hasSelectedItems = true;
|
110 |
+
}
|
111 |
+
}
|
112 |
+
parent::append($filter);
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* @return string name
|
117 |
+
*/
|
118 |
+
public function getName() {
|
119 |
+
return $this->name;
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* @return string unit
|
124 |
+
*/
|
125 |
+
public function getUnit() {
|
126 |
+
return $this->unit;
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* @return int
|
131 |
+
*/
|
132 |
+
public function getDetailedLinkCount() {
|
133 |
+
return $this->detailedLinkCount;
|
134 |
+
}
|
135 |
}
|
lib/FACTFinder/AsnSliderFilter.php
CHANGED
@@ -1,124 +1,131 @@
|
|
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 |
-
public function
|
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 |
-
* return float
|
64 |
-
*/
|
65 |
-
public function
|
66 |
-
return $this->
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* return float
|
71 |
-
*/
|
72 |
-
public function
|
73 |
-
return $this->
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* return float
|
78 |
-
*/
|
79 |
-
public function
|
80 |
-
return $this->
|
81 |
-
}
|
82 |
-
|
83 |
-
/**
|
84 |
-
*
|
85 |
-
*/
|
86 |
-
public function
|
87 |
-
return $this->
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* @return string
|
92 |
-
*/
|
93 |
-
public function
|
94 |
-
return $this->baseUrl;
|
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 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Common
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* represents an asn filter slider item
|
12 |
+
*
|
13 |
+
* @author Rudolf Batt <rb@omikron.net>
|
14 |
+
* @version $Id: AsnSliderFilter.php 25893 2010-06-29 08:19:43Z rb $
|
15 |
+
* @package FACTFinder\Common
|
16 |
+
*/
|
17 |
+
class FACTFinder_AsnSliderFilter
|
18 |
+
{
|
19 |
+
private $absoluteMin;
|
20 |
+
private $absoluteMax;
|
21 |
+
private $selectedMin;
|
22 |
+
private $selectedMax;
|
23 |
+
private $baseUrl;
|
24 |
+
private $field;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @param string base url - it should be possible to simply append the selected min and max value
|
28 |
+
* @param float absolute min (default: 0.0)
|
29 |
+
* @param float absolute max (default: 0.0)
|
30 |
+
* @param float selected min (default: 0.0)
|
31 |
+
* @param float selected max (default: 0.0)
|
32 |
+
*/
|
33 |
+
public function __construct($baseUrl, $absoluteMin = 0, $absoluteMax = 0, $selectedMin = 0, $selectedMax = 0, $field = '') {
|
34 |
+
$this->baseUrl = $baseUrl;
|
35 |
+
$this->setAbsoluteRange($absoluteMin, $absoluteMax);
|
36 |
+
$this->setSelectedRange($selectedMin, $selectedMax);
|
37 |
+
$this->field = strval($field);
|
38 |
+
}
|
39 |
+
|
40 |
+
public function getType() {
|
41 |
+
return 'slider';
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* @param float absolute min
|
46 |
+
* @param float absolute max
|
47 |
+
*/
|
48 |
+
private function setAbsoluteRange($min, $max) {
|
49 |
+
$this->absoluteMin = floatval($min);
|
50 |
+
$this->absoluteMax = floatval($max);
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @param float selected min
|
55 |
+
* @param float selected max
|
56 |
+
*/
|
57 |
+
public function setSelectedRange($min, $max) {
|
58 |
+
$this->selectedMin = floatval($min);
|
59 |
+
$this->selectedMax = floatval($max);
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* return float
|
64 |
+
*/
|
65 |
+
public function getAbsoluteMin() {
|
66 |
+
return $this->absoluteMin;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* return float
|
71 |
+
*/
|
72 |
+
public function getAbsoluteMax() {
|
73 |
+
return $this->absoluteMax;
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* return float
|
78 |
+
*/
|
79 |
+
public function getSelectedMin() {
|
80 |
+
return $this->selectedMin;
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* return float
|
85 |
+
*/
|
86 |
+
public function getSelectedMax() {
|
87 |
+
return $this->selectedMax;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* @return string url for the current selected range
|
92 |
+
*/
|
93 |
+
public function getUrl() {
|
94 |
+
return $this->baseUrl . $this->selectedMin . ' - ' . $this->selectedMax;
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* @return string base url
|
99 |
+
*/
|
100 |
+
public function getBaseUrl() {
|
101 |
+
return $this->baseUrl;
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* returns true if the selected range is not the same as the absolute range
|
106 |
+
*
|
107 |
+
* @return boolean true if selected
|
108 |
+
*/
|
109 |
+
public function isSelected() {
|
110 |
+
return $this->selectedMin != $this->absoluteMin || $this->selectedMax != $this->absoluteMax;
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* returns the associated field name to this filter
|
115 |
+
*
|
116 |
+
* @return string field-name
|
117 |
+
*/
|
118 |
+
public function getField() {
|
119 |
+
return $this->field;
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* returns the absolute values as parameters and the select parameter-key, so the selected values must be
|
124 |
+
* appended to set the selection.
|
125 |
+
*
|
126 |
+
* @return string parameters for this filter
|
127 |
+
*/
|
128 |
+
public function getValue() {
|
129 |
+
return 'filter'.$this->getField().'Absolute='.$this->getAbsoluteMin().' - '.$this->getAbsoluteMax().'&filter'.$this->getField().'=';
|
130 |
+
}
|
131 |
}
|
lib/FACTFinder/BreadCrumbItem.php
CHANGED
@@ -1,68 +1,75 @@
|
|
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 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Common
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* breadcrumb for the breadcrumb navigation
|
12 |
+
*
|
13 |
+
* @author Rudolf Batt <rb@omikron.net>
|
14 |
+
* @version $Id: BreadCrumbItem.php 25893 2010-06-29 08:19:43Z rb $
|
15 |
+
* @package FACTFinder\Common
|
16 |
+
*/
|
17 |
+
class FACTFinder_BreadCrumbItem extends FACTFinder_Item
|
18 |
+
{
|
19 |
+
const SEARCH_TYPE = 'search';
|
20 |
+
const FILTER_TYPE = 'filter';
|
21 |
+
|
22 |
+
private $type;
|
23 |
+
private $fieldName;
|
24 |
+
private $fieldUnit;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @param string value
|
28 |
+
* @param string url
|
29 |
+
* @param boolean true if this breadcrumb represents the current state of the result
|
30 |
+
* @param string type should be "search" or "filter", otherwise the "is..." methods will not work (default: 'filter')
|
31 |
+
* @param string filtername
|
32 |
+
* @param string filter value
|
33 |
+
*/
|
34 |
+
public function __construct($value, $url, $isSelected = false, $type = 'filter', $fieldName = '', $fieldUnit = '')
|
35 |
+
{
|
36 |
+
parent::__construct($value, $url, $isSelected);
|
37 |
+
$this->type = strval($type);
|
38 |
+
if ($this->isFilter()) {
|
39 |
+
$this->fieldName = strval($fieldName);
|
40 |
+
$this->fieldUnit = strval($fieldUnit);
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* @return boolean
|
46 |
+
*/
|
47 |
+
public function isFilter()
|
48 |
+
{
|
49 |
+
return $this->type == self::FILTER_TYPE;
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* @return boolean
|
54 |
+
*/
|
55 |
+
public function isSearch()
|
56 |
+
{
|
57 |
+
return $this->type == self::SEARCH_TYPE;
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* @return string
|
62 |
+
*/
|
63 |
+
public function getFieldName()
|
64 |
+
{
|
65 |
+
return $this->fieldName;
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* @return string
|
70 |
+
*/
|
71 |
+
public function getFieldUnit()
|
72 |
+
{
|
73 |
+
return $this->fieldUnit;
|
74 |
+
}
|
75 |
}
|
lib/FACTFinder/Campaign.php
CHANGED
@@ -1,198 +1,206 @@
|
|
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 |
-
* @return
|
64 |
-
*/
|
65 |
-
public function
|
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 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
*
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
*
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
*
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Common
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* represents a factfinder campaign
|
12 |
+
*
|
13 |
+
* @author Rudolf Batt <rb@omikron.net>
|
14 |
+
* @version $Id: Campaign.php 25985 2010-06-30 15:31:53Z rb $
|
15 |
+
* @package FACTFinder\Common
|
16 |
+
*/
|
17 |
+
class FACTFinder_Campaign
|
18 |
+
{
|
19 |
+
private $name;
|
20 |
+
private $category;
|
21 |
+
|
22 |
+
private $redirectUrl = null;
|
23 |
+
private $pushedProducts = array();
|
24 |
+
private $feedback = array();
|
25 |
+
private $activeQuestions = array();
|
26 |
+
private $advisorTree = array();
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @param string name
|
30 |
+
* @param string category
|
31 |
+
* @param string redirectUrl (default: empty string)
|
32 |
+
* @param array pushedProducts; array of records
|
33 |
+
* @param array feedback; array of strings with labels as keys
|
34 |
+
* @param array activeQuestions; array of FACTFinder_AdvisorQuestion objects
|
35 |
+
*/
|
36 |
+
public function __construct($name = '', $category = '', $redirectUrl = '', array $pushedProducts = array(), $feedback = array(), $activeQuestions = array(), $advisorTree = array()) {
|
37 |
+
$this->name = trim($name);
|
38 |
+
$this->category = trim($category);
|
39 |
+
$this->redirectUrl = trim($redirectUrl);
|
40 |
+
$this->addPushedProducts($pushedProducts);
|
41 |
+
$this->addFeedback($feedback);
|
42 |
+
$this->addActiveQuestions($activeQuestions);
|
43 |
+
$this->addToAdvisorTree($advisorTree);
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* @return string name
|
48 |
+
*/
|
49 |
+
public function getName() {
|
50 |
+
return $this->name;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @return string url
|
55 |
+
*/
|
56 |
+
public function getCategory(){
|
57 |
+
return $this->category;
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* true if a redirect link was set
|
62 |
+
*
|
63 |
+
* @return boolean
|
64 |
+
*/
|
65 |
+
public function hasRedirect()
|
66 |
+
{
|
67 |
+
return !empty($this->redirectUrl);
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* @return string url
|
72 |
+
*/
|
73 |
+
public function getRedirectUrl(){
|
74 |
+
return $this->redirectUrl;
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* add products to this campaign
|
79 |
+
*
|
80 |
+
* @param array of FACTFinder_Record objects
|
81 |
+
* @return void
|
82 |
+
*/
|
83 |
+
public function addPushedProducts(array $pushedProducts) {
|
84 |
+
foreach ($pushedProducts AS $product) {
|
85 |
+
$this->pushedProducts[] = $product;
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* true if pushed products exist
|
91 |
+
*
|
92 |
+
* @return boolean
|
93 |
+
*/
|
94 |
+
public function hasPushedProducts() {
|
95 |
+
return sizeof($this->pushedProducts) > 0;
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* @return array of FACTFinder_Record objects
|
100 |
+
*/
|
101 |
+
public function getPushedProducts() {
|
102 |
+
return $this->pushedProducts;
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* set the feedback strings. if a feedback with the same key (label) exist, it will be overwritten
|
107 |
+
*
|
108 |
+
* @param array of string
|
109 |
+
* @return void
|
110 |
+
*/
|
111 |
+
public function addFeedback(array $feedback) {
|
112 |
+
foreach($feedback AS $label => $text) {
|
113 |
+
$this->feedback[$label] = trim($text);
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* returns true if feedback exists. if argument is specified, this methods checks, whether there is any
|
119 |
+
* feedback text available. if a label is given, then this method only returns true, if there is a feedback text
|
120 |
+
* for this label
|
121 |
+
*
|
122 |
+
* @param string label of feedback (default: null)
|
123 |
+
* @return boolean
|
124 |
+
*/
|
125 |
+
public function hasFeedback($label = null) {
|
126 |
+
if ($label != null) {
|
127 |
+
$hasFeedback = isset($this->feedback[$label]) && $this->feedback[$label] != '';
|
128 |
+
} else {
|
129 |
+
$hasFeedback = sizeof($this->feedback) > 0 && implode('', $this->feedback) != '';
|
130 |
+
}
|
131 |
+
return $hasFeedback;
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* when label is specified, only the desired feedback text will be returned or an empty string, if this text does not exist.
|
136 |
+
* if no label is set, the complete feedback array will be returned
|
137 |
+
*
|
138 |
+
* @param string $label
|
139 |
+
* @return array|string
|
140 |
+
*/
|
141 |
+
public function getFeedback($label = null) {
|
142 |
+
if ($label === null) {
|
143 |
+
return $this->feedback;
|
144 |
+
} else if (isset($this->feedback[$label])) {
|
145 |
+
return $this->feedback[$label];
|
146 |
+
} else {
|
147 |
+
return '';
|
148 |
+
}
|
149 |
+
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* add active questions to this campaign
|
153 |
+
*
|
154 |
+
* @param array of FACTFinder_AdvisorQuestion objects
|
155 |
+
* @return void
|
156 |
+
*/
|
157 |
+
public function addActiveQuestions(array $activeQuestions) {
|
158 |
+
foreach ($activeQuestions AS $question) {
|
159 |
+
$this->activeQuestions[] = $question;
|
160 |
+
}
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* true if advisor questions exist
|
165 |
+
*
|
166 |
+
* @return boolean
|
167 |
+
*/
|
168 |
+
public function hasActiveQuestions() {
|
169 |
+
return sizeof($this->activeQuestions) > 0;
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* @return array of FACTFinder_AdvisorQuestion objects
|
174 |
+
*/
|
175 |
+
public function getActiveQuestions() {
|
176 |
+
return $this->activeQuestions;
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
* add questions to the advisor tree (top level) of this campaign
|
181 |
+
*
|
182 |
+
* @param array of FACTFinder_AdvisorQuestion objects
|
183 |
+
* @return void
|
184 |
+
*/
|
185 |
+
public function addToAdvisorTree(array $advisorTree) {
|
186 |
+
foreach ($advisorTree AS $question) {
|
187 |
+
$this->advisorTree[] = $question;
|
188 |
+
}
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* true if advisor tree exists
|
193 |
+
*
|
194 |
+
* @return boolean
|
195 |
+
*/
|
196 |
+
public function hasAdvisorTree() {
|
197 |
+
return sizeof($this->advisorTree) > 0;
|
198 |
+
}
|
199 |
+
|
200 |
+
/**
|
201 |
+
* @return array of FACTFinder_AdvisorQuestion objects
|
202 |
+
*/
|
203 |
+
public function getAdvisorTree() {
|
204 |
+
return $this->advisorTree;
|
205 |
+
}
|
206 |
}
|
lib/FACTFinder/CampaignIterator.php
CHANGED
@@ -1,182 +1,190 @@
|
|
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 |
-
|
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 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Common
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* represents the whole collection of campaigns. decorates some campaign functions to execute on every campaign.
|
12 |
+
* By iterating over an CampaignIterator you get FACTFinder_Campaign objects in the loop.
|
13 |
+
*
|
14 |
+
* @author Rudolf Batt <rb@omikron.net>
|
15 |
+
* @version $Id: CampaignIterator.php 25985 2010-06-30 15:31:53Z rb $
|
16 |
+
* @package FACTFinder\Common
|
17 |
+
*/
|
18 |
+
class FACTFinder_CampaignIterator extends ArrayIterator
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* true if a redirect link exists at one of all campaigns
|
22 |
+
*
|
23 |
+
* @see FACTFinder_Campaign::hasRedirect()
|
24 |
+
* @return boolean
|
25 |
+
*/
|
26 |
+
public function hasRedirect()
|
27 |
+
{
|
28 |
+
$hasRedirect = false;
|
29 |
+
foreach ($this AS $campaign) {
|
30 |
+
if ($campaign->hasRedirect()) {
|
31 |
+
$hasRedirect = true;
|
32 |
+
break;
|
33 |
+
}
|
34 |
+
}
|
35 |
+
return $hasRedirect;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* return the first redirect of all campaigns or null if non exists
|
40 |
+
*
|
41 |
+
* @see FACTFinder_Campaign::getRedirectUrl()
|
42 |
+
* @return string url
|
43 |
+
*/
|
44 |
+
public function getRedirectUrl(){
|
45 |
+
$redirectUrl = null;
|
46 |
+
foreach ($this AS $campaign) {
|
47 |
+
if ($campaign->hasRedirect()) {
|
48 |
+
$redirectUrl = $campaign->getRedirectUrl();
|
49 |
+
break;
|
50 |
+
}
|
51 |
+
}
|
52 |
+
return $redirectUrl;
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* true if pushed products exist in of all campaigns
|
57 |
+
*
|
58 |
+
* @see FACTFinder_Campaign::hasPushedProducts()
|
59 |
+
* @return boolean
|
60 |
+
*/
|
61 |
+
public function hasPushedProducts() {
|
62 |
+
$hasPushedProducts = false;
|
63 |
+
foreach ($this AS $campaign) {
|
64 |
+
if ($campaign->hasPushedProducts()) {
|
65 |
+
$hasPushedProducts = true;
|
66 |
+
break;
|
67 |
+
}
|
68 |
+
}
|
69 |
+
return $hasPushedProducts;
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* decorates FACTFinder_Campaign::getPushedProducts() for all campaigns
|
74 |
+
*
|
75 |
+
* @see FACTFinder_Campaign::getPushedProducts()
|
76 |
+
* @return array of records
|
77 |
+
*/
|
78 |
+
public function getPushedProducts() {
|
79 |
+
$pushedProducts = array();
|
80 |
+
foreach ($this AS $campaign) {
|
81 |
+
if ($campaign->hasPushedProducts()) {
|
82 |
+
$pushedProducts = array_merge($pushedProducts, $campaign->getPushedProducts());
|
83 |
+
}
|
84 |
+
}
|
85 |
+
return $pushedProducts;
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* decorates FACTFinder_Campaign::hasFeedback() for each campaign. return true, if one of all campaigns has feedback
|
90 |
+
* text snippets
|
91 |
+
*
|
92 |
+
* @see FACTFinder_Campaign::hasFeedback()
|
93 |
+
* @return boolean
|
94 |
+
*/
|
95 |
+
public function hasFeedback($nr = null) {
|
96 |
+
$hasFeedback = false;
|
97 |
+
foreach ($this AS $campaign) {
|
98 |
+
if ($campaign->hasFeedback($nr)) {
|
99 |
+
$hasFeedback = true;
|
100 |
+
break;
|
101 |
+
}
|
102 |
+
}
|
103 |
+
return $hasFeedback;
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* decorates FACTFinder_Campaign::getFeedback() for each campaign. returnes a string of each feedback from all
|
108 |
+
* campaigns, glued together with PHP_EOL
|
109 |
+
*
|
110 |
+
* @see FACTFinder_Campaign::getFeedback()
|
111 |
+
* @param int $nr of feedback text
|
112 |
+
* @return string
|
113 |
+
*/
|
114 |
+
public function getFeedback($nr) {
|
115 |
+
$feedback = '';
|
116 |
+
foreach ($this AS $campaign) {
|
117 |
+
if ($campaign->hasFeedback()) {
|
118 |
+
$feedback .= $campaign->getFeedback($nr).PHP_EOL;
|
119 |
+
}
|
120 |
+
}
|
121 |
+
return $feedback;
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* true if active advisor questions exist in any campaign
|
126 |
+
*
|
127 |
+
* @see FACTFinder_Campaign::hasActiveQuestions()
|
128 |
+
* @return boolean
|
129 |
+
*/
|
130 |
+
public function hasActiveQuestions() {
|
131 |
+
$hasActiveQuestions = false;
|
132 |
+
foreach ($this AS $campaign) {
|
133 |
+
if ($campaign->hasActiveQuestions()) {
|
134 |
+
$hasActiveQuestions = true;
|
135 |
+
break;
|
136 |
+
}
|
137 |
+
}
|
138 |
+
return $hasActiveQuestions;
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* decorates FACTFinder_Campaign::getActiveQuestions() for all campaigns
|
143 |
+
*
|
144 |
+
* @see FACTFinder_Campaign::getActiveQuestions()
|
145 |
+
* @return array of records
|
146 |
+
*/
|
147 |
+
public function getActiveQuestions() {
|
148 |
+
$activeQuestions = array();
|
149 |
+
foreach ($this AS $campaign) {
|
150 |
+
if ($campaign->hasActiveQuestions()) {
|
151 |
+
$activeQuestions = array_merge($activeQuestions, $campaign->getActiveQuestions());
|
152 |
+
}
|
153 |
+
}
|
154 |
+
return $activeQuestions;
|
155 |
+
}
|
156 |
+
|
157 |
+
|
158 |
+
/**
|
159 |
+
* true if an advisor tree exists in any campaign
|
160 |
+
*
|
161 |
+
* @see FACTFinder_Campaign::hasActiveQuestions()
|
162 |
+
* @return boolean
|
163 |
+
*/
|
164 |
+
public function hasAdvisorTree() {
|
165 |
+
$hasAdvisorTree = false;
|
166 |
+
foreach ($this AS $campaign) {
|
167 |
+
if ($campaign->hasAdvisorTree()) {
|
168 |
+
$hasAdvisorTree = true;
|
169 |
+
break;
|
170 |
+
}
|
171 |
+
}
|
172 |
+
return $hasAdvisorTree;
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* decorates FACTFinder_Campaign::getAdvisorTree() for all campaigns
|
177 |
+
*
|
178 |
+
* @see FACTFinder_Campaign::getAdvisorTree()
|
179 |
+
* @return array of records
|
180 |
+
*/
|
181 |
+
public function getAdvisorTree() {
|
182 |
+
$advisorTree = array();
|
183 |
+
foreach ($this AS $campaign) {
|
184 |
+
if ($campaign->hasAdvisorTree()) {
|
185 |
+
$advisorTree = array_merge($advisorTree, $campaign->getAdvisorTree());
|
186 |
+
}
|
187 |
+
}
|
188 |
+
return $advisorTree;
|
189 |
+
}
|
190 |
}
|
lib/FACTFinder/Configuration.php
CHANGED
@@ -1,362 +1,369 @@
|
|
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 |
public function getVersion() {
|
33 |
return $this->zendConfig->version;
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* @return boolean
|
38 |
-
|
39 |
-
*/
|
40 |
public function isDebugEnabled() {
|
41 |
return $this->zendConfig->debug == 'true';
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* @param string name
|
46 |
-
* @return string value
|
47 |
-
*/
|
48 |
public function getCustomValue($name) {
|
49 |
return $this->zendConfig->$name;
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
|
54 |
-
* @return string
|
55 |
-
*/
|
56 |
public function getRequestProtokoll() {
|
57 |
return $this->zendConfig->search->protokoll;
|
58 |
-
}
|
59 |
-
|
60 |
-
|
61 |
-
* @return string
|
62 |
-
*/
|
63 |
-
public function getRequestProtocol() {
|
64 |
-
$protocol = $this->zendConfig->search->protocol;
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
}
|
72 |
-
|
73 |
-
/**
|
74 |
-
* @return string
|
75 |
-
*/
|
76 |
public function getServerAddress() {
|
77 |
return $this->zendConfig->search->address;
|
78 |
-
}
|
79 |
-
|
80 |
-
/**
|
81 |
-
* @return int
|
82 |
-
*/
|
83 |
public function getServerPort() {
|
84 |
return $this->zendConfig->search->port;
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* @return string
|
89 |
-
*/
|
90 |
public function getContext() {
|
91 |
return $this->zendConfig->search->context;
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* @return string
|
96 |
-
*/
|
97 |
public function getChannel() {
|
98 |
return $this->zendConfig->search->channel;
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* @return string
|
103 |
-
*/
|
104 |
public function getLanguage() {
|
105 |
return $this->zendConfig->search->language;
|
106 |
-
}
|
107 |
-
|
108 |
-
/**
|
109 |
-
* @return string
|
110 |
-
*/
|
111 |
public function getAuthUser() {
|
112 |
return $this->zendConfig->search->auth->user;
|
113 |
-
}
|
114 |
-
|
115 |
-
/**
|
116 |
-
* @return string
|
117 |
-
*/
|
118 |
public function getAuthPasswort() {
|
119 |
return $this->zendConfig->search->auth->password;
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* @return boolean
|
124 |
-
*/
|
125 |
public function isHttpAuthenticationType() {
|
126 |
return $this->getAuthType() == self::HTTP_AUTH;
|
127 |
-
}
|
128 |
-
|
129 |
-
/**
|
130 |
-
* @return boolean
|
131 |
-
*/
|
132 |
public function isSimpleAuthenticationType() {
|
133 |
return $this->getAuthType() == self::SIMPLE_AUTH;
|
134 |
-
}
|
135 |
-
|
136 |
-
/**
|
137 |
-
* @return boolean
|
138 |
-
*/
|
139 |
public function isAdvancedAuthenticationType() {
|
140 |
return $this->getAuthType() == self::ADVANCED_AUTH;
|
141 |
-
}
|
142 |
-
|
143 |
-
private function getAuthType() {
|
144 |
-
if ($this->authType == null) {
|
145 |
-
$this->authType = $this->zendConfig->search->auth->type;
|
146 |
-
if ( $this->authType != self::HTTP_AUTH
|
147 |
-
&& $this->authType != self::SIMPLE_AUTH
|
148 |
-
&& $this->authType != self::ADVANCED_AUTH ) {
|
149 |
-
$this->authType = self::HTTP_AUTH;
|
150 |
-
}
|
151 |
-
}
|
152 |
-
return $this->authType;
|
153 |
-
}
|
154 |
-
|
155 |
-
/**
|
156 |
-
* @return string
|
157 |
-
*/
|
158 |
-
public function getAdvancedAuthPrefix() {
|
159 |
-
return $this->zendConfig->search->auth->advancedPrefix;
|
160 |
-
}
|
161 |
-
|
162 |
-
/**
|
163 |
-
* @return string
|
164 |
-
*/
|
165 |
-
public function getAdvancedAuthPostfix(){
|
166 |
-
return $this->zendConfig->search->auth->advancedPostfix;
|
167 |
-
}
|
168 |
-
|
169 |
-
/**
|
170 |
-
*
|
171 |
-
*
|
172 |
-
* @return array
|
173 |
-
*/
|
174 |
public function getPageMappings() {
|
175 |
-
if ($this->pageMappings == null) {
|
176 |
-
$this->pageMappings = array();
|
177 |
-
if ($this->zendConfig->params->client->mapping != null) {
|
178 |
-
|
179 |
-
// get mapping config as iterable variable
|
180 |
-
if ($this->zendConfig->params->client->mapping->from == null) {
|
181 |
-
$mapping = $this->zendConfig->params->client->mapping;
|
182 |
-
} else {
|
183 |
-
$mapping = array($this->zendConfig->params->client->mapping);
|
184 |
-
}
|
185 |
-
|
186 |
-
//load mappings
|
187 |
-
foreach($mapping AS $rule) {
|
188 |
-
$this->pageMappings[$rule->from] = $rule->to;
|
189 |
-
}
|
190 |
-
}
|
191 |
-
}
|
192 |
return $this->pageMappings;
|
193 |
-
}
|
194 |
-
|
195 |
-
/**
|
196 |
-
*
|
197 |
-
*
|
198 |
-
* @return array
|
199 |
-
*/
|
200 |
public function getServerMappings() {
|
201 |
-
if ($this->serverMappings == null) {
|
202 |
-
$this->serverMappings = array();
|
203 |
-
if ($this->zendConfig->params->server->mapping != null) {
|
204 |
-
|
205 |
-
// get mapping config as iterable variable
|
206 |
-
if ($this->zendConfig->params->server->mapping->from == null) {
|
207 |
-
$mapping = $this->zendConfig->params->server->mapping;
|
208 |
-
} else {
|
209 |
-
$mapping = array($this->zendConfig->params->server->mapping);
|
210 |
-
}
|
211 |
-
|
212 |
-
//load mappings
|
213 |
-
foreach($mapping AS $rule) {
|
214 |
-
$this->serverMappings[$rule->from] = $rule->to;
|
215 |
-
}
|
216 |
-
}
|
217 |
-
}
|
218 |
return $this->serverMappings;
|
219 |
-
}
|
220 |
-
|
221 |
-
/**
|
222 |
-
*
|
223 |
-
*
|
224 |
-
* @return array with string as key and boolean true as value for each of them
|
225 |
-
*/
|
226 |
public function getIgnoredPageParams() {
|
227 |
-
if ($this->pageIgnores == null) {
|
228 |
-
$this->pageIgnores = array();
|
229 |
-
if (isset($this->zendConfig->params->client->ignore)) {
|
230 |
-
|
231 |
-
// get ignore rules as iterable variable
|
232 |
-
if($this->zendConfig->params->client->ignore->name == null) {
|
233 |
-
$ignoreRules = $this->zendConfig->params->client->ignore ;
|
234 |
-
} else {
|
235 |
-
$ignoreRules = array($this->zendConfig->params->client->ignore );
|
236 |
-
}
|
237 |
-
|
238 |
-
// load ignore rules
|
239 |
-
foreach($ignoreRules AS $i) {
|
240 |
-
$this->pageIgnores[$i->name] = true;
|
241 |
-
}
|
242 |
-
}
|
243 |
-
|
244 |
-
$pageMappings = $this->getPageMappings();
|
245 |
-
foreach ($pageMappings AS $from => $to) {
|
246 |
-
$this->pageIgnores[$from] = true;
|
247 |
-
}
|
248 |
-
}
|
249 |
return $this->pageIgnores;
|
250 |
-
}
|
251 |
-
|
252 |
-
/**
|
253 |
-
*
|
254 |
-
*
|
255 |
-
* @return array with string as key and boolean true as value for each of them
|
256 |
-
*/
|
257 |
public function getIgnoredServerParams() {
|
258 |
-
if ($this->serverIgnores == null) {
|
259 |
-
$this->serverIgnores = array();
|
260 |
-
if (isset($this->zendConfig->params->server->ignore)) {
|
261 |
-
|
262 |
-
// get ignore rules as iterable variable
|
263 |
-
if($this->zendConfig->params->server->ignore->name == null) {
|
264 |
-
$ignoreRules = $this->zendConfig->params->server->ignore ;
|
265 |
-
} else {
|
266 |
-
$ignoreRules = array($this->zendConfig->params->server->ignore );
|
267 |
-
}
|
268 |
-
|
269 |
-
// load ignore rules
|
270 |
-
foreach($ignoreRules AS $i) {
|
271 |
-
$this->serverIgnores[$i->name] = true;
|
272 |
-
}
|
273 |
-
}
|
274 |
-
|
275 |
-
$serverMappings = $this->getServerMappings();
|
276 |
-
foreach ($serverMappings AS $from => $to) {
|
277 |
-
$this->serverIgnores[$from] = true;
|
278 |
-
}
|
279 |
-
}
|
280 |
return $this->serverIgnores;
|
281 |
-
}
|
282 |
-
|
283 |
-
/**
|
284 |
-
*
|
285 |
-
*
|
286 |
-
* @return array string to string map (param-name as array-key; default value as array-value)
|
287 |
-
*/
|
288 |
-
public function getRequiredPageParams(){
|
289 |
-
if ($this->requiredPageParams == null) {
|
290 |
-
$this->requiredPageParams = array();
|
291 |
-
if ($this->zendConfig->params->client->required != null) {
|
292 |
-
|
293 |
-
// get required params config as iterable variable
|
294 |
-
if ($this->zendConfig->params->client->required->name == null) {
|
295 |
-
$requiredParams = $this->zendConfig->params->client->required;
|
296 |
-
} else {
|
297 |
-
$requiredParams = array($this->zendConfig->params->client->required);
|
298 |
-
}
|
299 |
-
|
300 |
-
//load mappings
|
301 |
-
foreach($requiredParams AS $param) {
|
302 |
-
$this->requiredPageParams[$param->name] = $param->default;
|
303 |
-
}
|
304 |
-
}
|
305 |
-
}
|
306 |
-
return $this->requiredPageParams;
|
307 |
-
}
|
308 |
-
|
309 |
-
/**
|
310 |
-
*
|
311 |
-
*
|
312 |
-
* @return array string to string map (param-name as array-key; default value as array-value)
|
313 |
-
*/
|
314 |
-
function getRequiredServerParams(){
|
315 |
-
if ($this->requiredServerParams == null) {
|
316 |
-
$this->requiredServerParams = array();
|
317 |
-
if ($this->zendConfig->params->server->required != null) {
|
318 |
-
|
319 |
-
// get required params config as iterable variable
|
320 |
-
if ($this->zendConfig->params->server->required->name == null) {
|
321 |
-
$requiredParams = $this->zendConfig->params->server->required;
|
322 |
-
} else {
|
323 |
-
$requiredParams = array($this->zendConfig->params->server->required);
|
324 |
-
}
|
325 |
-
|
326 |
-
//load mappings
|
327 |
-
foreach($requiredParams AS $param) {
|
328 |
-
$this->requiredServerParams[$param->name] = $param->default;
|
329 |
-
}
|
330 |
-
}
|
331 |
-
}
|
332 |
-
return $this->requiredServerParams;
|
333 |
-
}
|
334 |
-
|
335 |
-
|
336 |
-
/**
|
337 |
-
*
|
338 |
-
*
|
339 |
-
* @return string
|
340 |
-
*/
|
341 |
-
function getPageContentEncoding() {
|
342 |
-
return $this->zendConfig->encoding->pageContent;
|
343 |
-
}
|
344 |
-
|
345 |
-
/**
|
346 |
-
*
|
347 |
-
*
|
348 |
-
* @return string
|
349 |
-
*/
|
350 |
-
function getPageUrlEncoding() {
|
351 |
-
return $this->zendConfig->encoding->pageURI;
|
352 |
-
}
|
353 |
-
|
354 |
-
/**
|
355 |
-
*
|
356 |
-
*
|
357 |
-
* @return string
|
358 |
-
*/
|
359 |
-
function getServerUrlEncoding() {
|
360 |
-
return $this->zendConfig->encoding->serverURI;
|
361 |
-
}
|
362 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Common
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* this class implements the FACTFinder configuration interface and uses the Zend_Config class. so it's like a decorator
|
12 |
+
* for the Zend_Config
|
13 |
+
*
|
14 |
+
* @package FACTFinder\Common
|
15 |
+
*/
|
16 |
+
class FACTFinder_Configuration implements FACTFinder_Abstract_Configuration
|
17 |
+
{
|
18 |
+
const HTTP_AUTH = 'http';
|
19 |
+
const SIMPLE_AUTH = 'simple';
|
20 |
+
const ADVANCED_AUTH = 'advanced';
|
21 |
+
|
22 |
+
protected $zendConfig;
|
23 |
+
private $authType;
|
24 |
+
private $pageMappings;
|
25 |
+
private $serverMappings;
|
26 |
+
private $pageIgnores;
|
27 |
+
private $serverIgnores;
|
28 |
+
private $requiredPageParams;
|
29 |
+
private $requiredServerParams;
|
30 |
+
|
31 |
+
public function __construct(Zend_Config $config)
|
32 |
+
{
|
33 |
+
$this->zendConfig = $config;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* @return string
|
38 |
+
*/
|
39 |
public function getVersion() {
|
40 |
return $this->zendConfig->version;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @return boolean
|
45 |
+
* @deprecated
|
46 |
+
*/
|
47 |
public function isDebugEnabled() {
|
48 |
return $this->zendConfig->debug == 'true';
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @param string name
|
53 |
+
* @return string value
|
54 |
+
*/
|
55 |
public function getCustomValue($name) {
|
56 |
return $this->zendConfig->$name;
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* @deprecated because of wrong spelling. use "getRequestProtocol()" instead
|
61 |
+
* @return string
|
62 |
+
*/
|
63 |
public function getRequestProtokoll() {
|
64 |
return $this->zendConfig->search->protokoll;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* @return string
|
69 |
+
*/
|
70 |
+
public function getRequestProtocol() {
|
71 |
+
$protocol = $this->zendConfig->search->protocol;
|
72 |
+
|
73 |
+
// legacy code for older configurations
|
74 |
+
if (empty($protocol)) {
|
75 |
+
$protocol = $this->getRequestProtokoll();
|
76 |
+
}
|
77 |
+
return $protocol;
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* @return string
|
82 |
+
*/
|
83 |
public function getServerAddress() {
|
84 |
return $this->zendConfig->search->address;
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* @return int
|
89 |
+
*/
|
90 |
public function getServerPort() {
|
91 |
return $this->zendConfig->search->port;
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* @return string
|
96 |
+
*/
|
97 |
public function getContext() {
|
98 |
return $this->zendConfig->search->context;
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* @return string
|
103 |
+
*/
|
104 |
public function getChannel() {
|
105 |
return $this->zendConfig->search->channel;
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* @return string
|
110 |
+
*/
|
111 |
public function getLanguage() {
|
112 |
return $this->zendConfig->search->language;
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* @return string
|
117 |
+
*/
|
118 |
public function getAuthUser() {
|
119 |
return $this->zendConfig->search->auth->user;
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* @return string
|
124 |
+
*/
|
125 |
public function getAuthPasswort() {
|
126 |
return $this->zendConfig->search->auth->password;
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* @return boolean
|
131 |
+
*/
|
132 |
public function isHttpAuthenticationType() {
|
133 |
return $this->getAuthType() == self::HTTP_AUTH;
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* @return boolean
|
138 |
+
*/
|
139 |
public function isSimpleAuthenticationType() {
|
140 |
return $this->getAuthType() == self::SIMPLE_AUTH;
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* @return boolean
|
145 |
+
*/
|
146 |
public function isAdvancedAuthenticationType() {
|
147 |
return $this->getAuthType() == self::ADVANCED_AUTH;
|
148 |
+
}
|
149 |
+
|
150 |
+
private function getAuthType() {
|
151 |
+
if ($this->authType == null) {
|
152 |
+
$this->authType = $this->zendConfig->search->auth->type;
|
153 |
+
if ( $this->authType != self::HTTP_AUTH
|
154 |
+
&& $this->authType != self::SIMPLE_AUTH
|
155 |
+
&& $this->authType != self::ADVANCED_AUTH ) {
|
156 |
+
$this->authType = self::HTTP_AUTH;
|
157 |
+
}
|
158 |
+
}
|
159 |
+
return $this->authType;
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* @return string
|
164 |
+
*/
|
165 |
+
public function getAdvancedAuthPrefix() {
|
166 |
+
return $this->zendConfig->search->auth->advancedPrefix;
|
167 |
+
}
|
168 |
+
|
169 |
+
/**
|
170 |
+
* @return string
|
171 |
+
*/
|
172 |
+
public function getAdvancedAuthPostfix(){
|
173 |
+
return $this->zendConfig->search->auth->advancedPostfix;
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* get mappings for the webpage
|
178 |
+
*
|
179 |
+
* @return array
|
180 |
+
*/
|
181 |
public function getPageMappings() {
|
182 |
+
if ($this->pageMappings == null) {
|
183 |
+
$this->pageMappings = array();
|
184 |
+
if ($this->zendConfig->params->client->mapping != null) {
|
185 |
+
|
186 |
+
// get mapping config as iterable variable
|
187 |
+
if ($this->zendConfig->params->client->mapping->from == null) {
|
188 |
+
$mapping = $this->zendConfig->params->client->mapping;
|
189 |
+
} else {
|
190 |
+
$mapping = array($this->zendConfig->params->client->mapping);
|
191 |
+
}
|
192 |
+
|
193 |
+
//load mappings
|
194 |
+
foreach($mapping AS $rule) {
|
195 |
+
$this->pageMappings[$rule->from] = $rule->to;
|
196 |
+
}
|
197 |
+
}
|
198 |
+
}
|
199 |
return $this->pageMappings;
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* get mappings for the server request
|
204 |
+
*
|
205 |
+
* @return array
|
206 |
+
*/
|
207 |
public function getServerMappings() {
|
208 |
+
if ($this->serverMappings == null) {
|
209 |
+
$this->serverMappings = array();
|
210 |
+
if ($this->zendConfig->params->server->mapping != null) {
|
211 |
+
|
212 |
+
// get mapping config as iterable variable
|
213 |
+
if ($this->zendConfig->params->server->mapping->from == null) {
|
214 |
+
$mapping = $this->zendConfig->params->server->mapping;
|
215 |
+
} else {
|
216 |
+
$mapping = array($this->zendConfig->params->server->mapping);
|
217 |
+
}
|
218 |
+
|
219 |
+
//load mappings
|
220 |
+
foreach($mapping AS $rule) {
|
221 |
+
$this->serverMappings[$rule->from] = $rule->to;
|
222 |
+
}
|
223 |
+
}
|
224 |
+
}
|
225 |
return $this->serverMappings;
|
226 |
+
}
|
227 |
+
|
228 |
+
/**
|
229 |
+
* get ignored parameters for the webpage request
|
230 |
+
*
|
231 |
+
* @return array with string as key and boolean true as value for each of them
|
232 |
+
*/
|
233 |
public function getIgnoredPageParams() {
|
234 |
+
if ($this->pageIgnores == null) {
|
235 |
+
$this->pageIgnores = array();
|
236 |
+
if (isset($this->zendConfig->params->client->ignore)) {
|
237 |
+
|
238 |
+
// get ignore rules as iterable variable
|
239 |
+
if($this->zendConfig->params->client->ignore->name == null) {
|
240 |
+
$ignoreRules = $this->zendConfig->params->client->ignore ;
|
241 |
+
} else {
|
242 |
+
$ignoreRules = array($this->zendConfig->params->client->ignore );
|
243 |
+
}
|
244 |
+
|
245 |
+
// load ignore rules
|
246 |
+
foreach($ignoreRules AS $i) {
|
247 |
+
$this->pageIgnores[$i->name] = true;
|
248 |
+
}
|
249 |
+
}
|
250 |
+
|
251 |
+
$pageMappings = $this->getPageMappings();
|
252 |
+
foreach ($pageMappings AS $from => $to) {
|
253 |
+
$this->pageIgnores[$from] = true;
|
254 |
+
}
|
255 |
+
}
|
256 |
return $this->pageIgnores;
|
257 |
+
}
|
258 |
+
|
259 |
+
/**
|
260 |
+
* get ignored parameters for the server request
|
261 |
+
*
|
262 |
+
* @return array with string as key and boolean true as value for each of them
|
263 |
+
*/
|
264 |
public function getIgnoredServerParams() {
|
265 |
+
if ($this->serverIgnores == null) {
|
266 |
+
$this->serverIgnores = array();
|
267 |
+
if (isset($this->zendConfig->params->server->ignore)) {
|
268 |
+
|
269 |
+
// get ignore rules as iterable variable
|
270 |
+
if($this->zendConfig->params->server->ignore->name == null) {
|
271 |
+
$ignoreRules = $this->zendConfig->params->server->ignore ;
|
272 |
+
} else {
|
273 |
+
$ignoreRules = array($this->zendConfig->params->server->ignore );
|
274 |
+
}
|
275 |
+
|
276 |
+
// load ignore rules
|
277 |
+
foreach($ignoreRules AS $i) {
|
278 |
+
$this->serverIgnores[$i->name] = true;
|
279 |
+
}
|
280 |
+
}
|
281 |
+
|
282 |
+
$serverMappings = $this->getServerMappings();
|
283 |
+
foreach ($serverMappings AS $from => $to) {
|
284 |
+
$this->serverIgnores[$from] = true;
|
285 |
+
}
|
286 |
+
}
|
287 |
return $this->serverIgnores;
|
288 |
+
}
|
289 |
+
|
290 |
+
/**
|
291 |
+
* get required parameters for the webpage request
|
292 |
+
*
|
293 |
+
* @return array string to string map (param-name as array-key; default value as array-value)
|
294 |
+
*/
|
295 |
+
public function getRequiredPageParams(){
|
296 |
+
if ($this->requiredPageParams == null) {
|
297 |
+
$this->requiredPageParams = array();
|
298 |
+
if ($this->zendConfig->params->client->required != null) {
|
299 |
+
|
300 |
+
// get required params config as iterable variable
|
301 |
+
if ($this->zendConfig->params->client->required->name == null) {
|
302 |
+
$requiredParams = $this->zendConfig->params->client->required;
|
303 |
+
} else {
|
304 |
+
$requiredParams = array($this->zendConfig->params->client->required);
|
305 |
+
}
|
306 |
+
|
307 |
+
//load mappings
|
308 |
+
foreach($requiredParams AS $param) {
|
309 |
+
$this->requiredPageParams[$param->name] = $param->default;
|
310 |
+
}
|
311 |
+
}
|
312 |
+
}
|
313 |
+
return $this->requiredPageParams;
|
314 |
+
}
|
315 |
+
|
316 |
+
/**
|
317 |
+
* get required paramters for the server request
|
318 |
+
*
|
319 |
+
* @return array string to string map (param-name as array-key; default value as array-value)
|
320 |
+
*/
|
321 |
+
function getRequiredServerParams(){
|
322 |
+
if ($this->requiredServerParams == null) {
|
323 |
+
$this->requiredServerParams = array();
|
324 |
+
if ($this->zendConfig->params->server->required != null) {
|
325 |
+
|
326 |
+
// get required params config as iterable variable
|
327 |
+
if ($this->zendConfig->params->server->required->name == null) {
|
328 |
+
$requiredParams = $this->zendConfig->params->server->required;
|
329 |
+
} else {
|
330 |
+
$requiredParams = array($this->zendConfig->params->server->required);
|
331 |
+
}
|
332 |
+
|
333 |
+
//load mappings
|
334 |
+
foreach($requiredParams AS $param) {
|
335 |
+
$this->requiredServerParams[$param->name] = $param->default;
|
336 |
+
}
|
337 |
+
}
|
338 |
+
}
|
339 |
+
return $this->requiredServerParams;
|
340 |
+
}
|
341 |
+
|
342 |
+
|
343 |
+
/**
|
344 |
+
* get encoding for the webpage
|
345 |
+
*
|
346 |
+
* @return string
|
347 |
+
*/
|
348 |
+
function getPageContentEncoding() {
|
349 |
+
return $this->zendConfig->encoding->pageContent;
|
350 |
+
}
|
351 |
+
|
352 |
+
/**
|
353 |
+
* get encoding for the webpage url
|
354 |
+
*
|
355 |
+
* @return string
|
356 |
+
*/
|
357 |
+
function getPageUrlEncoding() {
|
358 |
+
return $this->zendConfig->encoding->pageURI;
|
359 |
+
}
|
360 |
+
|
361 |
+
/**
|
362 |
+
* get server url encoding
|
363 |
+
*
|
364 |
+
* @return string
|
365 |
+
*/
|
366 |
+
function getServerUrlEncoding() {
|
367 |
+
return $this->zendConfig->encoding->serverURI;
|
368 |
+
}
|
369 |
}
|
lib/FACTFinder/EncodingHandler.php
CHANGED
@@ -1,209 +1,219 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
*
|
5 |
-
*
|
6 |
-
* @package
|
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 |
-
|
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 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Common
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* this class handles the different issues of encoding between the values of page-url, server-url, result and pagecontent
|
12 |
+
*
|
13 |
+
* @package FACTFinder\Common
|
14 |
+
*/
|
15 |
+
class FACTFinder_EncodingHandler
|
16 |
+
{
|
17 |
+
protected $convertMethod;
|
18 |
+
|
19 |
+
protected $pageContentEncoding;
|
20 |
+
protected $pageUrlEncoding;
|
21 |
+
protected $serverUrlEncoding;
|
22 |
+
|
23 |
+
protected $log;
|
24 |
+
|
25 |
+
public function __construct(FACTFinder_Abstract_Configuration $config, FACTFinder_Abstract_Logger $log = null)
|
26 |
+
{
|
27 |
+
if(isset($log))
|
28 |
+
$this->log = $log;
|
29 |
+
else
|
30 |
+
$this->log = FF::getSingleton('nullLogger');
|
31 |
+
|
32 |
+
$this->pageContentEncoding = $config->getPageContentEncoding();
|
33 |
+
$this->pageUrlEncoding = $config->getPageUrlEncoding();
|
34 |
+
$this->serverUrlEncoding = $config->getServerUrlEncoding();
|
35 |
+
|
36 |
+
if (function_exists('iconv')) {
|
37 |
+
$this->convertMethod = 'iConvert';
|
38 |
+
} else {
|
39 |
+
$this->convertMethod = 'utf8Convert';
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* converts the string from "inCharset" encoding into "outCharset" encoding. if the running php have no iconv support,
|
45 |
+
* the utf8_encode/decode are used, so only the encodings "utf-8" and "iso-8859-?" can be used
|
46 |
+
*
|
47 |
+
* @param input charset
|
48 |
+
* @param output charset
|
49 |
+
* @param string which should be converted
|
50 |
+
* @return string in specified output charset
|
51 |
+
* @throws exception for not supported charset
|
52 |
+
*/
|
53 |
+
public function convert($inCharset, $outCharset, $string)
|
54 |
+
{
|
55 |
+
return $this->{$this->convertMethod}($inCharset, $outCharset, $string);
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* uses iconvert to convert string
|
60 |
+
*
|
61 |
+
* @link http://bg.php.net/manual/en/book.iconv.php
|
62 |
+
* @param input charset
|
63 |
+
* @param output charset
|
64 |
+
* @param string which should be converted
|
65 |
+
* @return string in specified output charset
|
66 |
+
*/
|
67 |
+
protected function iConvert($inCharset, $outCharset, $string)
|
68 |
+
{
|
69 |
+
// see http://de2.php.net/manual/de/function.iconv.php to understand '//IGNORE'
|
70 |
+
return ($inCharset == $outCharset || empty($inCharset) || empty($outCharset)) ? $string : iconv($inCharset, $outCharset.'//IGNORE', $string);
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* uses utf8-convert functions to convert string
|
75 |
+
*
|
76 |
+
* @param input charset
|
77 |
+
* @param output charset
|
78 |
+
* @param string which should be converted
|
79 |
+
* @return string in specified output charset
|
80 |
+
* @throws exception for not supported charset
|
81 |
+
*/
|
82 |
+
protected function utf8Convert($inCharset, $outCharset, $string)
|
83 |
+
{
|
84 |
+
if (strtolower($inCharset) != strtolower($outCharset) && !empty($inCharset) && !empty($outCharset)) {
|
85 |
+
if (strtolower($inCharset) == 'utf-8') {
|
86 |
+
$string = utf8_decode($string);
|
87 |
+
} else if (strtolower($outCharset) == 'utf-8') {
|
88 |
+
$string = utf8_encode($string);
|
89 |
+
} else {
|
90 |
+
$this->log->error("Could not convert between non-UTF-8 charsets.");
|
91 |
+
throw new Exception("can not handle $inCharset to $outCharset conversion!");
|
92 |
+
}
|
93 |
+
}
|
94 |
+
return $string;
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* converts the url data, to display correctly at the page
|
99 |
+
*
|
100 |
+
* @param string|array data
|
101 |
+
* @return string|array converted data
|
102 |
+
*/
|
103 |
+
public function encodeUrlForPage($data)
|
104 |
+
{
|
105 |
+
// notice: urldecode is not needed, because php decodes the url automatically
|
106 |
+
if ($this->pageUrlEncoding != $this->pageContentEncoding) {
|
107 |
+
if (is_array($data)) {
|
108 |
+
$returnData = array();
|
109 |
+
foreach ($data AS $key => $value) {
|
110 |
+
$key = $this->convert($this->pageUrlEncoding, $this->pageContentEncoding, $key);
|
111 |
+
$returnData[$key] = $this->convert($this->pageUrlEncoding, $this->pageContentEncoding, $value);
|
112 |
+
}
|
113 |
+
} else if (is_string($data)) {
|
114 |
+
$returnData = $this->convert($this->pageUrlEncoding, $this->pageContentEncoding, $data);
|
115 |
+
}
|
116 |
+
} else {
|
117 |
+
$returnData = $data;
|
118 |
+
}
|
119 |
+
return $returnData;
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* converts the url data from the server result for the page url
|
124 |
+
*
|
125 |
+
* @param string|array data
|
126 |
+
* @return string|array converted data
|
127 |
+
*/
|
128 |
+
public function encodeServerUrlForPageUrl($data)
|
129 |
+
{
|
130 |
+
// notice: urldecode is not needed, because the parameters parser is already doing that
|
131 |
+
if ($this->serverUrlEncoding != $this->pageUrlEncoding) {
|
132 |
+
if (is_array($data)) {
|
133 |
+
$returnData = array();
|
134 |
+
foreach ($data AS $key => $value) {
|
135 |
+
$key = $this->convert($this->serverUrlEncoding, $this->pageUrlEncoding, $key);
|
136 |
+
$returnData[$key] = $this->convert($this->serverUrlEncoding, $this->pageUrlEncoding, $value);
|
137 |
+
}
|
138 |
+
} else if (is_string($data)) {
|
139 |
+
$returnData = $this->convert($this->serverUrlEncoding, $this->pageUrlEncoding, $data);
|
140 |
+
}
|
141 |
+
} else {
|
142 |
+
$returnData = $data;
|
143 |
+
}
|
144 |
+
return $returnData;
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* converts the data from the server result for the page content
|
149 |
+
*
|
150 |
+
* @param string|array data
|
151 |
+
* @return string|array converted data
|
152 |
+
*/
|
153 |
+
public function encodeServerContentForPage($data)
|
154 |
+
{
|
155 |
+
// server result data is always utf-8
|
156 |
+
if (strtolower($this->pageContentEncoding) != 'utf-8') {
|
157 |
+
if (is_array($data)) {
|
158 |
+
$returnData = array();
|
159 |
+
foreach ($data AS $key => $value) {
|
160 |
+
$key = $this->convert('UTF-8', $this->pageContentEncoding, $key);
|
161 |
+
$returnData[$key] = $this->convert('UTF-8', $this->pageContentEncoding, $value);
|
162 |
+
}
|
163 |
+
} else if (is_string($data)) {
|
164 |
+
$returnData = $this->convert('UTF-8', $this->pageContentEncoding, $data);
|
165 |
+
}
|
166 |
+
} else {
|
167 |
+
$returnData = $data;
|
168 |
+
}
|
169 |
+
return $returnData;
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* converts the data for the server url
|
174 |
+
*
|
175 |
+
* @param string|array data
|
176 |
+
* @return string|array converted data
|
177 |
+
*/
|
178 |
+
public function encodeForServerUrl($data)
|
179 |
+
{
|
180 |
+
if ($this->pageContentEncoding != $this->serverUrlEncoding) {
|
181 |
+
if (is_array($data)) {
|
182 |
+
$returnData = array();
|
183 |
+
foreach ($data AS $key => $value) {
|
184 |
+
$key = $this->convert($this->pageContentEncoding, $this->serverUrlEncoding, $key);
|
185 |
+
$returnData[$key] = $this->convert($this->pageContentEncoding, $this->serverUrlEncoding, $value);
|
186 |
+
}
|
187 |
+
} else if (is_string($data)) {
|
188 |
+
$returnData = $this->convert($this->pageContentEncoding, $this->serverUrlEncoding, $data);
|
189 |
+
}
|
190 |
+
} else {
|
191 |
+
$returnData = $data;
|
192 |
+
}
|
193 |
+
return $returnData;
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* converts the data from the page for the page url
|
198 |
+
*
|
199 |
+
* @param string|array data
|
200 |
+
* @return string|array converted data
|
201 |
+
*/
|
202 |
+
public function encodeForPageUrl($data)
|
203 |
+
{
|
204 |
+
if ($this->pageContentEncoding != $this->pageUrlEncoding) {
|
205 |
+
if (is_array($data)) {
|
206 |
+
$returnData = array();
|
207 |
+
foreach ($data AS $key => $value) {
|
208 |
+
$key = $this->convert($this->pageContentEncoding, $this->pageUrlEncoding, $key);
|
209 |
+
$returnData[$key] = $this->convert($this->pageContentEncoding, $this->pageUrlEncoding, $value);
|
210 |
+
}
|
211 |
+
} else if (is_string($data)) {
|
212 |
+
$returnData = $this->convert($this->pageContentEncoding, $this->pageUrlEncoding, $data);
|
213 |
+
}
|
214 |
+
} else {
|
215 |
+
$returnData = $data;
|
216 |
+
}
|
217 |
+
return $returnData;
|
218 |
+
}
|
219 |
}
|
lib/FACTFinder/Http/DataProvider.php
CHANGED
@@ -1,291 +1,309 @@
|
|
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 |
-
|
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 |
-
if ($
|
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 |
-
$url = $this->
|
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 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
$
|
183 |
-
$
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
$
|
195 |
-
$
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
$
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
$url
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
291 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Http
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* this data provider loads the data via http
|
12 |
+
*
|
13 |
+
* @author Rudolf Batt <rb@omikron.net>
|
14 |
+
* @version $Id: DataProvider.php 25893 2010-06-29 08:19:43Z rb $
|
15 |
+
* @package FACTFinder\Http
|
16 |
+
*/
|
17 |
+
class FACTFinder_Http_DataProvider extends FACTFinder_Abstract_DataProvider
|
18 |
+
{
|
19 |
+
protected $data;
|
20 |
+
protected $previousUrl;
|
21 |
+
protected $httpHeader = array();
|
22 |
+
protected $curlOptions = array(
|
23 |
+
CURLOPT_RETURNTRANSFER => true,
|
24 |
+
CURLOPT_SSL_VERIFYPEER => false,
|
25 |
+
CURLOPT_SSL_VERIFYHOST => false,
|
26 |
+
CURLOPT_CONNECTTIMEOUT => 2,
|
27 |
+
CURLOPT_TIMEOUT => 4
|
28 |
+
);
|
29 |
+
|
30 |
+
/**
|
31 |
+
* this implementation of the data provider uses the type as request path in addition to the request context path.
|
32 |
+
* please ensure that this is the full action name, i.e. "Search.ff"
|
33 |
+
*
|
34 |
+
* @param string type
|
35 |
+
*/
|
36 |
+
public function setType($type)
|
37 |
+
{
|
38 |
+
$this->type = $type;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* set a option for a cURL request like described at {@link http://php.net/manual/en/function.curl-setopt.php}.
|
43 |
+
* The second parameter can be set to false, so the option will not be overwritten if it already exists
|
44 |
+
*
|
45 |
+
* @link http://php.net/manual/en/function.curl-setopt.php
|
46 |
+
* @param the option key (should be a cURL constant)
|
47 |
+
* @param the option value
|
48 |
+
* @param boolean whether to overwrite existing options or not. optional, default = true
|
49 |
+
* @return void
|
50 |
+
*/
|
51 |
+
public function setCurlOption($option, $value, $overwriteExisting = true) {
|
52 |
+
if ($overwriteExisting || !isset($this->curlOptions[$option])) {
|
53 |
+
$this->curlOptions[$option] = $value;
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Set multiple options for a cURL request like described at {@link http://php.net/manual/en/function.curl-setopt.php}
|
59 |
+
*
|
60 |
+
* @link http://php.net/manual/en/function.curl-setopt.php
|
61 |
+
* @param array of options
|
62 |
+
* @return void
|
63 |
+
*/
|
64 |
+
public function setCurlOptions(array $options) {
|
65 |
+
foreach($options AS $option => $value) {
|
66 |
+
$this->setCurlOption($option, $value);
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* add an array of HTTP header fields in the format array('Content-type: text/plain', 'Content-length: 100')
|
72 |
+
*
|
73 |
+
* @param array $httpHeader
|
74 |
+
* @return void
|
75 |
+
*/
|
76 |
+
public function addHttpHeaderFields(array $httpHeader) {
|
77 |
+
$this->httpHeader = array_merge($this->httpHeader, $httpHeader);
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* this implementation returns the data as string, no matter what content type set at the http response
|
82 |
+
*
|
83 |
+
* @return string data
|
84 |
+
*/
|
85 |
+
public function getData()
|
86 |
+
{
|
87 |
+
$url = $this->getAuthenticationUrl();
|
88 |
+
if ($this->data == null || $url != $this->previousUrl) {
|
89 |
+
$this->previousUrl = $url;
|
90 |
+
$this->data = $this->loadResponse($url);
|
91 |
+
}
|
92 |
+
return $this->data;
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* this function sends the request to the server and loads the response data
|
97 |
+
*
|
98 |
+
* @throws Exception on connection error
|
99 |
+
* @return response data
|
100 |
+
**/
|
101 |
+
protected function loadResponse($url)
|
102 |
+
{
|
103 |
+
if ($this->type == null) {
|
104 |
+
$this->log->error("Request type missing.");
|
105 |
+
throw new Exception('request type not set! can not do a request without knowing the type.');
|
106 |
+
}
|
107 |
+
|
108 |
+
$config = $this->getConfig();
|
109 |
+
if ($config->getLanguage() != '') {
|
110 |
+
$this->addHttpHeaderFields(array('Accept-Language: ' . $config->getLanguage()));
|
111 |
+
}
|
112 |
+
|
113 |
+
if ($this->getConfig()->isDebugEnabled()) {
|
114 |
+
$url .= '&verbose=true';
|
115 |
+
if (isset($_SERVER['HTTP_REFERER'])) $this->setCurlOption(CURLOPT_REFERER, $_SERVER['HTTP_REFERER'], false);
|
116 |
+
}
|
117 |
+
return $this->sendRequest($url);
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* this function returns the request url with the correct authentication method (set by the configuration).
|
122 |
+
*
|
123 |
+
* @return string url
|
124 |
+
*/
|
125 |
+
public function getAuthenticationUrl() {
|
126 |
+
$config = $this->getConfig();
|
127 |
+
if ($config->isHttpAuthenticationType()) {
|
128 |
+
$url = $this->getHttpAuthenticationUrl();
|
129 |
+
} else if ($config->isSimpleAuthenticationType()) {
|
130 |
+
$url = $this->getSimpleAuthenticationUrl();
|
131 |
+
} else if ($config->isAdvancedAuthenticationType()) {
|
132 |
+
$url = $this->getAdvancedAuthenticationUrl();
|
133 |
+
} else {
|
134 |
+
$url = $this->getNonAuthenticationUrl();
|
135 |
+
}
|
136 |
+
return $url;
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* send request and return response data
|
141 |
+
*
|
142 |
+
* @param string url
|
143 |
+
* @return string returned http body
|
144 |
+
*/
|
145 |
+
protected function sendRequest($url)
|
146 |
+
{
|
147 |
+
$this->log->info("Trying to send request to ".$url."...");
|
148 |
+
$cResource = curl_init($url);
|
149 |
+
|
150 |
+
if (!empty($this->httpHeader)) {
|
151 |
+
$this->curlOptions[CURLOPT_HTTPHEADER] = $this->httpHeader;
|
152 |
+
}
|
153 |
+
|
154 |
+
if (sizeof($this->curlOptions) > 0) {
|
155 |
+
curl_setopt_array($cResource, $this->curlOptions);
|
156 |
+
}
|
157 |
+
|
158 |
+
$response = curl_exec($cResource);
|
159 |
+
$httpCode = curl_getinfo($cResource, CURLINFO_HTTP_CODE);
|
160 |
+
$curlErr = curl_error($cResource);
|
161 |
+
curl_close($cResource);
|
162 |
+
|
163 |
+
if (intval($httpCode) >= 400) {
|
164 |
+
$this->log->error("Conntection failed. HTTP code: $httpCode");
|
165 |
+
throw new Exception("Connection failed. HTTP code: $httpCode", $httpCode);
|
166 |
+
} else if ($httpCode == 0) {
|
167 |
+
$this->log->error("Connection refused. $curlErr");
|
168 |
+
throw new Exception("Connection refused. $curlErr");
|
169 |
+
} else if (floor(intval($httpCode) / 100) == 2) { // all successful status codes (2**)
|
170 |
+
$this->log->info("Received response from ".$url.".");
|
171 |
+
}
|
172 |
+
|
173 |
+
return $response;
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* get url with advanced authentication encryption
|
178 |
+
*
|
179 |
+
* @return string url
|
180 |
+
*/
|
181 |
+
protected function getAdvancedAuthenticationUrl() {
|
182 |
+
$config = $this->getConfig();
|
183 |
+
$params = $this->getParams();
|
184 |
+
$this->log->info("Server Request Params: ".http_build_query($params, '', ', '));
|
185 |
+
|
186 |
+
$channel = $this->getChannel($params, $config);
|
187 |
+
if ($channel != '') {
|
188 |
+
$params['channel'] = $channel;
|
189 |
+
}
|
190 |
+
|
191 |
+
$ts = time() . '000'; //millisecondes needed
|
192 |
+
$prefix = $config->getAdvancedAuthPrefix();
|
193 |
+
$postfix = $config->getAdvancedAuthPostfix();
|
194 |
+
$authParams = "timestamp=$ts&username=".$config->getAuthUser()
|
195 |
+
. '&password=' . md5($prefix . $ts . md5($config->getAuthPasswort()) . $postfix);
|
196 |
+
|
197 |
+
$url = $config->getRequestProtocol() . '://'
|
198 |
+
. $config->getServerAddress() . ':' . $config->getServerPort() . '/'
|
199 |
+
. $config->getContext() . '/'.$this->type.'?' . http_build_query($params, '', '&')
|
200 |
+
. (count($params)?'&':'') . $authParams;
|
201 |
+
|
202 |
+
// The following line removes all []-indices from array parameters, because tomcat doesn't need them
|
203 |
+
$url = preg_replace("/%5B[A-Za-z0-9]*%5D/", "", $url);
|
204 |
+
$this->log->info("Request Url: ".$url);
|
205 |
+
return $url;
|
206 |
+
}
|
207 |
+
|
208 |
+
/**
|
209 |
+
* get url with simple authentication encryption
|
210 |
+
*
|
211 |
+
* @return string url
|
212 |
+
*/
|
213 |
+
protected function getSimpleAuthenticationUrl() {
|
214 |
+
$config = $this->getConfig();
|
215 |
+
$params = $this->getParams();
|
216 |
+
$this->log->info("Server Request Params: ".http_build_query($params, '', ', '));
|
217 |
+
|
218 |
+
$channel = $this->getChannel($params, $config);
|
219 |
+
if ($channel != '') {
|
220 |
+
$params['channel'] = $channel;
|
221 |
+
}
|
222 |
+
|
223 |
+
$ts = time() . '000'; //millisecondes needed but won't be considered
|
224 |
+
$authParams = "timestamp=$ts&username=".$config->getAuthUser()
|
225 |
+
. '&password=' . md5($config->getAuthPasswort());
|
226 |
+
|
227 |
+
$url = $config->getRequestProtocol() . '://'
|
228 |
+
. $config->getServerAddress() . ':' . $config->getServerPort() . '/'
|
229 |
+
. $config->getContext() . '/'.$this->type.'?' . http_build_query($params, '', '&')
|
230 |
+
. (count($params)?'&':'') . $authParams;
|
231 |
+
|
232 |
+
// The following line removes all []-indices from array parameters, because tomcat doesn't need them
|
233 |
+
$url = preg_replace("/%5B[A-Za-z0-9]*%5D/", "", $url);
|
234 |
+
$this->log->info("Request Url: ".$url);
|
235 |
+
return $url;
|
236 |
+
}
|
237 |
+
|
238 |
+
/**
|
239 |
+
* get url with http authentication
|
240 |
+
*
|
241 |
+
* @return string url
|
242 |
+
*/
|
243 |
+
protected function getHttpAuthenticationUrl() {
|
244 |
+
$config = $this->getConfig();
|
245 |
+
$params = $this->getParams();
|
246 |
+
$this->log->info("Server Request Params: ".http_build_query($params, '', ', '));
|
247 |
+
|
248 |
+
$channel = $this->getChannel($params, $config);
|
249 |
+
if ($channel != '') {
|
250 |
+
$params['channel'] = $channel;
|
251 |
+
}
|
252 |
+
|
253 |
+
$auth = $config->getAuthUser() . ':' . $config->getAuthPasswort() . '@';
|
254 |
+
if ($auth == ':@') $auth = '';
|
255 |
+
|
256 |
+
$url = $config->getRequestProtocol() . '://' . $auth
|
257 |
+
. $config->getServerAddress() . ':' . $config->getServerPort() . '/'
|
258 |
+
. $config->getContext() . '/' . $this->type . (count($params)?'?':'')
|
259 |
+
. http_build_query($params, '', '&');
|
260 |
+
|
261 |
+
// The following line removes all []-indices from array parameters, because tomcat doesn't need them
|
262 |
+
$url = preg_replace("/%5B[A-Za-z0-9]*%5D/", "", $url);
|
263 |
+
$this->log->info("Request Url: ".$url);
|
264 |
+
return $url;
|
265 |
+
}
|
266 |
+
|
267 |
+
/**
|
268 |
+
* get url with no authentication.
|
269 |
+
*
|
270 |
+
* @return string url
|
271 |
+
*/
|
272 |
+
public function getNonAuthenticationUrl() {
|
273 |
+
$config = $this->getConfig();
|
274 |
+
$params = $this->getParams();
|
275 |
+
$this->log->info("Server Request Params: ".http_build_query($params, '', ', '));
|
276 |
+
|
277 |
+
$channel = $this->getChannel($params, $config);
|
278 |
+
if ($channel != '') {
|
279 |
+
$params['channel'] = $channel;
|
280 |
+
}
|
281 |
+
|
282 |
+
$url = $config->getRequestProtocol() . '://'
|
283 |
+
. $config->getServerAddress() . ':' . $config->getServerPort() . '/'
|
284 |
+
. $config->getContext() . '/' . $this->type . (count($params)?'?':'')
|
285 |
+
. http_build_query($params, '', '&');
|
286 |
+
|
287 |
+
// The following line removes all []-indices from array parameters, because tomcat doesn't need them
|
288 |
+
$url = preg_replace("/%5B[A-Za-z0-9]*%5D/", "", $url);
|
289 |
+
$this->log->info("Request Url: ".$url);
|
290 |
+
return $url;
|
291 |
+
}
|
292 |
+
|
293 |
+
/**
|
294 |
+
* get channel from params or config (params override config)
|
295 |
+
*
|
296 |
+
* @param array parameterse
|
297 |
+
* @param FACTFinderAbstractConfiguration config
|
298 |
+
* @return string channel
|
299 |
+
*/
|
300 |
+
protected function getChannel($params, $config) {
|
301 |
+
$channel = '';
|
302 |
+
if (isset($params['channel']) && strlen($params['channel']) > 0) {
|
303 |
+
$channel = $params['channel'];
|
304 |
+
} else if($config->getChannel() != '') {
|
305 |
+
$channel = $config->getChannel();
|
306 |
+
}
|
307 |
+
return $channel;
|
308 |
+
}
|
309 |
}
|
lib/FACTFinder/Http/DummyProvider.php
CHANGED
@@ -1,4 +1,11 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
/**
|
4 |
* this data provider loads the data from local static xml files
|
@@ -6,32 +13,32 @@
|
|
6 |
*
|
7 |
* @author Rudolf Batt <rb@omikron.net>, Martin Buettner <martin.buettner@omikron.net>
|
8 |
* @version $Id: DummyProvider.php 44086 2012-02-29 17:19:43Z martin.buettner $
|
9 |
-
* @package FACTFinder\
|
10 |
*/
|
11 |
class FACTFinder_Http_DummyProvider extends FACTFinder_Abstract_DataProvider
|
12 |
{
|
13 |
protected $data;
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
* @link http://php.net/manual/en/function.curl-setopt.php
|
27 |
* @param the option key (should be a cURL constant)
|
28 |
-
|
29 |
-
|
30 |
* @return void
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
|
36 |
/**
|
37 |
* we just offer this function, for compatibility with the DataProvider API
|
@@ -41,7 +48,7 @@ class FACTFinder_Http_DummyProvider extends FACTFinder_Abstract_DataProvider
|
|
41 |
* @return void
|
42 |
*/
|
43 |
public function setCurlOptions(array $options) {
|
44 |
-
|
45 |
}
|
46 |
|
47 |
/**
|
@@ -56,22 +63,21 @@ class FACTFinder_Http_DummyProvider extends FACTFinder_Abstract_DataProvider
|
|
56 |
}
|
57 |
|
58 |
/**
|
59 |
-
* {@inheritdoc}
|
60 |
* this implementation returns the data as string
|
61 |
*
|
62 |
* @return string data
|
63 |
*/
|
64 |
public function getData()
|
65 |
{
|
66 |
-
|
67 |
if ($this->data == null || $fileName != $this->previousFileName) {
|
68 |
$this->previousFileName = $fileName;
|
69 |
$this->data = $this->loadFileContent($fileName);
|
70 |
}
|
71 |
return $this->data;
|
72 |
}
|
73 |
-
|
74 |
-
|
75 |
* this function loads the correct file and returns its contents
|
76 |
*
|
77 |
* @throws Exception on connection error
|
@@ -79,52 +85,52 @@ class FACTFinder_Http_DummyProvider extends FACTFinder_Abstract_DataProvider
|
|
79 |
**/
|
80 |
protected function loadFileContent($fileName)
|
81 |
{
|
82 |
-
|
83 |
}
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
throw new Exception('request type not set! can not do a request without knowing the type.');
|
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 |
$channel = $config->getChannel();
|
127 |
}
|
128 |
-
|
129 |
-
|
130 |
}
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Http
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
|
10 |
/**
|
11 |
* this data provider loads the data from local static xml files
|
13 |
*
|
14 |
* @author Rudolf Batt <rb@omikron.net>, Martin Buettner <martin.buettner@omikron.net>
|
15 |
* @version $Id: DummyProvider.php 44086 2012-02-29 17:19:43Z martin.buettner $
|
16 |
+
* @package FACTFinder\Http
|
17 |
*/
|
18 |
class FACTFinder_Http_DummyProvider extends FACTFinder_Abstract_DataProvider
|
19 |
{
|
20 |
protected $data;
|
21 |
+
protected $previousFileName;
|
22 |
+
|
23 |
+
protected $fileLocation;
|
24 |
+
|
25 |
+
public function setFileLocation($loc)
|
26 |
+
{
|
27 |
+
$this->fileLocation = substr($loc, -1) == DS ? $loc : $loc.DS;
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* we just offer this function, for compatibility with the DataProvider API
|
32 |
+
*
|
33 |
* @link http://php.net/manual/en/function.curl-setopt.php
|
34 |
* @param the option key (should be a cURL constant)
|
35 |
+
* @param the option value
|
36 |
+
* @param boolean whether to overwrite existing options or not. optional, default = true
|
37 |
* @return void
|
38 |
+
*/
|
39 |
+
public function setCurlOption($option, $value, $overwriteExisting = true) {
|
40 |
+
return;
|
41 |
+
}
|
42 |
|
43 |
/**
|
44 |
* we just offer this function, for compatibility with the DataProvider API
|
48 |
* @return void
|
49 |
*/
|
50 |
public function setCurlOptions(array $options) {
|
51 |
+
return;
|
52 |
}
|
53 |
|
54 |
/**
|
63 |
}
|
64 |
|
65 |
/**
|
|
|
66 |
* this implementation returns the data as string
|
67 |
*
|
68 |
* @return string data
|
69 |
*/
|
70 |
public function getData()
|
71 |
{
|
72 |
+
$fileName = $this->getFileName();
|
73 |
if ($this->data == null || $fileName != $this->previousFileName) {
|
74 |
$this->previousFileName = $fileName;
|
75 |
$this->data = $this->loadFileContent($fileName);
|
76 |
}
|
77 |
return $this->data;
|
78 |
}
|
79 |
+
|
80 |
+
/**
|
81 |
* this function loads the correct file and returns its contents
|
82 |
*
|
83 |
* @throws Exception on connection error
|
85 |
**/
|
86 |
protected function loadFileContent($fileName)
|
87 |
{
|
88 |
+
return file_get_contents($fileName);
|
89 |
}
|
90 |
+
|
91 |
+
protected function getFileName()
|
92 |
+
{
|
93 |
+
if ($this->type == null) {
|
94 |
+
$this->log->error("Request type missing.");
|
95 |
throw new Exception('request type not set! can not do a request without knowing the type.');
|
96 |
}
|
97 |
+
|
98 |
+
// Remove ".ff" from the type name
|
99 |
+
$fileName = substr_replace($this->type, '', '-3')."_";
|
100 |
+
$config = $this->getConfig();
|
101 |
+
$params = $this->getParams();
|
102 |
+
unset($params["format"]);
|
103 |
+
unset($params["user"]);
|
104 |
+
unset($params["pw"]);
|
105 |
+
unset($params["timestamp"]);
|
106 |
+
unset($params["channel"]);
|
107 |
|
108 |
+
ksort($params, SORT_STRING);
|
109 |
+
$fileName .= http_build_query($params, '', '_');
|
110 |
+
$fileName .= ".xml";
|
111 |
+
|
112 |
+
// The following line removes all []-indices from array parameters, because tomcat doesn't need them
|
113 |
+
$fileName = preg_replace("/%5B[A-Za-z0-9]*%5D/", "", $fileName);
|
114 |
+
|
115 |
+
$this->log->info("Trying to load ".$this->fileLocation.$fileName);
|
116 |
+
|
117 |
+
return $this->fileLocation.$fileName;
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* get channel from params or config (params override config)
|
122 |
+
*
|
123 |
+
* @param array parameters
|
124 |
+
* @param FACTFinderAbstractConfiguration config
|
125 |
+
* @return string channel
|
126 |
+
**/
|
127 |
+
protected function getChannel($params, $config) {
|
128 |
+
$channel = '';
|
129 |
+
if (isset($params['channel']) && strlen($params['channel'] > 0)) {
|
130 |
+
$channel = $params['channel'];
|
131 |
+
} else if($config->getChannel() != '') {
|
132 |
$channel = $config->getChannel();
|
133 |
}
|
134 |
+
return $channel;
|
135 |
+
}
|
136 |
}
|
lib/FACTFinder/Http/ParallelDataProvider.php
CHANGED
@@ -1,152 +1,127 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @
|
6 |
-
* @version $Id: DataProvider.php 25893 2010-06-29 08:19:43Z rb $
|
7 |
* @package FACTFinder\Http
|
|
|
8 |
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
* this is an anonymous inner class which can't be used successfully from the outside
|
12 |
-
*/
|
13 |
-
class FACTFinder_Http_DataProviderProxy extends FACTFinder_Http_DataProvider
|
14 |
-
{
|
15 |
-
private $id;
|
16 |
-
private $master;
|
17 |
-
|
18 |
-
public function register($id, FACTFinder_Http_ParallelDataProvider $master) {
|
19 |
-
$this->id = $id;
|
20 |
-
$this->master = $master;
|
21 |
-
}
|
22 |
-
|
23 |
-
public function getData() {
|
24 |
-
return $this->master->getData($this->id);
|
25 |
-
}
|
26 |
-
|
27 |
-
public function getCurlOptions() {
|
28 |
-
return $this->curlOptions;
|
29 |
-
}
|
30 |
-
|
31 |
-
public function getHttpHeader() {
|
32 |
-
return $this->httpHeader;
|
33 |
-
}
|
34 |
-
}
|
35 |
-
|
36 |
-
// Exception type needed for parallel data provider
|
37 |
-
class DataNotLoadedException extends Exception {}
|
38 |
|
39 |
/**
|
40 |
-
* this data provider
|
41 |
-
*
|
|
|
|
|
|
|
|
|
42 |
*/
|
43 |
class FACTFinder_Http_ParallelDataProvider
|
44 |
{
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
protected $data;
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
|
70 |
/**
|
71 |
* this function sends all request to the server and loads the response data
|
72 |
-
|
73 |
-
|
74 |
**/
|
75 |
public static function loadAllData()
|
76 |
{
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
$handles = self::initHandles($multiHandle);
|
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 |
* @return string data
|
151 |
*/
|
152 |
public function getData($id)
|
@@ -156,4 +131,41 @@ class FACTFinder_Http_ParallelDataProvider
|
|
156 |
}
|
157 |
return isset($this->data[$id]) ? $this->data[$id] : null;
|
158 |
}
|
159 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
*
|
5 |
+
* @category Library
|
|
|
6 |
* @package FACTFinder\Http
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
/**
|
11 |
+
* this data provider has the ability to make multiple http request at the same time
|
12 |
+
*
|
13 |
+
* @todo describe usage
|
14 |
+
* @author Rudolf Batt <rb@omikron.net>
|
15 |
+
* @version $Id: DataProvider.php 25893 2010-06-29 08:19:43Z rb $
|
16 |
+
* @package FACTFinder\Http
|
17 |
*/
|
18 |
class FACTFinder_Http_ParallelDataProvider
|
19 |
{
|
20 |
+
protected static $instance;
|
21 |
+
protected static $dataProvider = array();
|
22 |
+
protected static $dataLoaded = false;
|
23 |
+
|
24 |
protected $data;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* singleton
|
28 |
+
*/
|
29 |
+
private function __construct() {}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @return FACTFinder_Abstract_DataProvider
|
33 |
+
*/
|
34 |
+
public static function getDataProvider(array $params = null, FACTFinder_Abstract_Configuration $config = null) {
|
35 |
+
if (self::$instance == null) {
|
36 |
+
self::$instance = new FACTFinder_Http_ParallelDataProvider();
|
37 |
+
}
|
38 |
+
$id = 'proxy' . count(self::$dataProvider); // use prefix so the id is a string
|
39 |
+
self::$dataProvider[$id] = new FACTFinder_Http_DataProviderProxy($params, $config);
|
40 |
+
self::$dataProvider[$id]->register($id, self::$instance);
|
41 |
+
|
42 |
+
return self::$dataProvider[$id];
|
43 |
+
}
|
44 |
|
45 |
/**
|
46 |
* this function sends all request to the server and loads the response data
|
47 |
+
*
|
48 |
+
* @return void
|
49 |
**/
|
50 |
public static function loadAllData()
|
51 |
{
|
52 |
+
if (self::$instance == null) {
|
53 |
+
throw new Exception("no dataprovider initialized");
|
54 |
+
}
|
55 |
+
|
56 |
+
// TODO: optimize:
|
57 |
+
// - deny multiple loading of single requests that were already loaded
|
58 |
+
// - warn if several loadings were done
|
59 |
+
// - add logging
|
60 |
+
|
61 |
+
// init handles
|
62 |
+
$multiHandle = curl_multi_init();
|
63 |
$handles = self::initHandles($multiHandle);
|
64 |
+
$data = self::executeHandles($multiHandle, $handles);
|
65 |
+
|
66 |
+
self::$instance->setData($data);
|
67 |
+
self::$dataLoaded = true;
|
68 |
}
|
69 |
|
70 |
+
protected static function initHandles($multiHandle) {
|
71 |
+
$handles = array();
|
72 |
+
foreach(self::$dataProvider AS $id => $dataProvider) {
|
73 |
+
$handle = curl_init($dataProvider->getAuthenticationUrl());
|
74 |
+
|
75 |
+
$curlOptions = $dataProvider->getCurlOptions();
|
76 |
+
$curlOptions[CURLOPT_HTTPHEADER] = $dataProvider->getHttpHeader();
|
77 |
+
$curlOptions[CURLOPT_RETURNTRANSFER] = true; // this is a must have option, so the data can be saved
|
78 |
+
curl_setopt_array($handle, $curlOptions);
|
79 |
+
|
80 |
+
$handles[$id] = $handle;
|
81 |
+
curl_multi_add_handle($multiHandle,$handle);
|
82 |
+
}
|
83 |
+
return $handles;
|
84 |
+
}
|
85 |
+
|
86 |
+
protected static function executeHandles($multiHandle, $handles) {
|
87 |
+
//execute the handles
|
88 |
+
$active = null;
|
89 |
+
do {
|
90 |
+
$mrc = curl_multi_exec($multiHandle, $active);
|
91 |
+
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
|
92 |
|
93 |
+
while ($active && $mrc == CURLM_OK) {
|
94 |
+
if (curl_multi_select($multiHandle) != -1) {
|
95 |
+
do {
|
96 |
+
$mrc = curl_multi_exec($multiHandle, $active);
|
97 |
+
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
// TODO: read data which is already loaded while the other data is still loading (is this possible?)
|
102 |
+
// TODO: handle errors
|
103 |
|
104 |
+
//close the handles
|
105 |
+
$data = array();
|
106 |
+
foreach($handles AS $id => $handle) {
|
107 |
+
$data[$id] = curl_multi_getcontent($handle);
|
108 |
+
curl_multi_remove_handle($multiHandle, $handle);
|
109 |
+
}
|
110 |
+
curl_multi_close($multiHandle);
|
111 |
+
return $data;
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
*
|
116 |
+
* internal method to apply data to
|
117 |
+
*/
|
118 |
+
protected function setData(array $data) {
|
119 |
+
$this->data = $data;
|
120 |
+
}
|
121 |
+
|
122 |
/**
|
123 |
+
* this method is called by the proxy data providers on the one and only existing instance
|
124 |
+
*
|
125 |
* @return string data
|
126 |
*/
|
127 |
public function getData($id)
|
131 |
}
|
132 |
return isset($this->data[$id]) ? $this->data[$id] : null;
|
133 |
}
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* @internal
|
138 |
+
* this is an anonymous inner class which can't be used successfully from the outside
|
139 |
+
*
|
140 |
+
* @package FACTFinder\Http
|
141 |
+
*/
|
142 |
+
class FACTFinder_Http_DataProviderProxy extends FACTFinder_Http_DataProvider
|
143 |
+
{
|
144 |
+
private $id;
|
145 |
+
private $master;
|
146 |
+
|
147 |
+
public function register($id, FACTFinder_Http_ParallelDataProvider $master) {
|
148 |
+
$this->id = $id;
|
149 |
+
$this->master = $master;
|
150 |
+
}
|
151 |
+
|
152 |
+
public function getData() {
|
153 |
+
return $this->master->getData($this->id);
|
154 |
+
}
|
155 |
+
|
156 |
+
public function getCurlOptions() {
|
157 |
+
return $this->curlOptions;
|
158 |
+
}
|
159 |
+
|
160 |
+
public function getHttpHeader() {
|
161 |
+
return $this->httpHeader;
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
/**
|
166 |
+
* @internal
|
167 |
+
* Exception type needed for parallel data provider
|
168 |
+
*
|
169 |
+
* @package FACTFinder\Http
|
170 |
+
*/
|
171 |
+
class DataNotLoadedException extends Exception {}
|
lib/FACTFinder/Http/ScicAdapter.php
CHANGED
@@ -1,29 +1,36 @@
|
|
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 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Http
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* http scic adapater
|
12 |
+
*
|
13 |
+
* @author Rudolf Batt <rb@omikron.net>
|
14 |
+
* @version $Id: ScicAdapter.php 25893 2010-06-29 08:19:43Z rb $
|
15 |
+
* @package FACTFinder\Http
|
16 |
+
*/
|
17 |
+
class FACTFinder_Http_ScicAdapter extends FACTFinder_Abstract_ScicAdapter
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* init
|
21 |
+
*/
|
22 |
+
protected function init() {
|
23 |
+
$this->log->info("Initializing new SCIC adapter.");
|
24 |
+
$this->getDataProvider()->setType('SCIC.ff');
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* send tracking
|
29 |
+
*
|
30 |
+
* @return boolean $success
|
31 |
+
*/
|
32 |
+
protected function applyTracking() {
|
33 |
+
$success = trim($this->getData());
|
34 |
+
return $success == 'true';
|
35 |
+
}
|
36 |
}
|
lib/FACTFinder/Http/SuggestAdapter.php
CHANGED
@@ -1,35 +1,41 @@
|
|
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 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Http
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* this suggest adapter requests the raw suggest data
|
12 |
+
*
|
13 |
+
* @author Rudolf Batt <rb@omikron.net>
|
14 |
+
* @version $Id: SuggestAdapter.php 25893 2010-06-29 08:19:43Z rb $
|
15 |
+
* @package FACTFinder\Http
|
16 |
+
*/
|
17 |
+
class FACTFinder_Http_SuggestAdapter extends FACTFinder_Abstract_SuggestAdapter
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* init
|
21 |
+
*/
|
22 |
+
protected function init()
|
23 |
+
{
|
24 |
+
$this->log->info("Initializing new suggest adapter.");
|
25 |
+
$this->getDataProvider()->setType('Suggest.ff');
|
26 |
+
$this->getDataProvider()->setCurlOptions(array(
|
27 |
+
CURLOPT_CONNECTTIMEOUT => 1,
|
28 |
+
CURLOPT_TIMEOUT => 2
|
29 |
+
));
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* this implementation returns raw suggestions strings
|
34 |
+
*
|
35 |
+
* @return string raw data
|
36 |
+
*/
|
37 |
+
protected function createSuggestions()
|
38 |
+
{
|
39 |
+
return $this->getData();
|
40 |
+
}
|
41 |
}
|
lib/FACTFinder/Item.php
CHANGED
@@ -1,48 +1,55 @@
|
|
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 |
-
* @return string
|
37 |
-
*/
|
38 |
-
public function
|
39 |
-
return $this->
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* @return
|
44 |
-
*/
|
45 |
-
public function
|
46 |
-
return $this->
|
47 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Common
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* an factfinder item is a simple selectable item on a website, so it is represented by a value and an url
|
12 |
+
* it is NOT defined in this class, what this item affects on the website
|
13 |
+
*
|
14 |
+
* @author Rudolf Batt <rb@omikron.net>
|
15 |
+
* @version $Id: Item.php 25893 2010-06-29 08:19:43Z rb $
|
16 |
+
* @package FACTFinder\Common
|
17 |
+
**/
|
18 |
+
class FACTFinder_Item
|
19 |
+
{
|
20 |
+
private $value;
|
21 |
+
private $url;
|
22 |
+
private $isSelected;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @param string value
|
26 |
+
* @param string url
|
27 |
+
* @param boolean is selected (default: false)
|
28 |
+
*/
|
29 |
+
public function __construct($value, $url, $isSelected = false){
|
30 |
+
$this->value = strval($value);
|
31 |
+
$this->url = strval($url);
|
32 |
+
$this->isSelected = $isSelected == true;
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* @return string
|
37 |
+
*/
|
38 |
+
public function getValue() {
|
39 |
+
return $this->value;
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* @return string
|
44 |
+
*/
|
45 |
+
public function getUrl() {
|
46 |
+
return $this->url;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* @return boolean
|
51 |
+
*/
|
52 |
+
public function isSelected() {
|
53 |
+
return $this->isSelected;
|
54 |
+
}
|
55 |
}
|
lib/FACTFinder/Loader.php
CHANGED
@@ -1,185 +1,192 @@
|
|
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 |
-
if (
|
31 |
-
|
32 |
-
}
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
/**
|
49 |
-
*
|
50 |
-
*
|
51 |
-
* @author Rudolf Batt <rb@omikron.net>
|
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 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
$
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
}
|
183 |
-
|
184 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Common
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* boot strap file which should be called on every request
|
12 |
+
* it defines some basic constants and loads the autoloader class, which handles the classloading,
|
13 |
+
* constructing and holds the singletons
|
14 |
+
*
|
15 |
+
* @author Rudolf Batt <rb@omikron.net>
|
16 |
+
* @version $Id: Loader.php 25893 2010-06-29 08:19:43Z rb $
|
17 |
+
* @package FACTFinder\Common
|
18 |
+
*/
|
19 |
+
|
20 |
+
/**
|
21 |
+
* short cut for the constant DIRECTORY_SEPARATOR
|
22 |
+
*/
|
23 |
+
if (!defined('DS')) {
|
24 |
+
define('DS', DIRECTORY_SEPARATOR);
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* contains the complete lib directory path
|
29 |
+
*/
|
30 |
+
if (!defined('LIB_DIR')) {
|
31 |
+
define('LIB_DIR', dirname(dirname(__FILE__)));
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* set as include path if this is not the case yet
|
36 |
+
*/
|
37 |
+
$includePaths = explode(PATH_SEPARATOR, get_include_path());
|
38 |
+
if ( array_search(LIB_DIR, $includePaths, true) === false ) {
|
39 |
+
set_include_path( get_include_path() . PATH_SEPARATOR . LIB_DIR);
|
40 |
+
}
|
41 |
+
spl_autoload_register(array('FACTFinder_Loader', 'autoload'));
|
42 |
+
|
43 |
+
// don't know, whether I should do that
|
44 |
+
if (function_exists('__autoload') && array_search('__autoload', spl_autoload_functions()) === false) {
|
45 |
+
spl_autoload_register('__autoload');
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* shortcut / alias for the loader class
|
50 |
+
*
|
51 |
+
* @author Rudolf Batt <rb@omikron.net>
|
52 |
+
* @package FACTFinder\Common
|
53 |
+
*/
|
54 |
+
final class FF extends FACTFinder_Loader{}
|
55 |
+
|
56 |
+
|
57 |
+
/**
|
58 |
+
* handles different loading tasks
|
59 |
+
*
|
60 |
+
* @author Rudolf Batt <rb@omikron.net>
|
61 |
+
* @package FACTFinder\Common
|
62 |
+
*/
|
63 |
+
class FACTFinder_Loader
|
64 |
+
{
|
65 |
+
protected static $singletons = array();
|
66 |
+
protected static $classNames = array();
|
67 |
+
protected static $logger = null;
|
68 |
+
|
69 |
+
public static function autoload($classname)
|
70 |
+
{
|
71 |
+
$filename = self::getFilename($classname);
|
72 |
+
if (file_exists($filename)) {
|
73 |
+
include_once $filename;
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
private static function getFilename($classname)
|
78 |
+
{
|
79 |
+
return LIB_DIR . DS . str_replace('_', DS, $classname) . '.php';
|
80 |
+
}
|
81 |
+
|
82 |
+
private static function canLoadClass($classname)
|
83 |
+
{
|
84 |
+
return file_exists(self::getFilename($classname));
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Creates an instance of a class taking into account classes with the prefix "Custom_" instead of "FACTFinder_".
|
89 |
+
* USE THIS method instead of the PHP "new" keyword.
|
90 |
+
* Eg. "$obj = new myclass;" should be "$obj = FACTFinder_Loader::getInstance("myclass")" instead!
|
91 |
+
* You can also pass arguments for a constructor:
|
92 |
+
* FACTFinder_Loader::getInstance('myClass', $arg1, $arg2, ..., $argN)
|
93 |
+
*
|
94 |
+
* @param string class name to instantiate
|
95 |
+
* @param mixed optional as many parameters as the class needs to be created
|
96 |
+
* @return object A reference to the object
|
97 |
+
*/
|
98 |
+
public static function getInstance($name)
|
99 |
+
{
|
100 |
+
if (isset(self::$classNames[$name])) {
|
101 |
+
$className = self::$classNames[$name];
|
102 |
+
} else {
|
103 |
+
$className = self::getClassName($name);
|
104 |
+
self::$classNames[$name] = $className;
|
105 |
+
}
|
106 |
+
|
107 |
+
// this snippet is from the typo3 class "t3lib_div" writen by Kasper Skaarhoj <kasperYYYY@typo3.com>
|
108 |
+
if (func_num_args() > 1) {
|
109 |
+
// getting the constructor arguments by removing this
|
110 |
+
// method's first argument (the class name)
|
111 |
+
$constructorArguments = func_get_args();
|
112 |
+
array_shift($constructorArguments);
|
113 |
+
|
114 |
+
$reflectedClass = new ReflectionClass($className);
|
115 |
+
$instance = $reflectedClass->newInstanceArgs($constructorArguments);
|
116 |
+
} else {
|
117 |
+
$instance = new $className;
|
118 |
+
}
|
119 |
+
|
120 |
+
return $instance;
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* creates an instance of the class once and returns it everytime. uses getInstance
|
125 |
+
*
|
126 |
+
* @param string class name to instantiate
|
127 |
+
* @param mixed optional as many parameters as the class needs to be created
|
128 |
+
* @return object A reference to the object
|
129 |
+
*/
|
130 |
+
public static function getSingleton($name)
|
131 |
+
{
|
132 |
+
if (!isset(self::$singletons[$name])) {
|
133 |
+
$params = func_get_args();
|
134 |
+
self::$singletons[$name] = call_user_func_array(array("self", "getInstance"), $params);
|
135 |
+
}
|
136 |
+
return self::$singletons[$name];
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* set a logger which will log the Loaders activity
|
141 |
+
*
|
142 |
+
* @param string file name of the configuration file
|
143 |
+
*/
|
144 |
+
public static function setLogger(FACTFinder_Abstract_Logger $logger)
|
145 |
+
{
|
146 |
+
self::$logger = $logger;
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* gets the set logger. if none is set, a NullLogger will be initialized, which does not log anything.
|
151 |
+
*
|
152 |
+
* @return Logger the Loader's logger
|
153 |
+
*/
|
154 |
+
public static function getLogger()
|
155 |
+
{
|
156 |
+
if (self::$logger == null) {
|
157 |
+
self::$logger = FF::getSingleton('nullLogger');
|
158 |
+
}
|
159 |
+
|
160 |
+
return self::$logger;
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* check whether there is a custom class with the prefix "FACTFinderCustom_" instead of "FACTFinder_"
|
165 |
+
* if non of them exists, it also checks if the name is the classname itselft
|
166 |
+
*/
|
167 |
+
protected static function getClassName($name)
|
168 |
+
{
|
169 |
+
$name = trim(str_replace('factfinder/', '', $name));
|
170 |
+
$name = str_replace(' ', '_', ucwords(str_replace('/', ' ', $name)));
|
171 |
+
|
172 |
+
// check whether there is a custom or lib-unrelated class
|
173 |
+
$oldCustomClassName = 'Custom_' . $name;
|
174 |
+
$customClassName = 'FACTFinderCustom_' . $name;
|
175 |
+
$factfinderClassName = 'FACTFinder_' . $name;
|
176 |
+
$defaultClassName = $name;
|
177 |
+
|
178 |
+
if (self::canLoadClass($customClassName)) {
|
179 |
+
$className = $customClassName;
|
180 |
+
} else if (self::canLoadClass($oldCustomClassName)) {
|
181 |
+
$className = $oldCustomClassName;
|
182 |
+
} else if (self::canLoadClass($factfinderClassName)) {
|
183 |
+
$className = $factfinderClassName;
|
184 |
+
} else if (class_exists($defaultClassName)) { //trigger other autload methods
|
185 |
+
$className = $defaultClassName;
|
186 |
+
} else {
|
187 |
+
self::getLogger()->error("Could not load class '$defaultClassName'.");
|
188 |
+
throw new Exception("class '$defaultClassName' not found");
|
189 |
+
}
|
190 |
+
return $className;
|
191 |
+
}
|
192 |
}
|
lib/FACTFinder/Log4PhpLogger.php
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Common
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* this class implements the FACTFinder logger interface and uses log4php's Logger class.
|
12 |
+
*
|
13 |
+
* @package FACTFinder\Common
|
14 |
+
*/
|
15 |
+
|
16 |
+
|
17 |
+
include_once LIB_DIR . DS . 'log4php' . DS . 'Logger.php';
|
18 |
+
|
19 |
+
class FACTFinder_Log4PhpLogger implements FACTFinder_Abstract_Logger
|
20 |
+
{
|
21 |
+
protected static $lastLogger = 0;
|
22 |
+
|
23 |
+
protected $name;
|
24 |
+
|
25 |
+
protected $log;
|
26 |
+
|
27 |
+
public function __construct()
|
28 |
+
{
|
29 |
+
self::$lastLogger++;
|
30 |
+
$this->name = "logger".self::$lastLogger;
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* configures the static Logger class supplied by log4php
|
35 |
+
* be aware that only the root loggers configuration will affect how the framework's interna are logged
|
36 |
+
*
|
37 |
+
* @param string file name of the configuration file
|
38 |
+
*/
|
39 |
+
public function configure($fileName)
|
40 |
+
{
|
41 |
+
$this->getLogger()->configure($fileName);
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* lazily gets a logger.
|
46 |
+
*
|
47 |
+
* @return Logger the logger
|
48 |
+
*/
|
49 |
+
protected function getLogger()
|
50 |
+
{
|
51 |
+
if(!isset($this->log))
|
52 |
+
$this->log = Logger::getLogger($this->name);
|
53 |
+
return $this->log;
|
54 |
+
}
|
55 |
+
|
56 |
+
public function trace($message)
|
57 |
+
{
|
58 |
+
$this->getLogger()->trace($message);
|
59 |
+
}
|
60 |
+
|
61 |
+
public function debug($message)
|
62 |
+
{
|
63 |
+
$this->getLogger()->debug($message);
|
64 |
+
}
|
65 |
+
|
66 |
+
public function info($message)
|
67 |
+
{
|
68 |
+
$this->getLogger()->info($message);
|
69 |
+
}
|
70 |
+
|
71 |
+
public function warn($message)
|
72 |
+
{
|
73 |
+
$this->getLogger()->warn($message);
|
74 |
+
}
|
75 |
+
|
76 |
+
public function error($message)
|
77 |
+
{
|
78 |
+
$this->getLogger()->error($message);
|
79 |
+
}
|
80 |
+
|
81 |
+
public function fatal($message)
|
82 |
+
{
|
83 |
+
$this->getLogger()->fatal($message);
|
84 |
+
}
|
85 |
+
|
86 |
+
}
|
lib/FACTFinder/Logger/BlackHole.php
DELETED
@@ -1,7 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class FACTFinder_Logger_BlackHole implements FACTFinder_Logger_LoggerInterface
|
4 |
-
{
|
5 |
-
public function error($error) {}
|
6 |
-
public function info($message) {}
|
7 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/FACTFinder/Logger/LoggerInterface.php
DELETED
@@ -1,6 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
interface FACTFinder_Logger_LoggerInterface {
|
4 |
-
public function error($error);
|
5 |
-
public function info($message);
|
6 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
lib/FACTFinder/NullLogger.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Common
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* this class implements the FACTFinder logger interface by doing nothing (this will be used if no logger is created or no logging is wanted).
|
12 |
+
*
|
13 |
+
* @package FACTFinder\Common
|
14 |
+
*/
|
15 |
+
|
16 |
+
class FACTFinder_NullLogger implements FACTFinder_Abstract_Logger
|
17 |
+
{
|
18 |
+
public function trace($message) {}
|
19 |
+
public function debug($message) {}
|
20 |
+
public function info($message) {}
|
21 |
+
public function warn($message) {}
|
22 |
+
public function error($message) {}
|
23 |
+
public function fatal($message) {}
|
24 |
+
}
|
lib/FACTFinder/Paging.php
CHANGED
@@ -1,170 +1,177 @@
|
|
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 |
-
|
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 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
return $
|
168 |
-
}
|
169 |
-
|
170 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Common
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class for creating pagelinks on a search result page. by iterating over an paging object, you will get FACTFinder_Item
|
12 |
+
* objects which represent the link for each page, beginning from "getFirtPageNumberShown()" to "getLastPageNumberShown()".
|
13 |
+
*
|
14 |
+
* @author Rudolf Batt <rb@omikron.net>
|
15 |
+
* @version $Id: Paging.php 25893 2010-06-29 08:19:43Z rb $
|
16 |
+
* @package FACTFinder\Common
|
17 |
+
**/
|
18 |
+
class FACTFinder_Paging implements IteratorAggregate
|
19 |
+
{
|
20 |
+
private $iterator;
|
21 |
+
private $currentPage;
|
22 |
+
private $pageCount;
|
23 |
+
protected $paramsParser;
|
24 |
+
protected $params;
|
25 |
+
protected $displayPageCount = 9;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* class constructor - puts paging data from the SimpleXMLElement object
|
29 |
+
* into usefull structure
|
30 |
+
*
|
31 |
+
* @param int $currentPage
|
32 |
+
* @param int $pageCount
|
33 |
+
* @param FACTFinder_ParametersParser $paramsParser because this class is creating its urls
|
34 |
+
*/
|
35 |
+
public function __construct($currentPage, $pageCount, FACTFinder_ParametersParser $paramsParser)
|
36 |
+
{
|
37 |
+
$this->currentPage = intval($currentPage);
|
38 |
+
$this->pageCount = intval($pageCount);
|
39 |
+
$this->paramsParser = $paramsParser;
|
40 |
+
$this->params = $paramsParser->getRequestParams();
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* get iterator to iterate over all paging items around the current page, altogether not more than set
|
45 |
+
* by "setDisplayPageCount" (default: 9). each item is an object of FACTFinder_Item
|
46 |
+
*
|
47 |
+
* @return Traversable
|
48 |
+
*/
|
49 |
+
public function getIterator()
|
50 |
+
{
|
51 |
+
$iterator = new ArrayIterator();
|
52 |
+
for($page = $this->getFirstPageNumberShown(); $page <= $this->getLastPageNumberShown(); $page++) {
|
53 |
+
$iterator->append(
|
54 |
+
FF::getInstance('item', $page, $this->getPageLink($page), ($page == $this->currentPage))
|
55 |
+
);
|
56 |
+
}
|
57 |
+
return $iterator;
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* returns the numer of all existing pages for the current result
|
62 |
+
*
|
63 |
+
* @return int pagecount
|
64 |
+
**/
|
65 |
+
public function getPageCount()
|
66 |
+
{
|
67 |
+
return $this->pageCount;
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* returns the current page number
|
72 |
+
*
|
73 |
+
* @return int pagenumber
|
74 |
+
**/
|
75 |
+
public function getCurrentPageNumber()
|
76 |
+
{
|
77 |
+
return $this->currentPage;
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* returns the url (link) for the given page. If the page does not exist,
|
82 |
+
* it returns an empty string
|
83 |
+
*
|
84 |
+
* @param int page number
|
85 |
+
* @param String optional: link target
|
86 |
+
* @return String url (link)
|
87 |
+
**/
|
88 |
+
public function getPageLink($page_number, $link_target = null)
|
89 |
+
{
|
90 |
+
if ($page_number > $this->pageCount || $page_number < 1) {
|
91 |
+
return '';
|
92 |
+
}
|
93 |
+
return $this->paramsParser->createPageLink($this->params, array('page' => $page_number), $link_target);
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* returns the url (link) for the previous page
|
98 |
+
*
|
99 |
+
* @param String optional: link target
|
100 |
+
* @return String url (link)
|
101 |
+
**/
|
102 |
+
public function getPreviousPageLink($link_target = '')
|
103 |
+
{
|
104 |
+
if ( $this->currentPage > 1) {
|
105 |
+
$previous_page_number = ($this->currentPage - 1);
|
106 |
+
} else {
|
107 |
+
return '';
|
108 |
+
}
|
109 |
+
return $this->getPageLink($previous_page_number, $link_target);
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* returns the url (link) for the next page
|
114 |
+
*
|
115 |
+
* @param String optional: link target
|
116 |
+
* @return String url (link)
|
117 |
+
**/
|
118 |
+
public function getNextPageLink($link_target = '')
|
119 |
+
{
|
120 |
+
if ( $this->currentPage < $this->pageCount) {
|
121 |
+
$previous_page_number = ($this->currentPage + 1);
|
122 |
+
} else {
|
123 |
+
return '';
|
124 |
+
}
|
125 |
+
return $this->getPageLink($previous_page_number, $link_target);
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* set maximum count of pages to display
|
130 |
+
*
|
131 |
+
* @param int count of pages to display
|
132 |
+
* @return void
|
133 |
+
*/
|
134 |
+
public function setDisplayPageCount($displayPageCount)
|
135 |
+
{
|
136 |
+
$this->displayPageCount = intval($displayPageCount);
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* returns the first page number for the pagelinks to be shown
|
141 |
+
* needs the number of the maximum shown links
|
142 |
+
*
|
143 |
+
* @param int page links count
|
144 |
+
* @return int first shown page number
|
145 |
+
**/
|
146 |
+
public function getFirstPageNumberShown()
|
147 |
+
{
|
148 |
+
if ($this->currentPage <= floor($this->displayPageCount / 2) || $this->pageCount < $this->displayPageCount) {
|
149 |
+
return 1;
|
150 |
+
} else if ($this->currentPage > ($this->pageCount - $this->displayPageCount +1 )) {
|
151 |
+
return ($this->pageCount - $this->displayPageCount + 1);
|
152 |
+
} else {
|
153 |
+
return ($this->currentPage - floor($this->displayPageCount / 2));
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* returns the last page number for the pagelinks to be shown
|
159 |
+
* needs the number of the maximum shown links
|
160 |
+
*
|
161 |
+
* @param int page links count
|
162 |
+
* @return int first shown page number
|
163 |
+
**/
|
164 |
+
public function getLastPageNumberShown()
|
165 |
+
{
|
166 |
+
if ($this->pageCount < $this->displayPageCount) {
|
167 |
+
return $this->pageCount;
|
168 |
+
}
|
169 |
+
|
170 |
+
$first_page_number = $this->getFirstPageNumberShown($this->displayPageCount);
|
171 |
+
if ($first_page_number+$this->displayPageCount >= $this->pageCount) {
|
172 |
+
return $this->pageCount;
|
173 |
+
} else {
|
174 |
+
return $first_page_number+$this->displayPageCount;
|
175 |
+
}
|
176 |
+
}
|
177 |
+
}
|
lib/FACTFinder/Parameters.php
CHANGED
@@ -1,106 +1,113 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
*
|
5 |
-
*
|
6 |
-
*
|
7 |
-
* @
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
private $
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
* @param
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
$this->
|
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 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Common
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* the factfinder parameters contains all relevant parameter which makes effect to the factfinder search result.
|
12 |
+
* It does NOT contain all request parameters. The parameters represents a state of a factfinder result.
|
13 |
+
*
|
14 |
+
* @author Rudolf Batt <rb@omikron.net>
|
15 |
+
* @version $Id: Parameters.php 25893 2010-06-29 08:19:43Z rb $
|
16 |
+
* @package FACTFinder\Common
|
17 |
+
*/
|
18 |
+
class FACTFinder_Parameters
|
19 |
+
{
|
20 |
+
private $query;
|
21 |
+
private $channel;
|
22 |
+
private $productsPerPage;
|
23 |
+
private $page;
|
24 |
+
private $filters;
|
25 |
+
private $sortings;
|
26 |
+
private $isNavigation;
|
27 |
+
private $followSearch;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @param string query
|
31 |
+
* @param string channel
|
32 |
+
* @param int productsPerPage
|
33 |
+
* @param int page
|
34 |
+
* @param array filters
|
35 |
+
* @param array sortings
|
36 |
+
* @param boolean isNavigation
|
37 |
+
* @param int followSearch
|
38 |
+
*/
|
39 |
+
public function __construct($query, $channel, $productsPerPage = null, $page = 1, array $filters = array(), array $sortings = array(), $isNavigation = false, $followSearch = 10000) {
|
40 |
+
$this->query = strval($query);
|
41 |
+
$this->channel = strval($channel);
|
42 |
+
$this->productsPerPage = $productsPerPage == null ? null : intval($productsPerPage);
|
43 |
+
$this->page = intval($page);
|
44 |
+
$this->filters = $filters;
|
45 |
+
$this->sortings = $sortings;
|
46 |
+
$this->isNavigation = $isNavigation == true;
|
47 |
+
$this->followSearch = intval($followSearch);
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @return string
|
52 |
+
*/
|
53 |
+
public function getQuery()
|
54 |
+
{
|
55 |
+
return $this->query;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* @return string
|
60 |
+
*/
|
61 |
+
public function getChannel()
|
62 |
+
{
|
63 |
+
return $this->channel;
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* @return int
|
68 |
+
*/
|
69 |
+
public function getProductsPerPage()
|
70 |
+
{
|
71 |
+
return $this->productsPerPage;
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* @return int
|
76 |
+
*/
|
77 |
+
public function getPage()
|
78 |
+
{
|
79 |
+
return $this->page;
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* @return array string => string
|
84 |
+
*/
|
85 |
+
public function getFilters()
|
86 |
+
{
|
87 |
+
return $this->filters;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* @return array string => string
|
92 |
+
*/
|
93 |
+
public function getSortings()
|
94 |
+
{
|
95 |
+
return $this->sortings;
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* @return boolean true if navigation is enabled
|
100 |
+
*/
|
101 |
+
public function isNavigation()
|
102 |
+
{
|
103 |
+
return $this->isNavigation;
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* @return int follow search value
|
108 |
+
*/
|
109 |
+
public function getFollowSearch()
|
110 |
+
{
|
111 |
+
return $this->followSearch;
|
112 |
+
}
|
113 |
}
|
lib/FACTFinder/ParametersParser.php
CHANGED
@@ -1,372 +1,379 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
* @
|
6 |
-
* @
|
7 |
-
* @
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
* this class handles the parameters conversion between the client url, the links on the webpage and the url for the
|
12 |
-
* server. it can be seen as a parameter factory.
|
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 |
-
|
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 |
-
isset($params['
|
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 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
$
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
$params
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
*
|
246 |
-
* @
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
372 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Common
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* this class handles the parameters conversion between the client url, the links on the webpage and the url for the
|
12 |
+
* server. it can be seen as a parameter factory.
|
13 |
+
*
|
14 |
+
* @package FACTFinder\Common
|
15 |
+
* @author Rudolf Batt <rb@omikron.net>
|
16 |
+
* @version $Id: ParametersParser.php 25893 2010-06-29 08:19:43Z rb $
|
17 |
+
*/
|
18 |
+
class FACTFinder_ParametersParser
|
19 |
+
{
|
20 |
+
private static $w283751Done = false;
|
21 |
+
private $requestParams;
|
22 |
+
private $requestTarget;
|
23 |
+
|
24 |
+
protected $config;
|
25 |
+
protected $encodingHandler;
|
26 |
+
|
27 |
+
protected $log;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @param FACTFinder_Abstract_IConfiguration config
|
31 |
+
* @param FACTFinder_EncodingHandler $encodingHandler
|
32 |
+
*/
|
33 |
+
public function __construct(FACTFinder_Abstract_Configuration $config, FACTFinder_EncodingHandler $encodingHandler, FACTFinder_Abstract_Logger $log = null)
|
34 |
+
{
|
35 |
+
if(isset($log))
|
36 |
+
$this->log = $log;
|
37 |
+
else
|
38 |
+
$this->log = FF::getSingleton('nullLogger');
|
39 |
+
$this->config = $config;
|
40 |
+
$this->encodingHandler = $encodingHandler;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* DEPRECATED, because it also might destroy other components of the system which rely on the standard PHP. For example this
|
45 |
+
* method don't manage array-parameters e.g. "foo[0]=bar" like expected.
|
46 |
+
* This method is not in internal use any more
|
47 |
+
*
|
48 |
+
* runs a workaround for php to restore the original parameter names from the url respectively $_SERVER['QUERY_STRING'].
|
49 |
+
* this method will only run once and change the global variables $GLOBALS, $_GET and $_REQUEST. parameters which are
|
50 |
+
* transformed by php will be left at the $_REQUEST array, the $_GET array will only contain the correct parameters
|
51 |
+
*
|
52 |
+
* @link http://stackoverflow.com/questions/283751/php-replaces-spaces-with-underlines
|
53 |
+
* @deprecated and not in interal use any more
|
54 |
+
* @return void
|
55 |
+
*/
|
56 |
+
final public static function runWorkaround283751()
|
57 |
+
{
|
58 |
+
if (self::$w283751Done === false && isset($_SERVER['QUERY_STRING'])) {
|
59 |
+
$params = self::parseParamsFromString($_SERVER['QUERY_STRING']);
|
60 |
+
$_GET = array();
|
61 |
+
$_GLOBALS['_GET'] = $_GET;
|
62 |
+
foreach($params AS $key => $value){
|
63 |
+
$_GET[$key] = $value;
|
64 |
+
$_REQUEST[$key] = $value;
|
65 |
+
$GLOBALS['_GET'][$key] = $value;
|
66 |
+
$GLOBALS['_REQUEST'][$key] = $value;
|
67 |
+
}
|
68 |
+
self::$w283751Done = true;
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* loads the parameters from request and returns them as string-to-string array
|
74 |
+
* also considers the mapping and ignore rules
|
75 |
+
*
|
76 |
+
* @return array of params
|
77 |
+
*/
|
78 |
+
public function getRequestParams()
|
79 |
+
{
|
80 |
+
if ($this->requestParams == null) {
|
81 |
+
if (isset($_SERVER['QUERY_STRING'])) {
|
82 |
+
$requestParams = array_merge($_POST, self::parseParamsFromString($_SERVER['QUERY_STRING']));
|
83 |
+
} else if (isset($_GET)) {
|
84 |
+
$requestParams = array_merge($_POST, $_GET); // dont use $_REQUEST, because it also contains $_COOKIE;
|
85 |
+
} else {
|
86 |
+
// for cli
|
87 |
+
$requestParams = array();
|
88 |
+
}
|
89 |
+
|
90 |
+
$this->requestParams = $this->encodingHandler->encodeUrlForPage($requestParams);
|
91 |
+
}
|
92 |
+
return $this->requestParams;
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* @param array parameters. if null, using the request parameters (default: null)
|
97 |
+
* @return FACTFinder_Parameters object
|
98 |
+
*/
|
99 |
+
public function getFactfinderParams(array $params = null)
|
100 |
+
{
|
101 |
+
if ($params == null) {
|
102 |
+
$params = $this->getServerRequestParams();
|
103 |
+
$params = $this->encodingHandler->encodeServerUrlForPageUrl($params);
|
104 |
+
}
|
105 |
+
|
106 |
+
$filters = array();
|
107 |
+
$sortings = array();
|
108 |
+
foreach($params AS $key => $value) {
|
109 |
+
if (strpos($key, 'filter') === 0) {
|
110 |
+
$filters[str_replace('filter', '', $key)] = $value;
|
111 |
+
} else
|
112 |
+
if (strpos($key, 'sort' && ($value == 'asc' || $value == 'desc')) === 0) {
|
113 |
+
$sortings[str_replace('sort', '', $key)] = $value;
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
+
return FF::getInstance('parameters',
|
118 |
+
isset($params['query']) ? $params['query'] : '',
|
119 |
+
$this->config->getChannel(),
|
120 |
+
isset($params['productsPerPage']) ? $params['productsPerPage'] : null,
|
121 |
+
isset($params['page']) ? $params['page'] : 1,
|
122 |
+
$filters,
|
123 |
+
$sortings,
|
124 |
+
(isset($params['catalog']) && $params['catalog'] == 'true'),
|
125 |
+
isset($params['followSearch']) ? $params['followSearch'] : 10000
|
126 |
+
);
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* @param String parameters
|
131 |
+
* @return FACTFinder_Parameters object
|
132 |
+
*/
|
133 |
+
public function getFactfinderParamsFromString($paramString)
|
134 |
+
{
|
135 |
+
$params = self::parseParamsFromString($paramString);
|
136 |
+
return $this->getFactfinderParams($params);
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* converts the factfinder parameters object into a params array
|
141 |
+
*
|
142 |
+
* @return array params
|
143 |
+
*/
|
144 |
+
public function parseFactfinderParams(FACTFinder_Parameters $ffparams)
|
145 |
+
{
|
146 |
+
$filters = array();
|
147 |
+
foreach($ffparams->getFilters() AS $key => $value) {
|
148 |
+
$filters['filter'.$key] = $value;
|
149 |
+
}
|
150 |
+
|
151 |
+
$sortings = array();
|
152 |
+
foreach($ffparams->getSortings() AS $key => $value) {
|
153 |
+
$sortings['sort'.$key] = $value;
|
154 |
+
}
|
155 |
+
|
156 |
+
return array_merge(
|
157 |
+
array(
|
158 |
+
'query' => $ffparams->getQuery(),
|
159 |
+
'channel' => $ffparams->getChannel(),
|
160 |
+
'productsPerPage' => $ffparams->getProductsPerPage(),
|
161 |
+
'page' => $ffparams->getPage(),
|
162 |
+
'followSearch' => $ffparams->getFollowSearch()
|
163 |
+
),
|
164 |
+
$filters,
|
165 |
+
$sortings
|
166 |
+
);
|
167 |
+
}
|
168 |
+
|
169 |
+
/**
|
170 |
+
* extracts a parameter array with name=>value pairs from an url string.
|
171 |
+
* also only url encoding is done but no further encodings.
|
172 |
+
* this method does not handle array variables such like "foo[0]=bar"
|
173 |
+
*
|
174 |
+
* @param string url
|
175 |
+
* @return array of parameter variables
|
176 |
+
*/
|
177 |
+
public static function parseParamsFromString($paramString)
|
178 |
+
{
|
179 |
+
if (strpos($paramString, '?') !== false) {
|
180 |
+
$paramString = substr($paramString, strpos($paramString, '?')+1);
|
181 |
+
}
|
182 |
+
$paramsArray = array();
|
183 |
+
$a_pairs = explode('&', $paramString);
|
184 |
+
foreach($a_pairs AS $s_pair){
|
185 |
+
$a_pair = explode('=', $s_pair);
|
186 |
+
if(empty($a_pair[0])) continue;
|
187 |
+
if(count($a_pair) == 1 || strlen($a_pair[1]) == 0) $a_pair[1] = '';
|
188 |
+
|
189 |
+
$a_pair[0] = urldecode($a_pair[0]);
|
190 |
+
$a_pair[1] = urldecode($a_pair[1]);
|
191 |
+
|
192 |
+
$paramsArray[$a_pair[0]] = $a_pair[1];
|
193 |
+
}
|
194 |
+
return $paramsArray;
|
195 |
+
}
|
196 |
+
|
197 |
+
/**
|
198 |
+
* the FACT-Finder result is UTF-8 encoded, so this method parses a url string from the request and also does
|
199 |
+
* utf-decoding if needed
|
200 |
+
*
|
201 |
+
* @param string from factfinder result
|
202 |
+
* @return array of paramter variables
|
203 |
+
*/
|
204 |
+
public function parseParamsFromResultString($paramString)
|
205 |
+
{
|
206 |
+
$params = self::parseParamsFromString($paramString);
|
207 |
+
$params = $this->encodingHandler->encodeServerUrlForPageUrl($params);
|
208 |
+
return $params;
|
209 |
+
}
|
210 |
+
|
211 |
+
/**
|
212 |
+
* get a single value from the request or the default value, if this value does not exist
|
213 |
+
*
|
214 |
+
* @param parameter name
|
215 |
+
* @param default value (default: null)
|
216 |
+
* @return request value of parameter $name or $defaultValue if parameter does not exist
|
217 |
+
*/
|
218 |
+
public function getRequestParam($name, $defaultValue = null)
|
219 |
+
{
|
220 |
+
$params = $this->getRequestParams();
|
221 |
+
return isset($params[$name]) ? trim($params[$name]) : $defaultValue;
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* returns the params array but with the server mappings and removed ignored server parameters . if params array is
|
226 |
+
* not set, the request params will be used
|
227 |
+
*
|
228 |
+
* @param array parameters (optional)
|
229 |
+
* @return array parameters without ignored parameters
|
230 |
+
*/
|
231 |
+
public function getServerRequestParams(array $params = null) {
|
232 |
+
if ($params == null) {
|
233 |
+
$params = $this->getRequestParams();
|
234 |
+
}
|
235 |
+
|
236 |
+
$params = $this->doServerMappings($params);
|
237 |
+
$params = $this->removeIgnoredParams($params, $this->config->getIgnoredServerParams());
|
238 |
+
$params = $this->addRequiredParams($params, $this->config->getRequiredServerParams());
|
239 |
+
$params = $this->encodingHandler->encodeForServerUrl($params);
|
240 |
+
|
241 |
+
return $params;
|
242 |
+
}
|
243 |
+
|
244 |
+
/**
|
245 |
+
* creates the link-url for the webpage (no html code!). see {@link http://de3.php.net/manual/en/function.array-merge.php array_merge}
|
246 |
+
* and {@link http://de3.php.net/manual/en/function.http-build-query.php http_build_query} to know, how the two arrays
|
247 |
+
* are merged and how the link will be constructed. additionaly this method will remove parameters which are configured
|
248 |
+
* to be ignored
|
249 |
+
*
|
250 |
+
* @param array of parameters
|
251 |
+
* @param array (optional) additional parameters which will overwrite the first parameters if a same key is used
|
252 |
+
* @param string (optional) string which will be prepended to the link. if none is given, getRequestTarget() is used
|
253 |
+
* @return url for a page link
|
254 |
+
*/
|
255 |
+
public function createPageLink(array $params, array $addParams = array(), $target = null)
|
256 |
+
{
|
257 |
+
if ($target == null) {
|
258 |
+
$target = $this->getRequestTarget();
|
259 |
+
}
|
260 |
+
|
261 |
+
$linkParams = array_merge($params, $addParams);
|
262 |
+
|
263 |
+
$linkParams = $this->doPageMappings($linkParams);
|
264 |
+
$linkParams = $this->removeIgnoredParams($linkParams, $this->config->getIgnoredPageParams());
|
265 |
+
$linkParams = $this->addRequiredParams($linkParams, $this->config->getRequiredPageParams());
|
266 |
+
|
267 |
+
return $target.'?'.http_build_query($linkParams, '', '&');
|
268 |
+
}
|
269 |
+
|
270 |
+
/**
|
271 |
+
* remove the ignored params from the params array if set
|
272 |
+
*
|
273 |
+
* @param array params
|
274 |
+
* @param array ignored params, where the param names are the array-keys
|
275 |
+
* @return array new modified params
|
276 |
+
*/
|
277 |
+
private function removeIgnoredParams($params, $ignoredParams)
|
278 |
+
{
|
279 |
+
$returnParams = array();
|
280 |
+
foreach($params as $key => $value) {
|
281 |
+
// copy each param and do not set to null, because mappings are stored as references in the params array
|
282 |
+
if(!isset($ignoredParams[$key]) && strlen($value) > 0) {
|
283 |
+
$returnParams[$key] = $value;
|
284 |
+
}
|
285 |
+
}
|
286 |
+
return $returnParams;
|
287 |
+
}
|
288 |
+
|
289 |
+
/**
|
290 |
+
* adds the params from the required params map to the params array if not already set
|
291 |
+
*
|
292 |
+
* @param array params
|
293 |
+
* @param array required params as string to string map (array-key = paramname; array-value = default param value)
|
294 |
+
* @return array new modified params
|
295 |
+
*/
|
296 |
+
private function addRequiredParams($params, $requiredParams)
|
297 |
+
{
|
298 |
+
$requestParams = $this->getRequestParams();
|
299 |
+
foreach($requiredParams AS $paramName => $defaultValue) {
|
300 |
+
if (!isset($params[$paramName])) {
|
301 |
+
$params[$paramName] = isset($requestParams[$paramName]) ? $requestParams[$paramName] : $defaultValue;
|
302 |
+
}
|
303 |
+
}
|
304 |
+
return $params;
|
305 |
+
}
|
306 |
+
|
307 |
+
/**
|
308 |
+
* get target of the current request url, from "$_SERVER['REQUEST_URI']".
|
309 |
+
*
|
310 |
+
* @return string request target
|
311 |
+
*/
|
312 |
+
protected function getRequestTarget()
|
313 |
+
{
|
314 |
+
if ($this->requestTarget == null) {
|
315 |
+
// workaround for some servers (IIS) which do not provide '$_SERVER['REQUEST_URI']'
|
316 |
+
if (!isset($_SERVER['REQUEST_URI'])) {
|
317 |
+
$arr = explode("/", $_SERVER['PHP_SELF']);
|
318 |
+
$_SERVER['REQUEST_URI'] = "/" . $arr[count($arr)-1];
|
319 |
+
if (isset($_SERVER['argv'][0]) && $_SERVER['argv'][0]) {
|
320 |
+
$_SERVER['REQUEST_URI'] .= "?" . $_SERVER['argv'][0];
|
321 |
+
}
|
322 |
+
}
|
323 |
+
|
324 |
+
if (strpos($_SERVER['REQUEST_URI'], '?') === false) {
|
325 |
+
$this->requestTarget = $_SERVER['REQUEST_URI'];
|
326 |
+
} else {
|
327 |
+
$this->requestTarget = substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?'));
|
328 |
+
}
|
329 |
+
}
|
330 |
+
return $this->requestTarget;
|
331 |
+
}
|
332 |
+
|
333 |
+
/**
|
334 |
+
* do mapping for a params array with the page mapping settings from the config. so this method expects server params
|
335 |
+
* and return params for the page
|
336 |
+
*
|
337 |
+
* @param array paramters
|
338 |
+
* @return array mapped parameters
|
339 |
+
*/
|
340 |
+
private function doPageMappings(array $params)
|
341 |
+
{
|
342 |
+
return $this->doMapping($params, $this->config->getPageMappings());
|
343 |
+
}
|
344 |
+
|
345 |
+
/**
|
346 |
+
* do mapping for a params array with the server mapping settings from the config. so this method expects page params
|
347 |
+
* and return params for the server
|
348 |
+
*
|
349 |
+
* @param array paramters
|
350 |
+
* @return array mapped parameters
|
351 |
+
*/
|
352 |
+
private function doServerMappings(array $params)
|
353 |
+
{
|
354 |
+
return $this->doMapping($params, $this->config->getServerMappings());
|
355 |
+
}
|
356 |
+
|
357 |
+
/**
|
358 |
+
* maps the keys in the array using the rules. if a "from" parameter does not exist, but the according "to" parameter
|
359 |
+
* exist, the "from" will be create - so this mapping normaly works for both directions
|
360 |
+
*
|
361 |
+
* @param array paramters
|
362 |
+
* @param mixed iterable mapping rules
|
363 |
+
* @return array mapped parameters
|
364 |
+
*/
|
365 |
+
private function doMapping(array $params, array $mappingRules)
|
366 |
+
{
|
367 |
+
foreach($mappingRules AS $from => $to) {
|
368 |
+
if (isset($params[$from])) { //"from" is more important..
|
369 |
+
$params[$to] = &$params[$from];
|
370 |
+
} else if (isset($params[$to])) { //but if it does not exist but "to" exists, then "create" from
|
371 |
+
$params[$from] = &$params[$to];
|
372 |
+
} else { //if none of them exists, just create the params with a null value
|
373 |
+
$params[$from] = null;
|
374 |
+
$params[$to] = &$params[$from];
|
375 |
+
}
|
376 |
+
}
|
377 |
+
return $params;
|
378 |
+
}
|
379 |
}
|
lib/FACTFinder/ProductsPerPageOptions.php
CHANGED
@@ -1,79 +1,86 @@
|
|
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 |
-
$this->
|
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 |
-
* @return
|
74 |
-
*/
|
75 |
-
public function
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Common
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* represents the fact-finder product-per-page-options. by iterating over an FACTFinder_ProductsPerPageOptions
|
12 |
+
* object, you will get FACTFinder_Item objects, where each represents one products-per-page option.
|
13 |
+
*
|
14 |
+
* @author Rudolf Batt <rb@omikron.net>
|
15 |
+
* @version $Id: ProductsPerPageOptions.php 25893 2010-06-29 08:19:43Z rb $
|
16 |
+
* @package FACTFinder\Common
|
17 |
+
**/
|
18 |
+
class FACTFinder_ProductsPerPageOptions implements IteratorAggregate
|
19 |
+
{
|
20 |
+
private $options;
|
21 |
+
private $selectedOption = null;
|
22 |
+
private $defaultOption = null;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @param array int to string map; the integer is product-per-page option and the string is the according url
|
26 |
+
* @param int default option (default: first option)
|
27 |
+
* @param int selected option (default: default option)
|
28 |
+
*/
|
29 |
+
public function __construct(array $options, $defaultOption = -1, $selectedOption = -1) {
|
30 |
+
$defaultOption = intval($defaultOption);
|
31 |
+
$selectedOption = intval($selectedOption);
|
32 |
+
|
33 |
+
$this->options = new ArrayIterator();
|
34 |
+
foreach($options AS $option => $url) {
|
35 |
+
$item = FF::getInstance('item', intval($option), $url, ($option == $selectedOption));
|
36 |
+
if ($option == $selectedOption) {
|
37 |
+
$this->selectedOption = $item;
|
38 |
+
}
|
39 |
+
if ($option == $defaultOption) {
|
40 |
+
$this->defaultOption = $item;
|
41 |
+
}
|
42 |
+
$this->options->append($item);
|
43 |
+
}
|
44 |
+
|
45 |
+
if ($this->defaultOption == null && $this->options->count() > 0) {
|
46 |
+
$this->defaultOption = $this->options[0];
|
47 |
+
}
|
48 |
+
if ($this->selectedOption == null && $this->defaultOption != null) {
|
49 |
+
$this->selectedOption = $this->defaultOption;
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* get iterator to iterate over all products-per-page-options. each item is an object of FACTFinder_Item
|
55 |
+
*
|
56 |
+
* @return Traversable
|
57 |
+
*/
|
58 |
+
public function getIterator()
|
59 |
+
{
|
60 |
+
return $this->options;
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* @return FACTFinder_Item default products per page option
|
65 |
+
*/
|
66 |
+
public function getDefaultOption()
|
67 |
+
{
|
68 |
+
return $this->defaultOption;
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* @param FACTFinder_Item
|
73 |
+
* @return boolean true, if the set object is the default product-per-page-option
|
74 |
+
*/
|
75 |
+
public function isDefaultOption(FACTFinder_Item $option) {
|
76 |
+
return $this->defaultOption->getValue() == $option->getValue();
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* @return FACTFinder_Item selected products per page option
|
81 |
+
*/
|
82 |
+
public function getSelectedOption()
|
83 |
+
{
|
84 |
+
return $this->selectedOption;
|
85 |
+
}
|
86 |
}
|
lib/FACTFinder/Record.php
CHANGED
@@ -1,251 +1,258 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
*
|
5 |
-
*
|
6 |
-
* @
|
7 |
-
* @
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
protected $
|
23 |
-
protected $
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
$this->
|
45 |
-
$this->
|
46 |
-
|
47 |
-
if (
|
48 |
-
$this->
|
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 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Common
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* represents a FACT-Finder data record
|
12 |
+
*
|
13 |
+
* @author Rudolf Batt <rb@omikron.net>
|
14 |
+
* @version $Id: Record.php 25893 2010-06-29 08:19:43Z rb $
|
15 |
+
* @package FACTFinder\Common
|
16 |
+
**/
|
17 |
+
class FACTFinder_Record
|
18 |
+
{
|
19 |
+
protected $id;
|
20 |
+
protected $similarity;
|
21 |
+
protected $position;
|
22 |
+
protected $origPosition;
|
23 |
+
protected $fieldValues;
|
24 |
+
protected $fieldNames;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* new values since FACT-Finder 6.6
|
28 |
+
*/
|
29 |
+
protected $seoPath = '';
|
30 |
+
protected $keywords = array();
|
31 |
+
|
32 |
+
/**
|
33 |
+
* class constructor - creates a record using the given values. if the array contains fieldnames as array-keys, they
|
34 |
+
* could be used to get the values again
|
35 |
+
*
|
36 |
+
* @param string id
|
37 |
+
* @param double similarity
|
38 |
+
* @param int originalPosition (optional)
|
39 |
+
* @param array fieldValues (optional)
|
40 |
+
**/
|
41 |
+
public function __construct($id, $similarity = 100, $position = 0, $origPosition = 0, array $fieldValues = null)
|
42 |
+
{
|
43 |
+
$this->id = trim($id);
|
44 |
+
$this->similarity = doubleval($similarity);
|
45 |
+
if ($this->similarity > 100.0) {
|
46 |
+
$this->similarity = 100.0;
|
47 |
+
} else if ($this->similarity < 0.0) {
|
48 |
+
$this->similarity = 0.0;
|
49 |
+
}
|
50 |
+
|
51 |
+
$this->position = intval($position);
|
52 |
+
$this->origPosition = intval($origPosition);
|
53 |
+
|
54 |
+
if (empty($fieldValues)) {
|
55 |
+
$this->fieldNames = array();
|
56 |
+
$this->fieldValues = array();
|
57 |
+
} else {
|
58 |
+
$this->setValues($fieldValues);
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* @return string id
|
64 |
+
*/
|
65 |
+
public function getId()
|
66 |
+
{
|
67 |
+
return $this->id;
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* get FACT-Finder similarity, which lays between 0.0 and 100.0, but normaly is greater then the set minSimilarity
|
72 |
+
*
|
73 |
+
* @return double similarity
|
74 |
+
*/
|
75 |
+
public function getSimilarity()
|
76 |
+
{
|
77 |
+
return $this->similarity;
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* get original position or 0 if there is no original position
|
82 |
+
*
|
83 |
+
* @return int original position
|
84 |
+
*/
|
85 |
+
public function getOriginalPosition()
|
86 |
+
{
|
87 |
+
return $this->origPosition;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* get position or 0 if there is no position
|
92 |
+
*
|
93 |
+
* @return int position
|
94 |
+
*/
|
95 |
+
public function getPosition()
|
96 |
+
{
|
97 |
+
return $this->position;
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* get array of keywords for this record. this keywords can be used as meta-keywords on the website
|
102 |
+
* for seo-optimization.
|
103 |
+
* by default (if used with an older FF-version or when the seo features are not enabled) the keywords are an empty array
|
104 |
+
*
|
105 |
+
* @version since FF6.6
|
106 |
+
* @return array
|
107 |
+
*/
|
108 |
+
public function getKeywords()
|
109 |
+
{
|
110 |
+
return $this->keywords;
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* returnes the seo path which can be used to fetch the data from this record from FACT-Finder.
|
115 |
+
* this can be used as link to the detail page of this product.
|
116 |
+
* by default (if used with an older FF-version or when the seo features are not enabled) this path is an empty string
|
117 |
+
*
|
118 |
+
* @version since FF6.6
|
119 |
+
* @return string seoPath to this record
|
120 |
+
*/
|
121 |
+
public function getSeoPath()
|
122 |
+
{
|
123 |
+
return $this->seoPath;
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* get a value from a field defined by the argument $field, which can be a fieldnumber or a fieldname
|
128 |
+
* of the field does not exist, null will be returned
|
129 |
+
*
|
130 |
+
* @throws Exception if the argument $field is either an integer nor a string
|
131 |
+
* @param int|string fieldnumber or fieldname
|
132 |
+
* @return string fieldvalue or null if field does not exist
|
133 |
+
*/
|
134 |
+
public function getValue($field)
|
135 |
+
{
|
136 |
+
$returnValue = null;
|
137 |
+
if (is_int($field)) {
|
138 |
+
$returnValue = isset($this->fieldValues[$field]) ? $this->fieldValues[$field] : null;
|
139 |
+
} else if (is_string($field)) {
|
140 |
+
//get value by number and the number by name (mapping from name to value)
|
141 |
+
$returnValue = isset($this->fieldNames[$field]) ? $this->fieldValues[$this->fieldNames[$field]] : null;
|
142 |
+
}
|
143 |
+
return $returnValue;
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* proxy method for getValue()
|
148 |
+
* @see FACTFinder_Record::getValue()
|
149 |
+
*/
|
150 |
+
public function __get($name)
|
151 |
+
{
|
152 |
+
return $this->getValue($name);
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* set seo path for this record. this seo path can't be set by the constructor, because it was added
|
157 |
+
* in a later version.
|
158 |
+
*
|
159 |
+
* @version since FF6.6
|
160 |
+
* @param string seo path
|
161 |
+
*/
|
162 |
+
public function setSeoPath($seoPath)
|
163 |
+
{
|
164 |
+
if ($seoPath != null) {
|
165 |
+
$this->seoPath = strval($seoPath);
|
166 |
+
}
|
167 |
+
}
|
168 |
+
|
169 |
+
/**
|
170 |
+
* add keyword to this record.
|
171 |
+
*
|
172 |
+
* @version since FF6.6
|
173 |
+
* @see FACTFinder_Record::getKeywords()
|
174 |
+
* @param string keyword
|
175 |
+
*/
|
176 |
+
public function addKeyword($keyword) {
|
177 |
+
$this->keywords[] = $keyword;
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* add keywords to this record.
|
182 |
+
* the keys of the array are ignored, so only the values are used to set the keywords.
|
183 |
+
*
|
184 |
+
* @version since FF6.6
|
185 |
+
* @see FACTFinder_Record::getKeywords()
|
186 |
+
* @param array of strings/keywords
|
187 |
+
*/
|
188 |
+
public function addKeywords(array $keywords) {
|
189 |
+
$this->keywords += array_values($keywords);
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* set keywords for this record.
|
194 |
+
* the keys of the array are ignored, so only the values are used to set the keywords.
|
195 |
+
*
|
196 |
+
* @version since FF6.6
|
197 |
+
* @see FACTFinder_Record::getKeywords()
|
198 |
+
* @param array of strings/keywords
|
199 |
+
*/
|
200 |
+
public function setKeywords(array $keywords)
|
201 |
+
{
|
202 |
+
$this->keywords = array_values($keywords);
|
203 |
+
}
|
204 |
+
|
205 |
+
/**
|
206 |
+
* set a value to field defined by the argument $field, which can be a fieldnumber or a fieldname
|
207 |
+
*
|
208 |
+
* @throws Exception if the argument $field is neither an integer nor a string
|
209 |
+
* @param int|string fieldnumber or fieldname
|
210 |
+
* @param string fieldvalue
|
211 |
+
* @return void
|
212 |
+
*/
|
213 |
+
public function setValue($field, $value)
|
214 |
+
{
|
215 |
+
if (is_int($field)) {
|
216 |
+
$this->fieldValues[$field] = $value;
|
217 |
+
} else if (is_string($field)) {
|
218 |
+
if (!isset($this->fieldNames[$field])) {
|
219 |
+
// create a new field
|
220 |
+
$this->fieldNames[$field] = sizeof($this->fieldValues);
|
221 |
+
$this->fieldValues[] = $value;
|
222 |
+
} else {
|
223 |
+
$this->fieldValues[$this->fieldNames[$field]] = $value;
|
224 |
+
}
|
225 |
+
} else {
|
226 |
+
$this->log->error("Could not refer to a field using ".gettype($field));
|
227 |
+
throw new Exception("it is not (yet) possible to refer to a field using ".gettype($field));
|
228 |
+
}
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* proxy method for setValue()
|
233 |
+
* @see FACTFinder_Record::setValue()
|
234 |
+
*
|
235 |
+
* @throws Exception if the argument $field is either an integer nor a string
|
236 |
+
* @param int|string fieldnumber or fieldname
|
237 |
+
* @param string fieldvalue
|
238 |
+
* @return void
|
239 |
+
*/
|
240 |
+
public function __set($name, $value)
|
241 |
+
{
|
242 |
+
return $this->setValue($name, $value);
|
243 |
+
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* set a bulk of values. if the array contains fieldnames as array-keys, they
|
247 |
+
* could be used to get the values again
|
248 |
+
*
|
249 |
+
* @param array fieldvalues with fieldnames as key
|
250 |
+
* @return void
|
251 |
+
*/
|
252 |
+
public function setValues(array $fieldValues)
|
253 |
+
{
|
254 |
+
foreach ($fieldValues AS $name => $value) {
|
255 |
+
$this->setValue($name, $value);
|
256 |
+
}
|
257 |
+
}
|
258 |
+
}
|
lib/FACTFinder/Result.php
CHANGED
@@ -1,34 +1,41 @@
|
|
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 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Common
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* this class represents a fact-finder search result. By iterating over a result object, you will get
|
12 |
+
* FACTFinder_Record objects in the loop.
|
13 |
+
*
|
14 |
+
* @author Rudolf Batt <rb@omikron.net>
|
15 |
+
* @version $Id: Result.php 25893 2010-06-29 08:19:43Z rb $
|
16 |
+
* @category Collection
|
17 |
+
* @package FACTFinder\Common
|
18 |
+
*/
|
19 |
+
class FACTFinder_Result extends ArrayIterator
|
20 |
+
{
|
21 |
+
private $foundRecordsCount;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @param array record (default: empty array)
|
25 |
+
* @param int number of records factfinder found for the according query (default: 0)
|
26 |
+
*/
|
27 |
+
public function __construct(array $records = array(), $foundRecordsCount = 0){
|
28 |
+
parent::__construct($records);
|
29 |
+
$this->foundRecordsCount = intval($foundRecordsCount);
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* return number of records found in the whole FACT-Finder result.
|
34 |
+
* this object only contains the records for the current page, that must not be the same count
|
35 |
+
*
|
36 |
+
* @return int found records count
|
37 |
+
*/
|
38 |
+
public function getFoundRecordsCount(){
|
39 |
+
return $this->foundRecordsCount;
|
40 |
+
}
|
41 |
}
|
lib/FACTFinder/SingleWordSearchItem.php
CHANGED
@@ -1,39 +1,46 @@
|
|
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 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Common
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* represents a suggest single word search item with a preview of the found products for this query
|
12 |
+
*
|
13 |
+
* @author Rudolf Batt <rb@omikron.net>
|
14 |
+
* @version $Id: SingleWordSearchItem.php 25893 2010-06-29 08:19:43Z rb $
|
15 |
+
* @package FACTFinder\Common
|
16 |
+
*/
|
17 |
+
class FACTFinder_SingleWordSearchItem extends FACTFinder_SuggestQuery
|
18 |
+
{
|
19 |
+
private $previewRecords = array();
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @param array of FACTFinder_Record objects
|
23 |
+
* @return void
|
24 |
+
*/
|
25 |
+
public function addPreviewRecords(array $previewRecords)
|
26 |
+
{
|
27 |
+
$this->previewRecords += $previewRecords;
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @param FACTFinder_Record object
|
32 |
+
* @return void
|
33 |
+
*/
|
34 |
+
public function addPreviewRecord(FACTFinder_Record $record)
|
35 |
+
{
|
36 |
+
$this->previewRecords[] = $record;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* @return array of FACTFinder_Record objects or empty array if there are no preview objects
|
41 |
+
*/
|
42 |
+
public function getPreviewRecords()
|
43 |
+
{
|
44 |
+
return $this->previewRecords;
|
45 |
+
}
|
46 |
}
|
lib/FACTFinder/SuggestQuery.php
CHANGED
@@ -1,71 +1,78 @@
|
|
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 |
-
* @return string
|
42 |
-
*/
|
43 |
-
public function
|
44 |
-
return $this->
|
45 |
-
}
|
46 |
-
|
47 |
-
/**
|
48 |
-
* return
|
49 |
-
*/
|
50 |
-
public function
|
51 |
-
return $this->
|
52 |
-
}
|
53 |
-
|
54 |
-
/**
|
55 |
-
*
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
* return
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Common
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* represents a query for suggest
|
12 |
+
*
|
13 |
+
* @author Rudolf Batt <rb@omikron.net>
|
14 |
+
* @version $Id: SuggestQuery.php 25893 2010-06-29 08:19:43Z rb $
|
15 |
+
* @package FACTFinder\Common
|
16 |
+
*/
|
17 |
+
class FACTFinder_SuggestQuery
|
18 |
+
{
|
19 |
+
private $query;
|
20 |
+
private $url;
|
21 |
+
private $hitCount;
|
22 |
+
private $type;
|
23 |
+
private $imageUrl;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @param string $value query
|
27 |
+
* @param string $url url which uses the suggested query
|
28 |
+
* @param string $hitCount number of products, which will be found with this query
|
29 |
+
* @param string $type type of the query
|
30 |
+
* @param string imageUrl
|
31 |
+
*/
|
32 |
+
public function __construct($query, $url, $hitCount = '', $type = '', $imageUrl = '') {
|
33 |
+
$this->query = strval($query);
|
34 |
+
$this->url = strval($url);
|
35 |
+
$this->hitCount = $hitCount;
|
36 |
+
$this->type = $type;
|
37 |
+
$this->imageUrl = $imageUrl;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @return string
|
42 |
+
*/
|
43 |
+
public function getQuery() {
|
44 |
+
return $this->query;
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* @return string
|
49 |
+
*/
|
50 |
+
public function getUrl() {
|
51 |
+
return $this->url;
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* return int how many products will be found by this query
|
56 |
+
*/
|
57 |
+
public function getHitCount() {
|
58 |
+
return $this->hitCount;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* simple string which describes where this suggest query comes from (i.e. productname, category, logfile)
|
63 |
+
*
|
64 |
+
* @return string
|
65 |
+
*/
|
66 |
+
public function getType() {
|
67 |
+
return $this->type;
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* return image url, if one exists, otherwise returns empty string
|
72 |
+
*
|
73 |
+
* @return string
|
74 |
+
*/
|
75 |
+
public function getImageUrl() {
|
76 |
+
return $this->imageUrl;
|
77 |
+
}
|
78 |
}
|
lib/FACTFinder/TagQuery.php
CHANGED
@@ -1,41 +1,48 @@
|
|
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 |
-
* @return
|
37 |
-
*/
|
38 |
-
public function
|
39 |
-
return $this->
|
40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Common
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* represents a tag item for the tagcloud
|
12 |
+
*
|
13 |
+
* @author Rudolf Batt <rb@omikron.net>
|
14 |
+
* @version $Id: TagQuery.php 25893 2010-06-29 08:19:43Z rb $
|
15 |
+
* @package FACTFinder\Common
|
16 |
+
*/
|
17 |
+
class FACTFinder_TagQuery extends FACTFinder_Item
|
18 |
+
{
|
19 |
+
private $weight;
|
20 |
+
private $searchCount;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @param string $value query
|
24 |
+
* @param string $url
|
25 |
+
* @param boolean true if this tag lead to the current search result
|
26 |
+
* @param double $weight value between 0.0 and 1.0 (optional - default 0.0)
|
27 |
+
* @param int $searchCount how often this query was searched in the last 7 days (optional - default 0)
|
28 |
+
*/
|
29 |
+
public function __construct($value, $url, $isSelected = false, $weight = 0.0, $searchCount = 0) {
|
30 |
+
parent::__construct($value, $url, $isSelected);
|
31 |
+
$this->weight = floatval($weight);
|
32 |
+
$this->searchCount = intval($searchCount);
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* @return double value between 0.0 and 1.0 to calculate the importance of the query
|
37 |
+
*/
|
38 |
+
public function getWeight() {
|
39 |
+
return $this->weight;
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* @return int how often this query was searched in the last 7 days
|
44 |
+
*/
|
45 |
+
public function getSearchCount() {
|
46 |
+
return $this->searchCount;
|
47 |
+
}
|
48 |
}
|
lib/FACTFinder/Util.php
CHANGED
@@ -1,48 +1,57 @@
|
|
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 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Common
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* util class for some repeated issues which do not fit to a single class
|
12 |
+
*
|
13 |
+
* @author Rudolf Batt <rb@omikron.net>
|
14 |
+
* @version $Id: Util.php 25893 2010-06-29 08:19:43Z rb $
|
15 |
+
* @package FACTFinder\Common
|
16 |
+
**/
|
17 |
+
class FACTFinder_Util
|
18 |
+
{
|
19 |
+
protected $searchAdapter;
|
20 |
+
protected $ffparams;
|
21 |
+
|
22 |
+
public function __construct(FACTFinder_Parameters $ffparams, FACTFinder_Abstract_SearchAdapter $searchAdapter) {
|
23 |
+
$this->ffparams = $ffparams;
|
24 |
+
$this->searchAdapter = $searchAdapter;
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @return string javascript method call "clickProduct" with all needed arguments
|
29 |
+
*/
|
30 |
+
public function createJavaScriptClickCode($record, $title, $sid)
|
31 |
+
{
|
32 |
+
$query = addcslashes(htmlspecialchars($this->ffparams->getQuery()), "'");
|
33 |
+
$channel = $this->ffparams->getChannel();
|
34 |
+
|
35 |
+
$currentPageNumber = $this->searchAdapter->getPaging()->getCurrentPageNumber();
|
36 |
+
$origPageSize = $this->searchAdapter->getProductsPerPageOptions()->getDefaultOption()->getValue();
|
37 |
+
$pageSize = $this->searchAdapter->getProductsPerPageOptions()->getSelectedOption()->getValue();
|
38 |
+
|
39 |
+
$position = $record->getPosition();
|
40 |
+
if ($position != 0 && $query != '') {
|
41 |
+
$originalPosition = $record->getOriginalPosition();
|
42 |
+
if (!$originalPosition) $originalPosition = $position;
|
43 |
+
|
44 |
+
$similarity = number_format($record->getSimilarity(), 2, '.', '');
|
45 |
+
$id = $record->getId();
|
46 |
+
|
47 |
+
$title = addslashes($title);
|
48 |
+
$sid = addslashes($sid);
|
49 |
+
$clickCode = "clickProduct('$query', '$id', '$position', '$originalPosition', '$currentPageNumber',"
|
50 |
+
."'$similarity', '$sid', '$title', '$pageSize', '$origPageSize', '$channel', 'click');";
|
51 |
+
} else {
|
52 |
+
$clickCode = '';
|
53 |
+
}
|
54 |
+
|
55 |
+
return $clickCode;
|
56 |
+
}
|
57 |
}
|
lib/FACTFinder/Xml64/SearchAdapter.php
CHANGED
@@ -1,111 +1,115 @@
|
|
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 |
-
|
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 |
-
if ($selectedOption
|
99 |
-
$
|
100 |
-
}
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
|
|
|
|
|
|
|
|
111 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Xml64
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* search adapter using the xml interface. expects a xml formatted string from the data-provider
|
12 |
+
*
|
13 |
+
* @author Rudolf Batt <rb@omikron.net>
|
14 |
+
* @version $Id: SearchAdapter.php 25893 2010-06-29 08:19:43Z rb $
|
15 |
+
* @package FACTFinder\Xml64
|
16 |
+
*/
|
17 |
+
class FACTFinder_Xml64_SearchAdapter extends FACTFinder_Xml65_SearchAdapter
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* the parameter for the xml result changed in FACT-Finder 6.5, so here it is set different
|
21 |
+
*/
|
22 |
+
protected function init()
|
23 |
+
{
|
24 |
+
$this->getDataProvider()->setParam('xml', 'true');
|
25 |
+
$this->getDataProvider()->setType('Search.ff');
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* until version 6.4 of FACT-Finder there are no slider elements
|
30 |
+
*
|
31 |
+
* @return FACTFinder_Asn
|
32 |
+
**/
|
33 |
+
protected function createAsn()
|
34 |
+
{
|
35 |
+
$xmlResult = $this->getData();
|
36 |
+
$asn = array();
|
37 |
+
|
38 |
+
if (!empty($xmlResult->asn)) {
|
39 |
+
$encodingHandler = $this->getEncodingHandler();
|
40 |
+
$params = $this->getParamsParser()->getRequestParams();
|
41 |
+
|
42 |
+
foreach ($xmlResult->asn->group AS $xmlGroup) {
|
43 |
+
$groupName = $encodingHandler->encodeServerContentForPage((string)$xmlGroup->attributes()->name);
|
44 |
+
$groupUnit = '';
|
45 |
+
if (isset($xmlGroup->attributes()->unit)) {
|
46 |
+
$groupUnit = strval($xmlGroup->attributes()->unit);
|
47 |
+
}
|
48 |
+
|
49 |
+
$group = FF::getInstance('asnGroup',
|
50 |
+
array(),
|
51 |
+
$encodingHandler->encodeServerContentForPage((string)$xmlGroup->attributes()->name),
|
52 |
+
$encodingHandler->encodeServerContentForPage((string)$xmlGroup->attributes()->detailedLinks),
|
53 |
+
$groupUnit,
|
54 |
+
false
|
55 |
+
);
|
56 |
+
|
57 |
+
//get filters of the current group
|
58 |
+
foreach ($xmlGroup->element AS $xmlFilter) {
|
59 |
+
$filterLink = $this->getParamsParser()->createPageLink(
|
60 |
+
$this->getParamsParser()->parseParamsFromResultString(trim($xmlFilter->searchParams))
|
61 |
+
);
|
62 |
+
$filter = FF::getInstance('asnFilterItem',
|
63 |
+
$encodingHandler->encodeServerContentForPage(trim($xmlFilter->attributes()->name)),
|
64 |
+
$filterLink,
|
65 |
+
strval($xmlFilter->attributes()->selected) == 'true',
|
66 |
+
strval($xmlFilter->attributes()->count),
|
67 |
+
strval($xmlFilter->attributes()->clusterLevel),
|
68 |
+
strval($xmlFilter->attributes()->previewImage)
|
69 |
+
);
|
70 |
+
|
71 |
+
$group->addFilter($filter);
|
72 |
+
}
|
73 |
+
|
74 |
+
$asn[] = $group;
|
75 |
+
}
|
76 |
+
}
|
77 |
+
return FF::getInstance('asn', $asn);
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* until version 6.4 of FACT-Finder, the products per page options are not delivered, so this method creates an
|
82 |
+
* artificial products per page options array, but uses the current set productsPerPage value from the result
|
83 |
+
*
|
84 |
+
* @return FACTFinder_ProductsPerPageOptions
|
85 |
+
*/
|
86 |
+
protected function createProductsPerPageOptions()
|
87 |
+
{
|
88 |
+
$pppOptions = array(); //default
|
89 |
+
$xmlResult = $this->getData();
|
90 |
+
|
91 |
+
if (!empty($xmlResult->paging)) {
|
92 |
+
$params = $this->getParamsParser()->getRequestParams();
|
93 |
+
|
94 |
+
$selectedOption = intval($xmlResult->paging->attributes()->productsPerPage);
|
95 |
+
$defaultOption = 12;
|
96 |
+
$options = array();
|
97 |
+
|
98 |
+
if ($selectedOption < $defaultOption) {
|
99 |
+
$defaultOption = $selectedOption;
|
100 |
+
}
|
101 |
+
$options[$defaultOption] = $this->getProductsPerPageLink($defaultOption);
|
102 |
+
if ($selectedOption != $defaultOption) {
|
103 |
+
$options[$selectedOption] = $this->getProductsPerPageLink($selectedOption);
|
104 |
+
}
|
105 |
+
|
106 |
+
$pppOptions = FF::getInstance('productsPerPageOptions', $options, $defaultOption, $selectedOption);
|
107 |
+
}
|
108 |
+
return $pppOptions;
|
109 |
+
}
|
110 |
+
|
111 |
+
protected function getProductsPerPageLink($pppOption) {
|
112 |
+
$params = $this->getParamsParser()->getRequestParams();
|
113 |
+
return $this->getParamsParser()->createPageLink($params, array('productsPerPage' => $pppOption));
|
114 |
+
}
|
115 |
}
|
lib/FACTFinder/Xml65/ImportAdapter.php
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Xml65
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* import adapter using the xml interface
|
12 |
+
*
|
13 |
+
* @author Rudolf Batt <rb@omikron.net>
|
14 |
+
* @version $Id: TagCloudAdapter.php 25893 2010-06-29 08:19:43Z rb $
|
15 |
+
* @package FACTFinder\Xml65
|
16 |
+
*/
|
17 |
+
class FACTFinder_Xml65_ImportAdapter extends FACTFinder_Abstract_ImportAdapter
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* @return void
|
21 |
+
**/
|
22 |
+
public function init()
|
23 |
+
{
|
24 |
+
$this->log->info("Initializing new import adapter.");
|
25 |
+
$this->getDataProvider()->setParam('format', 'xml');
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* try to parse data as xml
|
30 |
+
*
|
31 |
+
* @throws Exception of data is no valid XML
|
32 |
+
* @return SimpleXMLElement
|
33 |
+
*/
|
34 |
+
protected function getData()
|
35 |
+
{
|
36 |
+
libxml_use_internal_errors(true);
|
37 |
+
return new SimpleXMLElement(parent::getData()); //throws exception on error
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @param bool $download import files will also be updated if true
|
42 |
+
* @param string $type determines which import will be triggered. can be 'data', 'suggest' or 'recommendation'
|
43 |
+
* @return object $report import report in xml format
|
44 |
+
*/
|
45 |
+
protected function triggerImport($download, $type = 'data')
|
46 |
+
{
|
47 |
+
$this->getDataProvider()->setCurlOptions(array(
|
48 |
+
CURLOPT_CONNECTTIMEOUT => 10,
|
49 |
+
CURLOPT_TIMEOUT => 360
|
50 |
+
));
|
51 |
+
|
52 |
+
$this->getDataProvider()->setParam('download', $download ? 'true' : 'false');
|
53 |
+
switch($type)
|
54 |
+
{
|
55 |
+
case 'suggest':
|
56 |
+
$this->getDataProvider()->setType('Import.ff');
|
57 |
+
$this->getDataProvider()->setParam('type', 'suggest');
|
58 |
+
break;
|
59 |
+
case 'recommendation':
|
60 |
+
$this->getDataProvider()->setType('Recommender.ff');
|
61 |
+
$this->getDataProvider()->setParam('do', 'importData');
|
62 |
+
break;
|
63 |
+
case 'data':
|
64 |
+
default:
|
65 |
+
$this->getDataProvider()->setType('Import.ff');
|
66 |
+
break;
|
67 |
+
}
|
68 |
+
|
69 |
+
$report = $this->getData();
|
70 |
+
|
71 |
+
// clean up for next import
|
72 |
+
switch($type)
|
73 |
+
{
|
74 |
+
case 'suggest':
|
75 |
+
$this->getDataProvider()->unsetParam('type');
|
76 |
+
break;
|
77 |
+
case 'recommendation':
|
78 |
+
$this->getDataProvider()->unsetParam('do');
|
79 |
+
break;
|
80 |
+
}
|
81 |
+
|
82 |
+
return $report;
|
83 |
+
}
|
84 |
+
}
|
lib/FACTFinder/Xml65/RecommendationAdapter.php
CHANGED
@@ -1,83 +1,90 @@
|
|
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 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
$
|
78 |
-
$
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Xml65
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* adapter for the factfinder recommendation engine, working with the XML interface of FF6.5
|
12 |
+
*
|
13 |
+
* @author Rudolf Batt <rb@omikron.net>
|
14 |
+
* @version $Id$
|
15 |
+
* @package FACTFinder\Xml65
|
16 |
+
*/
|
17 |
+
class FACTFinder_Xml65_RecommendationAdapter extends FACTFinder_Abstract_RecommendationAdapter
|
18 |
+
{
|
19 |
+
|
20 |
+
protected $xmlData = null;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* init
|
24 |
+
*/
|
25 |
+
protected function init()
|
26 |
+
{
|
27 |
+
parent::init();
|
28 |
+
$this->log->info("Initializing new recommendation adapter.");
|
29 |
+
$this->getDataProvider()->setParam('do', 'getRecommendation');
|
30 |
+
$this->getDataProvider()->setParam('format', 'xml');
|
31 |
+
$this->getDataProvider()->setType('Recommender.ff');
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* try to parse data as xml
|
36 |
+
*
|
37 |
+
* @throws Exception of data is no valid XML
|
38 |
+
* @return SimpleXMLElement
|
39 |
+
*/
|
40 |
+
protected function getData()
|
41 |
+
{
|
42 |
+
if ($this->xmlData == null) {
|
43 |
+
libxml_use_internal_errors(true);
|
44 |
+
$data = parent::getData();
|
45 |
+
$this->xmlData = new SimpleXMLElement($data); //throws exception on error
|
46 |
+
}
|
47 |
+
return $this->xmlData;
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* creates the recommendation-records.
|
52 |
+
* each record has a similarity of 100.0%, because the similarity is not known. the position is just
|
53 |
+
* the position at the recommendations result starting from 0 - there is no "original position" at
|
54 |
+
* these records.
|
55 |
+
*
|
56 |
+
* @param string id of the product which should be used to get some recommendations
|
57 |
+
* @return array of FACTFinder_Record objects
|
58 |
+
*
|
59 |
+
*/
|
60 |
+
protected function createRecommendations() {
|
61 |
+
$xmlResult = $this->getData(); //throws exception on error
|
62 |
+
|
63 |
+
$records = array();
|
64 |
+
if (!empty($xmlResult->results)) {
|
65 |
+
$count = (int) $xmlResult->results->attributes()->count;
|
66 |
+
$encodingHandler = $this->getEncodingHandler();
|
67 |
+
|
68 |
+
//load result
|
69 |
+
foreach($xmlResult->results->record AS $xmlRecord){
|
70 |
+
|
71 |
+
if ($this->idsOnly) {
|
72 |
+
$records[] = FF::getInstance('record', $xmlRecord->attributes()->id);
|
73 |
+
continue;
|
74 |
+
}
|
75 |
+
|
76 |
+
// fetch record values
|
77 |
+
$fieldValues = array();
|
78 |
+
foreach($xmlRecord->field AS $xmlField){
|
79 |
+
$fieldName = (string) $xmlField->attributes()->name;
|
80 |
+
$fieldValues[$fieldName] = (string) $xmlField;
|
81 |
+
}
|
82 |
+
|
83 |
+
$record = FF::getInstance('record', $xmlRecord->attributes()->id, 100.0, $xmlRecord->attributes()->nr);
|
84 |
+
$record->setValues($fieldValues);
|
85 |
+
$records[] = $record;
|
86 |
+
}
|
87 |
+
}
|
88 |
+
return FF::getInstance('result', $records, $count);
|
89 |
+
}
|
90 |
+
}
|
lib/FACTFinder/Xml65/SearchAdapter.php
CHANGED
@@ -1,493 +1,480 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
*
|
5 |
-
*
|
6 |
-
* @
|
7 |
-
* @
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
protected
|
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 |
-
|
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 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
$
|
161 |
-
$
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
$
|
167 |
-
|
168 |
-
|
169 |
-
$
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
$positionCounter
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
$
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
$
|
197 |
-
$
|
198 |
-
$
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
*
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
$
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
$
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
$
|
221 |
-
$
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
$encodingHandler->encodeServerContentForPage((string)$xmlGroup->attributes()->
|
229 |
-
$
|
230 |
-
$
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
$params
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
$
|
248 |
-
strval($xmlFilter->attributes()->
|
249 |
-
strval($xmlFilter->attributes()->
|
250 |
-
strval($xmlFilter->attributes()->
|
251 |
-
strval($xmlFilter->attributes()->
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
$
|
257 |
-
$
|
258 |
-
strval($xmlFilter->attributes()->
|
259 |
-
strval($xmlFilter->attributes()->
|
260 |
-
strval($xmlFilter->attributes()->
|
261 |
-
strval($xmlFilter->attributes()->
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
$sorting
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
$
|
290 |
-
$
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
$fieldName
|
377 |
-
$fieldUnit
|
378 |
-
|
379 |
-
|
380 |
-
$
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
if (!empty($xmlCampaign->
|
413 |
-
$
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
$
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
$
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
* get error if there is one
|
481 |
-
*
|
482 |
-
* @return string if error exists, else null
|
483 |
-
*/
|
484 |
-
public function getError()
|
485 |
-
{
|
486 |
-
$error = null;
|
487 |
-
$xmlResult = $this->getData();
|
488 |
-
if (!empty($xmlResult->error)) {
|
489 |
-
$error = trim(strval($xmlResult->error));
|
490 |
-
}
|
491 |
-
return $error;
|
492 |
-
}
|
493 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Xml65
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* search adapter using the xml interface. expects a xml formated string from the dataprovider
|
12 |
+
*
|
13 |
+
* @author Rudolf Batt <rb@omikron.net>
|
14 |
+
* @version $Id: SearchAdapter.php 25985 2010-06-30 15:31:53Z rb $
|
15 |
+
* @package FACTFinder\Xml65
|
16 |
+
*/
|
17 |
+
class FACTFinder_Xml65_SearchAdapter extends FACTFinder_Abstract_SearchAdapter
|
18 |
+
{
|
19 |
+
protected $status = null;
|
20 |
+
protected $isArticleNumberSearch;
|
21 |
+
protected $xmlData = null;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* init
|
25 |
+
*/
|
26 |
+
protected function init()
|
27 |
+
{
|
28 |
+
$this->log->info("Initializing new search adapter.");
|
29 |
+
$this->getDataProvider()->setParam('format', 'xml');
|
30 |
+
$this->getDataProvider()->setType('Search.ff');
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* try to parse data as xml
|
35 |
+
*
|
36 |
+
* @throws Exception of data is no valid XML
|
37 |
+
* @return SimpleXMLElement
|
38 |
+
*/
|
39 |
+
protected function getData()
|
40 |
+
{
|
41 |
+
if ($this->xmlData == null) {
|
42 |
+
libxml_use_internal_errors(true);
|
43 |
+
$data = parent::getData();
|
44 |
+
$this->xmlData = new SimpleXMLElement($data); //throws exception on error
|
45 |
+
}
|
46 |
+
return $this->xmlData;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* get status of the article number search
|
51 |
+
*
|
52 |
+
* @return string status
|
53 |
+
**/
|
54 |
+
public function getArticleNumberSearchStatus() {
|
55 |
+
if ($this->articleNumberSearchStatus == null) {
|
56 |
+
|
57 |
+
$this->isArticleNumberSearch = false;
|
58 |
+
$this->articleNumberSearchStatus = self::NO_RESULT;
|
59 |
+
|
60 |
+
if ($this->getStatus() != self::NO_RESULT) {
|
61 |
+
$this->loadArticleNumberSearchInformations();
|
62 |
+
}
|
63 |
+
}
|
64 |
+
return $this->articleNumberSearchStatus;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* returns true if the search was an article number search
|
69 |
+
*
|
70 |
+
* @return boolean isArticleNumberSearch
|
71 |
+
**/
|
72 |
+
public function isArticleNumberSearch() {
|
73 |
+
if ($this->isArticleNumberSearch === null) {
|
74 |
+
|
75 |
+
$this->isArticleNumberSearch = false;
|
76 |
+
|
77 |
+
if ($this->getStatus() != self::NO_RESULT) {
|
78 |
+
$this->loadArticleNumberSearchInformations();
|
79 |
+
}
|
80 |
+
}
|
81 |
+
return $this->isArticleNumberSearch;
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* fetch article number search status from the xml result
|
86 |
+
*
|
87 |
+
* @return void
|
88 |
+
*/
|
89 |
+
private function loadArticleNumberSearchInformations() {
|
90 |
+
$xmlResult = $this->getData();
|
91 |
+
switch($xmlResult->articleNumberSearchStatus){
|
92 |
+
case 'nothingFound':
|
93 |
+
$this->isArticleNumberSearch = true;
|
94 |
+
$this->articleNumberSearchStatus = self::NOTHING_FOUND;
|
95 |
+
break;
|
96 |
+
case 'resultsFound':
|
97 |
+
$this->isArticleNumberSearch = true;
|
98 |
+
$this->articleNumberSearchStatus = self::RESULTS_FOUND;
|
99 |
+
break;
|
100 |
+
case 'noArticleNumberSearch':
|
101 |
+
default:
|
102 |
+
$this->isArticleNumberSearch = false;
|
103 |
+
$this->articleNumberSearchStatus = self::NO_RESULT;
|
104 |
+
}
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* returns true if the search-process was aborted because of an timeout
|
109 |
+
*
|
110 |
+
* @return boolean true if search timed out
|
111 |
+
**/
|
112 |
+
public function isSearchTimedOut()
|
113 |
+
{
|
114 |
+
$xmlResult = $this->getData();
|
115 |
+
if($xmlResult->searchTimedOut == 'true') {
|
116 |
+
return true;
|
117 |
+
} else {
|
118 |
+
return false;
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* get search status
|
124 |
+
*
|
125 |
+
* @return string status
|
126 |
+
**/
|
127 |
+
public function getStatus()
|
128 |
+
{
|
129 |
+
if ($this->status == null) {
|
130 |
+
$xmlResult = $this->getData();
|
131 |
+
switch($xmlResult->searchStatus){
|
132 |
+
case 'nothingFound':
|
133 |
+
$this->status = self::NOTHING_FOUND;
|
134 |
+
break;
|
135 |
+
case 'resultsFound':
|
136 |
+
$this->status = self::RESULTS_FOUND;
|
137 |
+
break;
|
138 |
+
default:
|
139 |
+
$this->status = self::NO_RESULT;
|
140 |
+
}
|
141 |
+
}
|
142 |
+
return $this->status;
|
143 |
+
}
|
144 |
+
|
145 |
+
protected function createSearchParams()
|
146 |
+
{
|
147 |
+
$breadCrumbTrail = $this->getBreadCrumbTrail();
|
148 |
+
if (sizeof($breadCrumbTrail) > 0) {
|
149 |
+
$paramString = $breadCrumbTrail[sizeof($breadCrumbTrail)-1]->getUrl();
|
150 |
+
$searchParams = $this->getParamsParser()->getFactfinderParamsFromString($paramString);
|
151 |
+
} else {
|
152 |
+
$searchParams = $this->getParamsParser()->getFactfinderParams();
|
153 |
+
}
|
154 |
+
return $searchParams;
|
155 |
+
}
|
156 |
+
|
157 |
+
protected function createResult()
|
158 |
+
{
|
159 |
+
//init default values
|
160 |
+
$result = array();
|
161 |
+
$resultCount = 0;
|
162 |
+
$xmlResult = $this->getData();
|
163 |
+
|
164 |
+
//load result values from the xml element
|
165 |
+
if (!empty($xmlResult->results)) {
|
166 |
+
$resultCount = (int) $xmlResult->results->attributes()->count;
|
167 |
+
$encodingHandler = $this->getEncodingHandler();
|
168 |
+
|
169 |
+
$paging = $this->getPaging();
|
170 |
+
$positionOffset = ($paging->getCurrentPageNumber() - 1) * $this->getProductsPerPageOptions()->getSelectedOption()->getValue();
|
171 |
+
|
172 |
+
//load result
|
173 |
+
$positionCounter = 1;
|
174 |
+
foreach($xmlResult->results->record AS $currentRecord){
|
175 |
+
// get current position
|
176 |
+
$position = $positionOffset + $positionCounter;
|
177 |
+
$positionCounter++;
|
178 |
+
|
179 |
+
// fetch record values
|
180 |
+
$fieldValues = array();
|
181 |
+
foreach($currentRecord->field AS $current_field){
|
182 |
+
$currentFieldname = (string) $current_field->attributes()->name;
|
183 |
+
$fieldValues[$currentFieldname] = (string) $current_field;
|
184 |
+
}
|
185 |
+
|
186 |
+
// get original position
|
187 |
+
if (isset($fieldValues['__ORIG_POSITION__'])) {
|
188 |
+
$origPosition = $fieldValues['__ORIG_POSITION__'];
|
189 |
+
unset($fieldValues['__ORIG_POSITION__']);
|
190 |
+
} else {
|
191 |
+
$origPosition = $position;
|
192 |
+
}
|
193 |
+
|
194 |
+
$result[] = FF::getInstance('record',
|
195 |
+
$currentRecord->attributes()->id,
|
196 |
+
floatval($currentRecord->attributes()->relevancy),
|
197 |
+
$position,
|
198 |
+
$origPosition,
|
199 |
+
$encodingHandler->encodeServerContentForPage($fieldValues)
|
200 |
+
);
|
201 |
+
}
|
202 |
+
}
|
203 |
+
return FF::getInstance('result', $result, $resultCount);
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* @return FACTFinder_Asn
|
208 |
+
**/
|
209 |
+
protected function createAsn()
|
210 |
+
{
|
211 |
+
$xmlResult = $this->getData();
|
212 |
+
$asn = array();
|
213 |
+
|
214 |
+
if (!empty($xmlResult->asn)) {
|
215 |
+
$encodingHandler = $this->getEncodingHandler();
|
216 |
+
$params = $this->getParamsParser()->getRequestParams();
|
217 |
+
|
218 |
+
foreach ($xmlResult->asn->group AS $xmlGroup) {
|
219 |
+
$groupName = $encodingHandler->encodeServerContentForPage((string)$xmlGroup->attributes()->name);
|
220 |
+
$groupUnit = '';
|
221 |
+
if (isset($xmlGroup->attributes()->unit)) {
|
222 |
+
$groupUnit = strval($xmlGroup->attributes()->unit);
|
223 |
+
}
|
224 |
+
|
225 |
+
$group = FF::getInstance('asnGroup',
|
226 |
+
array(),
|
227 |
+
$encodingHandler->encodeServerContentForPage((string)$xmlGroup->attributes()->name),
|
228 |
+
$encodingHandler->encodeServerContentForPage((string)$xmlGroup->attributes()->detailedLinks),
|
229 |
+
$groupUnit,
|
230 |
+
strval($xmlGroup->attributes()->style) == 'SLIDER'
|
231 |
+
);
|
232 |
+
|
233 |
+
//get filters of the current group
|
234 |
+
foreach ($xmlGroup->element AS $xmlFilter) {
|
235 |
+
$filterLink = $this->getParamsParser()->createPageLink(
|
236 |
+
$this->getParamsParser()->parseParamsFromResultString(trim($xmlFilter->searchParams))
|
237 |
+
);
|
238 |
+
|
239 |
+
if ($group->isSliderStyle()) {
|
240 |
+
// get last (empty) parameter from the search params property
|
241 |
+
$params = $this->getParamsParser()->parseParamsFromResultString(trim($xmlFilter->searchParams));
|
242 |
+
end($params);
|
243 |
+
$filterLink .= '&'.key($params).'=';
|
244 |
+
|
245 |
+
$filter = FF::getInstance('asnSliderFilter',
|
246 |
+
$filterLink,
|
247 |
+
strval($xmlFilter->attributes()->absoluteMin),
|
248 |
+
strval($xmlFilter->attributes()->absoluteMax),
|
249 |
+
strval($xmlFilter->attributes()->selectedMin),
|
250 |
+
strval($xmlFilter->attributes()->selectedMax),
|
251 |
+
isset($xmlFilter->attributes()->field) ? strval($xmlFilter->attributes()->field) : ''
|
252 |
+
);
|
253 |
+
} else {
|
254 |
+
$filter = FF::getInstance('asnFilterItem',
|
255 |
+
$encodingHandler->encodeServerContentForPage(trim($xmlFilter->attributes()->name)),
|
256 |
+
$filterLink,
|
257 |
+
strval($xmlFilter->attributes()->selected) == 'true',
|
258 |
+
strval($xmlFilter->attributes()->count),
|
259 |
+
strval($xmlFilter->attributes()->clusterLevel),
|
260 |
+
strval($xmlFilter->attributes()->previewImage),
|
261 |
+
isset($xmlFilter->attributes()->field) ? strval($xmlFilter->attributes()->field) : ''
|
262 |
+
);
|
263 |
+
}
|
264 |
+
|
265 |
+
$group->addFilter($filter);
|
266 |
+
}
|
267 |
+
|
268 |
+
$asn[] = $group;
|
269 |
+
}
|
270 |
+
}
|
271 |
+
return FF::getInstance('asn', $asn);
|
272 |
+
}
|
273 |
+
|
274 |
+
/**
|
275 |
+
* @return array of FACTFinder_SortItem objects
|
276 |
+
**/
|
277 |
+
protected function createSorting()
|
278 |
+
{
|
279 |
+
$sorting = array();
|
280 |
+
$xmlResult = $this->getData();
|
281 |
+
|
282 |
+
if (!empty($xmlResult->sorting)) {
|
283 |
+
$encodingHandler = $this->getEncodingHandler();
|
284 |
+
|
285 |
+
foreach ($xmlResult->sorting->sort AS $xmlSortItem) {
|
286 |
+
$sortLink = $this->getParamsParser()->createPageLink(
|
287 |
+
$this->getParamsParser()->parseParamsFromResultString(trim($xmlSortItem->searchParams))
|
288 |
+
);
|
289 |
+
$sortItem = FF::getInstance('item',
|
290 |
+
$encodingHandler->encodeServerContentForPage(trim($xmlSortItem->attributes()->description)),
|
291 |
+
$sortLink,
|
292 |
+
strval($xmlSortItem->attributes()->selected) == 'true'
|
293 |
+
);
|
294 |
+
$sorting[] = $sortItem;
|
295 |
+
}
|
296 |
+
}
|
297 |
+
return $sorting;
|
298 |
+
}
|
299 |
+
|
300 |
+
/**
|
301 |
+
* @return array of FACTFinder_Item objects
|
302 |
+
**/
|
303 |
+
protected function createPaging()
|
304 |
+
{
|
305 |
+
$paging = null;
|
306 |
+
$xmlResult = $this->getData();
|
307 |
+
|
308 |
+
if (!empty($xmlResult->paging)) {
|
309 |
+
$paging = FF::getInstance('paging',
|
310 |
+
intval(trim($xmlResult->paging->attributes()->currentPage)),
|
311 |
+
intval(trim($xmlResult->paging->attributes()->pageCount)),
|
312 |
+
$this->getParamsParser()
|
313 |
+
);
|
314 |
+
} else {
|
315 |
+
$paging = FF::getInstance('paging', 1, 1, $this->getParamsParser());
|
316 |
+
}
|
317 |
+
return $paging;
|
318 |
+
}
|
319 |
+
|
320 |
+
/**
|
321 |
+
* @return FACTFinder_ProductsPerPageOptions
|
322 |
+
*/
|
323 |
+
protected function createProductsPerPageOptions()
|
324 |
+
{
|
325 |
+
$pppOptions = array(); //default
|
326 |
+
$xmlResult = $this->getData();
|
327 |
+
|
328 |
+
if (!empty($xmlResult->productsPerPageOptions)) {
|
329 |
+
$defaultOption = intval(trim($xmlResult->productsPerPageOptions->attributes()->default));
|
330 |
+
$selectedOption = intval(trim($xmlResult->productsPerPageOptions->attributes()->selected));
|
331 |
+
|
332 |
+
$options = array();
|
333 |
+
foreach($xmlResult->productsPerPageOptions->option AS $option) {
|
334 |
+
$value = intval(trim($option->attributes()->value));
|
335 |
+
$url = $this->getParamsParser()->createPageLink(
|
336 |
+
$this->getParamsParser()->parseParamsFromResultString(trim($option->searchParams))
|
337 |
+
);
|
338 |
+
$options[$value] = $url;
|
339 |
+
}
|
340 |
+
$pppOptions = FF::getInstance('productsPerPageOptions', $options, $defaultOption, $selectedOption);
|
341 |
+
}
|
342 |
+
return $pppOptions;
|
343 |
+
}
|
344 |
+
|
345 |
+
/**
|
346 |
+
* @return array of FACTFinder_BreadCrumbItem objects
|
347 |
+
*/
|
348 |
+
protected function createBreadCrumbTrail()
|
349 |
+
{
|
350 |
+
$breadCrumbTrail = array();
|
351 |
+
$xmlResult = $this->getData();
|
352 |
+
|
353 |
+
if (!empty($xmlResult->breadCrumbTrail)) {
|
354 |
+
$encodingHandler = $this->getEncodingHandler();
|
355 |
+
|
356 |
+
$breadCrumbCount = count($xmlResult->breadCrumbTrail->item);
|
357 |
+
$i = 1;
|
358 |
+
foreach ($xmlResult->breadCrumbTrail->item AS $item) {
|
359 |
+
$link = $this->getParamsParser()->createPageLink(
|
360 |
+
$this->getParamsParser()->parseParamsFromResultString(trim($item->searchParams))
|
361 |
+
);
|
362 |
+
|
363 |
+
$fieldName = '';
|
364 |
+
$fieldUnit = '';
|
365 |
+
$breadCrumbType = $encodingHandler->encodeServerContentForPage(strval($item->attributes()->type));
|
366 |
+
if ($breadCrumbType == 'filter') {
|
367 |
+
$fieldName = $encodingHandler->encodeServerContentForPage(strval($item->attributes()->fieldName));
|
368 |
+
$fieldUnit = $encodingHandler->encodeServerContentForPage(strval($item->attributes()->fieldUnit));
|
369 |
+
}
|
370 |
+
|
371 |
+
$breadCrumb = FF::getInstance('breadCrumbItem',
|
372 |
+
$encodingHandler->encodeServerContentForPage(trim($item->attributes()->value)),
|
373 |
+
$link,
|
374 |
+
($i == $breadCrumbCount),
|
375 |
+
$breadCrumbType,
|
376 |
+
$fieldName,
|
377 |
+
$fieldUnit
|
378 |
+
);
|
379 |
+
|
380 |
+
$breadCrumbTrail[] = $breadCrumb;
|
381 |
+
$i++;
|
382 |
+
}
|
383 |
+
}
|
384 |
+
return $breadCrumbTrail;
|
385 |
+
}
|
386 |
+
|
387 |
+
/**
|
388 |
+
* @return array of FACTFinder_Campaign objects
|
389 |
+
*/
|
390 |
+
protected function createCampaigns()
|
391 |
+
{
|
392 |
+
$campaigns = array();
|
393 |
+
$xmlResult = $this->getData();
|
394 |
+
|
395 |
+
if (!empty($xmlResult->campaigns)) {
|
396 |
+
$encodingHandler = $this->getEncodingHandler();
|
397 |
+
|
398 |
+
foreach ($xmlResult->campaigns->campaign AS $xmlCampaign) {
|
399 |
+
//get redirect
|
400 |
+
$redirectUrl = '';
|
401 |
+
if (!empty($xmlCampaign->target->destination)) {
|
402 |
+
$redirectUrl = $encodingHandler->encodeServerUrlForPageUrl(strval($xmlCampaign->target->destination));
|
403 |
+
}
|
404 |
+
|
405 |
+
$campaign = FF::getInstance('campaign',
|
406 |
+
$encodingHandler->encodeServerContentForPage(strval($xmlCampaign->attributes()->name)),
|
407 |
+
$encodingHandler->encodeServerContentForPage(strval($xmlCampaign->attributes()->category)),
|
408 |
+
$redirectUrl
|
409 |
+
);
|
410 |
+
|
411 |
+
//get feedback
|
412 |
+
if (!empty($xmlCampaign->feedback)) {
|
413 |
+
$feedback = array();
|
414 |
+
foreach ($xmlCampaign->feedback->text as $text) {
|
415 |
+
$nr = intval(trim($text->attributes()->nr));
|
416 |
+
$feedback[$nr] = $encodingHandler->encodeServerContentForPage((string)$text);
|
417 |
+
}
|
418 |
+
$campaign->addFeedback($feedback);
|
419 |
+
}
|
420 |
+
|
421 |
+
//get pushed products
|
422 |
+
if (!empty($xmlCampaign->pushedProducts)) {
|
423 |
+
$pushedProducts = array();
|
424 |
+
foreach ($xmlCampaign->pushedProducts->product AS $xmlProduct) {
|
425 |
+
$product = FF::getInstance('record', $xmlProduct->attributes()->id, 100);
|
426 |
+
|
427 |
+
// fetch product values
|
428 |
+
$fieldValues = array();
|
429 |
+
foreach($xmlProduct->field AS $current_field){
|
430 |
+
$currentFieldname = (string) $current_field->attributes()->name;
|
431 |
+
$fieldValues[$currentFieldname] = (string) $current_field;
|
432 |
+
}
|
433 |
+
$product->setValues($encodingHandler->encodeServerContentForPage($fieldValues));
|
434 |
+
$pushedProducts[] = $product;
|
435 |
+
}
|
436 |
+
$campaign->addPushedProducts($pushedProducts);
|
437 |
+
}
|
438 |
+
|
439 |
+
$campaigns[] = $campaign;
|
440 |
+
}
|
441 |
+
}
|
442 |
+
$campaignIterator = FF::getInstance('campaignIterator', $campaigns);
|
443 |
+
return $campaignIterator;
|
444 |
+
}
|
445 |
+
|
446 |
+
/**
|
447 |
+
* @return array of FACTFinder_SuggestQuery objects
|
448 |
+
*/
|
449 |
+
protected function createSingleWordSearch() {
|
450 |
+
$xmlResult = $this->getData();
|
451 |
+
$singleWordSearch = array();
|
452 |
+
if (isset($xmlResult->singleWordSearch)) {
|
453 |
+
$encodingHandler = $this->getEncodingHandler();
|
454 |
+
foreach ($xmlResult->singleWordSearch->item AS $item) {
|
455 |
+
$query = $encodingHandler->encodeServerContentForPage(strval($item->attributes()->word));
|
456 |
+
$singleWordSearch[] = FF::getInstance('suggestQuery',
|
457 |
+
$query,
|
458 |
+
$this->getParamsParser()->createPageLink(array('query' => $query)),
|
459 |
+
intval(trim($item->attributes()->count))
|
460 |
+
);
|
461 |
+
}
|
462 |
+
}
|
463 |
+
return $singleWordSearch;
|
464 |
+
}
|
465 |
+
|
466 |
+
/**
|
467 |
+
* get error if there is one
|
468 |
+
*
|
469 |
+
* @return string if error exists, else null
|
470 |
+
*/
|
471 |
+
public function getError()
|
472 |
+
{
|
473 |
+
$error = null;
|
474 |
+
$xmlResult = $this->getData();
|
475 |
+
if (!empty($xmlResult->error)) {
|
476 |
+
$error = trim(strval($xmlResult->error));
|
477 |
+
}
|
478 |
+
return $error;
|
479 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
480 |
}
|
lib/FACTFinder/Xml65/SuggestAdapter.php
CHANGED
@@ -1,59 +1,65 @@
|
|
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 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Xml65
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* suggest adapter using the xml interface. expects a xml formated string from the dataprovider
|
12 |
+
*
|
13 |
+
* @author Rudolf Batt <rb@omikron.net>
|
14 |
+
* @version $Id: SuggestAdapter.php 25893 2010-06-29 08:19:43Z rb $
|
15 |
+
* @package FACTFinder\Xml65
|
16 |
+
*/
|
17 |
+
class FACTFinder_Xml65_SuggestAdapter extends FACTFinder_Http_SuggestAdapter
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* init
|
21 |
+
*/
|
22 |
+
protected function init()
|
23 |
+
{
|
24 |
+
parent::init();
|
25 |
+
$this->getDataProvider()->setParam('format', 'xml');
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* try to parse data as xml
|
30 |
+
*
|
31 |
+
* @throws Exception of data is no valid XML
|
32 |
+
* @return SimpleXMLElement
|
33 |
+
*/
|
34 |
+
protected function getData()
|
35 |
+
{
|
36 |
+
libxml_use_internal_errors(true);
|
37 |
+
return new SimpleXMLElement(parent::getData()); //throws exception on error
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* this implementation returns raw suggestions strings
|
42 |
+
*
|
43 |
+
* @return array of FACTFinder_SuggestQuery objects
|
44 |
+
*/
|
45 |
+
protected function createSuggestions()
|
46 |
+
{
|
47 |
+
$xmlResult = $this->getData();
|
48 |
+
$encodingHandler = $this->getEncodingHandler();
|
49 |
+
$paramsParser = $this->getParamsParser();
|
50 |
+
$suggest = array();
|
51 |
+
if (!empty($xmlResult)) {
|
52 |
+
foreach($xmlResult->suggest AS $xmlSuggestQuery) {
|
53 |
+
$query = strval($xmlSuggestQuery->attributes()->query);
|
54 |
+
$suggest[] = FF::getInstance('suggestQuery',
|
55 |
+
$encodingHandler->encodeServerContentForPage($query),
|
56 |
+
$paramsParser->createPageLink(array('query' => $query)),
|
57 |
+
strval($xmlSuggestQuery->attributes()->hitcount),
|
58 |
+
$encodingHandler->encodeServerContentForPage(strval($xmlSuggestQuery->attributes()->type)),
|
59 |
+
isset($xmlSuggestQuery->attributes()->hitcount) ? strval($xmlSuggestQuery->attributes()->hitcount) : ''
|
60 |
+
);
|
61 |
+
}
|
62 |
+
}
|
63 |
+
return $suggest;
|
64 |
+
}
|
65 |
}
|
lib/FACTFinder/Xml65/TagCloudAdapter.php
CHANGED
@@ -1,61 +1,64 @@
|
|
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 |
-
}
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Xml65
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* tag cloud adapter using the xml interface
|
12 |
+
*
|
13 |
+
* @author Rudolf Batt <rb@omikron.net>
|
14 |
+
* @version $Id: TagCloudAdapter.php 25893 2010-06-29 08:19:43Z rb $
|
15 |
+
* @package FACTFinder\Xml65
|
16 |
+
*/
|
17 |
+
class FACTFinder_Xml65_TagCloudAdapter extends FACTFinder_Abstract_TagCloudAdapter
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* @return void
|
21 |
+
**/
|
22 |
+
public function init()
|
23 |
+
{
|
24 |
+
$this->log->info("Initializing new tag cloud adapter.");
|
25 |
+
$this->getDataProvider()->setType('WhatsHot.ff');
|
26 |
+
$this->getDataProvider()->setParam('do', 'getTagCloud');
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* try to parse data as xml
|
31 |
+
*
|
32 |
+
* @throws Exception of data is no valid XML
|
33 |
+
* @return SimpleXMLElement
|
34 |
+
*/
|
35 |
+
protected function getData()
|
36 |
+
{
|
37 |
+
libxml_use_internal_errors(true);
|
38 |
+
return new SimpleXMLElement(parent::getData()); //throws exception on error
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @return array $tagCloud list of FACTFinder_TagQuery items
|
43 |
+
**/
|
44 |
+
protected function createTagCloud()
|
45 |
+
{
|
46 |
+
$tagCloud = array();
|
47 |
+
$xmlTagCloud = $this->getData();
|
48 |
+
if (!empty($xmlTagCloud)) {
|
49 |
+
$encodingHandler = $this->getEncodingHandler();
|
50 |
+
$ffparams = $this->getParamsParser()->getFactfinderParams();
|
51 |
+
foreach($xmlTagCloud->entry AS $xmlEntry) {
|
52 |
+
$query = $encodingHandler->encodeServerContentForPage(strval($xmlEntry));
|
53 |
+
$tagCloud[] = FF::getInstance('tagQuery',
|
54 |
+
$query,
|
55 |
+
$this->getParamsParser()->createPageLink(array('query' => $query)),
|
56 |
+
($ffparams->getQuery() == $query),
|
57 |
+
$xmlEntry->attributes()->weight,
|
58 |
+
$xmlEntry->attributes()->searchCount
|
59 |
+
);
|
60 |
+
}
|
61 |
+
}
|
62 |
+
return $tagCloud;
|
63 |
+
}
|
64 |
+
}
|
lib/FACTFinder/Xml66/CompareAdapter.php
CHANGED
@@ -1,4 +1,11 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
/**
|
4 |
* product comparison adapter using the xml interface
|
@@ -10,13 +17,11 @@
|
|
10 |
class FACTFinder_Xml66_CompareAdapter extends FACTFinder_Abstract_CompareAdapter
|
11 |
{
|
12 |
/**
|
13 |
-
* {@inheritdoc}
|
14 |
-
*
|
15 |
* @return void
|
16 |
**/
|
17 |
public function init() {
|
18 |
-
|
19 |
-
|
20 |
$this->getDataProvider()->setType('Compare.ff');
|
21 |
}
|
22 |
|
@@ -31,40 +36,36 @@ class FACTFinder_Xml66_CompareAdapter extends FACTFinder_Abstract_CompareAdapter
|
|
31 |
return new SimpleXMLElement(parent::getData()); //throws exception on error
|
32 |
}
|
33 |
|
34 |
-
|
35 |
-
* {@inheritdoc}
|
36 |
-
*
|
37 |
* @return array $comparableAttributes of strings (field names as keys, hasDifferences as values)
|
38 |
**/
|
39 |
protected function createComparableAttributes() {
|
40 |
-
|
41 |
$xmlComparableAttributes = $this->getData()->attributes;
|
42 |
if (!empty($xmlComparableAttributes)) {
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
}
|
48 |
return $comparableAttributes;
|
49 |
}
|
50 |
|
51 |
/**
|
52 |
-
* {@inheritdoc}
|
53 |
-
*
|
54 |
* @return array $comparedRecords list of FACTFinder_Record items
|
55 |
**/
|
56 |
protected function createComparedRecords() {
|
57 |
-
|
58 |
$xmlComparedRecords = $this->getData()->results;
|
59 |
if (!empty($xmlComparedRecords)) {
|
60 |
$encodingHandler = $this->getEncodingHandler();
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
foreach($xmlComparedRecords->record AS $currentRecord) {
|
69 |
// get current position
|
70 |
$position = $positionCounter;
|
@@ -74,9 +75,9 @@ class FACTFinder_Xml66_CompareAdapter extends FACTFinder_Abstract_CompareAdapter
|
|
74 |
$fieldValues = array();
|
75 |
foreach($currentRecord->field AS $current_field){
|
76 |
$currentFieldname = (string) $current_field->attributes()->name;
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
}
|
81 |
|
82 |
// get original position
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Xml66
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
|
10 |
/**
|
11 |
* product comparison adapter using the xml interface
|
17 |
class FACTFinder_Xml66_CompareAdapter extends FACTFinder_Abstract_CompareAdapter
|
18 |
{
|
19 |
/**
|
|
|
|
|
20 |
* @return void
|
21 |
**/
|
22 |
public function init() {
|
23 |
+
$this->log->info("Initializing new compare adapter.");
|
24 |
+
$this->getDataProvider()->setParam('format', 'xml');
|
25 |
$this->getDataProvider()->setType('Compare.ff');
|
26 |
}
|
27 |
|
36 |
return new SimpleXMLElement(parent::getData()); //throws exception on error
|
37 |
}
|
38 |
|
39 |
+
/**
|
|
|
|
|
40 |
* @return array $comparableAttributes of strings (field names as keys, hasDifferences as values)
|
41 |
**/
|
42 |
protected function createComparableAttributes() {
|
43 |
+
$comparableAttributes = array();
|
44 |
$xmlComparableAttributes = $this->getData()->attributes;
|
45 |
if (!empty($xmlComparableAttributes)) {
|
46 |
+
foreach($xmlComparableAttributes->attribute AS $currentAttribute){
|
47 |
+
$name = (string) $currentAttribute->attributes()->name;
|
48 |
+
$comparableAttributes[$name] = ((string) $currentAttribute->attributes()->hasDifferences == "true") ? true : false;
|
49 |
+
}
|
50 |
}
|
51 |
return $comparableAttributes;
|
52 |
}
|
53 |
|
54 |
/**
|
|
|
|
|
55 |
* @return array $comparedRecords list of FACTFinder_Record items
|
56 |
**/
|
57 |
protected function createComparedRecords() {
|
58 |
+
$comparedRecords = array();
|
59 |
$xmlComparedRecords = $this->getData()->results;
|
60 |
if (!empty($xmlComparedRecords)) {
|
61 |
$encodingHandler = $this->getEncodingHandler();
|
62 |
+
|
63 |
+
if($this->idsOnly && !$this->attributesUpToDate) {
|
64 |
+
$this->createComparableAttributes();
|
65 |
+
$this->attributesUpToDate = true;
|
66 |
+
}
|
67 |
+
|
68 |
+
$positionCounter = 1;
|
69 |
foreach($xmlComparedRecords->record AS $currentRecord) {
|
70 |
// get current position
|
71 |
$position = $positionCounter;
|
75 |
$fieldValues = array();
|
76 |
foreach($currentRecord->field AS $current_field){
|
77 |
$currentFieldname = (string) $current_field->attributes()->name;
|
78 |
+
if(!$this->idsOnly || array_key_exists($currentFieldname, $this->comparableAttributes)) {
|
79 |
+
$fieldValues[$currentFieldname] = (string) $current_field;
|
80 |
+
}
|
81 |
}
|
82 |
|
83 |
// get original position
|
lib/FACTFinder/Xml66/ImportAdapter.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Xml66
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* import adapter using the xml interface
|
12 |
+
*
|
13 |
+
* @author Rudolf Batt <rb@omikron.net>
|
14 |
+
* @version $Id: TagCloudAdapter.php 25893 2010-06-29 08:19:43Z rb $
|
15 |
+
* @package FACTFinder\Xml66
|
16 |
+
*/
|
17 |
+
class FACTFinder_Xml66_ImportAdapter extends FACTFinder_Xml65_ImportAdapter
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* no changes in FF6.6
|
21 |
+
**/
|
22 |
+
}
|
lib/FACTFinder/Xml66/RecommendationAdapter.php
CHANGED
@@ -1,15 +1,22 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
*
|
5 |
-
*
|
6 |
-
* @
|
7 |
-
* @
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Xml66
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* adapter for the factfinder recommendation engine, working with the XML interface of FF6.6
|
12 |
+
*
|
13 |
+
* @author Rudolf Batt <rb@omikron.net>
|
14 |
+
* @version $Id$
|
15 |
+
* @package FACTFinder\Xml66
|
16 |
+
*/
|
17 |
+
class FACTFinder_Xml66_RecommendationAdapter extends FACTFinder_Xml65_RecommendationAdapter
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* no changes in FF6.6
|
21 |
+
**/
|
22 |
+
}
|
lib/FACTFinder/Xml66/SearchAdapter.php
CHANGED
@@ -1,115 +1,120 @@
|
|
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 |
-
|
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 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Xml66
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* search adapter using the xml interface. expects a xml formated string from the dataprovider
|
12 |
+
*
|
13 |
+
* @author Rudolf Batt <rb@omikron.net>
|
14 |
+
* @version $Id: SearchAdapter.php 25985 2010-06-30 15:31:53Z rb $
|
15 |
+
* @package FACTFinder\Xml66
|
16 |
+
*/
|
17 |
+
class FACTFinder_Xml66_SearchAdapter extends FACTFinder_Xml65_SearchAdapter
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* create result object
|
21 |
+
**/
|
22 |
+
protected function createResult()
|
23 |
+
{
|
24 |
+
//init default values
|
25 |
+
$result = array();
|
26 |
+
$resultCount = 0;
|
27 |
+
$xmlResult = $this->getData();
|
28 |
+
|
29 |
+
//load result values from the xml element
|
30 |
+
if (!empty($xmlResult->results)) {
|
31 |
+
$resultCount = (int) $xmlResult->results->attributes()->count;
|
32 |
+
$encodingHandler = $this->getEncodingHandler();
|
33 |
+
|
34 |
+
$paging = $this->getPaging();
|
35 |
+
$positionOffset = ($paging->getCurrentPageNumber() - 1) * $this->getProductsPerPageOptions()->getSelectedOption()->getValue();
|
36 |
+
|
37 |
+
//load result
|
38 |
+
$positionCounter = 1;
|
39 |
+
foreach($xmlResult->results->record AS $rawRecord){
|
40 |
+
// get current position
|
41 |
+
$position = $positionOffset + $positionCounter;
|
42 |
+
$positionCounter++;
|
43 |
+
|
44 |
+
$result[] = $this->getRecordFromRawRecord($rawRecord, $position);
|
45 |
+
}
|
46 |
+
}
|
47 |
+
return FF::getInstance('result', $result, $resultCount);
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @return array of FACTFinder_SingleWordSearchItem objects
|
52 |
+
*/
|
53 |
+
protected function createSingleWordSearch()
|
54 |
+
{
|
55 |
+
$xmlResult = $this->getData();
|
56 |
+
$singleWordSearch = array();
|
57 |
+
if (isset($xmlResult->singleWordSearch)) {
|
58 |
+
$encodingHandler = $this->getEncodingHandler();
|
59 |
+
foreach ($xmlResult->singleWordSearch->item AS $item) {
|
60 |
+
$query = $encodingHandler->encodeServerContentForPage(strval($item->attributes()->word));
|
61 |
+
$singleWordSearchItem = FF::getInstance('singleWordSearchItem',
|
62 |
+
$query,
|
63 |
+
$this->getParamsParser()->createPageLink(array('query' => $query)),
|
64 |
+
intval(trim($item->attributes()->count))
|
65 |
+
);
|
66 |
+
|
67 |
+
//add preview records
|
68 |
+
if (isset($item->record)) {
|
69 |
+
$position = 1;
|
70 |
+
foreach($item->record AS $rawRecord) {
|
71 |
+
$record = $this->getRecordFromRawRecord($rawRecord, $position);
|
72 |
+
$singleWordSearchItem->addPreviewRecord($record);
|
73 |
+
$position++;
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
$singleWordSearch[] = $singleWordSearchItem;
|
78 |
+
}
|
79 |
+
}
|
80 |
+
return $singleWordSearch;
|
81 |
+
}
|
82 |
+
|
83 |
+
protected function getRecordFromRawRecord(SimpleXmlElement $rawRecord, $position)
|
84 |
+
{
|
85 |
+
// fetch record values
|
86 |
+
$fieldValues = array();
|
87 |
+
foreach($rawRecord->field AS $current_field){
|
88 |
+
$currentFieldname = (string) $current_field->attributes()->name;
|
89 |
+
$fieldValues[$currentFieldname] = (string) $current_field;
|
90 |
+
}
|
91 |
+
|
92 |
+
// get original position
|
93 |
+
if (isset($fieldValues['__ORIG_POSITION__'])) {
|
94 |
+
$origPosition = $fieldValues['__ORIG_POSITION__'];
|
95 |
+
unset($fieldValues['__ORIG_POSITION__']);
|
96 |
+
} else {
|
97 |
+
$origPosition = $position;
|
98 |
+
}
|
99 |
+
|
100 |
+
$record = FF::getInstance('record',
|
101 |
+
$rawRecord->attributes()->id,
|
102 |
+
floatval($rawRecord->attributes()->relevancy),
|
103 |
+
$position,
|
104 |
+
$origPosition,
|
105 |
+
$this->getEncodingHandler()->encodeServerContentForPage($fieldValues)
|
106 |
+
);
|
107 |
+
|
108 |
+
if (isset($rawRecord->seoPath)) {
|
109 |
+
$record->setSeoPath(strval($rawRecord->seoPath));
|
110 |
+
}
|
111 |
+
|
112 |
+
if (isset($rawRecord->keywords)) {
|
113 |
+
foreach($rawRecord->keywords->keyword AS $keyword) {
|
114 |
+
$record->addKeyword(strval($keyword));
|
115 |
+
}
|
116 |
+
}
|
117 |
+
|
118 |
+
return $record;
|
119 |
+
}
|
120 |
}
|
lib/FACTFinder/Xml66/SimilarRecordsAdapter.php
CHANGED
@@ -1,4 +1,11 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
/**
|
4 |
* similar records adapter using the xml interface
|
@@ -10,13 +17,11 @@
|
|
10 |
class FACTFinder_Xml66_SimilarRecordsAdapter extends FACTFinder_Abstract_SimilarRecordsAdapter
|
11 |
{
|
12 |
/**
|
13 |
-
* {@inheritdoc}
|
14 |
-
*
|
15 |
* @return void
|
16 |
**/
|
17 |
public function init() {
|
18 |
-
|
19 |
-
|
20 |
$this->getDataProvider()->setType('SimilarRecords.ff');
|
21 |
}
|
22 |
|
@@ -30,15 +35,13 @@ class FACTFinder_Xml66_SimilarRecordsAdapter extends FACTFinder_Abstract_Similar
|
|
30 |
libxml_use_internal_errors(true);
|
31 |
return new SimpleXMLElement(parent::getData()); //throws exception on error
|
32 |
}
|
33 |
-
|
34 |
-
|
35 |
libxml_use_internal_errors(true);
|
36 |
return new SimpleXMLElement(parent::reloadData()); //throws exception on error
|
37 |
}
|
38 |
-
|
39 |
-
|
40 |
-
* {@inheritdoc}
|
41 |
-
*
|
42 |
* @param string id of the product which should be used to get similar attributes
|
43 |
* @return array $similarAttributes of strings (field names as keys)
|
44 |
**/
|
@@ -46,17 +49,15 @@ class FACTFinder_Xml66_SimilarRecordsAdapter extends FACTFinder_Abstract_Similar
|
|
46 |
$similarAttributes = array();
|
47 |
$xmlSimilarAttributes = $this->reloadData()->similarAttributes;
|
48 |
if (!empty($xmlSimilarAttributes)) {
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
}
|
54 |
return $similarAttributes;
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
-
* {@inheritdoc}
|
59 |
-
*
|
60 |
* @param string id of the product which should be used to get similar records
|
61 |
* @return array $similarRecords list of FACTFinder_Record items
|
62 |
**/
|
@@ -65,18 +66,18 @@ class FACTFinder_Xml66_SimilarRecordsAdapter extends FACTFinder_Abstract_Similar
|
|
65 |
$xmlSimilarRecords = $this->reloadData()->similarRecords;
|
66 |
if (!empty($xmlSimilarRecords)) {
|
67 |
$encodingHandler = $this->getEncodingHandler();
|
68 |
-
|
69 |
-
|
70 |
foreach($xmlSimilarRecords->record AS $currentRecord) {
|
71 |
// get current position
|
72 |
$position = $positionCounter;
|
73 |
$positionCounter++;
|
74 |
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
// fetch record values
|
81 |
$fieldValues = array();
|
82 |
foreach($currentRecord->field AS $current_field){
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Xml66
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
|
10 |
/**
|
11 |
* similar records adapter using the xml interface
|
17 |
class FACTFinder_Xml66_SimilarRecordsAdapter extends FACTFinder_Abstract_SimilarRecordsAdapter
|
18 |
{
|
19 |
/**
|
|
|
|
|
20 |
* @return void
|
21 |
**/
|
22 |
public function init() {
|
23 |
+
$this->log->info("Initializing new similar records adapter.");
|
24 |
+
$this->getDataProvider()->setParam('format', 'xml');
|
25 |
$this->getDataProvider()->setType('SimilarRecords.ff');
|
26 |
}
|
27 |
|
35 |
libxml_use_internal_errors(true);
|
36 |
return new SimpleXMLElement(parent::getData()); //throws exception on error
|
37 |
}
|
38 |
+
|
39 |
+
protected function reloadData() {
|
40 |
libxml_use_internal_errors(true);
|
41 |
return new SimpleXMLElement(parent::reloadData()); //throws exception on error
|
42 |
}
|
43 |
+
|
44 |
+
/**
|
|
|
|
|
45 |
* @param string id of the product which should be used to get similar attributes
|
46 |
* @return array $similarAttributes of strings (field names as keys)
|
47 |
**/
|
49 |
$similarAttributes = array();
|
50 |
$xmlSimilarAttributes = $this->reloadData()->similarAttributes;
|
51 |
if (!empty($xmlSimilarAttributes)) {
|
52 |
+
foreach($xmlSimilarAttributes->attribute AS $currentAttribute){
|
53 |
+
$currentAttribute = (string) $currentAttribute->attributes()->name;
|
54 |
+
$similarAttributes[$currentAttribute] = (string) $currentAttribute;
|
55 |
+
}
|
56 |
}
|
57 |
return $similarAttributes;
|
58 |
}
|
59 |
|
60 |
/**
|
|
|
|
|
61 |
* @param string id of the product which should be used to get similar records
|
62 |
* @return array $similarRecords list of FACTFinder_Record items
|
63 |
**/
|
66 |
$xmlSimilarRecords = $this->reloadData()->similarRecords;
|
67 |
if (!empty($xmlSimilarRecords)) {
|
68 |
$encodingHandler = $this->getEncodingHandler();
|
69 |
+
|
70 |
+
$positionCounter = 1;
|
71 |
foreach($xmlSimilarRecords->record AS $currentRecord) {
|
72 |
// get current position
|
73 |
$position = $positionCounter;
|
74 |
$positionCounter++;
|
75 |
|
76 |
+
if ($this->idsOnly) {
|
77 |
+
$similarRecords[] = FF::getInstance('record', $currentRecord->attributes()->id);
|
78 |
+
continue;
|
79 |
+
}
|
80 |
+
|
81 |
// fetch record values
|
82 |
$fieldValues = array();
|
83 |
foreach($currentRecord->field AS $current_field){
|
lib/FACTFinder/Xml66/SuggestAdapter.php
CHANGED
@@ -1,15 +1,22 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
*
|
5 |
-
*
|
6 |
-
* @
|
7 |
-
* @
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Xml66
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* suggest adapter using the xml interface. expects a xml formated string from the dataprovider
|
12 |
+
*
|
13 |
+
* @author Rudolf Batt <rb@omikron.net>
|
14 |
+
* @version $Id: SuggestAdapter.php 25893 2010-06-29 08:19:43Z rb $
|
15 |
+
* @package FACTFinder\Xml66
|
16 |
+
*/
|
17 |
+
class FACTFinder_Xml66_SuggestAdapter extends FACTFinder_Xml65_SuggestAdapter
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* there are no special new features in FF6.6
|
21 |
+
*/
|
22 |
}
|
lib/FACTFinder/Xml66/TagCloudAdapter.php
CHANGED
@@ -1,15 +1,22 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
*
|
5 |
-
*
|
6 |
-
* @
|
7 |
-
* @
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Xml66
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* tag cloud adapter using the xml interface
|
12 |
+
*
|
13 |
+
* @author Rudolf Batt <rb@omikron.net>
|
14 |
+
* @version $Id: TagCloudAdapter.php 25893 2010-06-29 08:19:43Z rb $
|
15 |
+
* @package FACTFinder\Xml66
|
16 |
+
*/
|
17 |
+
class FACTFinder_Xml66_TagCloudAdapter extends FACTFinder_Xml65_TagCloudAdapter
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* no changes in FF6.6
|
21 |
+
**/
|
22 |
+
}
|
lib/FACTFinder/Xml67/CompareAdapter.php
CHANGED
@@ -1,4 +1,11 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
/**
|
4 |
* product comparison adapter using the xml interface
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Xml67
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
|
10 |
/**
|
11 |
* product comparison adapter using the xml interface
|
lib/FACTFinder/Xml67/ImportAdapter.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Xml67
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* import adapter using the xml interface
|
12 |
+
*
|
13 |
+
* @author Rudolf Batt <rb@omikron.net>
|
14 |
+
* @version $Id: TagCloudAdapter.php 25893 2010-06-29 08:19:43Z rb $
|
15 |
+
* @package FACTFinder\Xml67
|
16 |
+
*/
|
17 |
+
class FACTFinder_Xml67_ImportAdapter extends FACTFinder_Xml66_ImportAdapter
|
18 |
+
{
|
19 |
+
}
|
lib/FACTFinder/Xml67/ProductCampaignAdapter.php
CHANGED
@@ -1,4 +1,11 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
/**
|
4 |
* product campaign adapter using the xml interface
|
@@ -10,18 +17,16 @@
|
|
10 |
class FACTFinder_Xml67_ProductCampaignAdapter extends FACTFinder_Abstract_ProductCampaignAdapter
|
11 |
{
|
12 |
protected $xmlData = null;
|
13 |
-
|
14 |
/**
|
15 |
-
* {@inheritdoc}
|
16 |
-
*
|
17 |
* @return void
|
18 |
**/
|
19 |
public function init()
|
20 |
{
|
21 |
-
|
22 |
$this->getDataProvider()->setType('ProductCampaign.ff');
|
23 |
$this->getDataProvider()->setParam('format', 'xml');
|
24 |
-
|
25 |
}
|
26 |
|
27 |
/**
|
@@ -39,21 +44,19 @@ class FACTFinder_Xml67_ProductCampaignAdapter extends FACTFinder_Abstract_Produc
|
|
39 |
}
|
40 |
return $this->xmlData;
|
41 |
}
|
42 |
-
|
43 |
-
|
44 |
-
* {@inheritdoc}
|
45 |
-
*
|
46 |
* @return array of FACTFinder_Campaign objects
|
47 |
*/
|
48 |
protected function createCampaigns()
|
49 |
{
|
50 |
$campaigns = array();
|
51 |
$xmlResult = $this->getData();
|
52 |
-
|
53 |
if (!empty($xmlResult->campaigns)) {
|
54 |
$encodingHandler = $this->getEncodingHandler();
|
55 |
-
|
56 |
-
|
57 |
foreach ($xmlResult->campaigns->campaign AS $xmlCampaign) {
|
58 |
//get redirect
|
59 |
$redirectUrl = '';
|
@@ -68,64 +71,64 @@ class FACTFinder_Xml67_ProductCampaignAdapter extends FACTFinder_Abstract_Produc
|
|
68 |
);
|
69 |
|
70 |
// get feedback
|
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 |
$campaigns[] = $campaign;
|
131 |
}
|
@@ -133,29 +136,29 @@ class FACTFinder_Xml67_ProductCampaignAdapter extends FACTFinder_Abstract_Produc
|
|
133 |
$campaignIterator = FF::getInstance('campaignIterator', $campaigns);
|
134 |
return $campaignIterator;
|
135 |
}
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
}
|
161 |
-
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Xml67
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
|
10 |
/**
|
11 |
* product campaign adapter using the xml interface
|
17 |
class FACTFinder_Xml67_ProductCampaignAdapter extends FACTFinder_Abstract_ProductCampaignAdapter
|
18 |
{
|
19 |
protected $xmlData = null;
|
20 |
+
|
21 |
/**
|
|
|
|
|
22 |
* @return void
|
23 |
**/
|
24 |
public function init()
|
25 |
{
|
26 |
+
$this->log->info("Initializing new product campaign adapter.");
|
27 |
$this->getDataProvider()->setType('ProductCampaign.ff');
|
28 |
$this->getDataProvider()->setParam('format', 'xml');
|
29 |
+
$this->getDataProvider()->setParam('do', 'getProductCampaigns');
|
30 |
}
|
31 |
|
32 |
/**
|
44 |
}
|
45 |
return $this->xmlData;
|
46 |
}
|
47 |
+
|
48 |
+
/**
|
|
|
|
|
49 |
* @return array of FACTFinder_Campaign objects
|
50 |
*/
|
51 |
protected function createCampaigns()
|
52 |
{
|
53 |
$campaigns = array();
|
54 |
$xmlResult = $this->getData();
|
55 |
+
|
56 |
if (!empty($xmlResult->campaigns)) {
|
57 |
$encodingHandler = $this->getEncodingHandler();
|
58 |
+
$paramsParser = $this->getParamsParser();
|
59 |
+
|
60 |
foreach ($xmlResult->campaigns->campaign AS $xmlCampaign) {
|
61 |
//get redirect
|
62 |
$redirectUrl = '';
|
71 |
);
|
72 |
|
73 |
// get feedback
|
74 |
+
|
75 |
+
if ($xmlCampaign->attributes()->flavour == 'FEEDBACK') {
|
76 |
+
|
77 |
+
// here is the new feature: getting feedback texts from labels instead of number indices, if available
|
78 |
+
if (!empty($xmlCampaign->feedback)) {
|
79 |
+
$feedback = array();
|
80 |
+
foreach ($xmlCampaign->feedback->text as $text) {
|
81 |
+
if(isset($text->attributes()->label)) {
|
82 |
+
$label = trim($text->attributes()->label);
|
83 |
+
} else {
|
84 |
+
$label = trim($text->attributes()->nr);
|
85 |
+
}
|
86 |
+
$feedback[$label] = $encodingHandler->encodeServerContentForPage((string)$text);
|
87 |
+
}
|
88 |
+
$campaign->addFeedback($feedback);
|
89 |
+
}
|
90 |
|
91 |
+
//get pushed products
|
92 |
+
if (!empty($xmlCampaign->pushedProducts)) {
|
93 |
+
$pushedProducts = array();
|
94 |
+
foreach ($xmlCampaign->pushedProducts->product AS $xmlProduct) {
|
95 |
+
$product = FF::getInstance('record', $xmlProduct->attributes()->id, 100);
|
96 |
|
97 |
+
// fetch product values
|
98 |
+
$fieldValues = array();
|
99 |
+
foreach($xmlProduct->field AS $current_field){
|
100 |
+
$currentFieldname = (string) $current_field->attributes()->name;
|
101 |
+
$fieldValues[$currentFieldname] = (string) $current_field;
|
102 |
+
}
|
103 |
+
$product->setValues($encodingHandler->encodeServerContentForPage($fieldValues));
|
104 |
+
$pushedProducts[] = $product;
|
105 |
+
}
|
106 |
+
$campaign->addPushedProducts($pushedProducts);
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
//get advisor
|
111 |
+
if ($xmlCampaign->attributes()->flavour == 'ADVISOR') {
|
112 |
+
$activeQuestions = array();
|
113 |
+
|
114 |
+
// The active questions can still be empty if we have already moved down the whole question tree (while the search query still fulfills the campaign condition)
|
115 |
+
if (!empty($xmlCampaign->advisor->activeQuestions)) {
|
116 |
+
foreach($xmlCampaign->advisor->activeQuestions->question AS $xmlQuestion) {
|
117 |
+
$activeQuestions[] = $this->loadAdvisorQuestion($xmlQuestion);
|
118 |
+
}
|
119 |
+
}
|
120 |
+
$campaign->addActiveQuestions($activeQuestions);
|
121 |
+
|
122 |
+
// Fetch advisor tree if it exists
|
123 |
+
$advisorTree = array();
|
124 |
+
|
125 |
+
if (!empty($xmlCampaign->advisor->advisorTree)) {
|
126 |
+
foreach($xmlCampaign->advisor->advisorTree->question AS $xmlQuestion) {
|
127 |
+
$advisorTree[] = $this->loadAdvisorQuestion($xmlQuestion, true);
|
128 |
+
}
|
129 |
+
}
|
130 |
+
$campaign->addToAdvisorTree($advisorTree);
|
131 |
+
}
|
132 |
|
133 |
$campaigns[] = $campaign;
|
134 |
}
|
136 |
$campaignIterator = FF::getInstance('campaignIterator', $campaigns);
|
137 |
return $campaignIterator;
|
138 |
}
|
139 |
+
|
140 |
+
protected function loadAdvisorQuestion($xmlQuestion, $recursive = false) {
|
141 |
+
$encodingHandler = $this->getEncodingHandler();
|
142 |
+
$paramsParser = $this->getParamsParser();
|
143 |
+
|
144 |
+
$answers = array();
|
145 |
+
|
146 |
+
// Fetch answers. Follow-up questions are ignored here.
|
147 |
+
foreach($xmlQuestion->answer AS $xmlAnswer) {
|
148 |
+
$text = $encodingHandler->encodeServerContentForPage((string)$xmlAnswer->text);
|
149 |
+
$params = $paramsParser->createPageLink($paramsParser->parseParamsFromResultString($xmlAnswer->params));
|
150 |
+
$subquestions = array();
|
151 |
+
if ($recursive) {
|
152 |
+
foreach($xmlAnswer->question AS $xmlSubquestion) {
|
153 |
+
$subquestions[] = $this->loadAdvisorQuestion($xmlSubquestion, true);
|
154 |
+
}
|
155 |
+
}
|
156 |
+
$answer = FF::getInstance('advisorAnswer', $text, $params, $subquestions);
|
157 |
+
$answers[] = $answer;
|
158 |
+
}
|
159 |
+
|
160 |
+
return FF::getInstance('advisorQuestion', $encodingHandler->encodeServerContentForPage((string)$xmlQuestion->text), $answers);
|
161 |
+
}
|
162 |
+
|
163 |
}
|
164 |
+
|
lib/FACTFinder/Xml67/RecommendationAdapter.php
CHANGED
@@ -1,4 +1,11 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
/**
|
4 |
* adapter for the factfinder recommendation engine, working with the XML interface of FF6.7
|
@@ -9,25 +16,25 @@
|
|
9 |
*/
|
10 |
class FACTFinder_Xml67_RecommendationAdapter extends FACTFinder_Xml66_RecommendationAdapter
|
11 |
{
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
}
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Xml67
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
|
10 |
/**
|
11 |
* adapter for the factfinder recommendation engine, working with the XML interface of FF6.7
|
16 |
*/
|
17 |
class FACTFinder_Xml67_RecommendationAdapter extends FACTFinder_Xml66_RecommendationAdapter
|
18 |
{
|
19 |
+
/**
|
20 |
+
* Set ids of products to base recommendation on
|
21 |
+
*
|
22 |
+
* @param array $productIds list of integers
|
23 |
+
**/
|
24 |
+
public function setProductIds($productIds) {
|
25 |
+
$this->productIds = $productIds;
|
26 |
+
$this->getDataProvider()->setArrayParam('id', $productIds);
|
27 |
+
$this->recommendationUpToDate = false;
|
28 |
+
}
|
29 |
|
30 |
+
/**
|
31 |
+
* Adds an id to the list of products to base recommendation on
|
32 |
+
*
|
33 |
+
* @param int $productId
|
34 |
+
**/
|
35 |
+
public function addProductId($productId) {
|
36 |
+
$this->productIds[] = $productId;
|
37 |
+
$this->getDataProvider()->setArrayParam('id', $this->productIds);
|
38 |
+
$this->recommendationUpToDate = false;
|
39 |
+
}
|
40 |
}
|
lib/FACTFinder/Xml67/SearchAdapter.php
CHANGED
@@ -1,4 +1,11 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
/**
|
4 |
* search adapter using the xml interface. expects a xml formated string from the dataprovider
|
@@ -10,8 +17,6 @@
|
|
10 |
class FACTFinder_Xml67_SearchAdapter extends FACTFinder_Xml66_SearchAdapter
|
11 |
{
|
12 |
/**
|
13 |
-
* {@inheritdoc}
|
14 |
-
*
|
15 |
* @return array of FACTFinder_Campaign objects
|
16 |
*/
|
17 |
protected function createCampaigns()
|
@@ -21,8 +26,8 @@ class FACTFinder_Xml67_SearchAdapter extends FACTFinder_Xml66_SearchAdapter
|
|
21 |
|
22 |
if (!empty($xmlResult->campaigns)) {
|
23 |
$encodingHandler = $this->getEncodingHandler();
|
24 |
-
|
25 |
-
|
26 |
foreach ($xmlResult->campaigns->campaign AS $xmlCampaign) {
|
27 |
//get redirect
|
28 |
$redirectUrl = '';
|
@@ -37,64 +42,64 @@ class FACTFinder_Xml67_SearchAdapter extends FACTFinder_Xml66_SearchAdapter
|
|
37 |
);
|
38 |
|
39 |
// get feedback
|
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 |
$campaigns[] = $campaign;
|
100 |
}
|
@@ -102,27 +107,27 @@ class FACTFinder_Xml67_SearchAdapter extends FACTFinder_Xml66_SearchAdapter
|
|
102 |
$campaignIterator = FF::getInstance('campaignIterator', $campaigns);
|
103 |
return $campaignIterator;
|
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 |
}
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Xml67
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
|
10 |
/**
|
11 |
* search adapter using the xml interface. expects a xml formated string from the dataprovider
|
17 |
class FACTFinder_Xml67_SearchAdapter extends FACTFinder_Xml66_SearchAdapter
|
18 |
{
|
19 |
/**
|
|
|
|
|
20 |
* @return array of FACTFinder_Campaign objects
|
21 |
*/
|
22 |
protected function createCampaigns()
|
26 |
|
27 |
if (!empty($xmlResult->campaigns)) {
|
28 |
$encodingHandler = $this->getEncodingHandler();
|
29 |
+
$paramsParser = $this->getParamsParser();
|
30 |
+
|
31 |
foreach ($xmlResult->campaigns->campaign AS $xmlCampaign) {
|
32 |
//get redirect
|
33 |
$redirectUrl = '';
|
42 |
);
|
43 |
|
44 |
// get feedback
|
45 |
+
|
46 |
+
if ($xmlCampaign->attributes()->flavour == 'FEEDBACK') {
|
47 |
+
|
48 |
+
// here is the new feature: getting feedback texts from labels instead of number indices, if available
|
49 |
+
if (!empty($xmlCampaign->feedback)) {
|
50 |
+
$feedback = array();
|
51 |
+
foreach ($xmlCampaign->feedback->text as $text) {
|
52 |
+
if(isset($text->attributes()->label)) {
|
53 |
+
$label = trim($text->attributes()->label);
|
54 |
+
} else {
|
55 |
+
$label = trim($text->attributes()->nr);
|
56 |
+
}
|
57 |
+
$feedback[$label] = $encodingHandler->encodeServerContentForPage((string)$text);
|
58 |
+
}
|
59 |
+
$campaign->addFeedback($feedback);
|
60 |
+
}
|
61 |
|
62 |
+
//get pushed products
|
63 |
+
if (!empty($xmlCampaign->pushedProducts)) {
|
64 |
+
$pushedProducts = array();
|
65 |
+
foreach ($xmlCampaign->pushedProducts->product AS $xmlProduct) {
|
66 |
+
$product = FF::getInstance('record', $xmlProduct->attributes()->id, 100);
|
67 |
|
68 |
+
// fetch product values
|
69 |
+
$fieldValues = array();
|
70 |
+
foreach($xmlProduct->field AS $current_field){
|
71 |
+
$currentFieldname = (string) $current_field->attributes()->name;
|
72 |
+
$fieldValues[$currentFieldname] = (string) $current_field;
|
73 |
+
}
|
74 |
+
$product->setValues($encodingHandler->encodeServerContentForPage($fieldValues));
|
75 |
+
$pushedProducts[] = $product;
|
76 |
+
}
|
77 |
+
$campaign->addPushedProducts($pushedProducts);
|
78 |
+
}
|
79 |
+
}
|
80 |
+
|
81 |
+
//get advisor
|
82 |
+
if ($xmlCampaign->attributes()->flavour == 'ADVISOR') {
|
83 |
+
$activeQuestions = array();
|
84 |
+
|
85 |
+
// The active questions can still be empty if we have already moved down the whole question tree (while the search query still fulfills the campaign condition)
|
86 |
+
if (!empty($xmlCampaign->advisor->activeQuestions)) {
|
87 |
+
foreach($xmlCampaign->advisor->activeQuestions->question AS $xmlQuestion) {
|
88 |
+
$activeQuestions[] = $this->loadAdvisorQuestion($xmlQuestion);
|
89 |
+
}
|
90 |
+
}
|
91 |
+
$campaign->addActiveQuestions($activeQuestions);
|
92 |
+
|
93 |
+
// Fetch advisor tree if it exists
|
94 |
+
$advisorTree = array();
|
95 |
+
|
96 |
+
if (!empty($xmlCampaign->advisor->advisorTree)) {
|
97 |
+
foreach($xmlCampaign->advisor->advisorTree->question AS $xmlQuestion) {
|
98 |
+
$advisorTree[] = $this->loadAdvisorQuestion($xmlQuestion, true);
|
99 |
+
}
|
100 |
+
}
|
101 |
+
$campaign->addToAdvisorTree($advisorTree);
|
102 |
+
}
|
103 |
|
104 |
$campaigns[] = $campaign;
|
105 |
}
|
107 |
$campaignIterator = FF::getInstance('campaignIterator', $campaigns);
|
108 |
return $campaignIterator;
|
109 |
}
|
110 |
+
|
111 |
+
protected function loadAdvisorQuestion($xmlQuestion, $recursive = false) {
|
112 |
+
$encodingHandler = $this->getEncodingHandler();
|
113 |
+
$paramsParser = $this->getParamsParser();
|
114 |
+
|
115 |
+
$answers = array();
|
116 |
+
|
117 |
+
// Fetch answers. Follow-up questions are ignored here.
|
118 |
+
foreach($xmlQuestion->answer AS $xmlAnswer) {
|
119 |
+
$text = $encodingHandler->encodeServerContentForPage((string)$xmlAnswer->text);
|
120 |
+
$params = $paramsParser->createPageLink($paramsParser->parseParamsFromResultString($xmlAnswer->params));
|
121 |
+
$subquestions = array();
|
122 |
+
if ($recursive) {
|
123 |
+
foreach($xmlAnswer->question AS $xmlSubquestion) {
|
124 |
+
$subquestions[] = $this->loadAdvisorQuestion($xmlSubquestion, true);
|
125 |
+
}
|
126 |
+
}
|
127 |
+
$answer = FF::getInstance('advisorAnswer', $text, $params, $subquestions);
|
128 |
+
$answers[] = $answer;
|
129 |
+
}
|
130 |
+
|
131 |
+
return FF::getInstance('advisorQuestion', $encodingHandler->encodeServerContentForPage((string)$xmlQuestion->text), $answers);
|
132 |
+
}
|
133 |
}
|
lib/FACTFinder/Xml67/SimilarRecordsAdapter.php
CHANGED
@@ -1,4 +1,11 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
/**
|
4 |
* similar records adapter using the xml interface
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Xml67
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
|
10 |
/**
|
11 |
* similar records adapter using the xml interface
|
lib/FACTFinder/Xml67/SuggestAdapter.php
CHANGED
@@ -1,4 +1,11 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
/**
|
4 |
* suggest adapter using the xml interface. expects a xml formated string from the dataprovider
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Xml67
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
|
10 |
/**
|
11 |
* suggest adapter using the xml interface. expects a xml formated string from the dataprovider
|
lib/FACTFinder/Xml67/TagCloudAdapter.php
CHANGED
@@ -1,4 +1,11 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
/**
|
4 |
* tag cloud adapter using the xml interface
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* FACT-Finder PHP Framework
|
4 |
+
*
|
5 |
+
* @category Library
|
6 |
+
* @package FACTFinder\Xml67
|
7 |
+
* @copyright Copyright (c) 2012 Omikron Data Quality GmbH (www.omikron.net)
|
8 |
+
*/
|
9 |
|
10 |
/**
|
11 |
* tag cloud adapter using the xml interface
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Flagbit_Factfinder</name>
|
4 |
-
<version>3.3.
|
5 |
<stability>stable</stability>
|
6 |
<license>GPL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Integrates the FACT-Finder for improved product search functionality.</summary>
|
10 |
<description>Integrates the FACT-Finder for improved product search functionality.</description>
|
11 |
-
<notes>feature: FACT-Finder
|
12 |
<authors><author><name>Rudolf Batt</name><user>rbatt</user><email>rb@omikron.net</email></author></authors>
|
13 |
-
<date>2012-08-
|
14 |
-
<time>
|
15 |
-
<contents><target name="magecommunity"><dir name="Flagbit"><dir name="FactFinder"><dir name="Block"><dir name="Adminhtml"><file name="Cockpit.php" hash="7f5f3e8521f002c8c7b5a2d5f72cf5e1"/><file name="Exportlink.php" hash="f83a083279cec4d1e3fece4bbb94263e"/><dir name="Form"><dir name="Field"><file name="Attribute.php" hash="2e60d7473163fa523f10b2d0c441fe24"/><file name="Attributes.php" hash="cbaf317aa5ce4417cfcd02a6c4f36486"/></dir></dir></dir><dir name="Campaign"><file name="Advisory.php" hash="9eb34869abbc7e4ba4fe3825835793eb"/><dir name="Cart"><file name="Advisory.php" hash="9861e5ff8bb10fdec38d17bc9f61090a"/><file name="Feedback.php" hash="aa9239e92f528ff6b216942194f36776"/></dir><file name="Feedback.php" hash="ffb877d1e9cb5e7fb7b9d5731a8ace56"/><dir name="Product"><file name="Advisory.php" hash="d4736ab3436e7966c37b393a339110ca"/><file name="Feedback.php" hash="7843ed6669b7e6bdd92934b3aeb2fd41"/></dir></dir><dir name="Cart"><file name="Crosssell.php" hash="73e43a5c9048a1d139910dc7a2199952"/></dir><dir name="Filter"><file name="Slider.php" hash="159d3e1b403625dbbb970e5e7ada4ec7"/></dir><dir name="Layer"><file name="Abstract.php" hash="f53a3e2d6ce0da4afee58b4ea806a342"/></dir><file name="Layer.php" hash="fc9ae3f5197a73be5951a420d4b27124"/><dir name="Product"><dir name="List"><file name="Crosssell.php" hash="8b6936aa661cd77a1866da3bc2a40939"/><file name="Upsell.php" hash="5b09dab3ad5acfc213716b88d1f8ca43"/></dir></dir><file name="Scic.php" hash="9ba6aa43204d0aae206d9f24f09aecfc"/><file name="TagCloud.php" hash="664c18eceaa82779a60b6eb1694cdfca"/><dir name="XmlConnect"><dir name="Catalog"><dir name="Product"><file name="List.php" hash="79103c53bbaa03f02ed8a78554dcc791"/></dir><dir name="Search"><file name="Suggest.php" hash="5c7ef36939885a14ee0644cbb91a945d"/></dir><file name="Search.php" hash="662f7b0df8d21626bf6193906aed5162"/></dir></dir></dir><dir name="Helper"><file name="Backend.php" hash="57771ad274e7e0ea63b9a934b3757f04"/><file name="Data.php" hash="afede9edaf2bcfbc93a4049eee5be89e"/><file name="Debug.php" hash="0e35720a3c3fea9d4d2feece970e6ab0"/><file name="Search.php" hash="8e043ec61152a91d78361e73d7679f9d"/></dir><dir name="Model"><file name="Adapter.php" hash="c6c6b62e23feb9ce51eb972accf44696"/><dir name="Export"><file name="Price.php" hash="5561605bf639385c211f339f0c752a0f"/><file name="Product.php" hash="48ab88e730df3d3b30bf9f9fcf8cdb26"/><file name="Stock.php" hash="28e819f8f317957a70a7d4d318e04791"/></dir><dir name="Layer"><file name="Abstract.php" hash="0a0505e719ca55320da35c7510b82d3a"/><dir name="Filter"><dir name="Attribute"><file name="Abstract.php" hash="2ad710352f1803d15ba056cd93d519f1"/><file name="Catalog.php" hash="f6dce5ea64da9dfb3458ae9ff4b58a7b"/><file name="Catalogsearch.php" hash="75536576aaaa0186f166550ee746ae04"/></dir><file name="Item.php" hash="28e42624d764342dae6cb09a1b29b7b8"/></dir></dir><file name="Layer.php" hash="9da16c44259b4a31d73f63d87787ff11"/><dir name="Mysql4"><dir name="Campaign"><dir name="Pushedproducts"><file name="Collection.php" hash="c966a40c7569b70cef93e47781b95190"/></dir></dir><dir name="Product"><dir name="Attribute"><file name="Collection.php" hash="d9000f3e9c709fa63313b15f34803d74"/></dir><dir name="Recommendation"><file name="Collection.php" hash="fdb6f35fa1cca09aa405bc5cd0c68601"/></dir></dir><dir name="Scic"><dir name="Queue"><file name="Collection.php" hash="5f6b0b6a50838929065ebd941cedce42"/></dir><file name="Queue.php" hash="a1521000a1a10df8e6b580f33d06cf23"/></dir><dir name="Search"><file name="Collection.php" hash="12356224ac22113428b38120a1a002a6"/><file name="Engine.php" hash="88a56eb3b4587d87bb1152476b64036e"/></dir></dir><file name="Observer.php" hash="5478ee05a85d5c502211c66eab3f6190"/><file name="Processor.php" hash="1a48223d1208215013f314a5439b3028"/><dir name="Scic"><file name="Queue.php" hash="828d391339a22c15ad74ae1a2e784b41"/></dir><dir name="System"><dir name="Config"><dir name="Backend"><file name="Attributes.php" hash="8259883090dc4bca9b858d047983e736"/><file name="Enabled.php" hash="3b4d1f4b37d7ddba9768a7da6e3fc778"/></dir><dir name="Source"><file name="Authtype.php" hash="5bc0b1c745782cc51d44d56299059bcb"/><file name="Ffversion.php" hash="41ef9c853705c0777d9a2b7d2f3624ad"/><file name="Identifier.php" hash="cec45238f0e28a1bf66d10dee513c2ca"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Factfinder"><file name="CockpitController.php" hash="4c8665feaf14c38e6ba2384db496c95a"/></dir></dir><file name="ExportController.php" hash="01a45ff00a9b5a95ae397fd555507592"/><file name="ProxyController.php" hash="587f159bad384600c724568a61546b66"/></dir><dir name="documentation"><file name="Installation_FACT-Finder_Magento_de.pdf" hash="b4711171c625caaa8996a6a09e0eaaae"/><file name="Installation_FACT-Finder_Magento_en.pdf" hash="d4bef19418ee33a223fbda2d45cca686"/></dir><dir name="etc"><file name="adminhtml.xml" hash="1165a0fecfaa31f2aa4a882d1d8bc033"/><file name="config.xml" hash="6320805c4c2f8781cb9efb9b7dbe0703"/><file name="system.xml" hash="dcb150bd3e2dd310708d8641ed6aa072"/></dir><dir name="sql"><dir name="factfinder_setup"><file name="mysql4-install-3.2.0.php" hash="1342320595048cd96659c454381cfbb4"/><file name="mysql4-upgrade-3.2.0-3.2.1.php" hash="3d5276dfe971a6bd48aa8e2a085de004"/><file name="mysql4-upgrade-3.2.1-3.3.0.php" hash="71954ea0cf400950d23b020ff095a9ee"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="factfinder.xml" hash="5e5cb94967917aa2784d19434d02b2d4"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="factfinder.xml" hash="b4e442334228676e8847236bdc20bd25"/></dir><dir name="template"><dir name="factfinder"><dir name="campaign"><file name="advisory.phtml" hash="d0ef29b97aa4c3bdfa2b94596beb5b21"/><dir name="cart"><file name="advisory.phtml" hash="bb994272a6daaaba298a38023f6db212"/><file name="feedback.phtml" hash="01fa6a9cd024a2a8edaea7013b00fc89"/></dir><file name="feedback.phtml" hash="a44c2521e961cfb62b4b89ad0cb71b15"/><dir name="product"><file name="advisory.phtml" hash="d0ef29b97aa4c3bdfa2b94596beb5b21"/><file name="feedback.phtml" hash="40e944aa8dd3cb993cd0190a518f4ac8"/></dir></dir><dir name="filter"><file name="slider.phtml" hash="80e4e9e1c81437fe41b6a52d98e73549"/></dir><file name="form.mini.phtml" hash="54045a15eb78bea151f518303773ed0e"/><file name="logo.phtml" hash="7a40d67bf648e65345f69b2cf9d3c6b6"/><file name="scic.phtml" hash="3553a9f0f3c66015610f4c7f1d770a51"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="."><file name="factfinder.xml" hash="ca4dac634339217dd2ee6e8dc477d694"/></dir><dir name="modules"><file name="Flagbit_FactFinder.xml" hash="99c6b4e5981ac7592830a9fb3f5e5a0e"/></dir></target><target name="magelocale"><dir name="de_DE"><file name="Flagbit_FactFinder.csv" hash="f28b6aeb3f5b3d7b9dff68a17431170d"/></dir></target><target name="mageweb"><dir name="js"><dir name="factfinder"><file name="jXHR.js" hash="0473a3ea88f08797737814c7ffbeba18"/><file name="scic.js" hash="10f509fb3f468a8557ca17205a361d52"/><file name="suggest.js" hash="c39230ada8f44c3d3a8c7540c0b4a8c9"/></dir></dir></target><target name="magelib"><dir name="FACTFinder"><dir name="Abstract"><file name="Adapter.php" hash="469470db8fe9e148922e56ae37ca3862"/><file name="CompareAdapter.php" hash="7ec1139255b96d45b9e29973cfb0ec95"/><file name="Configuration.php" hash="7335710c0e999b3b4d3274f356d871fc"/><file name="DataProvider.php" hash="39dde70290a61f81d19200d36e063880"/><file name="ProductCampaignAdapter.php" hash="58c555e5e704e91c16cb9be5fc82e218"/><file name="RecommendationAdapter.php" hash="1881e3fa29e82a898c7ee3936650fdc7"/><file name="ScicAdapter.php" hash="478dc65ca80eef22696d2b0f4d83167c"/><file name="SearchAdapter.php" hash="48e692f054663c7fa7349c96d0452403"/><file name="SimilarRecordsAdapter.php" hash="302fe55861cef886abd6e210a501a4b3"/><file name="SuggestAdapter.php" hash="1793a1cafe52a21d87b7e9b0a5b4379e"/><file name="TagCloudAdapter.php" hash="8caf392c3a41b31ecf4a239d406576fc"/></dir><file name="AdvisorAnswer.php" hash="873206d7ff713e4dbe8d12035236fa88"/><file name="AdvisorQuestion.php" hash="45fc864b18cb650ea7ab6ad69fe4d2cf"/><file name="Asn.php" hash="415d7ca6e57fce1c2dc79a398f277a8e"/><file name="AsnFilterItem.php" hash="823ca331d4f0fb96cdaba37837eb4cf4"/><file name="AsnGroup.php" hash="eb5f98e61330d2086a6f2cbed9b22e2b"/><file name="AsnSliderFilter.php" hash="93960390f4b25235cc6b3fb0ac6e607f"/><file name="BreadCrumbItem.php" hash="926f78a0bdb1331e271b6027d639dcbd"/><file name="Campaign.php" hash="fb71fc56c52bafbf54928478e29a36c2"/><file name="CampaignIterator.php" hash="70ebfc5ab5db712f7bad1e9fff823868"/><file name="Configuration.php" hash="b203f9bb455cdb7d67bca04568ca90db"/><file name="EncodingHandler.php" hash="3cf4f8c653e2cf06101476c6ed0c5d91"/><dir name="Http"><file name="DataProvider.php" hash="23d3d4dea4c282467ebec881d6571633"/><file name="DummyProvider.php" hash="b4b3991dd1263291a286e3672509f640"/><file name="ParallelDataProvider.php" hash="1e3c196ca9db498d556f15e4f3a613ba"/><file name="ScicAdapter.php" hash="4c7f7f3f689e073976bf37cf6ccfbd02"/><file name="SuggestAdapter.php" hash="f9364c65034848444e2928617f71c357"/></dir><file name="Item.php" hash="82d6aa160364f1065d905d4bfb81595e"/><file name="Loader.php" hash="f90769906b975860d756db2c7c90bcef"/><dir name="Logger"><file name="BlackHole.php" hash="a69e509021e53c4605606b0a8b306506"/><file name="LoggerInterface.php" hash="1528b92855ea10d4166cea56e64facd5"/></dir><file name="Paging.php" hash="1e00f8a23eb7c77e25669662fa96e5d4"/><file name="Parameters.php" hash="3cff8bd17aae5a045eb8bdc9da7f36de"/><file name="ParametersParser.php" hash="32901cab2b4ac273707248a353c0e5d8"/><file name="ProductsPerPageOptions.php" hash="00d5fefb4798df35e5eb59ba7c520d21"/><file name="Record.php" hash="13d6d9d64b6914706866450869b38206"/><file name="Result.php" hash="bc67777850ff18b7784c48bb8f5fbd20"/><file name="SingleWordSearchItem.php" hash="3b806c3d26785f0260d09abe6469c999"/><file name="SuggestQuery.php" hash="9aaa4f18c5369acfe0dcb387245e4a75"/><file name="TagQuery.php" hash="a35b69db11cb856225c00f103b7c16ab"/><file name="Util.php" hash="7f3c81e2bd95a5c61365e8f2426c258e"/><dir name="Xml64"><file name="SearchAdapter.php" hash="d3ce38946d9df3c96e117b1a0a196b0c"/></dir><dir name="Xml65"><file name="RecommendationAdapter.php" hash="d9c1d57dba84ef5db4dc624c788b91dc"/><file name="SearchAdapter.php" hash="71b0cb4554b98cc7f7d74cd6754bf3cc"/><file name="SuggestAdapter.php" hash="f9742b1c720542d01ec622c6d65beea4"/><file name="TagCloudAdapter.php" hash="290ce886957e6760c9a3bdc5dec19e4f"/></dir><dir name="Xml66"><file name="CompareAdapter.php" hash="5ebc1da804fb2f27cdc6ab911d823f14"/><file name="RecommendationAdapter.php" hash="94cd09e149d85182a6b13773b4c6c601"/><file name="SearchAdapter.php" hash="e178a14e3173c123f38df9312030cdd3"/><file name="SimilarRecordsAdapter.php" hash="669541b29f87955d45d315545a1951bf"/><file name="SuggestAdapter.php" hash="982290e42670453a9597279ffe5fa86c"/><file name="TagCloudAdapter.php" hash="52a7937a07070f2477ccdb2185cdaab8"/></dir><dir name="Xml67"><file name="CompareAdapter.php" hash="f58ea46c0f0a634d2753ff4627937c3d"/><file name="ProductCampaignAdapter.php" hash="6a81f02658445dabc1f997b865e385d5"/><file name="RecommendationAdapter.php" hash="bdbcd5a489b2dc21555aa6db0a044eb3"/><file name="SearchAdapter.php" hash="894f602ab8736307a932354010ae8a07"/><file name="SimilarRecordsAdapter.php" hash="75663be522e408124198a3091a0cf9d9"/><file name="SuggestAdapter.php" hash="3323d92b9a9dcb80a0587fab203c5a73"/><file name="TagCloudAdapter.php" hash="cd4ebb2581682d478d71ba1aeb62e01e"/></dir></dir><dir name="FACTFinderCustom"><file name="Configuration.php" hash="96b16f73d80f74ee0a24d39bc81ac321"/></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.6</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Flagbit_Factfinder</name>
|
4 |
+
<version>3.3.11</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>GPL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Integrates the FACT-Finder for improved product search functionality.</summary>
|
10 |
<description>Integrates the FACT-Finder for improved product search functionality.</description>
|
11 |
+
<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)</notes>
|
12 |
<authors><author><name>Rudolf Batt</name><user>rbatt</user><email>rb@omikron.net</email></author></authors>
|
13 |
+
<date>2012-08-24</date>
|
14 |
+
<time>20:14:06</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Flagbit"><dir name="FactFinder"><dir name="Block"><dir name="Adminhtml"><file name="Cockpit.php" hash="7f5f3e8521f002c8c7b5a2d5f72cf5e1"/><file name="Exportlink.php" hash="f83a083279cec4d1e3fece4bbb94263e"/><dir name="Form"><dir name="Field"><file name="Attribute.php" hash="2e60d7473163fa523f10b2d0c441fe24"/><file name="Attributes.php" hash="cbaf317aa5ce4417cfcd02a6c4f36486"/></dir></dir></dir><dir name="Campaign"><file name="Advisory.php" hash="9eb34869abbc7e4ba4fe3825835793eb"/><dir name="Cart"><file name="Advisory.php" hash="9861e5ff8bb10fdec38d17bc9f61090a"/><file name="Feedback.php" hash="aa9239e92f528ff6b216942194f36776"/></dir><file name="Feedback.php" hash="ffb877d1e9cb5e7fb7b9d5731a8ace56"/><dir name="Product"><file name="Advisory.php" hash="d4736ab3436e7966c37b393a339110ca"/><file name="Feedback.php" hash="7843ed6669b7e6bdd92934b3aeb2fd41"/></dir></dir><dir name="Cart"><file name="Crosssell.php" hash="73e43a5c9048a1d139910dc7a2199952"/></dir><dir name="Filter"><file name="Slider.php" hash="159d3e1b403625dbbb970e5e7ada4ec7"/></dir><dir name="Layer"><file name="Abstract.php" hash="f53a3e2d6ce0da4afee58b4ea806a342"/></dir><file name="Layer.php" hash="fc9ae3f5197a73be5951a420d4b27124"/><dir name="Product"><dir name="List"><file name="Crosssell.php" hash="8b6936aa661cd77a1866da3bc2a40939"/><file name="Upsell.php" hash="5b09dab3ad5acfc213716b88d1f8ca43"/></dir></dir><file name="Scic.php" hash="9ba6aa43204d0aae206d9f24f09aecfc"/><file name="Secondaryresult.php" hash="c2647dd1db7fdd0b77b3f7124e08ce63"/><file name="TagCloud.php" hash="664c18eceaa82779a60b6eb1694cdfca"/><dir name="XmlConnect"><dir name="Catalog"><dir name="Product"><file name="List.php" hash="79103c53bbaa03f02ed8a78554dcc791"/></dir><dir name="Search"><file name="Suggest.php" hash="5c7ef36939885a14ee0644cbb91a945d"/></dir><file name="Search.php" hash="662f7b0df8d21626bf6193906aed5162"/></dir></dir></dir><dir name="Helper"><file name="Backend.php" hash="57771ad274e7e0ea63b9a934b3757f04"/><file name="Data.php" hash="afede9edaf2bcfbc93a4049eee5be89e"/><file name="Debug.php" hash="24b939b03efb2cd5f7815562f896576f"/><file name="Search.php" hash="edc5498b06f5e865cc7f34dce60dc96b"/></dir><dir name="Model"><file name="Adapter.php" hash="b5fc3e4a64610006fd8a5f38e25285c9"/><dir name="Export"><file name="Price.php" hash="5561605bf639385c211f339f0c752a0f"/><file name="Product.php" hash="48ab88e730df3d3b30bf9f9fcf8cdb26"/><file name="Stock.php" hash="28e819f8f317957a70a7d4d318e04791"/></dir><dir name="Layer"><file name="Abstract.php" hash="0a0505e719ca55320da35c7510b82d3a"/><dir name="Filter"><dir name="Attribute"><file name="Abstract.php" hash="2ad710352f1803d15ba056cd93d519f1"/><file name="Catalog.php" hash="f6dce5ea64da9dfb3458ae9ff4b58a7b"/><file name="Catalogsearch.php" hash="75536576aaaa0186f166550ee746ae04"/></dir><file name="Item.php" hash="28e42624d764342dae6cb09a1b29b7b8"/></dir></dir><file name="Layer.php" hash="9da16c44259b4a31d73f63d87787ff11"/><dir name="Mysql4"><dir name="Campaign"><dir name="Pushedproducts"><file name="Collection.php" hash="c966a40c7569b70cef93e47781b95190"/></dir></dir><dir name="Product"><dir name="Attribute"><file name="Collection.php" hash="d9000f3e9c709fa63313b15f34803d74"/></dir><dir name="Recommendation"><file name="Collection.php" hash="fdb6f35fa1cca09aa405bc5cd0c68601"/></dir></dir><dir name="Scic"><dir name="Queue"><file name="Collection.php" hash="5f6b0b6a50838929065ebd941cedce42"/></dir><file name="Queue.php" hash="a1521000a1a10df8e6b580f33d06cf23"/></dir><dir name="Search"><file name="Collection.php" hash="12356224ac22113428b38120a1a002a6"/><file name="Engine.php" hash="88a56eb3b4587d87bb1152476b64036e"/></dir></dir><file name="Observer.php" hash="5478ee05a85d5c502211c66eab3f6190"/><file name="Processor.php" hash="1a48223d1208215013f314a5439b3028"/><dir name="Scic"><file name="Queue.php" hash="828d391339a22c15ad74ae1a2e784b41"/></dir><dir name="System"><dir name="Config"><dir name="Backend"><file name="Attributes.php" hash="8259883090dc4bca9b858d047983e736"/><file name="Enabled.php" hash="3b4d1f4b37d7ddba9768a7da6e3fc778"/></dir><dir name="Source"><file name="Authtype.php" hash="5bc0b1c745782cc51d44d56299059bcb"/><file name="Ffversion.php" hash="41ef9c853705c0777d9a2b7d2f3624ad"/><file name="Identifier.php" hash="cec45238f0e28a1bf66d10dee513c2ca"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Factfinder"><file name="CockpitController.php" hash="4c8665feaf14c38e6ba2384db496c95a"/></dir></dir><file name="ExportController.php" hash="01a45ff00a9b5a95ae397fd555507592"/><file name="ProxyController.php" hash="587f159bad384600c724568a61546b66"/></dir><dir name="documentation"><file name="Installation_FACT-Finder_Magento_de.pdf" hash="b4711171c625caaa8996a6a09e0eaaae"/><file name="Installation_FACT-Finder_Magento_en.pdf" hash="d4bef19418ee33a223fbda2d45cca686"/></dir><dir name="etc"><file name="adminhtml.xml" hash="1165a0fecfaa31f2aa4a882d1d8bc033"/><file name="config.xml" hash="09182f5c81fe5fa733dcbbe3a2b66f60"/><file name="system.xml" hash="168f70622dd8d3f5622720f7c6871f08"/></dir><dir name="sql"><dir name="factfinder_setup"><file name="mysql4-install-3.2.0.php" hash="1342320595048cd96659c454381cfbb4"/><file name="mysql4-upgrade-3.2.0-3.2.1.php" hash="3d5276dfe971a6bd48aa8e2a085de004"/><file name="mysql4-upgrade-3.2.1-3.3.0.php" hash="71954ea0cf400950d23b020ff095a9ee"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="factfinder.xml" hash="5e5cb94967917aa2784d19434d02b2d4"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="factfinder.xml" hash="4f2db4f3bc4d77782a7f9e479e319adc"/></dir><dir name="template"><dir name="factfinder"><dir name="campaign"><file name="advisory.phtml" hash="d0ef29b97aa4c3bdfa2b94596beb5b21"/><dir name="cart"><file name="advisory.phtml" hash="bb994272a6daaaba298a38023f6db212"/><file name="feedback.phtml" hash="01fa6a9cd024a2a8edaea7013b00fc89"/></dir><file name="feedback.phtml" hash="a44c2521e961cfb62b4b89ad0cb71b15"/><dir name="product"><file name="advisory.phtml" hash="d0ef29b97aa4c3bdfa2b94596beb5b21"/><file name="feedback.phtml" hash="40e944aa8dd3cb993cd0190a518f4ac8"/></dir></dir><dir name="filter"><file name="slider.phtml" hash="80e4e9e1c81437fe41b6a52d98e73549"/></dir><file name="form.mini.phtml" hash="54045a15eb78bea151f518303773ed0e"/><file name="logo.phtml" hash="7a40d67bf648e65345f69b2cf9d3c6b6"/><file name="scic.phtml" hash="3553a9f0f3c66015610f4c7f1d770a51"/><file name="secondaryresult.phtml" hash="a4cdff409ccedb16d4fe9a038a4dd9e8"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="."><file name="factfinder.xml" hash="ca4dac634339217dd2ee6e8dc477d694"/></dir><dir name="modules"><file name="Flagbit_FactFinder.xml" hash="99c6b4e5981ac7592830a9fb3f5e5a0e"/></dir></target><target name="magelocale"><dir name="de_DE"><file name="Flagbit_FactFinder.csv" hash="e1b1aa6179c7aac9cd8dc294e136a7f5"/></dir></target><target name="mageweb"><dir name="js"><dir name="factfinder"><file name="jXHR.js" hash="0473a3ea88f08797737814c7ffbeba18"/><file name="scic.js" hash="10f509fb3f468a8557ca17205a361d52"/><file name="suggest.js" hash="c39230ada8f44c3d3a8c7540c0b4a8c9"/></dir></dir></target><target name="magelib"><dir name="FACTFinder"><dir name="Abstract"><file name="Adapter.php" hash="f0059219a3f00180007b99fb493e0d72"/><file name="CompareAdapter.php" hash="d26dec2f3dc98269dcb43f10bcfcdfe9"/><file name="Configuration.php" hash="5e421f8569742aa949c201249cb46581"/><file name="DataProvider.php" hash="5ba56f8daab07d86139cdcc67d73e270"/><file name="ImportAdapter.php" hash="8427bb6b4b33c37bfe9090d7c16e0238"/><file name="Logger.php" hash="c5b1ace6158035e80b3d4a79a942a381"/><file name="ProductCampaignAdapter.php" hash="daa4f28109edf685b33f31fce8573ced"/><file name="RecommendationAdapter.php" hash="655e55d17ba0eb790d3b2146299404d1"/><file name="ScicAdapter.php" hash="0ca4747a30249ed0b944e2f330390171"/><file name="SearchAdapter.php" hash="c03d9bea34da5cc0e0b5885bd2c89c74"/><file name="SimilarRecordsAdapter.php" hash="2cef8bdabc112c2c78fb95e75ef748bd"/><file name="SuggestAdapter.php" hash="ef13ace0995fa2f57b87f38cc2fb701a"/><file name="TagCloudAdapter.php" hash="ac5465a5dde73dde3ead1f6f08eced08"/></dir><file name="AdvisorAnswer.php" hash="b6dfbe2d43660b1624ce7788bef7356a"/><file name="AdvisorQuestion.php" hash="7f3d039dc86c5baebb4702f8a66ca6d4"/><file name="Asn.php" hash="8a3753feea0901c7ace25e011be38e56"/><file name="AsnFilterItem.php" hash="cdd0bb237873b54877b4b52744250018"/><file name="AsnGroup.php" hash="fd6834f2857c8dc15e79f46eeb977186"/><file name="AsnSliderFilter.php" hash="da4eb96cdb47553793b278aca2d0ec19"/><file name="BreadCrumbItem.php" hash="115ffb2f30e346b29f93ce2d84be724e"/><file name="Campaign.php" hash="138f990ff2180d369bd0b441998b9cb4"/><file name="CampaignIterator.php" hash="d58f054580f0057e8471dbd8334157f1"/><file name="Configuration.php" hash="6a514853077250ac0271f9dc4858fcf6"/><file name="EncodingHandler.php" hash="4f0b616bca9158bfb7eddcfcba192dc6"/><dir name="Http"><file name="DataProvider.php" hash="01d3616caf13b17183799cce4e7609c6"/><file name="DummyProvider.php" hash="30d61ea2ce373f5b501bb64d8ed19393"/><file name="ParallelDataProvider.php" hash="a513931b400bc940a8fe9e78bf489490"/><file name="ScicAdapter.php" hash="a1979f92c3c8d0bc7239ad63ef55dbaa"/><file name="SuggestAdapter.php" hash="c454126b2e5b18edc7e753973cc7b791"/></dir><file name="Item.php" hash="431843e9e2847e8a6c966a185c39f5e9"/><file name="Loader.php" hash="e76d471f86c6c68ef3228c0b98aaed6e"/><file name="Log4PhpLogger.php" hash="ecfb1f084b8d0bd2d51bf417fa0b0b3c"/><file name="NullLogger.php" hash="be8782000070665f0e9fcc011ae4fe77"/><file name="Paging.php" hash="a07db7cb4b02893792e6e29018a36858"/><file name="Parameters.php" hash="612c4a9b98cb8a17d0f2d30cf2641936"/><file name="ParametersParser.php" hash="187527e3d7f233ca60d89748be8c2896"/><file name="ProductsPerPageOptions.php" hash="1929e3d0c7ce95372b04e8925f7c17c7"/><file name="Record.php" hash="4bc036a2d47cd1b76d09af6290f49044"/><file name="Result.php" hash="6b4e959df31a73b9fe25de7a76551970"/><file name="SingleWordSearchItem.php" hash="8f0feac780e68a8b0eab6d44dd6c6813"/><file name="SuggestQuery.php" hash="cf3cf51839e06475bdcf62bb49ee96c5"/><file name="TagQuery.php" hash="ece1fda66af2c6053507941f35423c5f"/><file name="Util.php" hash="4ac8b8eb630e83c65a065fd4e01ab11f"/><dir name="Xml64"><file name="SearchAdapter.php" hash="58a49882c741216cf278c4556ea7d224"/></dir><dir name="Xml65"><file name="ImportAdapter.php" hash="329fcaf405969b30ea6cbd3ae4a783f2"/><file name="RecommendationAdapter.php" hash="14a126d5a9c14da3e754186f81bfeacb"/><file name="SearchAdapter.php" hash="5c2056713238ae017b4af8912e27f6b0"/><file name="SuggestAdapter.php" hash="878a1f04fdce6956b644cdff227d50c2"/><file name="TagCloudAdapter.php" hash="feacc3e6c13d3c49f748b4a85418d994"/></dir><dir name="Xml66"><file name="CompareAdapter.php" hash="a6f500504086c842e8e50772305b98df"/><file name="ImportAdapter.php" hash="5ea0d06cc2ddc7a1b7c880203c38fe40"/><file name="RecommendationAdapter.php" hash="9490ea2b17fded94d087046065596b1b"/><file name="SearchAdapter.php" hash="82214090045d963b15ccc7073d73d7ea"/><file name="SimilarRecordsAdapter.php" hash="532cbc18947dad44fdb296bc82ea3fa0"/><file name="SuggestAdapter.php" hash="813bfb64ac9d2dc45443cc7c33e854a7"/><file name="TagCloudAdapter.php" hash="a44dd623910bbb6766a0b0c25584212c"/></dir><dir name="Xml67"><file name="CompareAdapter.php" hash="37980ec507fd7f13e81ece413915da2d"/><file name="ImportAdapter.php" hash="dc0d334439aa59f3e0a4226bbf1456d2"/><file name="ProductCampaignAdapter.php" hash="64faea05ff05c3031da6f30b3a169980"/><file name="RecommendationAdapter.php" hash="b991b5e2570c28530164b3cacfffa6e1"/><file name="SearchAdapter.php" hash="f69bf92b5a42c2e46a777435e15adf2d"/><file name="SimilarRecordsAdapter.php" hash="b60a974a22d3e473538524dc57d1e91d"/><file name="SuggestAdapter.php" hash="7290503daae4ae9e595cc5b1480ce8a1"/><file name="TagCloudAdapter.php" hash="d3efa6616331286cb221f8ca79021324"/></dir></dir><dir name="FACTFinderCustom"><file name="Configuration.php" hash="96b16f73d80f74ee0a24d39bc81ac321"/></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.6</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|