-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PLUGINRANGERS-267 | Adjust plugin to the version 9 guidelines (#269)
* feat: Migrated config + autoloader * feat: Adapted doofinder-ajax.php * feat: Removed all the .php files from root folder except main file * feat: Version bump to 4.10.0 * fix: Changed PHP linter versions
- Loading branch information
1 parent
479b16c
commit bfa5473
Showing
19 changed files
with
389 additions
and
341 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/** | ||
* NOTICE OF LICENSE | ||
* | ||
* This file is licenced under the Software License Agreement. | ||
* With the purchase or the installation of the software in your application | ||
* you accept the licence agreement. | ||
* | ||
* You must not modify, adapt or create derivative works of this source code | ||
* | ||
* @author Doofinder | ||
* @copyright Doofinder | ||
* @license GPLv3 | ||
*/ | ||
if (!defined('_PS_VERSION_')) { | ||
exit; | ||
} | ||
|
||
use PrestaShop\Module\Doofinder\Src\Entity\DoofinderApi; | ||
use PrestaShop\Module\Doofinder\Src\Entity\DoofinderInstallation; | ||
|
||
class DoofinderAjaxModuleFrontController extends ModuleFrontController | ||
{ | ||
/** | ||
* Assign template vars related to page content. | ||
* | ||
* @see FrontController::initContent() | ||
*/ | ||
public function initContent() | ||
{ | ||
parent::initContent(); | ||
|
||
$this->ajax = 1; | ||
|
||
$checkApiKey = Tools::getValue('check_api_key'); | ||
if ($checkApiKey) { | ||
exit(DoofinderApi::checkApiKey(true)); | ||
} | ||
|
||
$autoinstaller = Tools::getValue('autoinstaller'); | ||
$shopId = Tools::getValue('shop_id', null); | ||
if ($autoinstaller) { | ||
if (Tools::getValue('token') == Tools::encrypt('doofinder-ajax')) { | ||
header('Content-Type:application/json; charset=utf-8'); | ||
DoofinderInstallation::autoinstaller($shopId); | ||
$this->ajaxRender(json_encode(['success' => true])); | ||
exit; | ||
} else { | ||
$this->ajaxRender(json_encode([ | ||
'success' => false, 'errors' => ['Forbidden access. Invalid token for autoinstaller.'], | ||
])); | ||
exit; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
/** | ||
* NOTICE OF LICENSE | ||
* | ||
* This file is licenced under the Software License Agreement. | ||
* With the purchase or the installation of the software in your application | ||
* you accept the licence agreement. | ||
* | ||
* You must not modify, adapt or create derivative works of this source code | ||
* | ||
* @author Doofinder | ||
* @copyright Doofinder | ||
* @license GPLv3 | ||
*/ | ||
if (!defined('_PS_VERSION_')) { | ||
exit; | ||
} | ||
|
||
class DoofinderCacheModuleFrontController extends ModuleFrontController | ||
{ | ||
/** | ||
* Assign template vars related to page content. | ||
* | ||
* @see FrontController::initContent() | ||
*/ | ||
public function initContent() | ||
{ | ||
parent::initContent(); | ||
|
||
$this->ajax = 1; | ||
|
||
if (Tools::isSubmit('landing')) { | ||
if ($_SERVER['REQUEST_METHOD'] === 'POST') { | ||
return Db::getInstance()->delete('doofinder_landing'); | ||
} | ||
exit; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<?php | ||
/** | ||
* NOTICE OF LICENSE | ||
* | ||
* This file is licenced under the Software License Agreement. | ||
* With the purchase or the installation of the software in your application | ||
* you accept the licence agreement. | ||
* | ||
* You must not modify, adapt or create derivative works of this source code | ||
* | ||
* @author Doofinder | ||
* @copyright Doofinder | ||
* @license GPLv3 | ||
*/ | ||
if (!defined('_PS_VERSION_')) { | ||
exit; | ||
} | ||
|
||
use PrestaShop\Module\Doofinder\Src\Entity\DfTools; | ||
use PrestaShop\Module\Doofinder\Src\Entity\DoofinderConfig; | ||
use PrestaShop\Module\Doofinder\Src\Entity\DoofinderConstants; | ||
|
||
class DoofinderConfigModuleFrontController extends ModuleFrontController | ||
{ | ||
/** | ||
* Assign template vars related to page content. | ||
* | ||
* @see FrontController::initContent() | ||
*/ | ||
public function initContent() | ||
{ | ||
parent::initContent(); | ||
|
||
$this->ajax = 1; | ||
|
||
header('Content-Type:application/json; charset=utf-8'); | ||
|
||
$module = Module::getInstanceByName('doofinder'); | ||
$autoinstallerToken = Tools::getValue('token'); | ||
if ($autoinstallerToken) { | ||
$redirect = Context::getContext()->shop->getBaseURL(true, false) | ||
. $module->getPathUri() . 'config.php'; | ||
$tmpToken = Tools::encrypt($redirect); | ||
if ($tmpToken == $autoinstallerToken) { | ||
$apiToken = Tools::getValue('api_token'); | ||
$api_endpoint = Tools::getValue('api_endpoint'); | ||
$admin_endpoint = Tools::getValue('admin_endpoint'); | ||
if ($apiToken) { | ||
DoofinderConfig::saveApiConfig($apiToken, $api_endpoint, $admin_endpoint); | ||
} | ||
echo json_encode(['success' => true]); | ||
exit; | ||
} else { | ||
header('HTTP/1.1 403 Forbidden', true, 403); | ||
$msgError = 'Forbidden access.' | ||
. ' Token for autoinstaller invalid.'; | ||
exit($msgError); | ||
} | ||
} | ||
|
||
$languages = []; | ||
$configurations = []; | ||
$currencies = array_keys(DfTools::getAvailableCurrencies()); | ||
|
||
$display_prices = (bool) Configuration::get('DF_GS_DISPLAY_PRICES'); | ||
$prices_with_taxes = (bool) Configuration::get('DF_GS_PRICES_USE_TAX'); | ||
|
||
foreach (Language::getLanguages(true, $this->context->shop->id) as $lang) { | ||
$lang = Tools::strtoupper($lang['iso_code']); | ||
$currency = DfTools::getCurrencyForLanguage($lang); | ||
|
||
$languages[] = $lang; | ||
$configurations[$lang] = [ | ||
'language' => $lang, | ||
'currency' => Tools::strtoupper($currency->iso_code), | ||
'prices' => $display_prices, | ||
'taxes' => $prices_with_taxes, | ||
]; | ||
} | ||
|
||
$force_ssl = (Configuration::get('PS_SSL_ENABLED') && Configuration::get('PS_SSL_ENABLED_EVERYWHERE')); | ||
$shop = $this->context->shop; | ||
$base = (($force_ssl) ? 'https://' . $shop->domain_ssl : 'http://' . $shop->domain); | ||
|
||
$cfg = [ | ||
'platform' => [ | ||
'name' => 'Prestashop', | ||
'version' => _PS_VERSION_, | ||
], | ||
'module' => [ | ||
'version' => DoofinderConstants::VERSION, | ||
'feed' => $base . $shop->getBaseURI() . 'modules/doofinder/feed.php', | ||
'options' => [ | ||
'language' => $languages, | ||
'currency' => $currencies, | ||
], | ||
'configuration' => $configurations, | ||
], | ||
]; | ||
|
||
$this->ajaxRender(DfTools::jsonEncode($cfg)); | ||
} | ||
} |
Oops, something went wrong.