mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 06:53:15 +00:00
Merge branch 4.0
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
|
||||
use Alchemy\Phrasea\Databox\SubdefGroup;
|
||||
use Alchemy\Phrasea\Media\MediaTypeFactory;
|
||||
use Assert\Assertion;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
|
||||
class databox_subdefsStructure implements IteratorAggregate, Countable
|
||||
@@ -215,6 +216,25 @@ class databox_subdefsStructure implements IteratorAggregate, Countable
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SubdefGroup[] $groups
|
||||
*/
|
||||
public function updateSubdefGroups($groups)
|
||||
{
|
||||
Assertion::allIsInstanceOf($groups, SubdefGroup::class);
|
||||
|
||||
$dom_xp = $this->databox->get_xpath_structure();
|
||||
|
||||
foreach ($groups as $group) {
|
||||
$nodes = $dom_xp->query('//record/subdefs/subdefgroup[@name="' . $group->getName() . '"]');
|
||||
|
||||
/** @var DOMElement $node */
|
||||
foreach ($nodes as $node) {
|
||||
$node->setAttribute('document_orderable', ($group->isDocumentOrderable() ? 'true' : 'false'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $group
|
||||
* @param string $name
|
||||
@@ -222,10 +242,11 @@ class databox_subdefsStructure implements IteratorAggregate, Countable
|
||||
* @param boolean $downloadable
|
||||
* @param array $options
|
||||
* @param array $labels
|
||||
* @param bool $orderable
|
||||
* @return databox_subdefsStructure
|
||||
* @throws Exception
|
||||
*/
|
||||
public function set_subdef($group, $name, $class, $downloadable, $options, $labels)
|
||||
public function set_subdef($group, $name, $class, $downloadable, $options, $labels, $orderable = true)
|
||||
{
|
||||
$dom_struct = $this->databox->get_dom_structure();
|
||||
|
||||
@@ -233,6 +254,7 @@ class databox_subdefsStructure implements IteratorAggregate, Countable
|
||||
$subdef->setAttribute('class', $class);
|
||||
$subdef->setAttribute('name', mb_strtolower($name));
|
||||
$subdef->setAttribute('downloadable', ($downloadable ? 'true' : 'false'));
|
||||
$subdef->setAttribute('orderable', ($orderable ? 'true' : 'false'));
|
||||
|
||||
foreach ($labels as $code => $label) {
|
||||
$child = $dom_struct->createElement('label');
|
||||
|
Reference in New Issue
Block a user