Skip to content

Commit fdc0c9a

Browse files
committed
chore: no longer use deprecated layouts
1 parent d9afe1d commit fdc0c9a

File tree

9 files changed

+47
-56
lines changed

9 files changed

+47
-56
lines changed

classes/ColdTrick/Questions/Menus.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ public static function registerFilter(\Elgg\Hook $hook) {
105105

106106
$page_owner = elgg_get_page_owner_entity();
107107

108+
// add default filter tabs since we're using a custom ID
109+
$defaults = elgg_get_filter_tabs($hook->getParam('filter_id'), $hook->getParam('filter_value'));
110+
if (!empty($defaults)) {
111+
$items->merge($defaults);
112+
}
113+
108114
// remove friends
109115
$items->remove('friend');
110116

@@ -127,15 +133,15 @@ public static function registerFilter(\Elgg\Hook $hook) {
127133
$items->add($all);
128134
}
129135
}
130-
136+
131137
if (questions_is_expert()) {
132138
$items[] = \ElggMenuItem::factory([
133139
'name' => 'todo',
134140
'text' => elgg_echo('questions:menu:filter:todo'),
135141
'href' => elgg_generate_url('collection:object:question:todo'),
136142
'priority' => 700,
137143
]);
138-
144+
139145
if ($page_owner instanceof \ElggGroup && questions_is_expert($page_owner)) {
140146
$items[] = \ElggMenuItem::factory([
141147
'name' => 'todo_group',
@@ -147,21 +153,21 @@ public static function registerFilter(\Elgg\Hook $hook) {
147153
]);
148154
}
149155
}
150-
156+
151157
if (questions_experts_enabled()) {
152158
$route_params = [];
153159
if ($page_owner instanceof \ElggGroup) {
154160
$route_params['group_guid'] = $page_owner->guid;
155161
}
156-
162+
157163
$items[] = \ElggMenuItem::factory([
158164
'name' => 'experts',
159165
'text' => elgg_echo('questions:menu:filter:experts'),
160166
'href' => elgg_generate_url('collection:object:question:experts', $route_params),
161167
'priority' => 800,
162168
]);
163169
}
164-
170+
165171
return $items;
166172
}
167173

views/default/resources/questions/add.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
elgg_push_collection_breadcrumbs('object', ElggQuestion::SUBTYPE, $page_owner);
1111

12+
// build page elements
1213
$title = elgg_echo('questions:add');
1314

1415
$form_vars = [];
@@ -18,9 +19,7 @@
1819
$body_vars = questions_prepare_question_form_vars();
1920
$content = elgg_view_form('object/question/save', $form_vars, $body_vars);
2021

21-
$body = elgg_view_layout('default', [
22-
'title' => $title,
22+
// draw page
23+
echo elgg_view_page($title, [
2324
'content' => $content,
2425
]);
25-
26-
echo elgg_view_page($title, $body);

views/default/resources/questions/all.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// prepare options
1313
$options = [
1414
'type' => 'object',
15-
'subtype' => 'question',
15+
'subtype' => ElggQuestion::SUBTYPE,
1616
'no_results' => elgg_echo('questions:none'),
1717
'wheres' => [],
1818
];
@@ -42,11 +42,9 @@
4242

4343
$content = elgg_list_entities($options);
4444

45-
// build page
46-
$body = elgg_view_layout('content', [
47-
'title' => $title,
45+
// draw page
46+
echo elgg_view_page($title, [
4847
'content' => $filter . $content,
48+
'filter_id' => 'questions',
49+
'filter_value' => 'all',
4950
]);
50-
51-
// draw page
52-
echo elgg_view_page($title, $body);

views/default/resources/questions/edit.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
elgg_push_entity_breadcrumbs($question, true);
2020

21+
// build page elements
22+
$title = elgg_echo('edit');
23+
2124
$form_vars = [];
2225
if (questions_limited_to_groups()) {
2326
$form_vars['class'] = 'questions-validate-container';
@@ -27,10 +30,7 @@
2730

2831
$content = elgg_view_form('object/question/save', $form_vars, $body_vars);
2932

30-
$body = elgg_view_layout('content', [
31-
'title' => elgg_echo('edit'),
33+
// draw page
34+
echo elgg_view_page($title, [
3235
'content' => $content,
33-
'filter' => '',
3436
]);
35-
36-
echo elgg_view_page(elgg_echo('edit'), $body);

views/default/resources/questions/experts.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,9 @@
4141
'no_results' => elgg_echo('questions:experts:none', [$container->getDisplayName()]),
4242
]);
4343

44-
// build page
45-
$page_data = elgg_view_layout('content', [
46-
'title' => $title_text,
44+
// draw page
45+
echo elgg_view_page($title_text, [
4746
'content' => $desciption . $user_list,
48-
'filter_context' => '',
47+
'filter_id' => 'questions',
48+
'filter_value' => 'experts',
4949
]);
50-
51-
// draw page
52-
echo elgg_view_page($title_text, $page_data);

views/default/resources/questions/group.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
// prepare options
1919
$options = [
2020
'type' => 'object',
21-
'subtype' => 'question',
21+
'subtype' => ElggQuestion::SUBTYPE,
2222
'container_guid' => $page_owner->guid,
2323
'full_view' => false,
2424
'list_type_toggle' => false,
@@ -51,11 +51,9 @@
5151

5252
$content = elgg_list_entities($options);
5353

54-
// build page
55-
$body = elgg_view_layout('content', [
56-
'title' => $title,
54+
// draw page
55+
echo elgg_view_page($title, [
5756
'content' => $filter . $content,
57+
'filter_id' => 'questions',
58+
'filter_value' => 'all',
5859
]);
59-
60-
// draw page
61-
echo elgg_view_page($title, $body);

views/default/resources/questions/owner.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// prepare options
2020
$options = [
2121
'type' => 'object',
22-
'subtype' => 'question',
22+
'subtype' => ElggQuestion::SUBTYPE,
2323
'owner_guid' => $page_owner->guid,
2424
'full_view' => false,
2525
'list_type_toggle' => false,
@@ -52,12 +52,9 @@
5252

5353
$content = elgg_list_entities($options);
5454

55-
// build page
56-
$body = elgg_view_layout('content', [
57-
'title' => $title,
55+
// draw page
56+
echo elgg_view_page($title, [
5857
'content' => $filter . $content,
59-
'filter_context' => ($page_owner->guid === elgg_get_logged_in_user_guid()) ? 'mine' : '',
58+
'filter_id' => 'questions',
59+
'filter_value' => ($page_owner->guid === elgg_get_logged_in_user_guid()) ? 'mine' : 'none',
6060
]);
61-
62-
// draw page
63-
echo elgg_view_page($title, $body);

views/default/resources/questions/todo.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
if (!questions_is_expert()) {
1212
$e = new EntityPermissionsException();
1313
$e->setRedirectUrl(elgg_generate_url('collection:object:question:all'));
14+
throw $e;
1415
}
1516

1617
// check for a group filter
@@ -24,6 +25,7 @@
2425
$e->setRedirectUrl(elgg_generate_url('collection:object:question:group', [
2526
'guid' => $group->guid,
2627
]));
28+
throw $e;
2729
}
2830
$page_owner = $group;
2931
}
@@ -64,7 +66,7 @@ function (QueryBuilder $qb, $main_alias) {
6466
];
6567

6668
if ($page_owner instanceof ElggGroup) {
67-
$options['container_guid'] = $page_owner->getGUID();
69+
$options['container_guid'] = $page_owner->guid;
6870
} else {
6971
$options['wheres'][] = questions_get_expert_where_sql();
7072
}
@@ -92,12 +94,9 @@ function (QueryBuilder $qb, $main_alias) {
9294

9395
$content = elgg_list_entities($options);
9496

95-
// build page
96-
$body = elgg_view_layout('content', [
97-
'title' => $title,
97+
// draw page
98+
echo elgg_view_page($title, [
9899
'content' => $content,
99-
'filter_context' => '',
100+
'filter_id' => 'questions',
101+
'filter_value' => ($page_owner instanceof ElggGroup) ? 'todo_group' : 'todo',
100102
]);
101-
102-
// draw page
103-
echo elgg_view_page($title, $body);

views/default/resources/questions/view.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,8 @@ function (QueryBuilder $qb, $main_alias) {
117117
]);
118118
}
119119

120-
$body = elgg_view_layout('content', [
120+
// draw page
121+
echo elgg_view_page($title, [
121122
'entity' => $question,
122-
'title' => $title,
123123
'content' => $content,
124-
'filter' => false,
125124
]);
126-
127-
echo elgg_view_page($title, $body);

0 commit comments

Comments
 (0)