Completed
Push — develop ( 7e2f59...0adf6c )
by Daniel
05:27
created

view   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 96
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 4
dl 0
loc 96
ccs 0
cts 35
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
B execute() 0 27 2
A get_data_overwrite() 0 15 2
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)) !== false)
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);
0 ignored issues
show
Unused Code introduced by
The call to views_interface::render_detail() has too many arguments starting with $overwrite.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
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 . '&amp;do=view&amp;type=' . $type . '&amp;t=' . $topic_id,
98
			'U_INFO'	=> '',
99
		);
100
101
		if ($mode === 'mcp')
102
		{
103
			$redirect_url = urlencode(str_replace('&amp;', '&', $u_action));
104
			$overwrite['U_DELETE'] = append_sid("{$this->phpbb_root_path}mcp.$this->php_ext", 'quickmod=1&amp;action=delete_topic&amp;t=' . $topic_id . '&amp;redirect=' . $redirect_url);
105
		}
106
107
		return $overwrite;
108
	}
109
}
110