From a098925938d734a06a1b7009e54ba02ec863788d Mon Sep 17 00:00:00 2001 From: tuegeb Date: Wed, 2 Mar 2016 15:48:24 +0100 Subject: [PATCH] CHG: Update of the FACT-Finder PHP library includes an alternative to the requested blackling solution in #117 --- .../FACTFinder/Adapter/AbstractAdapter.php | 17 +- src/lib/FACTFinder/Adapter/ScicTracking.php | 279 ------------------ src/lib/FACTFinder/Adapter/Search.php | 44 ++- src/lib/FACTFinder/Adapter/Suggest.php | 1 - .../FACTFinder/Core/AbstractConfiguration.php | 231 +++++++++++++++ .../Core/ConfigurationInterface.php | 15 + .../FACTFinder/Core/ManualConfiguration.php | 13 +- .../FACTFinder/Core/ParametersConverter.php | 37 +++ src/lib/FACTFinder/Core/XmlConfiguration.php | 39 ++- src/lib/FACTFinder/Data/FilterGroup.php | 17 +- src/lib/FACTFinder/Data/SearchParameters.php | 2 +- src/lib/FACTFinder/Data/SuggestQuery.php | 11 - src/lib/FACTFinder/Data/TrackingEventType.php | 62 ---- src/lib/FACTFinder/Loader.php | 23 +- src/lib/FACTFinderCustom/Configuration.php | 2 +- 15 files changed, 407 insertions(+), 386 deletions(-) delete mode 100755 src/lib/FACTFinder/Adapter/ScicTracking.php create mode 100644 src/lib/FACTFinder/Core/AbstractConfiguration.php delete mode 100644 src/lib/FACTFinder/Data/TrackingEventType.php diff --git a/src/lib/FACTFinder/Adapter/AbstractAdapter.php b/src/lib/FACTFinder/Adapter/AbstractAdapter.php index 69893734..2efebaa6 100644 --- a/src/lib/FACTFinder/Adapter/AbstractAdapter.php +++ b/src/lib/FACTFinder/Adapter/AbstractAdapter.php @@ -104,6 +104,12 @@ protected function useJsonResponseContentProcessor() "json_decode() raised an error: ".json_last_error() ); + if(is_array($jsonData) && isset($jsonData['error'])) { + $this->log->error("FACT-Finder returned error: " . strip_tags($jsonData['error'])); + if(isset($jsonData['stacktrace'])) { + $this->log->error("Stacktrace:\n" . $jsonData['stacktrace']); + } + } return $jsonData; }; } @@ -113,7 +119,14 @@ protected function useXmlResponseContentProcessor() $this->responseContentProcessor = function($string) { libxml_use_internal_errors(true); // The constructor throws an exception on error - return new \SimpleXMLElement($string); + $response = new \SimpleXMLElement($string); + if(isset($response->error)) { + $this->log->error("FACT-Finder returned error: " . strip_tags($response->error)); + if(isset($response->stacktrace)) { + $this->log->error("Stacktrace:\n" . $response->stacktrace); + } + } + return $response; }; } @@ -153,7 +166,7 @@ protected function getResponseContent() // properties if($content !== null) { - $this->responseContent = $this->responseContentProcessor->__invoke($content); + $this->responseContent = $this->responseContentProcessor->__invoke($content); if ($this->encodingConverter != null) { $this->responseContent = $this->encodingConverter->encodeContentForPage($this->responseContent); diff --git a/src/lib/FACTFinder/Adapter/ScicTracking.php b/src/lib/FACTFinder/Adapter/ScicTracking.php deleted file mode 100755 index 25ad1941..00000000 --- a/src/lib/FACTFinder/Adapter/ScicTracking.php +++ /dev/null @@ -1,279 +0,0 @@ -log = $loggerClass::getLogger(__CLASS__); - - $this->request->setAction('Tracking.ff'); - - $this->request->setConnectTimeout($configuration->getTrackingConnectTimeout()); - $this->request->setTimeout($configuration->getTrackingTimeout()); - - // $this->usePassthroughResponseContentProcessor(); (default) - } - - /** - * If all needed parameters are available at the request like described in - * the documentation, just use this method to fetch the needed parameters - * and track them. Make sure to set a session id if there is no parameter - * "sid". If this argument is not set or empty and the parameter "sid" is - * not available, it will try to use session_id() to fetch one. - * - * @param string $sid session id - * @return bool Success? - */ - public function doTrackingFromRequest($sid = null) - { - $this->setupTrackingFromRequest($sid); - return $this->applyTracking(); - } - - /** - * Use this method directly if you want to separate the setup from sending - * the request. This is particularly useful when using the - * MultiCurlRequestFactory. - */ - public function setupTrackingFromRequest($sid = null) - { - if (strlen($sid) > 0) - $this->parameters['sid'] = $sid; - else if (!isset($this->parameters['sid']) - || strlen($this->parameters['sid']) == 0 - ) { - $this->parameters['sid'] = session_id(); - } - } - - /** - * Track a detail click on a product. - * - * @param string $id id of product - * @param string $sid session id (if empty, then try to set using the function session_id() ) - * @param string $query query which led to the product - * @param int $pos position of product in the search result - * @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) - * @param int $page page number where the product was clicked (optional - is 1 by default) - * @param float $simi similiarity of the product (optional - is 100.00 by default) - * @param string $title title of product (optional - is empty by default) - * @param int $pageSize size of the page where the product was found (optional - is 12 by default) - * @param int $origPageSize original size of the page before the user could have changed it (optional - is set equals to $page by default) - * @return boolean $success - */ - public function trackClick( - $id, - $sid = null, - $query, - $pos, - $origPos = -1, - $page = 1, - $simi = 100.0, - $title = '', - $pageSize = 12, - $origPageSize = -1 - ) { - $this->setupClickTracking($id, $sid, $query, $pos, $origPos, $page, - $simi, $title, $pageSize, $origPageSize); - return $this->applyTracking(); - } - - /** - * Use this method directly if you want to separate the setup from sending - * the request. This is particularly useful when using the - * MultiCurlRequestFactory. - */ - public function setupClickTracking( - $id, - $sid = null, - $query, - $pos, - $origPos = -1, - $page = 1, - $simi = 100.0, - $title = '', - $pageSize = 12, - $origPageSize = -1 - ) { - if (strlen($sid) == 0) $sid = session_id(); - if ($origPos == -1) $origPos = $pos; - if ($origPageSize == -1) $origPageSize = $pageSize; - - $this->parameters->clear(); - $this->parameters->setAll( - array( - 'query' => $query, - 'id' => $id, - 'pos' => $pos, - 'origPos' => $origPos, - 'page' => $page, - 'simi' => $simi, - 'sid' => $sid, - 'title' => $title, - 'event' => 'click', - 'pageSize' => $pageSize, - 'origPageSize' => $origPageSize - ) - ); - } - - /** - * Track a product which was added to the cart. - * - * @param string $id id of product - * @param string $sid session id (if empty, then try to set using the function session_id() ) - * @param int $count number of items purchased for each product (optional - default 1) - * @param float $price this is the single unit price (optional) - * @return boolean $success - */ - public function trackCart( - $id, - $sid = null, - $count = 1, - $price = null, - $userid = null - ) { - $this->setupCartTracking($id, $sid, $count, $price, $userid); - return $this->applyTracking(); - } - - /** - * Use this method directly if you want to separate the setup from sending - * the request. This is particularly useful when using the - * MultiCurlRequestFactory. - */ - public function setupCartTracking( - $id, - $sid = null, - $count = 1, - $price = null, - $userid = null - ) { - if (strlen($sid) == 0) $sid = session_id(); - $params = array( - 'id' => $id, - 'sid' => $sid, - 'count' => $count, - 'event' => 'cart' - ); - - if (strlen($price) > 0) $params['price'] = $price; - if (strlen($userid) > 0) $params['userid'] = $userid; - - $this->parameters->clear(); - $this->parameters->setAll($params); - } - - /** - * Track a product which was purchased. - * - * @param string $id id of product - * @param string $sid session id (if empty, then try to set using the function session_id() ) - * @param int $count number of items purchased for each product (optional - default 1) - * @param float $price this is the single unit price (optional) - * @param string $userid id of user checking out - * @return boolean $success - */ - public function trackCheckout( - $id, - $sid = null, - $count = 1, - $price = null, - $userid = null - ) { - $this->setupCheckoutTracking($id, $sid, $count, $price, $userid); - return $this->applyTracking(); - } - - /** - * Use this method directly if you want to separate the setup from sending - * the request. This is particularly useful when using the - * MultiCurlRequestFactory. - */ - public function setupCheckoutTracking( - $id, - $sid = null, - $count = 1, - $price = null, - $userid = null - ) { - if (strlen($sid) == 0) $sid = session_id(); - $params = array( - 'id' => $id, - 'sid' => $sid, - 'count' => $count, - 'event' => 'checkout' - ); - - if (strlen($price) > 0) $params['price'] = $price; - if (strlen($userid) > 0) $params['userid'] = $userid; - - $this->parameters->clear(); - $this->parameters->setAll($params); - } - - /** - * Track a click on a recommended product. - * - * @param string $id id of product - * @param string $sid session id (if empty, then try to set using the function session_id() ) - * @param int $mainId ID of the product for which the clicked-upon item was recommended - * @return boolean $success - */ - public function trackRecommendationClick($id, $sid = null, $mainId) - { - $this->setupRecommendationClickTracking($id, $sid, $mainId); - return $this->applyTracking(); - } - - /** - * Use this method directly if you want to separate the setup from sending - * the request. This is particularly useful when using the - * MultiCurlRequestFactory. - */ - public function setupRecommendationClickTracking($id, $sid = null, $mainId) - { - if (strlen($sid) == 0) $sid = session_id(); - $params = array( - 'id' => $id, - 'sid' => $sid, - 'mainId' => $mainId, - 'event' => 'recommendationClick' - ); - - $this->parameters->clear(); - $this->parameters->setAll($params); - } - - /** - * send tracking - * - * @return boolean $success - */ - public function applyTracking() { - $success = trim($this->getResponseContent()); - return $success == 'The event was successfully tracked' || $success == 'true' || $success == '1'; - } -} diff --git a/src/lib/FACTFinder/Adapter/Search.php b/src/lib/FACTFinder/Adapter/Search.php index 9273468e..b3fdebde 100755 --- a/src/lib/FACTFinder/Adapter/Search.php +++ b/src/lib/FACTFinder/Adapter/Search.php @@ -334,9 +334,6 @@ private function createFilterGroup($groupData) case 'SLIDER': $filterStyle = $filterStyleEnum::Slider(); break; - case 'COLOR': - $filterStyle = $filterStyleEnum::Color(); - break; case 'TREE': $filterStyle = $filterStyleEnum::Tree(); break; @@ -401,7 +398,8 @@ private function createFilterGroup($groupData) $groupData['detailedLinks'], $groupData['unit'], $filterSelectionType, - $filterType + $filterType, + $groupData['showPreviewImages'] ); } @@ -453,10 +451,17 @@ private function createSliderFilter(array $filterData) $matches ); - $query = $matches[1] . $matches[3]; - $fieldName = $matches[2]; + if(!empty($matches)) { + $query = $matches[1] . $matches[3]; + $fieldName = $matches[2]; + } else { + // The URL of searchParams was not as expected, propably the current filter was not + // added as an empty parameter. Therefore no need to remove it and we can use full searchParams URL. + $query = $filterData['searchParams']; + $fieldName = $filterData['associatedFieldName']; + } - if ($fieldName != $filterData['associatedFieldName']) + if (urldecode($fieldName) != $filterData['associatedFieldName']) $this->log->warn('Filter parameter of slider does not correspond ' . 'to transmitted "associatedFieldName". Parameter: ' . "$fieldName. Field name: " @@ -956,27 +961,38 @@ public function getStackTrace() /** * Value for parameter "followSearch" for followups on initial search like filters, pagination, ... - * Either from request parameters or from search results "simiFirstRecord". - * Returns 0 if no valid value for followSearch exists. + * Either from search results searchParams, request parameters or from search results "simiFirstRecord". + * Returns 0 if no parameter "followSearch" could be acquired. + * * @return int */ public function getFollowSearchValue() { - + $jsonData = $this->getResponseContent(); + //use searchParams of result if available + if($jsonData && $jsonData['searchResult'] && isset($jsonData['searchResult']['searchParams'])) { + $parameters = FF::getInstance( + 'Util\Parameters', + $jsonData['searchResult']['searchParams'] + ); + //fallback to current request + } else { + $parameters = $this->parameters; + } $searchParameters = FF::getInstance( 'Data\SearchParameters', - $this->parameters + $parameters ); $sorting = $searchParameters->getSortings(); - // check if followSearch was set in request data - if($searchParameters->getFollowSearch() !== 10000) { + // check if followSearch was set in request data or sent by FF in result searchParams + if($searchParameters->getFollowSearch() !== 0) { $followSearch = $searchParameters->getFollowSearch(); // use simiFirstRecord only if result was not sorted } elseif (empty($sorting)) { $jsonData = $this->getResponseContent(); if($jsonData && $jsonData['searchResult'] && isset($jsonData['searchResult']['simiFirstRecord'])) $followSearch = $jsonData['searchResult']['simiFirstRecord']; - // mark as no followSearch + //mark as not valid } else { $followSearch = 0; } diff --git a/src/lib/FACTFinder/Adapter/Suggest.php b/src/lib/FACTFinder/Adapter/Suggest.php index 542a8266..1d63653c 100644 --- a/src/lib/FACTFinder/Adapter/Suggest.php +++ b/src/lib/FACTFinder/Adapter/Suggest.php @@ -90,7 +90,6 @@ private function createSuggestions() $suggestQueryData['hitCount'], $suggestQueryData['type'], $suggestQueryData['image'], - isset($suggestQueryData['refKey']) ? $suggestQueryData['refKey'] : '', $suggestAttributes ); } diff --git a/src/lib/FACTFinder/Core/AbstractConfiguration.php b/src/lib/FACTFinder/Core/AbstractConfiguration.php new file mode 100644 index 00000000..84865883 --- /dev/null +++ b/src/lib/FACTFinder/Core/AbstractConfiguration.php @@ -0,0 +1,231 @@ + true, + '/^sort.*/' => true, + '/^substringFilter.*/' => true, + 'advisorStatus' => true, + 'callback' => true, + 'catalog' => true, + 'channel' => true, + 'cookieId' => true, + 'count' => true, + 'do' => true, + 'event' => true, + 'followSearch' => true, + 'format' => true, + 'id' => true, + 'idsOnly' => true, + 'ignoreForCache' => true, + 'isArticleNumber' => true, + 'log' => true, + 'mainId' => true, + 'masterId' => true, + 'maxRecordCount' => true, + 'maxResults' => true, + 'navigation' => true, + 'noArticleNumberSearch' => true, + 'omitContextName' => true, + 'origPageSize' => true, + 'origPos' => true, + 'page' => true, + 'pageSize' => true, + 'pos' => true, + 'price' => true, + 'productNumber' => true, + 'productsPerPage' => true, + 'query' => true, + 'queryFromSuggest' => true, + 'searchField' => true, + 'sid' => true, + 'simi' => true, + 'title' => true, + 'useAsn' => true, + 'useAso' => true, + 'useCampaigns' => true, + 'useFoundWords' => true, + 'useKeywords' => true, + 'usePersonalization' => true, + 'userId' => true, + 'userInput' => true, + 'useSemanticEnhancer' => true, + 'verbose' => true, + 'wordCount' => true + ); + } + + public function getRequiredClientParameters() + { + return array(); + } + + public function getRequiredServerParameters() + { + return array(); + } + + public function getDefaultConnectTimeout() + { + return 2; + } + + public function getDefaultTimeout() + { + return 4; + } + + public function getSuggestConnectTimeout() + { + return 2; + } + + public function getSuggestTimeout() + { + return 2; + } + + public function getTrackingConnectTimeout() + { + return 2; + } + + public function getTrackingTimeout() + { + return 2; + } + + public function getImportConnectTimeout() + { + return 10; + } + + public function getImportTimeout() + { + return 360; + } + + public function getPageContentEncoding() + { + return 'UTF-8'; + } + + public function getClientUrlEncoding() + { + return 'UTF-8'; + } +} + diff --git a/src/lib/FACTFinder/Core/ConfigurationInterface.php b/src/lib/FACTFinder/Core/ConfigurationInterface.php index cdf0eaef..670b7086 100644 --- a/src/lib/FACTFinder/Core/ConfigurationInterface.php +++ b/src/lib/FACTFinder/Core/ConfigurationInterface.php @@ -111,6 +111,20 @@ public function getIgnoredClientParameters(); */ public function getIgnoredServerParameters(); + /** + * Get parameters which are allowed in client URLs. + * + * @return array with string as key and boolean true as value for each item + */ + public function getWhitelistClientParameters(); + + /** + * Get parameters which are allowed in server URLs. + * + * @return array with string as key and boolean true as value for each item + */ + public function getWhitelistServerParameters(); + /** * Get parameters which are required in client URLs. * @@ -195,3 +209,4 @@ public function getPageContentEncoding(); */ public function getClientUrlEncoding(); } + diff --git a/src/lib/FACTFinder/Core/ManualConfiguration.php b/src/lib/FACTFinder/Core/ManualConfiguration.php index 80914f64..f0b75c1e 100644 --- a/src/lib/FACTFinder/Core/ManualConfiguration.php +++ b/src/lib/FACTFinder/Core/ManualConfiguration.php @@ -6,7 +6,7 @@ * values to be set manually through the magic __set(). Really only useful for * testing. */ -class ManualConfiguration implements ConfigurationInterface +class ManualConfiguration extends AbstractConfiguration { const HTTP_AUTHENTICATION = 'http'; const SIMPLE_AUTHENTICATION = 'simple'; @@ -124,6 +124,16 @@ public function getIgnoredServerParameters() return $this->configuration['ignoredServerParameters']; } + public function getWhitelistClientParameters() + { + return $this->configuration['whitelistClientParameters']; + } + + public function getWhitelistServerParameters() + { + return $this->configuration['whitelistServerParameters']; + } + public function getRequiredClientParameters() { return $this->configuration['requiredClientParameters']; @@ -184,3 +194,4 @@ public function getClientUrlEncoding() return $this->configuration['clientUrlEncoding']; } } + diff --git a/src/lib/FACTFinder/Core/ParametersConverter.php b/src/lib/FACTFinder/Core/ParametersConverter.php index 0396eb39..92c3a951 100644 --- a/src/lib/FACTFinder/Core/ParametersConverter.php +++ b/src/lib/FACTFinder/Core/ParametersConverter.php @@ -40,6 +40,7 @@ public function convertClientToServerParameters($clientParameters) $result = clone $clientParameters; $this->applyParameterMappings($result, $this->configuration->getServerMappings()); $this->removeIgnoredParameters($result, $this->configuration->getIgnoredServerParameters()); + $this->applyWhitelist($result, $this->configuration->getWhitelistServerParameters()); $this->ensureChannelParameter($result); $this->addRequiredParameters($result, $this->configuration->getRequiredServerParameters()); @@ -55,6 +56,7 @@ public function convertServerToClientParameters($serverParameters) $result = clone $serverParameters; $this->applyParameterMappings($result, $this->configuration->getClientMappings()); $this->removeIgnoredParameters($result, $this->configuration->getIgnoredClientParameters()); + $this->applyWhitelist($result, $this->configuration->getWhitelistClientParameters()); $this->addRequiredParameters($result, $this->configuration->getRequiredClientParameters()); return $result; @@ -94,6 +96,41 @@ protected function removeIgnoredParameters($parameters, $ignoreRules) unset($parameters[$k]); } + /** + * Removes keys from a Parameters object according to the given whitelist rules. + * An empty whitelist means do NOT apply any whitelist (anything is allowed). + * It removes any keys that are not keys in the given whitelist array aswell. + * If the key of any rule starts with '/' the key is interpreted as a regular expression to be matched against. + * @param type $parameters + * @param bool[] $whitelistRules Array of parameters to be allowed. The keys + * are the parameter names, the values are simply "true", but could + * technically have any value. + */ + protected function applyWhitelist($parameters, $whitelistRules) + { + //do not apply empty whitelist as this means no whitelist desired + if(empty($whitelistRules)) { + return; + } + //collect all keys of parameters that pass any whitelist rule + $allowedKeys = array(); + $keys = array_keys($parameters->getArray()); + foreach ($whitelistRules as $rule => $v) { + if(strpos($rule, '/') === 0) { + $allowedKeys = array_merge($allowedKeys, preg_grep($rule, $keys)); + } else { + $allowedKeys[] = $rule; + } + } + $allowedKeys = array_flip($allowedKeys); + //unset any parameters that did not pass any whitelist rule + foreach($parameters->getArray() as $k => $v) { + if(!isset($allowedKeys[$k])) { + unset($parameters[$k]); + } + } + } + /** * Ensures that the passed parameters object has a "channel" parameter by * adding one if necessary. diff --git a/src/lib/FACTFinder/Core/XmlConfiguration.php b/src/lib/FACTFinder/Core/XmlConfiguration.php index b784c9ae..84b13915 100644 --- a/src/lib/FACTFinder/Core/XmlConfiguration.php +++ b/src/lib/FACTFinder/Core/XmlConfiguration.php @@ -5,7 +5,7 @@ * Implements ConfigurationInterface by reading from an XML file. Also allows * for some values to be changed later on. */ -class XmlConfiguration implements ConfigurationInterface +class XmlConfiguration extends AbstractConfiguration { const HTTP_AUTHENTICATION = 'http'; const SIMPLE_AUTHENTICATION = 'simple'; @@ -22,6 +22,8 @@ class XmlConfiguration implements ConfigurationInterface private $serverMappings; private $ignoredClientParameters; private $ignoredServerParameters; + private $whitelistClientParameters; + private $whitelistServerParameters; private $requiredClientParameters; private $requiredServerParameters; @@ -211,6 +213,41 @@ private function retrieveIgnoredParameters(\SimpleXMLElement $section) return $ignoredParameters; } + public function getWhitelistClientParameters() + { + if ($this->whitelistClientParameters == null) { + $this->whitelistClientParameters = $this->retrieveWhitelistParameters( + $this->configuration->parameters->client + ); + } + return $this->whitelistClientParameters; + } + + public function getWhitelistServerParameters() + { + if ($this->whitelistServerParameters == null) { + $this->whitelistServerParameters = $this->retrieveWhitelistParameters( + $this->configuration->parameters->server + ); + if (empty($this->whitelistServerParameters)) { + $this->whitelistServerParameters = parent::getWhitelistServerParameters(); + } + } + return $this->whitelistServerParameters; + } + + private function retrieveWhitelistParameters(\SimpleXMLElement $section) + { + $whitelist = array(); + if (isset($section->whitelist)) { + //load whitelist + foreach($section->whitelist as $rule) { + $whitelist[(string)$rule->attributes()->name] = true; + } + } + return $whitelist; + } + public function getRequiredClientParameters() { if ($this->requiredClientParameters == null) { diff --git a/src/lib/FACTFinder/Data/FilterGroup.php b/src/lib/FACTFinder/Data/FilterGroup.php index 0d70622e..41425f97 100644 --- a/src/lib/FACTFinder/Data/FilterGroup.php +++ b/src/lib/FACTFinder/Data/FilterGroup.php @@ -38,9 +38,13 @@ class FilterGroup extends \ArrayIterator */ private $type; + /** + * @var bool + */ + private $showPreviewImages; + /** * @param Filter[] $filters The Filter objects to add to the group. - * @param string $refKey * @param int $foundRecordsCount Total number of records found for the * search these records are from. This can be greater than * count($records), because $records may just be the records from a @@ -54,7 +58,8 @@ public function __construct( $detailedLinkCount = 0, $unit = '', FilterSelectionType $selectionType = null, - FilterType $type = null + FilterType $type = null, + $showPreviewImages = false ) { parent::__construct($filters); @@ -67,6 +72,7 @@ public function __construct( $this->selectionType = $selectionType ?: $filterSelectionTypeEnum::SingleHideUnselected(); $filterTypeEnum = FF::getClassName('Data\FilterType'); $this->type = $type ?: $filterTypeEnum::Text(); + $this->showPreviewImages = (bool)$showPreviewImages; } /** @@ -114,6 +120,7 @@ public function isMultiSelectStyle() } /** + * @deprecated use hasPreviewImages instead * @return bool */ public function isColorStyle() @@ -143,11 +150,7 @@ public function getUnit() */ public function hasPreviewImages() { - foreach ($this as $filter) - if ($filter->hasPreviewImage()) - return true; - - return false; + return $this->showPreviewImages; } /** diff --git a/src/lib/FACTFinder/Data/SearchParameters.php b/src/lib/FACTFinder/Data/SearchParameters.php index 0cf8d9d8..ed445fe9 100644 --- a/src/lib/FACTFinder/Data/SearchParameters.php +++ b/src/lib/FACTFinder/Data/SearchParameters.php @@ -58,7 +58,7 @@ public function __construct( : 1; $this->followSearch = isset($parameters['followSearch']) ? $parameters['followSearch'] - : 10000; + : 0; $this->navigationEnabled = (isset($parameters['catalog']) && $parameters['catalog'] == 'true') || (isset($parameters['navigation']) && $parameters['navigation'] == 'true'); diff --git a/src/lib/FACTFinder/Data/SuggestQuery.php b/src/lib/FACTFinder/Data/SuggestQuery.php index c92d163f..cee1c5ad 100755 --- a/src/lib/FACTFinder/Data/SuggestQuery.php +++ b/src/lib/FACTFinder/Data/SuggestQuery.php @@ -9,7 +9,6 @@ class SuggestQuery extends Item private $hitCount; private $type; private $imageUrl; - private $refKey; private $attributes; /** @@ -20,7 +19,6 @@ class SuggestQuery extends Item * @param string $type Simple string which describes where this suggest * query comes from (e.g. product name, category, log file). * @param string $imageUrl - * @param string $refKey * @param array $attributes Additional return data fields */ public function __construct( @@ -29,7 +27,6 @@ public function __construct( $hitCount = 0, $type = '', $imageUrl = '', - $refKey = '', array $attributes = array() ) { // Suggestions are never pre-selected. @@ -37,7 +34,6 @@ public function __construct( $this->hitCount = (int)$hitCount; $this->type = (string)$type; $this->imageUrl = (string)$imageUrl; - $this->refKey = (string)$refKey; $this->attributes = $attributes; } @@ -63,13 +59,6 @@ public function getImageUrl() { return $this->imageUrl; } - /** - * @return string - */ - public function getRefKey() { - return $this->refKey; - } - /** * @return array Returns the additional return data fields */ diff --git a/src/lib/FACTFinder/Data/TrackingEventType.php b/src/lib/FACTFinder/Data/TrackingEventType.php deleted file mode 100644 index cfcdd2f8..00000000 --- a/src/lib/FACTFinder/Data/TrackingEventType.php +++ /dev/null @@ -1,62 +0,0 @@ -id = self::$nextID++; - } - - static private $initialized = false; - public static function initialize() - { - if (!self::$initialized) - { - self::$display = new TrackingEventType(); - self::$feedback = new TrackingEventType(); - self::$inspect = new TrackingEventType(); - self::$availabilityCheck = new TrackingEventType(); - self::$cart = new TrackingEventType(); - self::$buy = new TrackingEventType(); - self::$cacheHit = new TrackingEventType(); - self::$sessionStart = new TrackingEventType(); - - self::$initialized = true; - } - } - - // A result (search result or suggest) referenced by the key has been displayed. - static public function Display() { return self::$display; } - // The user has given geedback about a result. Reference key is optional. - static public function Feedback() { return self::$feedback; } - // The user viewed a product / detail view by clicking or hovering. - static public function Inspect() { return self::$inspect; } - // The user checked the availability of a product. - static public function AvailabilityCheck() { return self::$availabilityCheck; } - // The user added an item to the cart. - static public function Cart() { return self::$cart; } - // The user bought or booked a product or service. - static public function Buy() { return self::$buy; } - // A request of the user could be answered from the client cache. - static public function CacheHit() { return self::$cacheHit; } - // A new session has been created for a user. - static public function SessionStart() { return self::$sessionStart; } -} - -TrackingEventType::initialize(); diff --git a/src/lib/FACTFinder/Loader.php b/src/lib/FACTFinder/Loader.php index b26a944a..ea25e5d7 100755 --- a/src/lib/FACTFinder/Loader.php +++ b/src/lib/FACTFinder/Loader.php @@ -29,7 +29,7 @@ $includePaths = explode(PATH_SEPARATOR, get_include_path()); if ( array_search(FF_LIB_DIR, $includePaths, true) === false ) { - set_include_path( get_include_path() . PATH_SEPARATOR . FF_LIB_DIR); + set_include_path( get_include_path() . PATH_SEPARATOR . FF_LIB_DIR); } spl_autoload_register(array('FACTFinder\Loader', 'autoload')); @@ -52,6 +52,8 @@ class Loader { protected static $classNames = array(); + protected static $loadCustomClasses = true; + // TODO: Check parent namespaces, too? public static function autoload($classname) { @@ -136,10 +138,9 @@ public static function getClassName($name) $factfinderClassName = 'FACTFinder\\' . $name; $defaultClassName = $name; - //if (class_exists($customClassName)) - // $className = $customClassName; - //else - if (class_exists($factfinderClassName)) + if (self::$loadCustomClasses && class_exists($customClassName)) + $className = $customClassName; + else if (class_exists($factfinderClassName)) $className = $factfinderClassName; else if (class_exists($defaultClassName)) $className = $defaultClassName; @@ -166,4 +167,14 @@ public static function isInstanceOf($object, $class) $className = self::getClassName($class); return $object instanceof $className; } -} + + /** + * It may happen that your application's autoloader is not compatible + * with this one due to the custom class loading feature. + * This method disables the loading of custom classes. + */ + public static function disableCustomClasses() + { + self::$loadCustomClasses = false; + } +} \ No newline at end of file diff --git a/src/lib/FACTFinderCustom/Configuration.php b/src/lib/FACTFinderCustom/Configuration.php index 48464cf0..4b217b49 100644 --- a/src/lib/FACTFinderCustom/Configuration.php +++ b/src/lib/FACTFinderCustom/Configuration.php @@ -6,7 +6,7 @@ * * @package FACTFinder\Common */ -class FACTFinderCustom_Configuration implements FACTFinder\Core\ConfigurationInterface +class FACTFinderCustom_Configuration extends FACTFinder\Core\AbstractConfiguration { const HTTP_AUTH = 'http'; const SIMPLE_AUTH = 'simple';