Completed
Push — master ( db7709...24ebcc )
by Daniel
10:24
created

members::get_config()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.6667
cc 1
eloc 6
nc 1
nop 1
crap 1
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\blocks;
11
12
/**
13
 * Login Block
14
 */
15
class members extends \blitze\sitemaker\services\blocks\driver\block
16
{
17
	/** @var \phpbb\user */
18
	private $user;
19
20
	/** @var \blitze\sitemaker\services\members */
21
	private $members;
22
23
	/** @var array */
24
	private $query_type_options;
25
26
	/** @var array */
27
	private $range_options;
28
29
	/**
30
	 * Constructor
31
	 *
32
	 * @param \phpbb\user							$user		User object
33
	 * @param \blitze\sitemaker\services\members	$members	Members object
34
	 */
35 6
	public function __construct(\phpbb\user $user, \blitze\sitemaker\services\members $members)
36
	{
37 6
		$this->user = $user;
38 6
		$this->members = $members;
39
40 6
		$this->query_type_options = array(
41 6
			'visits'	=> 'LAST_VISITED',
42 6
			'bots'		=> 'RECENT_BOTS',
43 6
			'recent'	=> 'RECENT_MEMBERS',
44 6
			'tenured'	=> 'MOST_TENURED',
45 6
			'posts'		=> 'TOP_POSTERS',
46
		);
47
48 6
		$this->range_options = array(
49 6
			''		=> 'ALL_TIME',
50 6
			'today'	=> 'TODAY',
51 6
			'week'	=> 'THIS_WEEK',
52 6
			'month'	=> 'THIS_MONTH',
53 6
			'year'	=> 'THIS_YEAR',
54
		);
55
56 6
	}
57
58
	/**
59
	 * {@inheritdoc}
60
	 */
61 1
	public function get_config(array $settings)
62
	{
63
		return array(
64 1
			'legend1'		=> $this->user->lang('SETTINGS'),
65 1
			'query_type'	=> array('lang' => 'QUERY_TYPE', 'validate' => 'string', 'type' => 'select', 'options' => $this->query_type_options, 'default' => 'recent', 'explain' => false),
66 1
			'date_range'	=> array('lang' => 'DATE_RANGE', 'validate' => 'string', 'type' => 'select', 'options' => $this->range_options, 'default' => '', 'explain' => false),
67 1
			'max_members'	=> array('lang' => 'MAX_MEMBERS', 'validate' => 'int:0:20', 'type' => 'number:0:20', 'maxlength' => 2, 'explain' => false, 'default' => 5),
68 1
		);
69
	}
70
71
	/**
72
	 * {@inheritdoc}
73
	 */
74 5
	public function display(array $bdata, $edit_mode = false)
75
	{
76 5
		$bdata['settings']['range'] = ($bdata['settings']['query_type'] != 'tenured') ? $bdata['settings']['date_range'] : '';
77
78 5
		$this->ptemplate->assign_var('RANGE', $this->user->lang($this->range_options[$bdata['settings']['range']]));
79
80
		return array(
81 5
			'title'		=> $this->query_type_options[$bdata['settings']['query_type']],
82 5
			'content'	=> $this->members->get_list($bdata['settings']),
83 5
		);
84
	}
85
}
86