mirror of
https://github.com/Karaka-Management/oms-Exchange.git
synced 2026-02-18 02:28:40 +00:00
Automated formatting changes
This commit is contained in:
parent
1fcd3a75f6
commit
715d53ac61
|
|
@ -84,8 +84,8 @@ final class ApiController extends Controller
|
||||||
{
|
{
|
||||||
/** @var \Modules\Exchange\Models\InterfaceManager $interface */
|
/** @var \Modules\Exchange\Models\InterfaceManager $interface */
|
||||||
$interface = InterfaceManagerMapper::get($request->getData('id'));
|
$interface = InterfaceManagerMapper::get($request->getData('id'));
|
||||||
$class = '\\Modules\\Exchange\\Interfaces\\' . $interface->getInterfacePath() . '\\Importer';
|
$class = '\\Modules\\Exchange\\Interfaces\\' . $interface->getInterfacePath() . '\\Importer';
|
||||||
$importer = new $class($this->app->dbPool->get());
|
$importer = new $class($this->app->dbPool->get());
|
||||||
|
|
||||||
return $importer->importFromRequest($request);
|
return $importer->importFromRequest($request);
|
||||||
}
|
}
|
||||||
|
|
@ -209,8 +209,8 @@ final class ApiController extends Controller
|
||||||
{
|
{
|
||||||
/** @var \Modules\Exchange\Models\InterfaceManager $interface */
|
/** @var \Modules\Exchange\Models\InterfaceManager $interface */
|
||||||
$interface = InterfaceManagerMapper::get($request->getData('id'));
|
$interface = InterfaceManagerMapper::get($request->getData('id'));
|
||||||
$class = '\\Modules\\Exchange\\Interfaces\\' . $interface->getInterfacePath() . '\\Exporter';
|
$class = '\\Modules\\Exchange\\Interfaces\\' . $interface->getInterfacePath() . '\\Exporter';
|
||||||
$exporter = new $class($this->app->dbPool->get());
|
$exporter = new $class($this->app->dbPool->get());
|
||||||
|
|
||||||
return $exporter->exportFromRequest($request);
|
return $exporter->exportFromRequest($request);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,12 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Modules\Exchange\Controller;
|
namespace Modules\Exchange\Controller;
|
||||||
|
|
||||||
|
use Modules\Exchange\Models\ExchangeLogMapper;
|
||||||
use Modules\Exchange\Models\InterfaceManagerMapper;
|
use Modules\Exchange\Models\InterfaceManagerMapper;
|
||||||
use phpOMS\Contract\RenderableInterface;
|
use phpOMS\Contract\RenderableInterface;
|
||||||
use phpOMS\Message\RequestAbstract;
|
use phpOMS\Message\RequestAbstract;
|
||||||
use phpOMS\Message\ResponseAbstract;
|
use phpOMS\Message\ResponseAbstract;
|
||||||
use phpOMS\Views\View;
|
use phpOMS\Views\View;
|
||||||
use Modules\Exchange\Models\ExchangeLogMapper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exchange controller class.
|
* Exchange controller class.
|
||||||
|
|
|
||||||
|
|
@ -16,16 +16,9 @@ namespace Modules\Exchange\Interfaces\OMS;
|
||||||
|
|
||||||
use Modules\Exchange\Models\ExchangeLog;
|
use Modules\Exchange\Models\ExchangeLog;
|
||||||
use Modules\Exchange\Models\ExchangeType;
|
use Modules\Exchange\Models\ExchangeType;
|
||||||
use phpOMS\DataStorage\Database\Connection\ConnectionAbstract;
|
|
||||||
use phpOMS\DataStorage\Database\Connection\ConnectionFactory;
|
|
||||||
use phpOMS\DataStorage\Database\DatabaseStatus;
|
|
||||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
|
||||||
use phpOMS\Localization\ISO3166TwoEnum;
|
|
||||||
use phpOMS\Localization\ISO639x1Enum;
|
|
||||||
use phpOMS\Message\RequestAbstract;
|
|
||||||
use phpOMS\System\File\Local\Directory;
|
|
||||||
use phpOMS\Utils\IO\Zip\Zip;
|
|
||||||
use Modules\Exchange\Models\ExporterAbstract;
|
use Modules\Exchange\Models\ExporterAbstract;
|
||||||
|
use phpOMS\DataStorage\Database\Connection\ConnectionAbstract;
|
||||||
|
use phpOMS\Message\RequestAbstract;
|
||||||
use phpOMS\Utils\StringUtils;
|
use phpOMS\Utils\StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -88,11 +81,11 @@ final class Exporter extends ExporterAbstract
|
||||||
if ($request->getData('type') === 'language') {
|
if ($request->getData('type') === 'language') {
|
||||||
$result = $this->exportLanguage();
|
$result = $this->exportLanguage();
|
||||||
|
|
||||||
$log = new ExchangeLog();
|
$log = new ExchangeLog();
|
||||||
$log->createdBy = $this->account;
|
$log->createdBy = $this->account;
|
||||||
$log->setType(ExchangeType::EXPORT);
|
$log->setType(ExchangeType::EXPORT);
|
||||||
$log->message = 'Language file exported.'; // @todo: localize!
|
$log->message = 'Language file exported.'; // @todo: localize!
|
||||||
$log->subtype = 'language';
|
$log->subtype = 'language';
|
||||||
$log->exchange = (int) $request->getData('id');
|
$log->exchange = (int) $request->getData('id');
|
||||||
|
|
||||||
$result['logs'][] = $log;
|
$result['logs'][] = $log;
|
||||||
|
|
@ -110,11 +103,11 @@ final class Exporter extends ExporterAbstract
|
||||||
*/
|
*/
|
||||||
public function exportLanguage() : array
|
public function exportLanguage() : array
|
||||||
{
|
{
|
||||||
$languageArray = [];
|
$languageArray = [];
|
||||||
$supportedLanguages = [];
|
$supportedLanguages = [];
|
||||||
|
|
||||||
$basePath = __DIR__ . '/../../../';
|
$basePath = __DIR__ . '/../../../';
|
||||||
$modules = \scandir($basePath);
|
$modules = \scandir($basePath);
|
||||||
foreach ($modules as $module) {
|
foreach ($modules as $module) {
|
||||||
$themePath = $basePath . $module . '/Theme/';
|
$themePath = $basePath . $module . '/Theme/';
|
||||||
|
|
||||||
|
|
@ -143,8 +136,8 @@ final class Exporter extends ExporterAbstract
|
||||||
if (\strlen($components[0]) === 2) {
|
if (\strlen($components[0]) === 2) {
|
||||||
// normal language file
|
// normal language file
|
||||||
$supportedLanguages[] = $components[0];
|
$supportedLanguages[] = $components[0];
|
||||||
$array = include $themePath . $theme . '/Lang/' . $language;
|
$array = include $themePath . $theme . '/Lang/' . $language;
|
||||||
$array = \reset($array);
|
$array = \reset($array);
|
||||||
|
|
||||||
if ($array === false) {
|
if ($array === false) {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -174,7 +167,7 @@ final class Exporter extends ExporterAbstract
|
||||||
}
|
}
|
||||||
|
|
||||||
$template = \file_get_contents($item->getPathname());
|
$template = \file_get_contents($item->getPathname());
|
||||||
$keys = [];
|
$keys = [];
|
||||||
\preg_match_all('/(\$this\->getHtml\(\')([a-zA-Z:]+)(\'\))/', $template, $keys, \PREG_PATTERN_ORDER);
|
\preg_match_all('/(\$this\->getHtml\(\')([a-zA-Z:]+)(\'\))/', $template, $keys, \PREG_PATTERN_ORDER);
|
||||||
|
|
||||||
foreach ($keys[2] ?? [] as $key) {
|
foreach ($keys[2] ?? [] as $key) {
|
||||||
|
|
@ -204,7 +197,7 @@ final class Exporter extends ExporterAbstract
|
||||||
return [
|
return [
|
||||||
'type' => 'file',
|
'type' => 'file',
|
||||||
'name' => 'languages.csv',
|
'name' => 'languages.csv',
|
||||||
'content' => $content
|
'content' => $content,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,19 +15,14 @@ declare(strict_types=1);
|
||||||
namespace Modules\Exchange\Interfaces\OMS;
|
namespace Modules\Exchange\Interfaces\OMS;
|
||||||
|
|
||||||
use Modules\Exchange\Models\ExchangeLog;
|
use Modules\Exchange\Models\ExchangeLog;
|
||||||
|
use Modules\Exchange\Models\ExchangeType;
|
||||||
|
use Modules\Exchange\Models\ImporterAbstract;
|
||||||
|
use Modules\Media\Controller\ApiController;
|
||||||
use phpOMS\DataStorage\Database\Connection\ConnectionAbstract;
|
use phpOMS\DataStorage\Database\Connection\ConnectionAbstract;
|
||||||
use phpOMS\DataStorage\Database\Connection\ConnectionFactory;
|
use phpOMS\DataStorage\Database\Connection\ConnectionFactory;
|
||||||
use phpOMS\DataStorage\Database\DatabaseStatus;
|
use phpOMS\DataStorage\Database\DatabaseStatus;
|
||||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
|
||||||
use phpOMS\Localization\ISO3166TwoEnum;
|
|
||||||
use phpOMS\Localization\ISO639x1Enum;
|
|
||||||
use phpOMS\Message\RequestAbstract;
|
|
||||||
use phpOMS\System\File\Local\Directory;
|
|
||||||
use phpOMS\Utils\IO\Zip\Zip;
|
|
||||||
use Modules\Media\Controller\ApiController;
|
|
||||||
use Modules\Exchange\Models\ImporterAbstract;
|
|
||||||
use phpOMS\Message\Http\HttpRequest;
|
use phpOMS\Message\Http\HttpRequest;
|
||||||
use Modules\Exchange\Models\ExchangeType;
|
use phpOMS\Message\RequestAbstract;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OMS import class
|
* OMS import class
|
||||||
|
|
@ -108,11 +103,11 @@ final class Importer extends ImporterAbstract
|
||||||
|
|
||||||
if ($request->getData('type') === 'language') {
|
if ($request->getData('type') === 'language') {
|
||||||
$this->importLanguage($request);
|
$this->importLanguage($request);
|
||||||
$log = new ExchangeLog();
|
$log = new ExchangeLog();
|
||||||
$log->createdBy = $this->account;
|
$log->createdBy = $this->account;
|
||||||
$log->setType(ExchangeType::IMPORT);
|
$log->setType(ExchangeType::IMPORT);
|
||||||
$log->message = 'Language file imported.'; // @todo: localize!
|
$log->message = 'Language file imported.'; // @todo: localize!
|
||||||
$log->subtype = 'language';
|
$log->subtype = 'language';
|
||||||
$log->exchange = (int) $request->getData('id');
|
$log->exchange = (int) $request->getData('id');
|
||||||
|
|
||||||
$result['logs'][] = $log;
|
$result['logs'][] = $log;
|
||||||
|
|
@ -132,10 +127,10 @@ final class Importer extends ImporterAbstract
|
||||||
{
|
{
|
||||||
$upload = ApiController::uploadFilesToDestination($request->getFiles());
|
$upload = ApiController::uploadFilesToDestination($request->getFiles());
|
||||||
|
|
||||||
$fp = \fopen($upload['file0']['path'] . '/' . $upload['file0']['filename'], 'r');
|
$fp = \fopen($upload['file0']['path'] . '/' . $upload['file0']['filename'], 'r');
|
||||||
$header = \fgetcsv($fp, 0, ';', '"');
|
$header = \fgetcsv($fp, 0, ';', '"');
|
||||||
|
|
||||||
$languageArray = [];
|
$languageArray = [];
|
||||||
$supportedLanguages = \array_slice($header, 3);
|
$supportedLanguages = \array_slice($header, 3);
|
||||||
|
|
||||||
while(($line = \fgetcsv($fp, 0, ';', '"')) !== false) {
|
while(($line = \fgetcsv($fp, 0, ';', '"')) !== false) {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<?php
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
$lang = $this->getData('lang');
|
$lang = $this->getData('lang');
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<?php
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
$lang = $this->getData('lang');
|
$lang = $this->getData('lang');
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,9 @@ class ExchangeLog implements \JsonSerializable, ArrayableInterface
|
||||||
* @var int
|
* @var int
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public int|InterfaceManager $exchange = 0;
|
public int |
|
||||||
|
|
||||||
|
InterfaceManager $exchange = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Date type.
|
* Date type.
|
||||||
|
|
@ -77,7 +79,9 @@ class ExchangeLog implements \JsonSerializable, ArrayableInterface
|
||||||
*/
|
*/
|
||||||
public \DateTimeImmutable $createdAt;
|
public \DateTimeImmutable $createdAt;
|
||||||
|
|
||||||
public int|Account $createdBy = 0;
|
public int |
|
||||||
|
|
||||||
|
Account $createdBy = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Modules\Exchange\Models;
|
namespace Modules\Exchange\Models;
|
||||||
|
|
||||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
|
||||||
use Modules\Admin\Models\AccountMapper;
|
use Modules\Admin\Models\AccountMapper;
|
||||||
|
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exchange log mapper class.
|
* Exchange log mapper class.
|
||||||
|
|
@ -34,14 +34,14 @@ final class ExchangeLogMapper extends DataMapperAbstract
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected static array $columns = [
|
protected static array $columns = [
|
||||||
'exchange_log_id' => ['name' => 'exchange_log_id', 'type' => 'int', 'internal' => 'id'],
|
'exchange_log_id' => ['name' => 'exchange_log_id', 'type' => 'int', 'internal' => 'id'],
|
||||||
'exchange_log_message' => ['name' => 'exchange_log_message', 'type' => 'string', 'internal' => 'message'],
|
'exchange_log_message' => ['name' => 'exchange_log_message', 'type' => 'string', 'internal' => 'message'],
|
||||||
'exchange_log_fields' => ['name' => 'exchange_log_fields', 'type' => 'Json', 'internal' => 'fields'],
|
'exchange_log_fields' => ['name' => 'exchange_log_fields', 'type' => 'Json', 'internal' => 'fields'],
|
||||||
'exchange_log_type' => ['name' => 'exchange_log_type', 'type' => 'int', 'internal' => 'type'],
|
'exchange_log_type' => ['name' => 'exchange_log_type', 'type' => 'int', 'internal' => 'type'],
|
||||||
'exchange_log_subtype' => ['name' => 'exchange_log_subtype', 'type' => 'string', 'internal' => 'subtype'],
|
'exchange_log_subtype' => ['name' => 'exchange_log_subtype', 'type' => 'string', 'internal' => 'subtype'],
|
||||||
'exchange_log_created_at' => ['name' => 'exchange_log_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true],
|
'exchange_log_created_at' => ['name' => 'exchange_log_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true],
|
||||||
'exchange_log_created_by' => ['name' => 'exchange_log_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
|
'exchange_log_created_by' => ['name' => 'exchange_log_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
|
||||||
'exchange_log_exchange' => ['name' => 'exchange_log_exchange', 'type' => 'int', 'internal' => 'exchange'],
|
'exchange_log_exchange' => ['name' => 'exchange_log_exchange', 'type' => 'int', 'internal' => 'exchange'],
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -13,19 +13,19 @@ declare(strict_types=1);
|
||||||
|
|
||||||
return ['Exchange' => [
|
return ['Exchange' => [
|
||||||
'Database' => 'Datenbank',
|
'Database' => 'Datenbank',
|
||||||
'End' => 'Ende',
|
'End' => 'Ende',
|
||||||
'Exchange' => 'Exchange',
|
'Exchange' => 'Exchange',
|
||||||
'Export' => 'Export',
|
'Export' => 'Export',
|
||||||
'Exports' => 'Exporte',
|
'Exports' => 'Exporte',
|
||||||
'File' => 'Dateien',
|
'File' => 'Dateien',
|
||||||
'Host' => 'Host',
|
'Host' => 'Host',
|
||||||
'Import' => 'Import',
|
'Import' => 'Import',
|
||||||
'Imports' => 'Importe',
|
'Imports' => 'Importe',
|
||||||
'Login' => 'Login',
|
'Login' => 'Login',
|
||||||
'Options' => 'Optionen',
|
'Options' => 'Optionen',
|
||||||
'Password' => 'Passwort',
|
'Password' => 'Passwort',
|
||||||
'Port' => 'Port',
|
'Port' => 'Port',
|
||||||
'Start' => 'Start',
|
'Start' => 'Start',
|
||||||
'Title' => 'Titel',
|
'Title' => 'Titel',
|
||||||
'Website' => 'Webseite',
|
'Website' => 'Webseite',
|
||||||
]];
|
]];
|
||||||
|
|
|
||||||
|
|
@ -13,19 +13,19 @@ declare(strict_types=1);
|
||||||
|
|
||||||
return ['Exchange' => [
|
return ['Exchange' => [
|
||||||
'Database' => 'Database',
|
'Database' => 'Database',
|
||||||
'End' => 'End',
|
'End' => 'End',
|
||||||
'Exchange' => 'Exchange',
|
'Exchange' => 'Exchange',
|
||||||
'Export' => 'Export',
|
'Export' => 'Export',
|
||||||
'Exports' => 'Exports',
|
'Exports' => 'Exports',
|
||||||
'File' => 'File',
|
'File' => 'File',
|
||||||
'Host' => 'Host',
|
'Host' => 'Host',
|
||||||
'Import' => 'Import',
|
'Import' => 'Import',
|
||||||
'Imports' => 'Imports',
|
'Imports' => 'Imports',
|
||||||
'Login' => 'Login',
|
'Login' => 'Login',
|
||||||
'Options' => 'Options',
|
'Options' => 'Options',
|
||||||
'Password' => 'Password',
|
'Password' => 'Password',
|
||||||
'Port' => 'Port',
|
'Port' => 'Port',
|
||||||
'Start' => 'Start',
|
'Start' => 'Start',
|
||||||
'Title' => 'Title',
|
'Title' => 'Title',
|
||||||
'Website' => 'Website',
|
'Website' => 'Website',
|
||||||
]];
|
]];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user