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\factory; |
12
|
|
|
|
13
|
|
|
use phpbb\controller\helper; |
14
|
|
|
use phpbb\user_loader; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Class for helping with common links |
18
|
|
|
*/ |
19
|
|
|
class linkhelper |
20
|
|
|
{ |
21
|
|
|
/* @var helper */ |
22
|
|
|
protected $helper; |
23
|
|
|
|
24
|
|
|
/* @var user_loader */ |
25
|
|
|
protected $user_loader; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @param helper $helper |
29
|
|
|
* @param user_loader $user_loader |
30
|
|
|
*/ |
31
|
|
|
public function __construct(helper $helper, user_loader $user_loader) |
32
|
|
|
{ |
33
|
|
|
$this->helper = $helper; |
34
|
|
|
$this->user_loader = $user_loader; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Shortcut method to get the link to a specified idea. |
39
|
|
|
* Optionally add mode and hash URL arguments. |
40
|
|
|
* |
41
|
|
|
* @param int $idea_id The ID of the idea |
42
|
|
|
* @param string $mode The mode argument (vote, delete, etc.) |
43
|
|
|
* @param bool $hash Add a link hash |
44
|
|
|
* @return string The route |
45
|
|
|
*/ |
46
|
|
|
public function get_idea_link($idea_id, $mode = '', $hash = false) |
47
|
|
|
{ |
48
|
|
|
$params = array('idea_id' => $idea_id); |
49
|
|
|
$params = $mode ? array_merge($params, array('mode' => $mode)) : $params; |
50
|
|
|
$params = $hash ? array_merge($params, array('hash' => generate_link_hash("{$mode}_$idea_id"))) : $params; |
51
|
|
|
|
52
|
|
|
return $this->helper->route('phpbb_ideas_idea_controller', $params); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Returns a link to the users profile, complete with colour. |
57
|
|
|
* |
58
|
|
|
* Is there a function that already does this? This seems fairly database heavy. |
59
|
|
|
* |
60
|
|
|
* @param int $id The ID of the user |
61
|
|
|
* @return string An HTML link to the users profile |
62
|
|
|
*/ |
63
|
|
|
public function get_user_link($id) |
64
|
|
|
{ |
65
|
|
|
$this->user_loader->load_users(array($id)); |
66
|
|
|
return $this->user_loader->get_username($id, 'full'); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|