diff --git a/Models/L11nTag.php b/Models/L11nTag.php index f50c2cc..2cb518c 100755 --- a/Models/L11nTag.php +++ b/Models/L11nTag.php @@ -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 * diff --git a/Models/L11nTagMapper.php b/Models/L11nTagMapper.php index e7c1c96..a0b93a1 100755 --- a/Models/L11nTagMapper.php +++ b/Models/L11nTagMapper.php @@ -54,6 +54,7 @@ final class L11nTagMapper extends DataMapperAbstract 'self' => 'tag_l11n_language', 'by' => 'code2', 'column' => 'code2', + 'conditional' => true, ], ]; diff --git a/Models/Tag.php b/Models/Tag.php index a647f89..204fb79 100755 --- a/Models/Tag.php +++ b/Models/Tag.php @@ -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); + } } /** diff --git a/Models/TagMapper.php b/Models/TagMapper.php index 0525994..455d248 100755 --- a/Models/TagMapper.php +++ b/Models/TagMapper.php @@ -56,6 +56,7 @@ final class TagMapper extends DataMapperAbstract 'table' => 'tag_l11n', 'external' => 'tag_l11n_tag', 'column' => 'title', + 'conditional' => true, 'self' => null, ], ]; diff --git a/Theme/Backend/Components/TagSelector/base.tpl.php b/Theme/Backend/Components/TagSelector/base.tpl.php index c9e98e3..ce103d5 100755 --- a/Theme/Backend/Components/TagSelector/base.tpl.php +++ b/Theme/Backend/Components/TagSelector/base.tpl.php @@ -15,7 +15,7 @@