|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* |
|
4
|
|
|
* Topic Image Preview. An extension for the phpBB Forum Software package. |
|
5
|
|
|
* |
|
6
|
|
|
* @copyright (c) 2017, 2020, Matt Friedman |
|
7
|
|
|
* @license GNU General Public License, version 2 (GPL-2.0) |
|
8
|
|
|
* |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace vse\topicimagepreview\event; |
|
12
|
|
|
|
|
13
|
|
|
use phpbb\config\config; |
|
14
|
|
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
|
15
|
|
|
use vse\topicimagepreview\factory; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Topic Image Preview Event listener. |
|
19
|
|
|
*/ |
|
20
|
|
|
class preview implements EventSubscriberInterface |
|
21
|
|
|
{ |
|
22
|
|
|
/** @var config */ |
|
23
|
|
|
protected $config; |
|
24
|
|
|
|
|
25
|
|
|
/** @var factory */ |
|
26
|
|
|
private $factory; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* {@inheritdoc} |
|
30
|
|
|
*/ |
|
31
|
|
|
public static function getSubscribedEvents() |
|
32
|
|
|
{ |
|
33
|
|
|
return [ |
|
34
|
|
|
// Viewforum events |
|
35
|
|
|
'core.viewforum_modify_topics_data' => 'viewforum_row', |
|
36
|
|
|
'core.viewforum_modify_topicrow' => 'viewforum_tpl', |
|
37
|
|
|
// Search events |
|
38
|
|
|
'core.search_modify_rowset' => 'searchresults_row', |
|
39
|
|
|
'core.search_modify_tpl_ary' => 'searchresults_tpl', |
|
40
|
|
|
// Precise Similar Topics events |
|
41
|
|
|
'vse.similartopics.modify_rowset' => 'similartopics_row', |
|
42
|
|
|
'vse.similartopics.modify_topicrow' => 'similartopics_tpl', |
|
43
|
|
|
]; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Constructor |
|
48
|
|
|
* |
|
49
|
|
|
* @param config $config |
|
50
|
|
|
* @param factory $factory |
|
51
|
|
|
*/ |
|
52
|
|
|
public function __construct(config $config, factory $factory) |
|
53
|
|
|
{ |
|
54
|
|
|
$this->config = $config; |
|
55
|
|
|
$this->factory = $factory; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Update viewforum row |
|
60
|
|
|
* |
|
61
|
|
|
* @param \phpbb\event\data $event The event object |
|
62
|
|
|
*/ |
|
63
|
|
|
public function viewforum_row($event) |
|
64
|
|
|
{ |
|
65
|
|
|
$this->factory->update_row_data($event); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Update viewforum template |
|
70
|
|
|
* |
|
71
|
|
|
* @param \phpbb\event\data $event The event object |
|
72
|
|
|
*/ |
|
73
|
|
|
public function viewforum_tpl($event) |
|
74
|
|
|
{ |
|
75
|
|
|
$this->factory->update_tpl_data($event); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Update search results topics row |
|
80
|
|
|
* |
|
81
|
|
|
* @param \phpbb\event\data $event The event object |
|
82
|
|
|
*/ |
|
83
|
|
|
public function searchresults_row($event) |
|
84
|
|
|
{ |
|
85
|
|
|
if ($event['show_results'] === 'topics' && $this->config->offsetGet('vse_tip_srt')) |
|
86
|
|
|
{ |
|
87
|
|
|
$this->factory->update_row_data($event); |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Update search results topics template |
|
93
|
|
|
* |
|
94
|
|
|
* @param \phpbb\event\data $event The event object |
|
95
|
|
|
*/ |
|
96
|
|
|
public function searchresults_tpl($event) |
|
97
|
|
|
{ |
|
98
|
|
|
if ($event['show_results'] === 'topics' && $this->config->offsetGet('vse_tip_srt')) |
|
99
|
|
|
{ |
|
100
|
|
|
$this->factory->update_tpl_data($event); |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* Update similar topics row |
|
106
|
|
|
* |
|
107
|
|
|
* @param \phpbb\event\data $event The event object |
|
108
|
|
|
*/ |
|
109
|
|
|
public function similartopics_row($event) |
|
110
|
|
|
{ |
|
111
|
|
|
if ($this->config->offsetGet('vse_tip_pst')) |
|
112
|
|
|
{ |
|
113
|
|
|
$this->factory->update_row_data($event); |
|
114
|
|
|
} |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* Update similar topics template |
|
119
|
|
|
* |
|
120
|
|
|
* @param \phpbb\event\data $event The event object |
|
121
|
|
|
*/ |
|
122
|
|
|
public function similartopics_tpl($event) |
|
123
|
|
|
{ |
|
124
|
|
|
if ($this->config->offsetGet('vse_tip_pst')) |
|
125
|
|
|
{ |
|
126
|
|
|
$this->factory->update_tpl_data($event); |
|
127
|
|
|
} |
|
128
|
|
|
} |
|
129
|
|
|
} |
|
130
|
|
|
|