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/Controller/RecordsRequest.php b/lib/Alchemy/Phrasea/Controller/RecordsRequest.php index 5d0c93b9de..afd86c0a15 100644 --- a/lib/Alchemy/Phrasea/Controller/RecordsRequest.php +++ b/lib/Alchemy/Phrasea/Controller/RecordsRequest.php @@ -104,7 +104,7 @@ class RecordsRequest extends ArrayCollection /** @var \record_adapter $record */ foreach ($this as $record) { if (! isset($this->collections[$record->getBaseId()])) { - $this->collections[$record->getBaseId()] = $record->getCollection(); + $this->collections[$record->getBaseId()] = $record->get_collection(); } } 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) %} diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/OrderTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/OrderTest.php index e6bb39931c..558b599b88 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/OrderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/OrderTest.php @@ -16,11 +16,6 @@ use Alchemy\Phrasea\Model\Entities\OrderElement; */ class OrderTest extends \PhraseanetAuthenticatedWebTestCase { - /** - * @covers Alchemy\Phrasea\Controller\Prod\Order::createOrder - * @covers Alchemy\Phrasea\Controller\Prod\Order::connect - * @covers Alchemy\Phrasea\Controller\Prod\Order::call - */ public function testCreateOrder() { $app = $this->getApplication(); @@ -46,9 +41,6 @@ class OrderTest extends \PhraseanetAuthenticatedWebTestCase $this->assertTrue($triggered, 'Creation listener should have been triggered'); } - /** - * @covers Alchemy\Phrasea\Controller\Prod\Order::createOrder - */ public function testCreateOrderJson() { $app = $this->getApplication(); @@ -76,9 +68,6 @@ class OrderTest extends \PhraseanetAuthenticatedWebTestCase $this->assertTrue($content->success, 'Success attribute of response content should be true'); } - /** - * @covers Alchemy\Phrasea\Controller\Prod\Order::displayOrders - */ public function testDisplayOrders() { $this->XMLHTTPRequest('POST', '/prod/order/', [ @@ -91,9 +80,6 @@ class OrderTest extends \PhraseanetAuthenticatedWebTestCase $this->assertTrue($response->isOk()); } - /** - * @covers Alchemy\Phrasea\Controller\Prod\Order::displayOneOrder - */ public function testDisplayOneOrder() { $order = $this->createOneOrder('I need this pictures'); @@ -102,9 +88,6 @@ class OrderTest extends \PhraseanetAuthenticatedWebTestCase $this->assertTrue($client->getResponse()->isOk()); } - /** - * @covers Alchemy\Phrasea\Controller\Prod\Order::sendOrder - */ public function testSendOrder() { $order = $this->createOneOrder('I need this pictures'); @@ -123,9 +106,6 @@ class OrderTest extends \PhraseanetAuthenticatedWebTestCase $this->assertTrue(strpos($url['query'], 'success=1') === 0, 'Validation of elements is not successful'); } - /** - * @covers Alchemy\Phrasea\Controller\Prod\Order::sendOrder - */ public function testSendOrderJson() { $order = $this->createOneOrder('I need this pictures'); @@ -148,9 +128,6 @@ class OrderTest extends \PhraseanetAuthenticatedWebTestCase $this->assertObjectHasAttribute('order_id', $content, $response->getContent()); } - /** - * @covers Alchemy\Phrasea\Controller\Prod\Order::denyOrder - */ public function testDenyOrder() { $order = $this->createOneOrder('I need this pictures'); @@ -171,9 +148,6 @@ class OrderTest extends \PhraseanetAuthenticatedWebTestCase $this->assertTrue( ! ! $var['success']); } - /** - * @covers Alchemy\Phrasea\Controller\Prod\Order::denyOrder - */ public function testDenyOrderJson() { $order = $this->createOneOrder('I need this pictures');