Skip to content

Commit

Permalink
v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Proske committed Aug 12, 2021
1 parent cc9a752 commit 8363552
Show file tree
Hide file tree
Showing 99 changed files with 4,319 additions and 2,807 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,16 @@ report
vendor/
node_modules
adminmenu/js/dist
.php-cs-fixer.php
phpcs-gitlab.xml
phpcs.xml
psalm.xml
adminmenu/app/postcss.config.js
adminmenu/app/prettier.config.js
adminmenu/app/README.md
adminmenu/app/tsconfig.json
adminmenu/app/yarn.lock
adminmenu/app/src
adminmenu/app/public
adminmenu/app/test
*.map
126 changes: 21 additions & 105 deletions Bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
<?php

/**
* @copyright 2020 WebStollen GmbH
* @copyright 2021 WebStollen GmbH
* @link https://www.webstollen.de
*/

namespace Plugin\ws5_mollie;

use JTL\Events\Dispatcher;
use JTL\Plugin\Bootstrapper;
use JTL\Plugin\Helper;
use JTL\Shop;
use JTL\Smarty\JTLSmarty;
use JTL\Exceptions\CircularReferenceException;
use JTL\Exceptions\ServiceNotFoundException;
use Plugin\ws5_mollie\lib\Hook\ApplePay;
use Plugin\ws5_mollie\lib\Hook\Checkbox;
use Plugin\ws5_mollie\lib\Hook\Queue;
use Plugin\ws5_mollie\lib\Mapper\MollieUpgradeMapper;
use WS\JTL5\Mapper\UpgradeMapperInterface;

class Bootstrap extends Bootstrapper
{

/** @var Dispatcher */
protected $dispatcher;
require_once __DIR__ . '/vendor/autoload.php';

public function boot(Dispatcher $dispatcher)
class Bootstrap extends \WS\JTL5\Bootstrap
{
/**
* @param Dispatcher $dispatcher
* @throws CircularReferenceException
* @throws ServiceNotFoundException
*/
public function boot(Dispatcher $dispatcher): void
{

parent::boot($dispatcher);
$this->dispatcher = $dispatcher;

require_once __DIR__ . '/vendor/autoload.php';

$this->listen(HOOK_SMARTY_OUTPUTFILTER, [ApplePay::class, 'execute']);

Expand All @@ -41,98 +42,13 @@ public function boot(Dispatcher $dispatcher)
if ($this->getPlugin()->getConfig()->getValue('useCustomerAPI') === 'C') {
$this->listen(HOOK_CHECKBOX_CLASS_GETCHECKBOXFRONTEND, [Checkbox::class, 'execute']);
}

}

protected function listen(int $hook, callable $listener, int $priority = 5): Bootstrap
{
if ($this->dispatcher) {
try {
$this->dispatcher->listen('shop.hook.' . $hook, $listener, $priority);
} catch (\Exception $e) {
\Shop::Container()->getLogService()->error($e->getMessage());
}
}
return $this;
}

public function renderAdminMenuTab(string $tabName, int $menuID, JTLSmarty $smarty): string
{
switch ($tabName) {
case 'Dashboard':
$oPlugin = Helper::getPluginById("ws5_mollie");
$info = null;
if ($oPlugin) {
$info = (object)[
'id' => $oPlugin->getID(),
'shopURL' => Shop::getURL(),
'adminURL' => Shop::getAdminURL(),
'token' => $_SESSION['jtl_token'],
'endpoint' => $oPlugin->getPaths()->getAdminURL() . 'api.php',
'pluginID' => $oPlugin->getPluginID(),
'version' => $oPlugin->getCurrentVersion()->getOriginalVersion(),
'name' => $oPlugin->getMeta()->getName(),
'svg' => http_build_query([
'p' => $oPlugin->getPluginID(),
'v' => $oPlugin->getCurrentVersion()->getOriginalVersion(),
's' => APPLICATION_VERSION,
//'b' => JTL_MINOR_VERSION,
'd' => self::getDomain(),
'm' => base64_encode(self::getMasterMail(true)),
'php' => PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION . PHP_EXTRA_VERSION,
]),
/*'settings' => array_map(static function ($value) {
return $value->value;
}, $oPlugin->getConfig()->getAssoc())*/
];
}

$css = [];
if (file_exists(__DIR__ . '/adminmenu/app/build/index.html')) {
$build = \phpQuery::newDocumentFileHTML(__DIR__ . '/adminmenu/app/build/index.html');

pq('#pluginInfo', $build)->text(json_encode($info));
$pqCSSs = pq('head link', $build);
/** @var \DOMElement $pqCSS */
foreach ($pqCSSs as $pqCSS) {
$css[] = $oPlugin->getPaths()->getAdminURL() . 'app/build' . $pqCSS->getAttribute('href');
}
$body = str_replace('/static/', $oPlugin->getPaths()->getAdminURL() . 'app/build/static/', (string)pq('body', $build)->contents());
} else {
throw new \Exception('Backend-Build is missing!');
}

Shop::Smarty()
->assign('body', $body)
->assign('css', $css)
->assign('root', $oPlugin->getPaths()->getAdminURL());
return Shop::Smarty()->fetch($oPlugin->getPaths()->getAdminPath() . '/root.tpl');
default:
return parent::renderAdminMenuTab($tabName, $menuID, $smarty);
}
}

public static function getDomain($url = URL_SHOP)
/**
* @return null|UpgradeMapperInterface
*/
public function getUpgradeMapper(): ?UpgradeMapperInterface
{

$matches = array();
@preg_match("/^((http(s)?):\/\/)?(www\.)?([a-zA-Z0-9-\.]+)(\/.*)?$/i", $url, $matches);
return strtolower(isset($matches[5]) ? $matches[5] : $url);
}

public static function getMasterMail($e = false)
{
$settings = \Shop::getSettings(array(CONF_EMAILS));
$mail = trim($settings['emails']['email_master_absender']);
if ($e === true && $mail != '') {
$mail = base64_encode($mail);
$eMail = "";
foreach (str_split($mail, 1) as $c) {
$eMail .= chr(ord($c) ^ 0x00100110);
}
return base64_encode($eMail);
}
return $mail;
return new MollieUpgradeMapper('ws_mollie', 'ws5_mollie');
}

}
8 changes: 5 additions & 3 deletions Migrations/Migration20200715104300.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

/**
* @copyright 2020 WebStollen GmbH
* @copyright 2021 WebStollen GmbH
* @link https://www.webstollen.de
*/

namespace Plugin\ws5_mollie\Migrations;
Expand All @@ -12,12 +14,12 @@ class Migration20200715104300 extends Migration implements IMigration
{
public function up()
{
$this->execute('CREATE TABLE IF NOT EXISTS `xplugin_ws5_mollie_kunde` (
$this->execute(
'CREATE TABLE IF NOT EXISTS `xplugin_ws5_mollie_kunde` (
`kKunde` int NOT NULL PRIMARY KEY,
`customerId` varchar(32) NOT NULL UNIQUE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;'
);

}

public function down()
Expand Down
10 changes: 7 additions & 3 deletions Migrations/Migration20200717130530.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

/**
* @copyright 2020 WebStollen GmbH
* @copyright 2021 WebStollen GmbH
* @link https://www.webstollen.de
*/

namespace Plugin\ws5_mollie\Migrations;
Expand All @@ -12,7 +14,8 @@ class Migration20200717130530 extends Migration implements IMigration
{
public function up()
{
$this->execute('CREATE TABLE IF NOT EXISTS `xplugin_ws5_mollie_orders` (
$this->execute(
'CREATE TABLE IF NOT EXISTS `xplugin_ws5_mollie_orders` (
`kId` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`kBestellung` int(11) DEFAULT NULL,
`cOrderId` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
Expand All @@ -27,7 +30,8 @@ public function up()
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;'
);

$this->execute('ALTER TABLE `xplugin_ws5_mollie_orders`
$this->execute(
'ALTER TABLE `xplugin_ws5_mollie_orders`
ADD UNIQUE KEY `cOrderId` (`cOrderId`),
ADD UNIQUE KEY `kBestellung` (`kBestellung`);'
);
Expand Down
9 changes: 5 additions & 4 deletions Migrations/Migration20201120155700.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<?php

/**
* @copyright 2021 WebStollen GmbH
* @link https://www.webstollen.de
*/

namespace Plugin\ws5_mollie\Migrations;

use JTL\Plugin\Migration;
use JTL\Update\IMigration;


class Migration20201120155700 extends Migration implements IMigration
{

/**
* @inheritDoc
*/
Expand All @@ -30,5 +32,4 @@ public function getDescription(): string
{
return 'Extend Order Plugin-Tables (Shop<->Mollie)';
}

}
}
8 changes: 6 additions & 2 deletions Migrations/Migration20201130170200.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<?php

/**
* @copyright 2021 WebStollen GmbH
* @link https://www.webstollen.de
*/

namespace Plugin\ws5_mollie\Migrations;

use JTL\Plugin\Migration;
use JTL\Update\IMigration;

class Migration20201130170200 extends Migration implements IMigration
{

public function up()
{
$this->execute('CREATE TABLE IF NOT EXISTS `xplugin_ws5_mollie_queue` (
Expand All @@ -30,4 +34,4 @@ public function getDescription(): string
{
return 'Queue Plugin-Table (WAWI<->Shop<->Mollie)';
}
}
}
8 changes: 6 additions & 2 deletions Migrations/Migration20210211144800.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<?php

/**
* @copyright 2021 WebStollen GmbH
* @link https://www.webstollen.de
*/

namespace Plugin\ws5_mollie\Migrations;

use JTL\Plugin\Migration;
use JTL\Update\IMigration;

class Migration20210211144800 extends Migration implements IMigration
{

public function up()
{
$this->execute('CREATE TABLE IF NOT EXISTS `xplugin_ws5_mollie_shipments` (
Expand All @@ -32,4 +36,4 @@ public function getDescription(): string
{
return 'Shipments-Table (WAWI<->Shop<->Mollie)';
}
}
}
11 changes: 6 additions & 5 deletions Migrations/Migration20210323152500.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<?php

/**
* @copyright 2021 WebStollen GmbH
* @link https://www.webstollen.de
*/

namespace Plugin\ws5_mollie\Migrations;


use JTL\Plugin\Migration;
use JTL\Update\IMigration;

class Migration20210323152500 extends Migration implements IMigration
{

public function up()
{
$this->execute('ALTER TABLE `xplugin_ws5_mollie_orders` ADD `dReminder` datetime NULL;');
Expand All @@ -22,7 +24,6 @@ public function down()

public function getDescription(): string
{
return "adds Payment Reminder Column";
return 'adds Payment Reminder Column';
}

}
}
13 changes: 7 additions & 6 deletions Migrations/Migration20210409161100.php
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
<?php

/**
* @copyright 2021 WebStollen GmbH
* @link https://www.webstollen.de
*/

namespace Plugin\ws5_mollie\Migrations;


use JTL\Plugin\Migration;
use JTL\Update\IMigration;

class Migration20210409161100 extends Migration implements IMigration
{

/**
* @inheritDoc
*/
public function up()
{
$this->execute("ALTER TABLE `xplugin_ws5_mollie_shipments` CHANGE `kLieferschien` `kLieferschein` int(11) NOT NULL FIRST;");
$this->execute('ALTER TABLE `xplugin_ws5_mollie_shipments` CHANGE `kLieferschien` `kLieferschein` int(11) NOT NULL FIRST;');
}

/**
* @inheritDoc
*/
public function down()
{
$this->execute("ALTER TABLE `xplugin_ws5_mollie_shipments` CHANGE `kLieferschein` `kLieferschien` int(11) NOT NULL FIRST;");
$this->execute('ALTER TABLE `xplugin_ws5_mollie_shipments` CHANGE `kLieferschein` `kLieferschien` int(11) NOT NULL FIRST;');
}

public function getDescription(): string
{
return "Fix 'shipments'-Column Typo";
}

}
}
Loading

0 comments on commit 8363552

Please sign in to comment.