diff --git a/lib/Alchemy/Phrasea/Collection/CollectionHelper.php b/lib/Alchemy/Phrasea/Collection/CollectionHelper.php new file mode 100644 index 0000000000..a56df2e356 --- /dev/null +++ b/lib/Alchemy/Phrasea/Collection/CollectionHelper.php @@ -0,0 +1,39 @@ +get_ord() < $right->get_ord()) ? -1 : (($left->get_ord() < $right->get_ord()) ? 1 : 0); + }); + + return $collections; + } +} diff --git a/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php b/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php index 56c7040c7d..b1d081ff7a 100644 --- a/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php +++ b/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php @@ -3,6 +3,7 @@ namespace Alchemy\Phrasea\Twig; use Alchemy\Phrasea\Application; +use Alchemy\Phrasea\Collection\CollectionHelper; use Alchemy\Phrasea\Model\Entities\ElasticsearchRecord; use Alchemy\Phrasea\Model\Entities\User; use Alchemy\Phrasea\Model\RecordInterface; @@ -22,6 +23,7 @@ class PhraseanetExtension extends \Twig_Extension public function getFilters() { return array( + new \Twig_SimpleFilter('sort_collections', array(CollectionHelper::class, 'sort')), ); } diff --git a/templates/web/admin/tree.html.twig b/templates/web/admin/tree.html.twig index a682e7eb36..259ec05c4c 100644 --- a/templates/web/admin/tree.html.twig +++ b/templates/web/admin/tree.html.twig @@ -166,7 +166,7 @@ {% endif %} - {% for collection in databox.get_collections() %} + {% for collection in databox.get_collections()|sort_collections %} {% if (collection.get_base_id() in app.getAclForUser(app.getAuthenticatedUser()).get_granted_base(['canadmin'])|keys or collection.get_base_id() in app.getAclForUser(app.getAuthenticatedUser()).get_granted_base(['manage'])|keys or collection.get_base_id() in app.getAclForUser(app.getAuthenticatedUser()).get_granted_base(['modify_struct'])|keys) %}