|
8 | 8 | /* @var $group \ElggGroup */ |
9 | 9 | $group = elgg_get_page_owner_entity(); |
10 | 10 |
|
| 11 | +$manual_sorting_enabled = (bool) $group->getPluginSetting('static', 'enable_manual_sorting', false); |
| 12 | + |
11 | 13 | elgg_push_collection_breadcrumbs('object', \StaticPage::SUBTYPE, $group); |
12 | 14 |
|
13 | 15 | $can_write = $group->canWriteToContainer(0, 'object', \StaticPage::SUBTYPE); |
14 | 16 | if ($can_write) { |
15 | 17 | elgg_register_title_button('add', 'object', \StaticPage::SUBTYPE); |
| 18 | + |
| 19 | + if ($manual_sorting_enabled) { |
| 20 | + $count = elgg_count_entities([ |
| 21 | + 'type' => 'object', |
| 22 | + 'subtype' => \StaticPage::SUBTYPE, |
| 23 | + 'metadata_name_value_pairs' => [ |
| 24 | + 'parent_guid' => 0, |
| 25 | + ], |
| 26 | + 'container_guid' => $group->guid, |
| 27 | + ]); |
| 28 | + |
| 29 | + if ($count > 1) { |
| 30 | + elgg_register_menu_item('title', [ |
| 31 | + 'name' => 'sort_pages', |
| 32 | + 'text' => elgg_echo('sort'), |
| 33 | + 'icon' => 'sort', |
| 34 | + 'href' => elgg_http_add_url_query_elements('ajax/form/static/sort', [ |
| 35 | + 'container_guid' => $group->guid, |
| 36 | + ]), |
| 37 | + 'class' => ['elgg-button', 'elgg-button-action', 'elgg-lightbox'], |
| 38 | + ]); |
| 39 | + } |
| 40 | + } |
16 | 41 | } |
17 | 42 |
|
18 | 43 | $ignore_access = $can_write ? ELGG_IGNORE_ACCESS : 0; |
19 | 44 |
|
20 | | -$body = elgg_call($ignore_access, function() use ($group) { |
21 | | - return elgg_list_entities([ |
| 45 | +$body = elgg_call($ignore_access, function() use ($group, $manual_sorting_enabled) { |
| 46 | + $options = [ |
22 | 47 | 'type' => 'object', |
23 | 48 | 'subtype' => \StaticPage::SUBTYPE, |
24 | 49 | 'metadata_name_value_pairs' => [ |
|
30 | 55 | 'direction' => 'asc', |
31 | 56 | ], |
32 | 57 | 'no_results' => elgg_echo('static:admin:empty'), |
33 | | - ]); |
| 58 | + ]; |
| 59 | + |
| 60 | + if ($manual_sorting_enabled) { |
| 61 | + $options['sort_by'] = [ |
| 62 | + 'property' => 'order', |
| 63 | + 'direction' => 'asc', |
| 64 | + 'join_type' => 'left', |
| 65 | + 'signed' => true, |
| 66 | + ]; |
| 67 | + } |
| 68 | + |
| 69 | + return elgg_list_entities($options); |
34 | 70 | }); |
35 | 71 |
|
36 | 72 | echo elgg_view_page(elgg_echo('static:groups:title'), [ |
|
0 commit comments