Skip to content

Commit f5f15c6

Browse files
authored
Merge pull request #124 from VSEphpbb/myideas
View Your Ideas Quick Link
2 parents de120c1 + c25a0e3 commit f5f15c6

14 files changed

Lines changed: 235 additions & 161 deletions

File tree

controller/base.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,18 @@ protected function assign_template_block_vars($block, $rows)
133133
}
134134

135135
/**
136-
* Assign template variables for a search ideas field
136+
* Assign common template variables for Ideas pages
137137
*
138138
* @return void
139139
*/
140-
protected function display_search_ideas()
140+
protected function display_common_vars()
141141
{
142-
$this->template->assign_vars(array(
142+
$this->template->assign_vars([
143143
'S_DISPLAY_SEARCHBOX' => (bool) $this->auth->acl_get('u_search') && $this->auth->acl_get('f_search', $this->config['ideas_forum_id']) && $this->config['load_search'],
144144
'S_SEARCHBOX_ACTION' => append_sid("{$this->root_path}search.{$this->php_ext}"),
145-
'S_SEARCH_IDEAS_HIDDEN_FIELDS' => build_hidden_fields(array('fid' => array($this->config['ideas_forum_id']))),
146-
));
145+
'S_SEARCH_IDEAS_HIDDEN_FIELDS' => build_hidden_fields(['fid' => [$this->config['ideas_forum_id']]]),
146+
147+
'U_SEARCH_MY_IDEAS' => $this->helper->route('phpbb_ideas_list_controller', ['sort' => ideas::SORT_MYIDEAS, 'status' => '-1']),
148+
]);
147149
}
148150
}

controller/idea_controller.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
use phpbb\exception\http_exception;
1414
use phpbb\ideas\factory\ideas;
15+
use Symfony\Component\HttpFoundation\JsonResponse;
1516
use Symfony\Component\HttpFoundation\RedirectResponse;
1617

1718
class idea_controller extends base
@@ -24,7 +25,7 @@ class idea_controller extends base
2425
*
2526
* @param $idea_id int The ID of the requested idea, maybe?
2627
* @throws http_exception
27-
* @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
28+
* @return JsonResponse|RedirectResponse
2829
*/
2930
public function idea($idea_id)
3031
{
@@ -44,7 +45,7 @@ public function idea($idea_id)
4445
{
4546
$result = $this->$mode();
4647

47-
return new \Symfony\Component\HttpFoundation\JsonResponse($result);
48+
return new JsonResponse($result);
4849
}
4950

5051
$params = array(

controller/index_controller.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ public function index()
4343
$this->assign_template_block_vars('implemented_ideas', $ideas);
4444

4545
$this->template->assign_vars(array(
46-
'U_VIEW_TOP' => $this->link_helper->get_list_link(ideas::SORT_TOP),
47-
'U_VIEW_LATEST' => $this->link_helper->get_list_link(ideas::SORT_NEW),
48-
'U_VIEW_IMPLEMENTED'=> $this->link_helper->get_list_link(ideas::SORT_IMPLEMENTED),
46+
'U_VIEW_TOP' => $this->helper->route('phpbb_ideas_list_controller', ['sort' => ideas::SORT_TOP]),
47+
'U_VIEW_LATEST' => $this->helper->route('phpbb_ideas_list_controller', ['sort' => ideas::SORT_NEW]),
48+
'U_VIEW_IMPLEMENTED'=> $this->helper->route('phpbb_ideas_list_controller', ['sort' => ideas::SORT_DATE, 'status' => ideas::$statuses['IMPLEMENTED']]),
4949
'U_POST_ACTION' => $this->helper->route('phpbb_ideas_post_controller'),
5050
'U_MCP' => ($this->auth->acl_get('m_', $this->config['ideas_forum_id'])) ? append_sid("{$this->root_path}mcp.{$this->php_ext}", "f={$this->config['ideas_forum_id']}&i=main&mode=forum_view", true, $this->user->session_id) : '',
5151

@@ -57,8 +57,8 @@ public function index()
5757
'FORUM_NAME' => $this->language->lang('IDEAS'),
5858
));
5959

60-
// Display the search ideas field
61-
$this->display_search_ideas();
60+
// Display common ideas template vars
61+
$this->display_common_vars();
6262

6363
return $this->helper->render('index_body.html', $this->language->lang('IDEAS_TITLE'));
6464
}

controller/list_controller.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,22 +52,16 @@ public function ideas_list($sort)
5252
$sort = ideas::SORT_DATE;
5353
}
5454

55-
// if sort by "implemented", sort ideas with status implemented by date
56-
if ($sort === ideas::SORT_IMPLEMENTED)
57-
{
58-
$status = ideas::$statuses['IMPLEMENTED'];
59-
$sort = ideas::SORT_DATE;
60-
}
61-
62-
// Set the status name for displaying in the template
63-
$status_name = (!$status && $sort === ideas::SORT_TOP) ? $this->language->lang('TOP_IDEAS') : $this->ideas->get_status_from_id($status);
55+
// Set the name for displaying in the template
56+
$status_name = 'LIST_' . strtoupper($status > 0 ? array_search($status, ideas::$statuses) : $sort);
57+
$status_name = $this->language->is_set($status_name) ? $this->language->lang($status_name) : '';
6458

6559
// For special case where we want to request ALL ideas,
6660
// including the statuses normally hidden from lists.
6761
if ($status === -1)
6862
{
6963
$status = ideas::$statuses;
70-
$status_name = $this->language->lang('ALL_IDEAS');
64+
$status_name = $status_name ?: $this->language->lang('ALL_IDEAS');
7165
}
7266

7367
// Generate ideas
@@ -118,8 +112,8 @@ public function ideas_list($sort)
118112
$start
119113
);
120114

121-
// Display the search ideas field
122-
$this->display_search_ideas();
115+
// Display common ideas template vars
116+
$this->display_common_vars();
123117

124118
return $this->helper->render('list_body.html', $this->language->lang('IDEA_LIST'));
125119
}

event/listener.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ public function show_idea($event)
223223
'U_REMOVE_VOTE' => $this->link_helper->get_idea_link($idea['idea_id'], 'removevote', true),
224224
'U_IDEA_VOTE' => $this->link_helper->get_idea_link($idea['idea_id'], 'vote', true),
225225
'U_IDEA_DUPLICATE' => $this->link_helper->get_idea_link($idea['duplicate_id']),
226-
'U_IDEA_STATUS_LINK'=> $this->helper->route('phpbb_ideas_list_controller', array('status' => $idea['idea_status'])),
226+
'U_IDEA_STATUS_LINK'=> $this->helper->route('phpbb_ideas_list_controller', ['status' => $idea['idea_status']]),
227+
'U_SEARCH_MY_IDEAS' => $this->helper->route('phpbb_ideas_list_controller', ['sort' => ideas::SORT_MYIDEAS, 'status' => '-1']),
227228
'U_TITLE_LIVESEARCH'=> $this->helper->route('phpbb_ideas_livesearch_controller'),
228229
));
229230

0 commit comments

Comments
 (0)