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\sitemaker\blocks; |
11
|
|
|
|
12
|
|
|
use blitze\sitemaker\services\blocks\driver\block; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Forum Topics Block config |
16
|
|
|
*/ |
17
|
|
|
abstract class forum_topics_config extends block |
18
|
|
|
{ |
19
|
|
|
/** @var \blitze\sitemaker\services\forum\options */ |
20
|
|
|
protected $forum_options; |
21
|
|
|
|
22
|
|
|
const FORUMS_ORDER_FIRST_POST = 0; |
23
|
|
|
const FORUMS_ORDER_LAST_POST = 1; |
24
|
|
|
const FORUMS_ORDER_LAST_READ = 2; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Constructor |
28
|
|
|
* |
29
|
|
|
* @param \blitze\sitemaker\services\forum\options $forum_options Forum Data object |
30
|
|
|
*/ |
31
|
7 |
|
public function __construct(\blitze\sitemaker\services\forum\options $forum_options) |
32
|
|
|
{ |
33
|
7 |
|
$this->forum_options = $forum_options; |
34
|
7 |
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param array $settings |
38
|
|
|
* @return array |
39
|
|
|
*/ |
40
|
1 |
|
public function get_config(array $settings) |
41
|
|
|
{ |
42
|
1 |
|
$forum_options = $this->forum_options->get_all(); |
43
|
1 |
|
$topic_type_options = $this->forum_options->get_topic_types(); |
44
|
1 |
|
$preview_options = $this->get_preview_options(); |
45
|
1 |
|
$range_options = $this->get_range_options(); |
46
|
1 |
|
$sort_options = $this->get_sorting_options(); |
47
|
1 |
|
$template_options = $this->get_view_options(); |
48
|
|
|
|
49
|
|
|
return array( |
50
|
1 |
|
'legend1' => 'SETTINGS', |
51
|
1 |
|
'forum_ids' => array('lang' => 'SELECT_FORUMS', 'validate' => 'string', 'type' => 'multi_select', 'options' => $forum_options, 'default' => array(), 'explain' => false), |
52
|
1 |
|
'topic_type' => array('lang' => 'TOPIC_TYPE', 'validate' => 'string', 'type' => 'checkbox', 'options' => $topic_type_options, 'default' => array(), 'explain' => false), |
53
|
1 |
|
'max_topics' => array('lang' => 'MAX_TOPICS', 'validate' => 'int:0:20', 'type' => 'number:0:20', 'maxlength' => 2, 'explain' => false, 'default' => 5), |
54
|
1 |
|
'date_range' => array('lang' => 'LIMIT_POST_TIME', 'validate' => 'string', 'type' => 'select', 'options' => $range_options, 'default' => '', 'explain' => false), |
55
|
1 |
|
'order_by' => array('lang' => 'ORDER_BY', 'validate' => 'string', 'type' => 'select', 'options' => $sort_options, 'default' => self::FORUMS_ORDER_LAST_POST, 'explain' => false), |
56
|
|
|
|
57
|
1 |
|
'legend2' => 'DISPLAY', |
58
|
1 |
|
'enable_tracking' => array('lang' => 'ENABLE_TOPIC_TRACKING', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false, 'default' => false), |
59
|
1 |
|
'topic_title_limit' => array('lang' => 'TOPIC_TITLE_LIMIT', 'validate' => 'int:0:255', 'type' => 'number:0:255', 'maxlength' => 3, 'explain' => false, 'default' => 25), |
60
|
1 |
|
'template' => array('lang' => 'TEMPLATE', 'validate' => 'string', 'type' => 'select', 'options' => $template_options, 'default' => 'titles', 'explain' => false), |
61
|
1 |
|
'context' => array('lang' => 'BASED_ON', 'validate' => 'string', 'type' => 'select', 'options' => $preview_options, 'default' => 'last', 'explain' => false), |
62
|
1 |
|
'preview_chars' => array('lang' => 'PREVIEW_MAX_CHARS', 'validate' => 'int:0:255', 'type' => 'number:0:255', 'maxlength' => 3, 'explain' => false, 'default' => 0), |
63
|
1 |
|
); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @return array |
68
|
|
|
*/ |
69
|
1 |
|
private function get_preview_options() |
70
|
|
|
{ |
71
|
|
|
return array( |
72
|
1 |
|
'last' => 'SHOW_LAST_POST', |
73
|
1 |
|
'first' => 'SHOW_FIRST_POST', |
74
|
1 |
|
); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return array |
79
|
|
|
*/ |
80
|
1 |
|
private function get_range_options() |
81
|
|
|
{ |
82
|
|
|
return array( |
83
|
1 |
|
'' => 'ALL_TIME', |
84
|
1 |
|
'today' => 'TODAY', |
85
|
1 |
|
'week' => 'THIS_WEEK', |
86
|
1 |
|
'month' => 'THIS_MONTH', |
87
|
1 |
|
'year' => 'THIS_YEAR', |
88
|
1 |
|
); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @return array |
93
|
|
|
*/ |
94
|
1 |
|
private function get_sorting_options() |
95
|
|
|
{ |
96
|
|
|
return array( |
97
|
1 |
|
self::FORUMS_ORDER_FIRST_POST => 'FIRST_POST_TIME', |
98
|
1 |
|
self::FORUMS_ORDER_LAST_POST => 'LAST_POST_TIME', |
99
|
1 |
|
self::FORUMS_ORDER_LAST_READ => 'LAST_READ_TIME', |
100
|
1 |
|
); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @return array |
105
|
|
|
*/ |
106
|
1 |
|
private function get_view_options() |
107
|
|
|
{ |
108
|
|
|
return array( |
109
|
1 |
|
'titles' => 'TITLES', |
110
|
1 |
|
'mini' => 'MINI', |
111
|
1 |
|
'context' => 'CONTEXT', |
112
|
1 |
|
); |
113
|
|
|
} |
114
|
|
|
} |
115
|
|
|
|