mirror of
https://github.com/Karaka-Management/oms-Tag.git
synced 2026-01-11 07:38:41 +00:00
adjust tag l11n for new l11n loading
This commit is contained in:
parent
489a21d403
commit
d628803aaa
|
|
@ -59,6 +59,18 @@ class L11nTag implements ArrayableInterface, \JsonSerializable
|
|||
*/
|
||||
private string $title = '';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $title Title
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(string $title = '')
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ final class L11nTagMapper extends DataMapperAbstract
|
|||
'self' => 'tag_l11n_language',
|
||||
'by' => 'code2',
|
||||
'column' => 'code2',
|
||||
'conditional' => true,
|
||||
],
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ namespace Modules\Tag\Models;
|
|||
use Modules\Admin\Models\Account;
|
||||
use Modules\Admin\Models\NullAccount;
|
||||
use phpOMS\Contract\ArrayableInterface;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
|
||||
/**
|
||||
* Tag class.
|
||||
|
|
@ -39,10 +40,10 @@ class Tag implements ArrayableInterface, \JsonSerializable
|
|||
/**
|
||||
* Title.
|
||||
*
|
||||
* @var string
|
||||
* @var string|L11nTag
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private string $title = '';
|
||||
private $title = '';
|
||||
|
||||
/**
|
||||
* Color RGBA.
|
||||
|
|
@ -165,21 +166,29 @@ class Tag implements ArrayableInterface, \JsonSerializable
|
|||
*/
|
||||
public function getTitle() : string
|
||||
{
|
||||
return $this->title;
|
||||
return $this->title instanceof L11nTag ? $this->title->getTitle() : $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title
|
||||
*
|
||||
* @param string $title Tag article title
|
||||
* @param string|L11nTag $title Tag article title
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setTitle(string $title) : void
|
||||
public function setTitle($title, string $lang = ISO639x1Enum::_EN) : void
|
||||
{
|
||||
$this->title = $title;
|
||||
if ($title instanceof L11nTag) {
|
||||
$this->title = new L11nTag();
|
||||
} elseif ($this->title instanceof L11nTag && \is_string($title)) {
|
||||
$this->title->setTitle($title);
|
||||
} elseif (\is_string($title)) {
|
||||
$this->title = new L11nTag();
|
||||
$this->title->setTitle($title);
|
||||
$this->title->setLanguage($lang);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ final class TagMapper extends DataMapperAbstract
|
|||
'table' => 'tag_l11n',
|
||||
'external' => 'tag_l11n_tag',
|
||||
'column' => 'title',
|
||||
'conditional' => true,
|
||||
'self' => null,
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
<div class="advancedInput wf-100" id="<?= $this->printHtml($this->getId()); ?>">
|
||||
<input autocomplete="off" class="input" type="text" id="i<?= $this->printHtml($this->getId()); ?>" placeholder=" Guest"
|
||||
data-emptyAfter="true"
|
||||
data-autocomplete="false"
|
||||
data-autocomplete="off"
|
||||
data-src="api/tag/find?search={#i<?= $this->printHtml($this->getId()); ?>}">
|
||||
<div id="<?= $this->printHtml($this->getId()); ?>-dropdown" class="dropdown" data-active="true">
|
||||
<table class="default">
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
$url = UriFactory::build('{/prefix}tag/single?{?}&id=' . $value->getId()); ?>
|
||||
<tr tabindex="0" data-href="<?= $url; ?>">
|
||||
<td data-label="<?= $this->getHtml('Title') ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getTitle()); ?></a>
|
||||
<td data-label="<?= $this->getHtml('Title') ?>"><a href="<?= $url; ?>"><span class="tag" style="background: <?= $this->printHtml($value->getColor()); ?>"> </span></a>
|
||||
<td data-label="<?= $this->getHtml('Title') ?>"><a href="<?= $url; ?>"><span class="tag" style="background: <?= $this->printHtml(\substr($value->getColor(), 0, 7)); ?>"> </span></a>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($count === 0) : ?>
|
||||
<tr><td colspan="3" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user