Completed
Push — develop ( f82636...1d611b )
by Daniel
17:02 queued 11:17
created

forum::handle()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 28
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 2

Importance

Changes 5
Bugs 3 Features 0
Metric Value
c 5
b 3
f 0
dl 0
loc 28
ccs 10
cts 10
cp 1
rs 8.8571
cc 2
eloc 11
nc 2
nop 0
crap 2
1
<?php
2
/**
3
 *
4
 * @package sitemaker
5
 * @copyright (c) 2013 Daniel A. (blitze)
6
 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
7
 *
8
 */
9
10
namespace blitze\sitemaker\controller;
11
12
class forum
13
{
14
	/** @var \phpbb\config\config */
15
	protected $config;
16
17
	/** @var \phpbb\controller\helper */
18
	protected $helper;
19
20
	/** @var \phpbb\template\template */
21
	protected $template;
22
23
	/** @var \phpbb\language\language */
24
	protected $translator;
25
26
	/** @var string phpBB root path */
27
	protected $phpbb_root_path;
28
29
	/** @var string phpEx */
30
	protected $php_ext;
31
32
	/**
33
	 * Constructor
34
	 *
35
	 * @param \phpbb\config\config			$config			Config object
36
	 * @param \phpbb\controller\helper		$helper			Controller Helper object
37
	 * @param \phpbb\template\template		$template		Template object
38
	 * @param \phpbb\language\language		$translator		Language object
39
	 * @param string						$root_path		phpBB root path
40
	 * @param string						$php_ext		phpEx
41
	 */
42 1
	public function __construct(\phpbb\config\config $config, \phpbb\controller\helper $helper, \phpbb\template\template $template, \phpbb\language\language $translator, $root_path, $php_ext)
43
	{
44 1
		$this->config = $config;
45 1
		$this->helper = $helper;
46 1
		$this->template = $template;
47 1
		$this->translator = $translator;
48 1
		$this->phpbb_root_path = $root_path;
49 1
		$this->php_ext = $php_ext;
50 1
	}
51
52
	/**
53
	 * @return \Symfony\Component\HttpFoundation\Response
54
	 */
55 1
	public function handle()
56
	{
57
		/**
58
		 * This is ugly but the only way I could find
59
		 * to fix relative paths for forum images
60
		 */
61 1
		global $phpbb_root_path;
62 1
		$phpbb_root_path = generate_board_url() . '/';
63
64
		// @codeCoverageIgnoreStart
65
		if (!function_exists('display_forums'))
66
		{
67
			include($this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext);
68
		}
69
		// @codeCoverageIgnoreEnd
70
71 1
		display_forums('', $this->config['load_moderators']);
72
73
		// restore phpbb_root_path
74 1
		$phpbb_root_path = $this->phpbb_root_path;
75
76 1
		$this->template->assign_block_vars('navlinks', array(
77 1
			'FORUM_NAME'	=> $this->translator->lang('FORUM'),
78 1
			'U_VIEW_FORUM'	=> $this->helper->route('blitze_sitemaker_forum')
79 1
		));
80
81 1
		return $this->helper->render('index_body.html', $this->translator->lang('FORUM_INDEX'));
82
	}
83
}
84