first commit

This commit is contained in:
2024-12-17 13:43:22 +01:00
commit 8e6cd8b410
21292 changed files with 3514826 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
<?php
/**
* NOTICE OF LICENSE
*
* This file is licenced under the GNU General Public License, version 3 (GPL-3.0).
* With the purchase or the installation of the software in your application
* you accept the licence agreement.
*
* @author emarketing www.emarketing.com <integrations@emarketing.com>
* @copyright 2020 emarketing AG
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
*/
namespace Emarketing\Action;
/**
* Class Attributes
* @package Emarketing\Action
*/
class Attributes
{
/**
* @param $postData
* @return array
*/
public function fetchAttributes($postData)
{
$idLang = $this->getIdLanguage($postData);
$serviceAttributes = new \Emarketing\Service\Attributes;
return $serviceAttributes->buildAttributeInformation($idLang);
}
/**
* @param $postData
* @return mixed
*/
private function getIdLanguage($postData)
{
if (!isset($postData['id_language']) || !is_numeric($postData['id_language'])) {
return \Context::getContext()->language->id;
}
return $postData['id_language'];
}
}

View File

@@ -0,0 +1,70 @@
<?php
/**
* NOTICE OF LICENSE
*
* This file is licenced under the GNU General Public License, version 3 (GPL-3.0).
* With the purchase or the installation of the software in your application
* you accept the licence agreement.
*
* @author emarketing www.emarketing.com <integrations@emarketing.com>
* @copyright 2020 emarketing AG
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
*/
namespace Emarketing\Action;
use Emarketing\ClientError;
/**
* Class Categories
* @package Emarketing\Action
*/
class Categories
{
/**
* @param $postData
* @return array
* @throws ClientError
*/
public function fetchCategory($postData)
{
$idCategory = $this->getIdCategory($postData);
$idLang = $this->getIdLanguage($postData);
$serviceCategory = new \Emarketing\Service\Category;
return $serviceCategory->buildCategoryInformation($idCategory, $idLang);
}
/**
* @param $postData
* @return string
* @throws ClientError
*/
private function getIdCategory($postData)
{
if (!isset($postData['id_category']) || !is_numeric($postData['id_category'])) {
throw new ClientError('Invalid Category ID');
}
if ($postData['id_category'] === 0) {
return \Configuration::get('PS_HOME_CATEGORY');
}
return $postData['id_category'];
}
/**
* @param $postData
* @return mixed
*/
private function getIdLanguage($postData)
{
if (!isset($postData['id_language']) || !is_numeric($postData['id_language'])) {
return \Context::getContext()->language->id;
}
return $postData['id_language'];
}
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* NOTICE OF LICENSE
*
* This file is licenced under the GNU General Public License, version 3 (GPL-3.0).
* With the purchase or the installation of the software in your application
* you accept the licence agreement.
*
* @author emarketing www.emarketing.com <integrations@emarketing.com>
* @copyright 2020 emarketing AG
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
*/
namespace Emarketing\Action;
/**
* Class Countries
* @package Emarketing\Action
*/
class Countries
{
/**
* @return array
*/
public function fetchCountries()
{
$serviceCountries = new \Emarketing\Service\Countries;
return $serviceCountries->buildCountryInformation();
}
}

View File

@@ -0,0 +1,55 @@
<?php
/**
* NOTICE OF LICENSE
*
* This file is licenced under the GNU General Public License, version 3 (GPL-3.0).
* With the purchase or the installation of the software in your application
* you accept the licence agreement.
*
* @author emarketing www.emarketing.com <integrations@emarketing.com>
* @copyright 2020 emarketing AG
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
*/
namespace Emarketing\Action;
/**
* Class FacebookTracker
* @package Emarketing\Action
*/
class FacebookPixel
{
/**
* @param $postData
* @return bool|array
* @throws \Exception
*/
public function receivePixel($postData)
{
$serviceTracker = new \Emarketing\Service\FacebookPixel();
$globalTag = $this->getCode($postData, 'global_tag');
$viewContent = $this->getCode($postData, 'view_content_snippet');
$addToCart = $this->getCode($postData, 'add_to_cart_snippet');
$purchase = $this->getCode($postData, 'purchase_snippet');
return $serviceTracker->savePixel($globalTag, $viewContent, $addToCart, $purchase);
}
/**
* @param $postData
* @param $name
* @return string|null
*/
private function getCode($postData, $name)
{
if (!isset($postData[$name])) {
return null;
}
return $postData[$name];
}
}

View File

@@ -0,0 +1,51 @@
<?php
/**
* NOTICE OF LICENSE
*
* This file is licenced under the GNU General Public License, version 3 (GPL-3.0).
* With the purchase or the installation of the software in your application
* you accept the licence agreement.
*
* @author emarketing www.emarketing.com <integrations@emarketing.com>
* @copyright 2020 emarketing AG
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
*/
namespace Emarketing\Action;
/**
* Class Tracker
* @package Emarketing\Action
*/
class GoogleTracker
{
/**
* @param $postData
* @return bool|array
* @throws \Exception
*/
public function receiveTracker($postData)
{
$serviceTracker = new \Emarketing\Service\GoogleTracker();
$globalSiteTracker = $this->getCode($postData, 'global_site_tracker');
$conversionTracker = $this->getCode($postData, 'conversion_tracker');
return $serviceTracker->saveTracker($globalSiteTracker, $conversionTracker);
}
/**
* @param $postData
* @param $name
* @return string|null
*/
private function getCode($postData, $name)
{
if (!isset($postData[$name])) {
return null;
}
return $postData[$name];
}
}

View File

@@ -0,0 +1,100 @@
<?php
/**
* NOTICE OF LICENSE
*
* This file is licenced under the GNU General Public License, version 3 (GPL-3.0).
* With the purchase or the installation of the software in your application
* you accept the licence agreement.
*
* @author emarketing www.emarketing.com <integrations@emarketing.com>
* @copyright 2020 emarketing AG
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
*/
namespace Emarketing\Action;
use Emarketing\ClientError;
/**
* Class Products
* @package Emarketing\Action
*/
class Products
{
/**
* @param $postData
* @return array
* @throws ClientError
* @throws \Exception
*/
public function fetchProducts($postData)
{
$offset = $this->checkValidParam($postData, 'offset');
$limit = $this->checkValidParam($postData, 'limit');
$idLang = $this->getIdLanguage($postData);
$idCountry = $this->getIdCountry($postData);
$idCurrency = $this->getIdCurrency($postData);
$serviceProducts = new \Emarketing\Service\Products;
return $serviceProducts->buildProductsInformation($offset, $limit, $idLang, $idCountry, $idCurrency);
}
/**
* @param $postData
* @param $param
* @return mixed
* @throws ClientError
*/
private function checkValidParam($postData, $param)
{
if (!isset($postData[$param]) || !is_numeric($postData[$param]) || $postData[$param] < 0) {
throw new ClientError('Invalid ' . $param);
}
return $postData[$param];
}
/**
* @param $postData
* @return mixed
*/
private function getIdLanguage($postData)
{
if (!isset($postData['id_language']) || !is_numeric($postData['id_language'])) {
return \Context::getContext()->language->id;
}
return $postData['id_language'];
}
/**
* @param $postData
* @return string
*/
private function getIdCountry($postData)
{
if (!isset($postData['id_country']) || !is_numeric($postData['id_country'])) {
return \Configuration::get('PS_COUNTRY_DEFAULT');
}
return $postData['id_country'];
}
/**
* @param $postData
* @return string
*/
private function getIdCurrency($postData)
{
if (!isset($postData['id_currency']) || !is_numeric($postData['id_currency'])) {
return \Configuration::get('PS_CURRENCY_DEFAULT');
}
return $postData['id_currency'];
}
}

View File

@@ -0,0 +1,39 @@
<?php
/**
* NOTICE OF LICENSE
*
* This file is licenced under the GNU General Public License, version 3 (GPL-3.0).
* With the purchase or the installation of the software in your application
* you accept the licence agreement.
*
* @author emarketing www.emarketing.com <integrations@emarketing.com>
* @copyright 2020 emarketing AG
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
*/
namespace Emarketing\Action;
use Emarketing\ClientError;
/**
* Class Verification
* @package Emarketing\Action
*/
class Verification
{
/**
* @param $postData
* @return bool
* @throws \Exception
*/
public function receiveTag($postData)
{
$serviceVerification = new \Emarketing\Service\Verification;
if (!isset($postData['tag'])) {
throw new ClientError('Missing tag');
}
return $serviceVerification->saveTag($postData['tag']);
}
}

View File

@@ -0,0 +1,11 @@
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;