mirror of
https://github.com/Karaka-Management/oms-Editor.git
synced 2026-01-11 17:18:42 +00:00
backup
This commit is contained in:
parent
8a04478688
commit
4bdb208dce
|
|
@ -153,7 +153,7 @@ final class Installer extends InstallerAbstract
|
|||
$id = $type->id;
|
||||
|
||||
$isFirst = true;
|
||||
foreach ($data['l11n'] as $l11n) {
|
||||
foreach ($data['l11n'] as $lang => $l11n) {
|
||||
if ($isFirst) {
|
||||
$isFirst = false;
|
||||
continue;
|
||||
|
|
@ -163,8 +163,8 @@ final class Installer extends InstallerAbstract
|
|||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->header->account = 1;
|
||||
$request->setData('title', $l11n['title'] ?? '');
|
||||
$request->setData('lang', $l11n['lang'] ?? null);
|
||||
$request->setData('title', $l11n);
|
||||
$request->setData('lang', $lang);
|
||||
$request->setData('type', $id);
|
||||
|
||||
$module->apiEditorDocTypeL11nCreate($request, $response);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ use Modules\Editor\Models\EditorDoc;
|
|||
use Modules\Editor\Models\EditorDocHistory;
|
||||
use Modules\Editor\Models\EditorDocHistoryMapper;
|
||||
use Modules\Editor\Models\EditorDocMapper;
|
||||
use Modules\Editor\Models\EditorDocType;
|
||||
use Modules\Editor\Models\EditorDocTypeL11nMapper;
|
||||
use Modules\Editor\Models\EditorDocTypeMapper;
|
||||
use Modules\Media\Models\CollectionMapper;
|
||||
|
|
@ -32,6 +31,8 @@ use Modules\Media\Models\Reference;
|
|||
use Modules\Media\Models\ReferenceMapper;
|
||||
use Modules\Tag\Models\NullTag;
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
use phpOMS\Localization\BaseStringL11nType;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
use phpOMS\Message\Http\HttpResponse;
|
||||
use phpOMS\Message\Http\RequestStatusCode;
|
||||
use phpOMS\Message\NotificationLevel;
|
||||
|
|
@ -105,21 +106,15 @@ final class ApiController extends Controller
|
|||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return EditorDocType
|
||||
* @return BaseStringL11nType
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createDocTypeFromRequest(RequestAbstract $request) : EditorDocType
|
||||
private function createDocTypeFromRequest(RequestAbstract $request) : BaseStringL11nType
|
||||
{
|
||||
$type = new EditorDocType();
|
||||
$type->name = $request->getDataString('name') ?? '';
|
||||
|
||||
if ($request->hasData('title')) {
|
||||
$type->setL11n(
|
||||
$request->getDataString('title') ?? '',
|
||||
$request->getDataString('lang') ?? $request->header->l11n->language
|
||||
);
|
||||
}
|
||||
$type = new BaseStringL11nType();
|
||||
$type->title = $request->getDataString('name') ?? '';
|
||||
$type->setL11n($request->getDataString('title') ?? '', $request->getDataString('language') ?? ISO639x1Enum::_EN);
|
||||
|
||||
return $type;
|
||||
}
|
||||
|
|
@ -184,14 +179,14 @@ final class ApiController extends Controller
|
|||
*/
|
||||
private function createEditorDocTypeL11nFromRequest(RequestAbstract $request) : BaseStringL11n
|
||||
{
|
||||
$l11nEditorDocType = new BaseStringL11n();
|
||||
$l11nEditorDocType->ref = $request->getDataInt('type') ?? 0;
|
||||
$l11nEditorDocType->content = $request->getDataString('title') ?? '';
|
||||
$l11nEditorDocType->setLanguage(
|
||||
$typeL11n = new BaseStringL11n();
|
||||
$typeL11n->ref = $request->getDataInt('type') ?? 0;
|
||||
$typeL11n->setLanguage(
|
||||
$request->getDataString('language') ?? $request->header->l11n->language
|
||||
);
|
||||
$typeL11n->content = $request->getDataString('title') ?? '';
|
||||
|
||||
return $l11nEditorDocType;
|
||||
return $typeL11n;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ use Modules\Admin\Models\Account;
|
|||
use Modules\Admin\Models\NullAccount;
|
||||
use Modules\Media\Models\Media;
|
||||
use Modules\Tag\Models\Tag;
|
||||
use phpOMS\Localization\BaseStringL11nType;
|
||||
|
||||
/**
|
||||
* News article class.
|
||||
|
|
@ -75,7 +76,7 @@ class EditorDoc implements \JsonSerializable
|
|||
* @var null|EditorDocType
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public ?EditorDocType $type = null;
|
||||
public ?BaseStringL11nType $type = null;
|
||||
|
||||
/**
|
||||
* Doc path for organizing.
|
||||
|
|
|
|||
|
|
@ -1,120 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Editor\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Editor\Models;
|
||||
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
|
||||
/**
|
||||
* EditorDoc type class.
|
||||
*
|
||||
* @package Modules\Editor\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class EditorDocType implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* Article ID.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $id = 0;
|
||||
|
||||
/**
|
||||
* Name.
|
||||
*
|
||||
* Name used for additional identification, doesn't have to be unique.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public string $name = '';
|
||||
|
||||
/**
|
||||
* Title.
|
||||
*
|
||||
* @var string|BaseStringL11n
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $title = '';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $name Name
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(string $name = '')
|
||||
{
|
||||
$this->setL11n($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getL11n() : string
|
||||
{
|
||||
return $this->title instanceof BaseStringL11n ? $this->title->content : $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title
|
||||
*
|
||||
* @param string|BaseStringL11n $title EditorDoc article title
|
||||
* @param string $lang Language
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setL11n(string | BaseStringL11n $title, string $lang = ISO639x1Enum::_EN) : void
|
||||
{
|
||||
if ($title instanceof BaseStringL11n) {
|
||||
$this->title = $title;
|
||||
} elseif ($this->title instanceof BaseStringL11n) {
|
||||
$this->title->content = $title;
|
||||
} else {
|
||||
$this->title = new BaseStringL11n();
|
||||
$this->title->content = $title;
|
||||
$this->title->setLanguage($lang);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'title' => $this->title,
|
||||
'name' => $this->name,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize() : mixed
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
}
|
||||
|
|
@ -15,6 +15,7 @@ declare(strict_types=1);
|
|||
namespace Modules\Editor\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
use phpOMS\Localization\BaseStringL11nType;
|
||||
|
||||
/**
|
||||
* Editor type mapper class.
|
||||
|
|
@ -23,6 +24,9 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
|||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @template T of BaseStringL11nType
|
||||
* @extends DataMapperFactory<T>
|
||||
*/
|
||||
final class EditorDocTypeMapper extends DataMapperFactory
|
||||
{
|
||||
|
|
@ -34,7 +38,7 @@ final class EditorDocTypeMapper extends DataMapperFactory
|
|||
*/
|
||||
public const COLUMNS = [
|
||||
'editor_doc_type_id' => ['name' => 'editor_doc_type_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'editor_doc_type_name' => ['name' => 'editor_doc_type_name', 'type' => 'string', 'internal' => 'name'],
|
||||
'editor_doc_type_name' => ['name' => 'editor_doc_type_name', 'type' => 'string', 'internal' => 'title'],
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
@ -44,12 +48,11 @@ final class EditorDocTypeMapper extends DataMapperFactory
|
|||
* @since 1.0.0
|
||||
*/
|
||||
public const HAS_MANY = [
|
||||
'title' => [
|
||||
'l11n' => [
|
||||
'mapper' => EditorDocTypeL11nMapper::class,
|
||||
'table' => 'editor_doc_type_l11n',
|
||||
'self' => 'editor_doc_type_l11n_type',
|
||||
'column' => 'title',
|
||||
'conditional' => true,
|
||||
'column' => 'content',
|
||||
'external' => null,
|
||||
],
|
||||
];
|
||||
|
|
@ -60,7 +63,7 @@ final class EditorDocTypeMapper extends DataMapperFactory
|
|||
* @var class-string<T>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const MODEL = EditorDocType::class;
|
||||
public const MODEL = BaseStringL11nType::class;
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
|
|
|
|||
|
|
@ -1,47 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Editor\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Editor\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\Editor\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullEditorDocType extends EditorDocType
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize() : mixed
|
||||
{
|
||||
return ['id' => $this->id];
|
||||
}
|
||||
}
|
||||
|
|
@ -302,7 +302,7 @@ if (\defined('RESET') && RESET === '1') {
|
|||
$db->exec('DROP DATABASE IF EXISTS ' . $CONFIG['db']['core']['masters']['admin']['database']);
|
||||
$db->exec('CREATE DATABASE IF NOT EXISTS ' . $CONFIG['db']['core']['masters']['admin']['database']);
|
||||
$db = null;
|
||||
} catch (\Throwable $t) {
|
||||
} catch (\Throwable $_) {
|
||||
echo "\nCouldn't connect to MYSQL DB\n";
|
||||
}
|
||||
}
|
||||
|
|
@ -317,7 +317,7 @@ if (\defined('RESET') && RESET === '1') {
|
|||
$db->exec('DROP DATABASE IF EXISTS ' . $CONFIG['db']['core']['postgresql']['admin']['database']);
|
||||
$db->exec('CREATE DATABASE ' . $CONFIG['db']['core']['postgresql']['admin']['database']);
|
||||
$db = null;
|
||||
} catch (\Throwable $t) {
|
||||
} catch (\Throwable $_) {
|
||||
echo "\nCouldn't connect to POSTGRESQL DB\n";
|
||||
}
|
||||
}
|
||||
|
|
@ -332,7 +332,7 @@ if (\defined('RESET') && RESET === '1') {
|
|||
$db->exec('DROP DATABASE IF EXISTS ' . $CONFIG['db']['core']['mssql']['admin']['database']);
|
||||
$db->exec('CREATE DATABASE ' . $CONFIG['db']['core']['mssql']['admin']['database']);
|
||||
$db = null;
|
||||
} catch (\Throwable $t) {
|
||||
} catch (\Throwable $_) {
|
||||
echo "\nCouldn't connect to MSSQL DB\n";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user