PHRAS-3822 Prod : Improve Image WaterMarking (#4266)

* admin improve watermark

* unused

* allow to use collection wm image to wm a subdef (set <watermark>coll_wm</watermark> in structure)

* [skip ci] upload a wm for subdef (WIP to be continued ?)

* allow to use a record as wm image (document) to wmark subdefs

* cleanup

---------

Co-authored-by: jygaulier <gaulier@alchemy.fr>
This commit is contained in:
Aina Sitraka
2023-03-15 16:26:25 +03:00
committed by GitHub
parent e7027c7220
commit b4a3bb0c8c
7 changed files with 173 additions and 50 deletions

View File

@@ -22,6 +22,9 @@ use Symfony\Component\Translation\TranslatorInterface;
class databox_subdef
{
/** @var databox|null */
private $databox;
/**
* The class type of the subdef
* Is null or one of the CLASS_* constants
@@ -67,8 +70,9 @@ class databox_subdef
*
* @return databox_subdef
*/
public function __construct(SubdefType $type, SimpleXMLElement $sd, TranslatorInterface $translator)
public function __construct(SubdefType $type, SimpleXMLElement $sd, TranslatorInterface $translator, databox $databox = null)
{
$this->databox = $databox;
$this->subdef_group = $type;
$this->class = (string)$sd->attributes()->class;
$this->translator = $translator;
@@ -113,6 +117,12 @@ class databox_subdef
break;
}
}
public function getDatabox()
{
return $this->databox;
}
/**
* Build Image Subdef object depending the SimpleXMLElement
*
@@ -141,11 +151,14 @@ class databox_subdef
$image->setOptionValue(Image::OPTION_FLATTEN, p4field::isyes($sd->flatten));
}
if ($sd->watermark) {
$image->setOptionValue(Image::OPTION_WATERMARK, p4field::isyes($sd->watermark));
$image->setOptionValue(Image::OPTION_WATERMARK, (string) $sd->watermark);
}
if ($sd->watermarktext) {
$image->setOptionValue(Image::OPTION_WATERMARKTEXT, $sd->watermarktext);
}
if ($sd->watermarkrid) {
$image->setOptionValue(Image::OPTION_WATERMARKRID, $sd->watermarkrid);
}
return $image;
}
/**
@@ -456,4 +469,4 @@ class databox_subdef
{
return $this->subdef_type->getOptions();
}
}
}

View File

@@ -107,7 +107,7 @@ class databox_subdefsStructure implements IteratorAggregate, Countable
$group = $this->getSubdefGroup($subdefgroup_name);
foreach ($subdefs as $sd) {
$group->addSubdef(new databox_subdef($group->getType(), $sd, $this->translator));
$group->addSubdef(new databox_subdef($group->getType(), $sd, $this->translator, $this->databox));
}
}
}