1 | <?php |
||
22 | class preview implements EventSubscriberInterface |
||
23 | { |
||
24 | /** @var auth */ |
||
25 | protected $auth; |
||
26 | |||
27 | /** @var config */ |
||
28 | protected $config; |
||
29 | |||
30 | /** @var driver_interface */ |
||
31 | protected $db; |
||
32 | |||
33 | /** @var user */ |
||
34 | protected $user; |
||
35 | |||
36 | /** |
||
37 | * {@inheritdoc} |
||
38 | */ |
||
39 | public static function getSubscribedEvents() |
||
54 | |||
55 | /** |
||
56 | * Constructor |
||
57 | * |
||
58 | * @param auth $auth |
||
59 | * @param config $config |
||
60 | * @param driver_interface $db |
||
61 | * @param user $user |
||
62 | */ |
||
63 | public function __construct(auth $auth, config $config, driver_interface $db, user $user) |
||
70 | |||
71 | /** |
||
72 | * Add administrative permissions to manage forums |
||
73 | * |
||
74 | * @param \phpbb\event\data $event The event object |
||
75 | * @return void |
||
76 | */ |
||
77 | public function add_permission($event) |
||
84 | |||
85 | /** |
||
86 | * Add post text containing images to topic row data. |
||
87 | * |
||
88 | * @param \phpbb\event\data $event The event object |
||
89 | * |
||
90 | * @return void |
||
91 | */ |
||
92 | public function update_row_data($event) |
||
107 | |||
108 | /** |
||
109 | * Add image previews to the template data. |
||
110 | * |
||
111 | * @param \phpbb\event\data $event The event object |
||
112 | * |
||
113 | * @return void |
||
114 | */ |
||
115 | public function update_tpl_data($event) |
||
126 | |||
127 | /** |
||
128 | * Run an SQL query on a group of topics, and find the newest (or oldest) |
||
129 | * post with [IMG] images. Then update the topic's row set array to include |
||
130 | * the post's text in the cases where images were found. |
||
131 | * |
||
132 | * @param array $topic_list An array of topic ids |
||
133 | * @param array $rowset The row set of topic data |
||
134 | * |
||
135 | * @return array The updated row set of topic data which now includes |
||
136 | * the post_text of a post containing images. |
||
137 | */ |
||
138 | protected function query_images(array $topic_list, array $rowset) |
||
178 | |||
179 | /** |
||
180 | * Extract images from a post and return them as HTML image tags. |
||
181 | * |
||
182 | * @param string $post Post text from the database. |
||
183 | * |
||
184 | * @return string An string of HTML IMG tags. |
||
185 | */ |
||
186 | protected function extract_images($post) |
||
203 | |||
204 | /** |
||
205 | * Is the forum allowed to show topic image previews |
||
206 | * |
||
207 | * @param int $forum_id Forum identifier |
||
208 | * @return bool True if allowed, false if not |
||
209 | */ |
||
210 | protected function forum_allowed($forum_id) |
||
214 | |||
215 | /** |
||
216 | * Does the user allow topic image previews? |
||
217 | * |
||
218 | * @return bool True if allowed, false if not |
||
219 | */ |
||
220 | protected function user_allowed() |
||
224 | |||
225 | /** |
||
226 | * Check if we have post with images |
||
227 | * |
||
228 | * @param \phpbb\event\data $event The event object |
||
229 | * @return bool True if images found in post text, false if not |
||
230 | */ |
||
231 | protected function has_images($event) |
||
235 | } |
||
236 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.