|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* |
|
4
|
|
|
* Ideas extension for the phpBB Forum Software package. |
|
5
|
|
|
* |
|
6
|
|
|
* @copyright (c) phpBB Limited <https://www.phpbb.com> |
|
7
|
|
|
* @license GNU General Public License, version 2 (GPL-2.0) |
|
8
|
|
|
* |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace phpbb\ideas\controller; |
|
12
|
|
|
|
|
13
|
|
|
use phpbb\exception\http_exception; |
|
14
|
|
|
use phpbb\ideas\ext; |
|
15
|
|
|
|
|
16
|
|
|
class index_controller extends base |
|
17
|
|
|
{ |
|
18
|
|
|
/* @var \phpbb\ideas\factory\ideas */ |
|
19
|
|
|
protected $entity; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Controller for /ideas |
|
23
|
|
|
* |
|
24
|
|
|
* @throws http_exception |
|
25
|
|
|
* @return \Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
26
|
|
|
*/ |
|
27
|
|
|
public function index() |
|
28
|
|
|
{ |
|
29
|
|
|
if (!$this->is_available()) |
|
30
|
|
|
{ |
|
31
|
|
|
throw new http_exception(404, 'IDEAS_NOT_AVAILABLE'); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
// Generate latest ideas |
|
35
|
|
|
$ideas = $this->entity->get_ideas(ext::NUM_IDEAS, ext::SORT_DATE, 'DESC'); |
|
36
|
|
|
$this->assign_template_block_vars('latest_ideas', $ideas); |
|
37
|
|
|
|
|
38
|
|
|
// Generate top ideas |
|
39
|
|
|
$ideas = $this->entity->get_ideas(ext::NUM_IDEAS, ext::SORT_TOP, 'DESC'); |
|
40
|
|
|
$this->assign_template_block_vars('top_ideas', $ideas); |
|
41
|
|
|
|
|
42
|
|
|
// Generate recently implemented |
|
43
|
|
|
$ideas = $this->entity->get_ideas(ext::NUM_IDEAS, ext::SORT_DATE, 'DESC', ext::$statuses['IMPLEMENTED']); |
|
44
|
|
|
$this->assign_template_block_vars('implemented_ideas', $ideas); |
|
45
|
|
|
|
|
46
|
|
|
$this->template->assign_vars(array( |
|
47
|
|
|
'U_VIEW_TOP' => $this->helper->route('phpbb_ideas_list_controller', ['sort' => ext::SORT_TOP]), |
|
48
|
|
|
'U_VIEW_LATEST' => $this->helper->route('phpbb_ideas_list_controller', ['sort' => ext::SORT_NEW]), |
|
49
|
|
|
'U_VIEW_IMPLEMENTED'=> $this->helper->route('phpbb_ideas_list_controller', ['sort' => ext::SORT_DATE, 'status' => ext::$statuses['IMPLEMENTED']]), |
|
50
|
|
|
'U_POST_ACTION' => $this->helper->route('phpbb_ideas_post_controller'), |
|
51
|
|
|
'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) : '', |
|
52
|
|
|
|
|
53
|
|
|
)); |
|
54
|
|
|
|
|
55
|
|
|
// Assign breadcrumb template vars |
|
56
|
|
|
$this->template->assign_block_vars('navlinks', array( |
|
57
|
|
|
'U_VIEW_FORUM' => $this->helper->route('phpbb_ideas_index_controller'), |
|
58
|
|
|
'FORUM_NAME' => $this->language->lang('IDEAS'), |
|
59
|
|
|
)); |
|
60
|
|
|
|
|
61
|
|
|
// Display common ideas template vars |
|
62
|
|
|
$this->display_common_vars(); |
|
63
|
|
|
|
|
64
|
|
|
return $this->helper->render('@phpbb_ideas/index_body.html', $this->language->lang('IDEAS_TITLE')); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|