Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
2841636
add cs-fixer & fix files, add phpstan & begin lvl 0
arnaud-hours Feb 25, 2026
b9611dc
remove dev dependencies breaking prestashop
arnaud-hours Feb 26, 2026
9aef3b8
fix some Tools functions & product page
arnaud-hours Feb 26, 2026
7bfdd11
fixes for product export
arnaud-hours Feb 26, 2026
cafbc07
phpstan lvl 0
arnaud-hours Feb 27, 2026
dd890d8
phpstan lvl 2
arnaud-hours Feb 27, 2026
2ad73d5
phpstan lvl 3
arnaud-hours Feb 27, 2026
f3f254b
phpstan lvl 4 (wip)
arnaud-hours Feb 27, 2026
a54d990
phpstan lvl 4
arnaud-hours Feb 27, 2026
9a6fd55
phpstan lvl 5
arnaud-hours Feb 27, 2026
ea265a8
phpstan lvl 6
arnaud-hours Feb 27, 2026
b5d4785
type hint everything
arnaud-hours Feb 27, 2026
7afe9c5
type hint everything
arnaud-hours Feb 27, 2026
aeefd96
fix: type attributes, arguments, etc..
arnaud-hours Mar 4, 2026
3a02f66
migrate controllers
arnaud-hours Mar 4, 2026
8cb7cde
controllers
arnaud-hours Mar 9, 2026
63ce1fb
validator step 1
arnaud-hours Mar 9, 2026
b13ccd1
validator step 2 ?
arnaud-hours Mar 10, 2026
d04c61a
front controllers, fix front dashboard issues
arnaud-hours Mar 11, 2026
a25d2fb
fix settings front issues
arnaud-hours Mar 11, 2026
b2ccd4f
fix nav header front issues
arnaud-hours Mar 11, 2026
c70f87f
fix orders header front issues
arnaud-hours Mar 11, 2026
78609db
fix order settings mktp front issues
arnaud-hours Mar 11, 2026
c61cf53
front controllers & backward url compatibility
arnaud-hours Mar 11, 2026
a6956f8
fix toolbox front controller
arnaud-hours Mar 11, 2026
898668d
fix nullable variables
arnaud-hours Mar 12, 2026
5f4bb2e
fix cron import
arnaud-hours Mar 12, 2026
5d987a6
fix deprecated
arnaud-hours Mar 12, 2026
c3af45a
remove controller override
arnaud-hours Mar 12, 2026
ec95eba
fix some var typing
arnaud-hours Mar 13, 2026
28bc320
fix some var typing & cancel hook
arnaud-hours Mar 13, 2026
3c1b9d4
remove pre v8.0 code
arnaud-hours Mar 13, 2026
c72f353
fix: harden JavaScript against XSS and open redirect vulnerabilities
arnaud-hours Mar 13, 2026
5bae0bc
fix security issues reported by AppScan
arnaud-hours Mar 13, 2026
35d8b12
prestashop validator fixes
arnaud-hours Mar 16, 2026
a71065d
prestashop validator fixes
arnaud-hours Mar 16, 2026
da41d9f
translate
arnaud-hours Mar 18, 2026
f34c03e
remove webservice folder, use only front controllers
arnaud-hours Mar 20, 2026
2d5678e
admin page title translations
arnaud-hours Mar 20, 2026
3e4ae7e
fix install status
arnaud-hours Mar 20, 2026
6dcb5e5
fix lengow backup
arnaud-hours Mar 23, 2026
37fc862
legacy links
arnaud-hours Mar 23, 2026
4f2b852
fix tmp return in LengowImport
arnaud-hours Mar 25, 2026
914a09c
backward compatibility for v8.0.0
arnaud-hours Mar 25, 2026
ad39790
paymentTop -> displayPaymentTop
arnaud-hours Mar 26, 2026
b8daad7
clean docs & old pre v8.0 code
arnaud-hours Mar 26, 2026
96e5dd3
remove not used anymore .htaccess
arnaud-hours Mar 26, 2026
9a0066e
add .htaccess back (avoid 403 on legacy urls)
arnaud-hours Mar 27, 2026
a9c1fdc
revert back to 3.9.4 (will be updated with release please)
arnaud-hours Mar 27, 2026
51fc2e7
fix potentiel hook duplicate error
arnaud-hours Mar 27, 2026
4ecc1c4
fix deprecated curl_close with php8.5
arnaud-hours Mar 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ config/marketplaces.json
tools/vars.sh
.php_cs.cache
.php-cs-fixer.cache
.php-cs-fixer.dist.php
60 changes: 60 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

$finder = PhpCsFixer\Finder::create()->in([
__DIR__.'/classes',
__DIR__.'/src',
__DIR__.'/controllers',
__DIR__.'/upgrade',
__DIR__.'/webservice',
]);

return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'array_indentation' => true,
'cast_spaces' => [
'space' => 'single',
],
'combine_consecutive_issets' => true,
'concat_space' => [
'spacing' => 'one',
],
'error_suppression' => [
'mute_deprecation_error' => false,
'noise_remaining_usages' => false,
'noise_remaining_usages_exclude' => [],
],
'function_to_constant' => false,
'method_chaining_indentation' => true,
'no_alias_functions' => false,
'no_superfluous_phpdoc_tags' => false,
'non_printable_character' => [
'use_escape_sequences_in_strings' => true,
],
'phpdoc_align' => [
'align' => 'left',
],
'phpdoc_summary' => false,
'protected_to_private' => false,
'psr_autoloading' => false,
'self_accessor' => false,
'yoda_style' => false,
'single_line_throw' => false,
'no_alias_language_construct_call' => false,
'no_null_property_initialization' => false,
'nullable_type_declaration_for_default_null_value' => true,
'global_namespace_import' => [
'import_classes' => false,
'import_constants' => false,
'import_functions' => false,
],
'blank_line_after_opening_tag' => false,
'no_extra_blank_lines' => [
'tokens' => [
'extra',
'use',
],
],
])
->setFinder($finder);
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Lengow for PrestaShop

- **Requires at least:** 1.7.7
- **Tested up to:** 8.1.7
- **Requires PHP:** 7.4
- **Requires at least:** 8.0.0
- **Tested up to:** 9.0.0
- **Requires PHP:** 8.1
- **Stable tag:** 3.9.4 <!-- x-release-please-version -->
- **License:** Apache-2.0
- **License URI:** http://www.apache.org/licenses/LICENSE-2.0
Expand Down Expand Up @@ -75,7 +75,7 @@ Translations in the plugin are managed via a key system and associated yaml file

Start by installing Yaml Parser:

sudo apt-get install php5-dev libyaml-dev
sudo apt-get install php-dev libyaml-dev
sudo pecl install yaml

To translate the project, use specific key in php code and modify the *.yml files in the directory: `lengow/translations/yml/`
Expand Down
161 changes: 114 additions & 47 deletions classes/controllers/LengowController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,95 +22,160 @@
/*
* Lengow Controller Class
*/
use Twig\Environment;

if (!defined('_PS_VERSION_')) {
exit;
}
class LengowController
{
/**
* @var Lengow Lengow module instance
* @var Lengow|false Lengow module instance
*/
protected $module;
protected Lengow|false $module;

/**
* @var Context PrestaShop context instance
*/
protected $context;
protected Context $context;

/**
* @var LengowLink Lengow link instance
*/
protected $lengowLink;
protected LengowLink $lengowLink;

/**
* @var LengowTranslation Lengow translation instance
*/
protected $locale;
protected LengowTranslation $locale;

/**
* @var bool Check if is a new merchant
*/
protected $isNewMerchant;
protected bool $isNewMerchant;

/**
* @var Environment|null Twig environment instance
*/
protected ?Environment $twig = null;

/**
* @var array<string, mixed> Variables passed to Twig templates
*/
protected array $templateVars = [];

/**
* @var bool Whether controller runs through Symfony bridge and must not echo/exit
*/
protected bool $bridgeMode = false;

/**
* @var array<string, mixed>|null JSON payload produced during postProcess in bridge mode
*/
private ?array $jsonResponsePayload = null;

/**
* Construct the main Lengow controller
*
* @param Context $context PrestaShop context (injected from Symfony controller on PS9,
* or resolved via LengowContext on PS8)
* @param Environment|null $twig Twig environment instance
* @param bool $bridgeMode Enable bridge mode to avoid direct output side effects
*/
public function __construct()
public function __construct(Context $context, ?Environment $twig = null, bool $bridgeMode = false)
{
$this->module = Module::getInstanceByName('lengow');
$this->context = Context::getContext();
$this->context = $context;
$this->twig = $twig;
$this->bridgeMode = $bridgeMode;
$this->lengowLink = new LengowLink();
$this->locale = new LengowTranslation();
$this->locale = new LengowTranslation($this->context);
$this->isNewMerchant = LengowConfiguration::isNewMerchant();
$this->context->smarty->assign('locale', $this->locale);
$this->templateVars['locale'] = $this->locale;
$lengowPathUri = $this->module->getPathUri();
$this->context->smarty->assign('lengowPathUri', $lengowPathUri);
$this->templateVars['lengowPathUri'] = $lengowPathUri;
$this->templateVars['lengow_link'] = $this->lengowLink;
}

/**
* Process Post Parameters
*
* @return void
*/
public function postProcess()
public function postProcess(): void
{
$this->prepareDisplay();
}

/**
* Display data page
*
* @return void
*/
public function display()
public function display(): void
{
$this->prepareDisplay();
$this->context->smarty->assign('total_pending_order', LengowOrder::countOrderToBeSent());
$this->templateVars['total_pending_order'] = LengowOrder::countOrderToBeSent();
}

/**
* Force Display data page
* Get all template variables
*
* @return array<string, mixed>
*/
public function forceDisplay()
public function getTemplateVars(): array
{
$module = Module::getInstanceByName('lengow');
$lengowMain = new LengowMain();
$className = get_class($this);
$path = $lengowMain->fromCamelCase(Tools::substr($className, 0, Tools::strlen($className) - 10));
$this->prepareDisplay();
echo $module->display(_PS_MODULE_LENGOW_DIR_, 'views/templates/admin/' . $path . '/helpers/view/view.tpl');
return $this->templateVars;
}

/**
* @return array<string, mixed>|null
*/
public function consumeJsonResponse(): ?array
{
$payload = $this->jsonResponsePayload;
$this->jsonResponsePayload = null;

return $payload;
}

/**
* @param array<string, mixed> $payload
*/
protected function respondJson(array $payload): void
{
if ($this->bridgeMode) {
$this->jsonResponsePayload = $payload;

return;
}

echo json_encode($payload);
}

protected function finishPostProcess(): void
{
if ($this->bridgeMode) {
return;
}

exit;
}

/**
* Checks if the plugin upgrade modal should be displayed or not
*
* @return bool
*/
private function showPluginUpgradeModal()
private function showPluginUpgradeModal(): bool
{
// never display the upgrade modal during the connection process
$className = get_class($this);
if (Tools::substr($className, 0, 10) === 'LengowHome') {
return false;
}
$updatedAt = LengowConfiguration::getGlobalValue(LengowConfiguration::LAST_UPDATE_PLUGIN_MODAL);
if ($updatedAt !== null && (time() - (int) $updatedAt) < 86400) {
if ($updatedAt !== '' && (time() - (int) $updatedAt) < 86400) {
return false;
}
LengowConfiguration::updateGlobalValue(LengowConfiguration::LAST_UPDATE_PLUGIN_MODAL, time());
Expand All @@ -120,10 +185,12 @@ private function showPluginUpgradeModal()

/**
* affect variables to template display
*
* @return void
*/
protected function prepareDisplay()
protected function prepareDisplay(): void
{
$localeIsoCode = Tools::substr(Context::getContext()->language->language_code, 0, 2);
$localeIsoCode = Tools::substr($this->context->language->language_code, 0, 2);
$multiShop = Shop::isFeatureActive();
$debugMode = LengowConfiguration::debugModeIsActive();
$merchantStatus = LengowSync::getStatusAccount();
Expand All @@ -145,26 +212,26 @@ protected function prepareDisplay()
}
// get actual plugin urls in current language
$pluginLinks = LengowSync::getPluginLinks($localeIsoCode, true);
// assignment of all smarty variables for the entire plugin

$this->context->smarty->assign('current_controller', get_class($this));
$this->context->smarty->assign('lengow_link', $this->lengowLink);
$this->context->smarty->assign('localeIsoCode', $localeIsoCode);
$this->context->smarty->assign('version', _PS_VERSION_);
$this->context->smarty->assign('lengowVersion', $this->module->version);
$this->context->smarty->assign('lengowUrl', LengowConfiguration::getLengowUrl());
$this->context->smarty->assign('displayToolbar', $displayToolbar);
$this->context->smarty->assign('pluginData', $pluginData);
$this->context->smarty->assign('pluginIsUpToDate', $pluginIsUpToDate);
$this->context->smarty->assign('showPluginUpgradeModal', $showPluginUpgradeModal);
$this->context->smarty->assign('lengowModalAjaxLink', $lengowModalAjaxLink);
$this->context->smarty->assign('helpCenterLink', $pluginLinks[LengowSync::LINK_TYPE_HELP_CENTER]);
$this->context->smarty->assign('updateGuideLink', $pluginLinks[LengowSync::LINK_TYPE_UPDATE_GUIDE]);
$this->context->smarty->assign('changelogLink', $pluginLinks[LengowSync::LINK_TYPE_CHANGELOG]);
$this->context->smarty->assign('supportLink', $pluginLinks[LengowSync::LINK_TYPE_SUPPORT]);
$this->context->smarty->assign('multiShop', $multiShop);
$this->context->smarty->assign('debugMode', $debugMode);
$this->context->smarty->assign('isNewMerchant', $this->isNewMerchant);
$this->context->smarty->assign('merchantStatus', $merchantStatus);
// assignment of all template variables for the entire plugin

$this->templateVars['current_controller'] = get_class($this);
$this->templateVars['lengow_link'] = $this->lengowLink;
$this->templateVars['localeIsoCode'] = $localeIsoCode;
$this->templateVars['version'] = _PS_VERSION_;
$this->templateVars['lengowVersion'] = $this->module->version;
$this->templateVars['lengowUrl'] = LengowConfiguration::getLengowUrl();
$this->templateVars['displayToolbar'] = $displayToolbar;
$this->templateVars['pluginData'] = $pluginData;
$this->templateVars['pluginIsUpToDate'] = $pluginIsUpToDate;
$this->templateVars['showPluginUpgradeModal'] = $showPluginUpgradeModal;
$this->templateVars['lengowModalAjaxLink'] = $lengowModalAjaxLink;
$this->templateVars['helpCenterLink'] = $pluginLinks[LengowSync::LINK_TYPE_HELP_CENTER];
$this->templateVars['updateGuideLink'] = $pluginLinks[LengowSync::LINK_TYPE_UPDATE_GUIDE];
$this->templateVars['changelogLink'] = $pluginLinks[LengowSync::LINK_TYPE_CHANGELOG];
$this->templateVars['supportLink'] = $pluginLinks[LengowSync::LINK_TYPE_SUPPORT];
$this->templateVars['multiShop'] = $multiShop;
$this->templateVars['debugMode'] = $debugMode;
$this->templateVars['isNewMerchant'] = $this->isNewMerchant;
$this->templateVars['merchantStatus'] = $merchantStatus;
}
}
14 changes: 9 additions & 5 deletions classes/controllers/LengowDashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ class LengowDashboardController extends LengowController
{
/**
* Process Post Parameters
*
* @return void
*/
public function postProcess()
public function postProcess(): void
{
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : false;
if ($action) {
Expand All @@ -41,20 +43,22 @@ public function postProcess()
case 'remind_me_later':
$timestamp = time() + (7 * 86400);
LengowConfiguration::updateGlobalValue(LengowConfiguration::LAST_UPDATE_PLUGIN_MODAL, $timestamp);
echo json_encode(['success' => true]);
$this->respondJson(['success' => true]);
break;
}
exit;
$this->finishPostProcess();
}
}

/**
* Display data page
*
* @return void
*/
public function display()
public function display(): void
{
$refreshStatus = $this->lengowLink->getAbsoluteAdminLink('AdminLengowDashboard') . '&action=refresh_status';
$this->context->smarty->assign('refresh_status', $refreshStatus);
$this->templateVars['refresh_status'] = $refreshStatus;
parent::display();
}
}
Loading
Loading