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