|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* |
|
4
|
|
|
* @package sitemaker |
|
5
|
|
|
* @copyright (c) 2016 Daniel A. (blitze) |
|
6
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 |
|
7
|
|
|
* |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace blitze\content\services\actions\topic; |
|
11
|
|
|
|
|
12
|
|
|
use blitze\content\services\actions\action_interface; |
|
13
|
|
|
|
|
14
|
|
|
class view implements action_interface |
|
15
|
|
|
{ |
|
16
|
|
|
/** @var \phpbb\request\request_interface */ |
|
17
|
|
|
protected $request; |
|
18
|
|
|
|
|
19
|
|
|
/** @var \phpbb\template\template */ |
|
20
|
|
|
protected $template; |
|
21
|
|
|
|
|
22
|
|
|
/** @var \blitze\content\services\types */ |
|
23
|
|
|
protected $content_types; |
|
24
|
|
|
|
|
25
|
|
|
/** @var \blitze\content\services\views\views_factory */ |
|
26
|
|
|
protected $views; |
|
27
|
|
|
|
|
28
|
|
|
/** @var string */ |
|
29
|
|
|
protected $phpbb_root_path; |
|
30
|
|
|
|
|
31
|
|
|
/** @var string */ |
|
32
|
|
|
protected $php_ext; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Constructor |
|
36
|
|
|
* |
|
37
|
|
|
* @param \phpbb\request\request_interface $request Request object |
|
38
|
|
|
* @param \phpbb\template\template $template Template object |
|
39
|
|
|
* @param \blitze\content\services\types $content_types Content types object |
|
40
|
|
|
* @param \blitze\content\services\views\views_factory $views Views factory object |
|
41
|
|
|
* @param string $phpbb_root_path Path to the phpbb includes directory. |
|
42
|
|
|
* @param string $php_ext php file extension |
|
43
|
|
|
*/ |
|
44
|
|
|
public function __construct(\phpbb\request\request_interface $request, \phpbb\template\template $template, \blitze\content\services\types $content_types, \blitze\content\services\views\views_factory $views, $phpbb_root_path, $php_ext) |
|
45
|
|
|
{ |
|
46
|
|
|
$this->request = $request; |
|
47
|
|
|
$this->template = $template; |
|
48
|
|
|
$this->content_types = $content_types; |
|
49
|
|
|
$this->views = $views; |
|
50
|
|
|
$this->phpbb_root_path = $phpbb_root_path; |
|
51
|
|
|
$this->php_ext = $php_ext; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @inheritdoc |
|
56
|
|
|
*/ |
|
57
|
|
|
public function execute($u_action, $mode = '') |
|
58
|
|
|
{ |
|
59
|
|
|
$topic_id = $this->request->variable('t', 0); |
|
60
|
|
|
$type = $this->request->variable('type', ''); |
|
61
|
|
|
|
|
62
|
|
|
$view_tpl = ''; |
|
63
|
|
|
if ($entity = $this->content_types->get_type($type) |
|
|
|
|
|
|
64
|
|
|
{ |
|
65
|
|
|
$entity->set_show_poster_info(false); |
|
|
|
|
|
|
66
|
|
|
$entity->set_show_poster_contents(false); |
|
67
|
|
|
$entity->set_allow_comments(false); |
|
68
|
|
|
|
|
69
|
|
|
$update_count = array(); |
|
70
|
|
|
$overwrite = $this->get_data_overwrite($mode, $u_action, $type, $topic_id); |
|
71
|
|
|
|
|
72
|
|
|
/** @var \blitze\content\services\views\driver\views_interface $view_handler */ |
|
73
|
|
|
$view_handler = $this->views->get($entity->get_content_view()); |
|
74
|
|
|
$view_handler->render_detail($entity, $topic_id, $update_count, $overwrite); |
|
75
|
|
|
$view_tpl = $view_handler->get_detail_template(); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
$this->template->assign_vars(array( |
|
79
|
|
|
'MODE' => $mode, |
|
80
|
|
|
'S_HIDE_HEADERS' => true, |
|
81
|
|
|
'S_VIEWING' => $view_tpl, |
|
82
|
|
|
)); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* Overwrite template data |
|
87
|
|
|
* |
|
88
|
|
|
* @param string $mode |
|
89
|
|
|
* @param string $u_action |
|
90
|
|
|
* @param string $type |
|
91
|
|
|
* @param int $topic_id |
|
92
|
|
|
* @return string[] |
|
93
|
|
|
*/ |
|
94
|
|
|
protected function get_data_overwrite($mode, $u_action, $type, $topic_id) |
|
95
|
|
|
{ |
|
96
|
|
|
$overwrite = array( |
|
97
|
|
|
'TOPIC_URL' => $u_action . '&do=view&type=' . $type . '&t=' . $topic_id, |
|
98
|
|
|
'U_INFO' => '', |
|
99
|
|
|
); |
|
100
|
|
|
|
|
101
|
|
|
if ($mode === 'mcp') |
|
102
|
|
|
{ |
|
103
|
|
|
$redirect_url = urlencode(str_replace('&', '&', $u_action)); |
|
104
|
|
|
$overwrite['U_DELETE'] = append_sid("{$this->phpbb_root_path}mcp.$this->php_ext", 'quickmod=1&action=delete_topic&t=' . $topic_id . '&redirect=' . $redirect_url); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
return $overwrite; |
|
108
|
|
|
} |
|
109
|
|
|
} |
|
110
|
|
|
|