Merge branch 4.0

This commit is contained in:
Thibaud Fabre
2016-12-05 15:26:48 +01:00
parent f6700fbe12
commit b5bbb1851f
315 changed files with 6552 additions and 29445 deletions

View File

@@ -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');