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->get_topic_type_options(); |
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' => 'CONTEXT', '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_topic_type_options() |
70
|
|
|
{ |
71
|
|
|
return array( |
72
|
1 |
|
POST_NORMAL => 'POST_NORMAL', |
73
|
1 |
|
POST_STICKY => 'POST_STICKY', |
74
|
1 |
|
POST_ANNOUNCE => 'POST_ANNOUNCEMENT', |
75
|
1 |
|
POST_GLOBAL => 'POST_GLOBAL', |
76
|
1 |
|
); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @return array |
81
|
|
|
*/ |
82
|
1 |
|
private function get_preview_options() |
83
|
|
|
{ |
84
|
|
|
return array( |
85
|
1 |
|
'last' => 'SHOW_LAST_POST', |
86
|
1 |
|
'first' => 'SHOW_FIRST_POST', |
87
|
1 |
|
); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @return array |
92
|
|
|
*/ |
93
|
1 |
|
private function get_range_options() |
94
|
|
|
{ |
95
|
|
|
return array( |
96
|
1 |
|
'' => 'ALL_TIME', |
97
|
1 |
|
'today' => 'TODAY', |
98
|
1 |
|
'week' => 'THIS_WEEK', |
99
|
1 |
|
'month' => 'THIS_MONTH', |
100
|
1 |
|
'year' => 'THIS_YEAR', |
101
|
1 |
|
); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @return array |
106
|
|
|
*/ |
107
|
1 |
|
private function get_sorting_options() |
108
|
|
|
{ |
109
|
|
|
return array( |
110
|
1 |
|
self::FORUMS_ORDER_FIRST_POST => 'FIRST_POST_TIME', |
111
|
1 |
|
self::FORUMS_ORDER_LAST_POST => 'LAST_POST_TIME', |
112
|
1 |
|
self::FORUMS_ORDER_LAST_READ => 'LAST_READ_TIME', |
113
|
1 |
|
); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @return array |
118
|
|
|
*/ |
119
|
1 |
|
private function get_view_options() |
120
|
|
|
{ |
121
|
|
|
return array( |
122
|
1 |
|
'titles' => 'TITLES', |
123
|
1 |
|
'mini' => 'MINI', |
124
|
1 |
|
'context' => 'CONTEXT', |
125
|
1 |
|
); |
126
|
|
|
} |
127
|
|
|
} |
128
|
|
|
|