Completed
Push — develop ( 613db1...73b4e9 )
by Daniel
05:02
created

author_info   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 73
ccs 0
cts 32
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A get_name() 0 4 1
A get_langname() 0 4 1
A show_block() 0 19 1
1
<?php
2
/**
3
 *
4
 * @package sitemaker
5
 * @copyright (c) 2018 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\topic\driver;
11
12
class author_info implements block_interface
13
{
14
	/** @var\phpbb\language\language */
15
	protected $language;
16
17
	/** @var \phpbb\template\template */
18
	protected $template;
19
20
	/** @var \blitze\sitemaker\services\forum\data */
21
	protected $forum;
22
23
	/* @var \blitze\content\services\helper */
24
	protected $helper;
25
26
	/**
27
	 * Constructor
28
	 *
29
	 * @param \phpbb\language\language					$language			Language Object
30
	 * @param \phpbb\template\template					$template			Template object
31
	 * @param \blitze\sitemaker\services\forum\data		$forum				Forum Data object
32
	 * @param \blitze\content\services\helper			$helper				Content helper object
33
	*/
34
	public function __construct(\phpbb\language\language $language, \phpbb\template\template $template, \blitze\sitemaker\services\forum\data $forum, \blitze\content\services\helper $helper)
35
	{
36
		$this->language = $language;
37
		$this->template = $template;
38
		$this->forum = $forum;
39
		$this->helper = $helper;
40
	}
41
42
	/**
43
	 * @inheritdoc
44
	 */
45
	public function get_name()
46
	{
47
		return 'author_info';
48
	}
49
50
	/**
51
	 * @inheritdoc
52
	 */
53
	public function get_langname()
54
	{
55
		return 'AUTHOR_INFO';
56
	}
57
58
	/**
59
	 * @param \blitze\content\model\entity\type $entity
60
	 * @param array $topic_data
61
	 * @param array $post_data
62
	 * @param array $user_cache
63
	 * @return void
64
	 */
65
	public function show_block(\blitze\content\model\entity\type $entity, array $topic_data, array $post_data, array $user_cache)
66
	{
67
		$forum_id = $topic_data['forum_id'];
68
		$content_langname = $entity->get_content_langname();
69
70
		$this->forum->query()
71
			->fetch_forum($forum_id)
72
			->fetch_topic_poster($topic_data['topic_poster'])
73
			->build(true, true, false);
74
		$user_content_topics = $this->forum->get_topics_count();
75
76
		$this->template->assign_vars(array_merge($user_cache, array(
77
			'S_USER_INFO'			=> true,
78
			'L_USER_ABOUT'			=> $this->language->lang('AUTHOR_INFO_EXPLAIN', $user_cache['username_full'], $user_cache['joined'], $user_content_topics, $content_langname, $user_cache['posts']),
79
			'L_USER_VIEW_ALL'		=> $this->language->lang('VIEW_AUTHOR_CONTENTS', $content_langname, $user_cache['username']),
80
			'L_SEARCH_USER_POSTS'	=> $this->language->lang('SEARCH_USER_POSTS', $user_cache['username']),
81
			'U_SEARCH_CONTENTS'		=> $this->helper->get_search_users_posts_url($forum_id, $user_cache['username']),
82
		)));
83
	}
84
}
85