mirror of
https://github.com/Karaka-Management/oms-Exchange.git
synced 2026-02-16 17:58:41 +00:00
Exchange fixes
This commit is contained in:
parent
d47963320c
commit
a507b208ea
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* PHP Version 7.2
|
* PHP Version 7.2
|
||||||
*
|
*
|
||||||
* @package TBD
|
* @package Modules\Exchange
|
||||||
* @copyright Dennis Eichhorn
|
* @copyright Dennis Eichhorn
|
||||||
* @license OMS License 1.0
|
* @license OMS License 1.0
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
|
|
@ -18,15 +18,58 @@ use phpOMS\DataStorage\Database\DatabaseType;
|
||||||
use phpOMS\DataStorage\Database\DatabasePool;
|
use phpOMS\DataStorage\Database\DatabasePool;
|
||||||
use phpOMS\Module\InstallerAbstract;
|
use phpOMS\Module\InstallerAbstract;
|
||||||
use phpOMS\Module\InfoManager;
|
use phpOMS\Module\InfoManager;
|
||||||
|
use phpOMS\System\File\Local\Directory;
|
||||||
|
|
||||||
|
use Modules\Exchange\Models\InterfaceManager;
|
||||||
|
use Modules\Exchange\Models\InterfaceManagerMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exchange install class.
|
* Exchange install class.
|
||||||
*
|
*
|
||||||
* @package Modules
|
* @package Modules\Exchange
|
||||||
* @license OMS License 1.0
|
* @license OMS License 1.0
|
||||||
* @link http://website.orange-management.de
|
* @link http://website.orange-management.de
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
class Installer extends InstallerAbstract
|
class Installer extends InstallerAbstract
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public static function install(DatabasePool $dbPool, InfoManager $info) : void
|
||||||
|
{
|
||||||
|
parent::install($dbPool, $info);
|
||||||
|
|
||||||
|
switch ($dbPool->get()->getType()) {
|
||||||
|
case DatabaseType::MYSQL:
|
||||||
|
$dbPool->get()->con->beginTransaction();
|
||||||
|
|
||||||
|
$dbPool->get()->con->prepare(
|
||||||
|
'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'exchange` (
|
||||||
|
`exchange_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`exchange_title` varchar(255) DEFAULT NULL,
|
||||||
|
`exchange_path` text NOT NULL,
|
||||||
|
`exchange_import` tinyint(1) NOT NULL,
|
||||||
|
`exchange_export` tinyint(1) NOT NULL,
|
||||||
|
`exchange_version` varchar(255) NOT NULL,
|
||||||
|
`exchange_website` varchar(255) NOT NULL,
|
||||||
|
`exchange_created_by` int(11) DEFAULT NULL,
|
||||||
|
`exchange_created_at` datetime DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`exchange_id`)
|
||||||
|
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
|
||||||
|
)->execute();
|
||||||
|
|
||||||
|
$dbPool->get()->con->commit();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$interfaces = Directory::list(__DIR__ . '/../Interfaces', '.*interface\.json');
|
||||||
|
|
||||||
|
foreach ($interfaces as $interface) {
|
||||||
|
$exchange = new InterfaceManager(__DIR__ . '/../Interfaces/' . $interface);
|
||||||
|
$exchange->load();
|
||||||
|
|
||||||
|
InterfaceManagerMapper::create($exchange);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* PHP Version 7.2
|
* PHP Version 7.2
|
||||||
*
|
*
|
||||||
* @package TBD
|
* @package Modules\Exchange
|
||||||
* @copyright Dennis Eichhorn
|
* @copyright Dennis Eichhorn
|
||||||
* @license OMS License 1.0
|
* @license OMS License 1.0
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
|
|
@ -21,7 +21,7 @@ use phpOMS\Module\InfoManager;
|
||||||
/**
|
/**
|
||||||
* Navigation class.
|
* Navigation class.
|
||||||
*
|
*
|
||||||
* @package Modules
|
* @package Modules\Exchange
|
||||||
* @license OMS License 1.0
|
* @license OMS License 1.0
|
||||||
* @link http://website.orange-management.de
|
* @link http://website.orange-management.de
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* PHP Version 7.2
|
* PHP Version 7.2
|
||||||
*
|
*
|
||||||
* @package TBD
|
* @package Modules\Exchange
|
||||||
* @copyright Dennis Eichhorn
|
* @copyright Dennis Eichhorn
|
||||||
* @license OMS License 1.0
|
* @license OMS License 1.0
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
|
|
@ -19,9 +19,9 @@ use phpOMS\Module\UninstallerAbstract;
|
||||||
use phpOMS\Module\InfoManager;
|
use phpOMS\Module\InfoManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Navigation class.
|
* Uninstaller class.
|
||||||
*
|
*
|
||||||
* @package Modules
|
* @package Modules\Exchange
|
||||||
* @license OMS License 1.0
|
* @license OMS License 1.0
|
||||||
* @link http://website.orange-management.de
|
* @link http://website.orange-management.de
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* PHP Version 7.2
|
* PHP Version 7.2
|
||||||
*
|
*
|
||||||
* @package TBD
|
* @package Modules\Exchange
|
||||||
* @copyright Dennis Eichhorn
|
* @copyright Dennis Eichhorn
|
||||||
* @license OMS License 1.0
|
* @license OMS License 1.0
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
|
|
@ -22,7 +22,7 @@ use phpOMS\Module\InfoManager;
|
||||||
/**
|
/**
|
||||||
* Updater class.
|
* Updater class.
|
||||||
*
|
*
|
||||||
* @package Modules
|
* @package Modules\Exchange
|
||||||
* @license OMS License 1.0
|
* @license OMS License 1.0
|
||||||
* @link http://website.orange-management.de
|
* @link http://website.orange-management.de
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
|
|
||||||
8
Interfaces/GSD/interface.json
Normal file
8
Interfaces/GSD/interface.json
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"name": "GSD",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"website": "",
|
||||||
|
"path": "GSD",
|
||||||
|
"export": true,
|
||||||
|
"import": false
|
||||||
|
}
|
||||||
8
Interfaces/Intrexx/interface.json
Normal file
8
Interfaces/Intrexx/interface.json
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"name": "Intrexx",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"website": "",
|
||||||
|
"path": "Intrexx",
|
||||||
|
"export": true,
|
||||||
|
"import": false
|
||||||
|
}
|
||||||
145
Models/InterfaceManager.php
Normal file
145
Models/InterfaceManager.php
Normal file
|
|
@ -0,0 +1,145 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.2
|
||||||
|
*
|
||||||
|
* @package phpOMS\Module
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Modules\Exchange\Models;
|
||||||
|
|
||||||
|
use phpOMS\System\File\PathException;
|
||||||
|
use phpOMS\Utils\ArrayUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* InfoManager class.
|
||||||
|
*
|
||||||
|
* Handling the info files for modules
|
||||||
|
*
|
||||||
|
* @package phpOMS\Module
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
final class InterfaceManager
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Interface ID.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
private $id = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* File path.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
private $path = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Info data.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
private $info = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Object constructor.
|
||||||
|
*
|
||||||
|
* @param string $path Info file path
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function __construct(string $path)
|
||||||
|
{
|
||||||
|
$this->path = $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get info path
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function getPath() : string
|
||||||
|
{
|
||||||
|
return $this->path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load info data from path.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @throws PathException This exception is thrown in case the info file path doesn't exist.
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function load() : void
|
||||||
|
{
|
||||||
|
if (!file_exists($this->path)) {
|
||||||
|
throw new PathException($this->path);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->info = json_decode(file_get_contents($this->path), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update info file
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function update() : void
|
||||||
|
{
|
||||||
|
if (!file_exists($this->path)) {
|
||||||
|
throw new PathException($this->path);
|
||||||
|
}
|
||||||
|
|
||||||
|
file_put_contents($this->path, json_encode($this->info, JSON_PRETTY_PRINT));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set data
|
||||||
|
*
|
||||||
|
* @param string $path Value path
|
||||||
|
* @param mixed $data Scalar or array of data to set
|
||||||
|
* @param string $delim Delimiter of path
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function set(string $path, $data, string $delim = '/') : void
|
||||||
|
{
|
||||||
|
if (!is_scalar($data) && !is_array($data) && !($data instanceof \JsonSerializable)) {
|
||||||
|
throw new \InvalidArgumentException('Type of $data "' . gettype($data) . '" is not supported.');
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayUtils::setArray($path, $this->info, $data, $delim, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get info data.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function get() : array
|
||||||
|
{
|
||||||
|
return $this->info;
|
||||||
|
}
|
||||||
|
}
|
||||||
72
Models/InterfaceManagerMapper.php
Normal file
72
Models/InterfaceManagerMapper.php
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.2
|
||||||
|
*
|
||||||
|
* @package Modules\Exchange
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Modules\Exchange\Models;
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||||
|
use phpOMS\DataStorage\Database\Query\Builder;
|
||||||
|
use phpOMS\DataStorage\Database\Query\Column;
|
||||||
|
use phpOMS\DataStorage\Database\RelationType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mapper class.
|
||||||
|
*
|
||||||
|
* @package Modules\Exchange
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
class InterfaceManagerMapper extends DataMapperAbstract
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Columns.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected static $columns = [
|
||||||
|
'exchange_id' => ['name' => 'exchange_id', 'type' => 'int', 'internal' => 'id'],
|
||||||
|
'exchange_title' => ['name' => 'exchange_title', 'type' => 'string', 'internal' => 'info/title'],
|
||||||
|
'exchange_path' => ['name' => 'exchange_path', 'type' => 'string', 'internal' => 'info/path'],
|
||||||
|
'exchange_version' => ['name' => 'exchange_version', 'type' => 'string', 'internal' => 'info/version'],
|
||||||
|
'exchange_export' => ['name' => 'exchange_export', 'type' => 'bool', 'internal' => 'info/export'],
|
||||||
|
'exchange_import' => ['name' => 'exchange_import', 'type' => 'bool', 'internal' => 'info/import'],
|
||||||
|
'exchange_website' => ['name' => 'exchange_website', 'type' => 'string', 'internal' => 'info/website'],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Primary table.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected static $table = 'exchange';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created at.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected static $createdAt = 'exchange_created_at';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Primary field name.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected static $primaryField = 'exchange_id';
|
||||||
|
}
|
||||||
|
|
@ -12,4 +12,8 @@
|
||||||
*/
|
*/
|
||||||
return ['Exchange' => [
|
return ['Exchange' => [
|
||||||
'Exchange' => 'Exchange',
|
'Exchange' => 'Exchange',
|
||||||
|
'Exports' => 'Exports',
|
||||||
|
'Imports' => 'Imports',
|
||||||
|
'Title' => 'Title',
|
||||||
|
'Website' => 'Website',
|
||||||
]];
|
]];
|
||||||
|
|
|
||||||
|
|
@ -15,3 +15,29 @@
|
||||||
* @var \phpOMS\Views\View $this
|
* @var \phpOMS\Views\View $this
|
||||||
*/
|
*/
|
||||||
echo $this->getData('nav')->render(); ?>
|
echo $this->getData('nav')->render(); ?>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-12">
|
||||||
|
<div class="box wf-100">
|
||||||
|
<table class="table red">
|
||||||
|
<caption><?= $this->getHtml('Exports') ?></caption>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td class="wf-100"><?= $this->getHtml('Title') ?>
|
||||||
|
<td><?= $this->getHtml('Website') ?>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<tbody>
|
||||||
|
<?php $count = 0; foreach ($interfaces as $key => $value) : $count++;
|
||||||
|
$url = \phpOMS\Uri\UriFactory::build('/{/lang}/backend/admin/exchange/export/profile?{?}&id=' . $value->getId()); ?>
|
||||||
|
<tr data-href="<?= $url; ?>">
|
||||||
|
<td data-label="<?= $this->getHtml('Title') ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getTitle()); ?></a>
|
||||||
|
<td data-label="<?= $this->getHtml('Website') ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getCreatedBy()->getName1()); ?></a>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php if ($count === 0) : ?>
|
||||||
|
<tr><td colspan="2" class="empty"><?= $this->getHtml('Empty', 0, 0); ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -15,3 +15,29 @@
|
||||||
* @var \phpOMS\Views\View $this
|
* @var \phpOMS\Views\View $this
|
||||||
*/
|
*/
|
||||||
echo $this->getData('nav')->render(); ?>
|
echo $this->getData('nav')->render(); ?>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-12">
|
||||||
|
<div class="box wf-100">
|
||||||
|
<table class="table red">
|
||||||
|
<caption><?= $this->getHtml('Imports') ?></caption>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td class="wf-100"><?= $this->getHtml('Title') ?>
|
||||||
|
<td><?= $this->getHtml('Website') ?>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<tbody>
|
||||||
|
<?php $count = 0; foreach ($interfaces as $key => $value) : $count++;
|
||||||
|
$url = \phpOMS\Uri\UriFactory::build('/{/lang}/backend/admin/exchange/import/profile?{?}&id=' . $value->getId()); ?>
|
||||||
|
<tr data-href="<?= $url; ?>">
|
||||||
|
<td data-label="<?= $this->getHtml('Title') ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getTitle()); ?></a>
|
||||||
|
<td data-label="<?= $this->getHtml('Website') ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getCreatedBy()->getName1()); ?></a>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php if ($count === 0) : ?>
|
||||||
|
<tr><td colspan="2" class="empty"><?= $this->getHtml('Empty', 0, 0); ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user