Skip to content
This repository was archived by the owner on Mar 9, 2023. It is now read-only.

Commit

Permalink
Merge pull request #130 from tuegeb/master
Browse files Browse the repository at this point in the history
Several bugfixes and improvements
  • Loading branch information
xpoback committed Feb 23, 2016
2 parents b7e4563 + 90c5def commit 9fea655
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 278 deletions.
2 changes: 1 addition & 1 deletion src/app/code/community/FACTFinder/Campaigns/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<factfinder>
<config>
<campaigns_identifier>sku</campaigns_identifier>
<enable_campaigns_on_prod_page>1</enable_campaigns_on_prod_page>
<enable_campaigns_on_prod_page>0</enable_campaigns_on_prod_page>
</config>
</factfinder>
</default>
Expand Down
2 changes: 1 addition & 1 deletion src/app/code/community/FACTFinder/Core/Helper/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class FACTFinder_Core_Helper_Search extends Mage_Core_Helper_Abstract
*/
public function getQueryText()
{
return Mage::helper('catalogsearch')->getEscapedQueryText();
return strip_tags(Mage::helper('catalogsearch')->getQueryText());
}


Expand Down
11 changes: 7 additions & 4 deletions src/app/code/community/FACTFinder/Core/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,11 @@
<identifier>entity_id</identifier>
</config>
<search>
<address>example.com</address>
<address>cname.fact-finder.com</address>
<port>80</port>
<protocol>http</protocol>
<context>FACT-Finder</context>
<!-- possible values: http, https -->

<!--<ffversion>68</ffversion>-->

<auth_type>advanced</auth_type>
<!-- possible values: http (for FF <= 6.4); simple | advanced (for FF >= 6.5)-->
<auth_advancedPrefix>FACT-FINDER</auth_advancedPrefix>
Expand All @@ -146,8 +144,13 @@
<fallback>
<use_fallback>0</use_fallback>
</fallback>
<export>
<remove_tags>1</remove_tags>
</export>
<modules>
<asn>1</asn>
<suggest>1</suggest>
<tracking>1</tracking>
</modules>
</factfinder>
<advanced>
Expand Down
7 changes: 7 additions & 0 deletions src/app/code/community/FACTFinder/Suggest/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,11 @@
</modules>
</translate>
</frontend>
<default>
<factfinder>
<config>
<proxy>1</proxy>
</config>
</factfinder>
</default>
</config>
23 changes: 2 additions & 21 deletions src/app/code/community/FACTFinder/Tracking/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,14 @@
class FACTFinder_Tracking_Helper_Data extends Mage_Core_Helper_Abstract
{


/**
* Decide whether old tracking should be used
*
* @return bool
*/
public function useOldTracking()
{
$ffVersion = Mage::getStoreConfig('factfinder/search/ffversion');
// to use the new tracking, change the comparison to '$ffVersion < 69'
return ($ffVersion <= 69);
}


/**
/**
* Get the correct path where the tracking should be sent
*
* @return string
*/
public function getTrackingUrlPath()
{
$urlPath = 'ff_tracking/proxy/tracking';
if ($this->useOldTracking()) {
$urlPath = 'ff_tracking/proxy/scic';
}

return $urlPath;
return 'ff_tracking/proxy/tracking';
}

/**
Expand Down
14 changes: 0 additions & 14 deletions src/app/code/community/FACTFinder/Tracking/Model/Facade.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,4 @@ public function getTrackingAdapter($channel = null)
return $this->_getAdapter("tracking", $channel);
}


/**
* Get instance of SCIC adapter
*
* @param string $channel
*
* @return \FACTFinder\Adapter\AbstractAdapter
*/
public function getScicAdapter($channel = null)
{
return $this->_getAdapter("scicTracking", $channel);
}


}
228 changes: 9 additions & 219 deletions src/app/code/community/FACTFinder/Tracking/Model/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/**
* Model class
*
* Request Processor for fast handling
* Request Processor for click tracking handling
*
* @category Mage
* @package FACTFinder_Tracking
Expand All @@ -28,10 +28,6 @@
class FACTFinder_Tracking_Model_Processor
{

const CACHE_TAG = 'FACTFINDER'; // Cache Tag
const REQUEST_ID_PREFIX = 'FACTFINDER_';
const XML_CONFIG_PATH = 'factfinder/search/';

/**
* FactFinder Facade
*
Expand All @@ -50,13 +46,7 @@ class FACTFinder_Tracking_Model_Processor
*/
public function __construct()
{
$uri = $this->_getFullPageUrl();

$this->_initFFAutoloader();

$this->_requestId = $uri;
$this->_requestCacheId = $this->prepareCacheId($this->_requestId);
$this->_requestTags = array(self::CACHE_TAG);
}


Expand Down Expand Up @@ -90,227 +80,27 @@ protected function _getFacade($config = null)
return $this->_facade;
}


/**
* Get page content from cache storage
/**
* Bypass app cache.
*
* @param string $content
*
* @return string | false
* @return false
*/
public function extractContent($content)
{
// handle in App Request if "ff_suggest" in Request path
if (empty($content)
&& strpos($this->_requestId, 'ff_tracking')
&& $this->isAllowed()
) {
$requestCacheId = $this->prepareCacheId($this->getRequestId() . 'request');
$request = Mage::app()->loadCache($requestCacheId);
if ($request) {
$content = $this->handleWithoutAppRequest($request);
}
}

return $content;
return false;
}


/**
* handle in App Requests
*
* @param string $request
*
* @return string
*/
public function handleInAppRequest($request)
{
$requestCacheId = $this->prepareCacheId($this->getRequestId() . 'request');
Mage::app()->saveCache($request, $requestCacheId, $this->getRequestTags());

$configCacheId = $this->prepareCacheId($this->getRequestId() . 'config');
Mage::app()->saveCache(
serialize(Mage::getStoreConfig('factfinder/search')),
$configCacheId, $this->getRequestTags()
);

return $this->_handleRequest($request);
}


/**
* hanlde without App Requests
*
* @param mixed $request
*
* @return string
*/
public function handleWithoutAppRequest($request)
{
$configCacheId = $this->prepareCacheId($this->getRequestId() . 'config');
$config = null;

try {
$config = unserialize(Mage::app()->loadCache($configCacheId));
} catch (Exception $e) {
return '';
}

if (!is_array($config) || empty($config)) {
return '';
}

$this->_getFacade($config);

return $this->_handleRequest($request);
}



/**
* handle Requests
*
* @param string $request
*
* @return string
*/
protected function _handleRequest($request)
{
$result = '';
switch ($request) {
case 'factfinder_tracking_proxy_scic':
$result = $this->_getFacade()->getScicAdapter()->doTrackingFromRequest();
break;

case 'factfinder_tracking_proxy_tracking':
$result = $this->_getFacade()->getTrackingAdapter()->doTrackingFromRequest();
break;
default:;
}

return $result;
}


/**
* get Request Param by Key
*
* @param string $key
*
* @return string
*/
protected function _getRequestParam($key)
{
$value = null;
if (isset($_REQUEST[$key])) {
$value = $_REQUEST[$key];
}
return $value;
}


/**
* Return current page base url
*
* @return string
*/
protected function _getFullPageUrl()
public function handleRequest($request)
{
$uri = false;
/**
* Define server HTTP HOST
*/
if (isset($_SERVER['HTTP_HOST'])) {
$uri = $_SERVER['HTTP_HOST'];
} elseif (isset($_SERVER['SERVER_NAME'])) {
$uri = $_SERVER['SERVER_NAME'];
}

/**
* Define request URI
*/
if ($uri) {
if (isset($_SERVER['REQUEST_URI'])) {
$uri .= $_SERVER['REQUEST_URI'];
} elseif (!empty($_SERVER['IIS_WasUrlRewritten']) && !empty($_SERVER['UNENCODED_URL'])) {
$uri .= $_SERVER['UNENCODED_URL'];
} elseif (isset($_SERVER['ORIG_PATH_INFO'])) {
$uri .= $_SERVER['ORIG_PATH_INFO'];
if (!empty($_SERVER['QUERY_STRING'])) {
$uri .= $_SERVER['QUERY_STRING'];
}
}
}

$pieces = explode('?', $uri);
$uri = array_shift($pieces);

return $uri;
}


/**
* Prepare page identifier
*
* @param string $id
*
* @return string
*/
public function prepareCacheId($id)
{
return self::REQUEST_ID_PREFIX . md5($id);
}


/**
* Get HTTP request identifier
*
* @return string
*/
public function getRequestId()
{
return $this->_requestId . (isset($_COOKIE['store']) ? $_COOKIE['store'] : '');
}


/**
* Get page identifier for loading page from cache
*
* @return string
*/
public function getRequestCacheId()
{
return $this->_requestCacheId;
}


/**
* Check if processor is allowed for current HTTP request.
* Disable processing HTTPS requests and requests with "NO_CACHE" cookie
*
* @return bool
*/
public function isAllowed()
{
if (!$this->_requestId
|| isset($_COOKIE['NO_CACHE'])
|| isset($_GET['no_cache'])
) {
return false;
}

return true;
}


/**
* Get cache request associated tags
*
* @return array
*/
public function getRequestTags()
{
return $this->_requestTags;
}


return $this->_getFacade()->getTrackingAdapter()->doTrackingFromRequest();
}
}
Loading

0 comments on commit 9fea655

Please sign in to comment.