PHRAS-1766 Add orderable checkbox for each subdef - Remove order option on groups

This commit is contained in:
Xavier Rousset
2017-12-18 18:02:48 +01:00
parent 3a6f2eb365
commit c7f6b325d8
3 changed files with 11 additions and 70 deletions

View File

@@ -220,36 +220,19 @@ 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
* @param string $class
* @param string $preset
* @param boolean $downloadable
* @param array $options
* @param array $labels
* @param boolean $orderable
* @param string $preset
* @return databox_subdefsStructure
* @throws Exception
*/
public function set_subdef($group, $name, $class, $downloadable, $options, $labels, $preset = "Custom")
public function set_subdef($group, $name, $class, $downloadable, $options, $labels, $orderable = true, $preset = "Custom")
{
$dom_struct = $this->databox->get_dom_structure();
@@ -257,6 +240,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'));
$subdef->setAttribute('presets', $preset);
foreach ($labels as $code => $label) {