diff --git a/views/bootstrap/class.AddDocument.php b/views/bootstrap/class.AddDocument.php
index 924ba0ee7..92ad726b1 100644
--- a/views/bootstrap/class.AddDocument.php
+++ b/views/bootstrap/class.AddDocument.php
@@ -241,7 +241,7 @@ console.log(params);
}
}
if(!$nodocumentformfields || !in_array('sequence', $nodocumentformfields)) {
- $this->formField(getMLText("sequence"), $this->getSequenceChooser($folder->getDocuments('s')).($orderby != 's' ? "
".getMLText('order_by_sequence_off') : ''));
+ $this->formField(getMLText("sequence"), $this->getSequenceChooser($folder, 'd').($orderby != 's' ? "
".getMLText('order_by_sequence_off') : ''));
} else {
$minmax = $folder->getDocumentsMinMax();
if($this->params['defaultposition'] == 'start') {
diff --git a/views/bootstrap/class.AddSubFolder.php b/views/bootstrap/class.AddSubFolder.php
index 1cf7a286c..fea0a7f98 100644
--- a/views/bootstrap/class.AddSubFolder.php
+++ b/views/bootstrap/class.AddSubFolder.php
@@ -98,7 +98,7 @@ $(document).ready( function() {
)
);
if(!$nofolderformfields || !in_array('sequence', $nofolderformfields)) {
- $this->formField(getMLText("sequence"), $this->getSequenceChooser($folder->getSubFolders('s')).($orderby != 's' ? "
".getMLText('order_by_sequence_off') : ''));
+ $this->formField(getMLText("sequence"), $this->getSequenceChooser($folder, 'f').($orderby != 's' ? "
".getMLText('order_by_sequence_off') : ''));
} else {
$minmax = $folder->getFoldersMinMax();
if($this->params['defaultposition'] == 'start') {
diff --git a/views/bootstrap/class.Bootstrap.php b/views/bootstrap/class.Bootstrap.php
index 37cfe7de5..18ff23438 100644
--- a/views/bootstrap/class.Bootstrap.php
+++ b/views/bootstrap/class.Bootstrap.php
@@ -1598,17 +1598,43 @@ $(document).ready(function() {
print "";
} /* }}} */
- function printSequenceChooser($objArr, $keepID = -1) { /* {{{ */
- echo $this->getSequenceChooser($objArr, $keepID);
+ function printSequenceChooser($parent, $type, $keepID = -1) { /* {{{ */
+ echo $this->getSequenceChooser($parent, $type, $keepID);
} /* }}} */
- function getSequenceChooser($objArr, $keepID = -1) { /* {{{ */
- if (count($objArr) > 0) {
- $max = $objArr[count($objArr)-1]->getSequence() + 1;
- $min = $objArr[0]->getSequence() - 1;
+ /**
+ * Return html code for sequence chooser
+ *
+ * This method will return the html code of the ѕelect menu for setting
+ * the ѕequence number of a document or folder. The select menu will contain
+ * a list of all siblings to select to positon relative to a sibling.
+ * For performance reasons the select menu will not contain any siblings
+ * if the number of siblings is greater than 50.
+ *
+ * @param $parent object parent folder of new or updated document/folder
+ * @param $type string type of new object 'f'=folder, 'd'=document
+ * @param $keepID integer id of current object
+ */
+ function getSequenceChooser($parent, $type, $keepID = -1) { /* {{{ */
+ $objArr = [];
+ if($type == 'd') {
+ if(($c = $parent->hasDocuments()) < 50)
+ $objArr = $parent->getDocuments('s');
+ $minmax = $parent->getDocumentsMinMax();
+ } elseif($type = 'f') {
+ if(($c = $parent->hasSubFolders()) < 50)
+ $objArr = $parent->getSubFolders('s');
+ $minmax = $parent->getFoldersMinMax();
+ } else
+ return '';
+
+ if ($objArr) {
+ $min = $minmax['min']-1.0;
+ $max = $minmax['max']+1.0;
}
else {
- $max = 1.0;
+ $min = (float) $minmax['min'];
+ $max = $minmax['max']+1.0;
}
$content = "";
} /* }}} */
- function printSequenceChooser($objArr, $keepID = -1) { /* {{{ */
- echo $this->getSequenceChooser($objArr, $keepID);
+ function printSequenceChooser($parent, $type, $keepID = -1) { /* {{{ */
+ echo $this->getSequenceChooser($parent, $type, $keepID);
} /* }}} */
- function getSequenceChooser($objArr, $keepID = -1) { /* {{{ */
- if (count($objArr) > 0) {
- $max = $objArr[count($objArr)-1]->getSequence() + 1;
- $min = $objArr[0]->getSequence() - 1;
+ /**
+ * Return html code for sequence chooser
+ *
+ * This method will return the html code of the ѕelect menu for setting
+ * the ѕequence number of a document or folder. The select menu will contain
+ * a list of all siblings to select to positon relative to a sibling.
+ * For performance reasons the select menu will not contain any siblings
+ * if the number of siblings is greater than 50.
+ *
+ * @param $parent object parent folder of new or updated document/folder
+ * @param $type string type of new object 'f'=folder, 'd'=document
+ * @param $keepID integer id of current object
+ */
+ function getSequenceChooser($parent, $type, $keepID = -1) { /* {{{ */
+ $objArr = [];
+ if($type == 'd') {
+ if(($c = $parent->hasDocuments()) < 50)
+ $objArr = $parent->getDocuments('s');
+ $minmax = $parent->getDocumentsMinMax();
+ } elseif($type = 'f') {
+ if(($c = $parent->hasSubFolders()) < 50)
+ $objArr = $parent->getSubFolders('s');
+ $minmax = $parent->getFoldersMinMax();
+ } else
+ return '';
+
+ if ($objArr) {
+ $min = $minmax['min']-1.0;
+ $max = $minmax['max']+1.0;
}
else {
- $max = 1.0;
+ $min = (float) $minmax['min'];
+ $max = $minmax['max']+1.0;
}
$content = "