@@ -16,380 +16,380 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class listener implements EventSubscriberInterface |
| 18 | 18 | { |
| 19 | - /** @var \tas2580\seourls\event\base */ |
|
| 20 | - protected $base; |
|
| 21 | - |
|
| 22 | - /** @var \phpbb\template\template */ |
|
| 23 | - protected $template; |
|
| 24 | - |
|
| 25 | - /** @var \phpbb\request\request */ |
|
| 26 | - protected $request; |
|
| 27 | - |
|
| 28 | - /** @var \phpbb\path_helper */ |
|
| 29 | - protected $path_helper; |
|
| 30 | - |
|
| 31 | - /** @var string phpbb_root_path */ |
|
| 32 | - protected $phpbb_root_path; |
|
| 33 | - |
|
| 34 | - /** @var string php_ext */ |
|
| 35 | - protected $php_ext; |
|
| 36 | - |
|
| 37 | - private $in_viewforum; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * Constructor |
|
| 41 | - * |
|
| 42 | - * @param \tas2580\seourls\event\base $base |
|
| 43 | - * @param \phpbb\template\template $template Template object |
|
| 44 | - * @param \phpbb\request\request $request Request object |
|
| 45 | - * @param \phpbb\path_helper $path_helper Controller helper object |
|
| 46 | - * @param string $phpbb_root_path phpbb_root_path |
|
| 47 | - * @param string $php_ext php_ext |
|
| 48 | - * @access public |
|
| 49 | - */ |
|
| 50 | - public function __construct(\tas2580\seourls\event\base $base, \phpbb\template\template $template, \phpbb\request\request $request, \phpbb\path_helper $path_helper, $phpbb_root_path, $php_ext) |
|
| 51 | - { |
|
| 52 | - $this->base = $base; |
|
| 53 | - $this->template = $template; |
|
| 54 | - $this->request = $request; |
|
| 55 | - $this->path_helper = $path_helper; |
|
| 56 | - $this->phpbb_root_path = $phpbb_root_path; |
|
| 57 | - $this->php_ext = $php_ext; |
|
| 58 | - |
|
| 59 | - $this->in_viewtopic = false; |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * Assign functions defined in this class to event listeners in the core |
|
| 64 | - * |
|
| 65 | - * @return array |
|
| 66 | - * @static |
|
| 67 | - * @access public |
|
| 68 | - */ |
|
| 69 | - public static function getSubscribedEvents() |
|
| 70 | - { |
|
| 71 | - return array( |
|
| 72 | - 'core.append_sid' => 'append_sid', |
|
| 73 | - 'core.display_forums_modify_sql' => 'display_forums_modify_sql', |
|
| 74 | - 'core.display_forums_modify_template_vars' => 'display_forums_modify_template_vars', |
|
| 75 | - 'core.display_forums_modify_forum_rows' => 'display_forums_modify_forum_rows', |
|
| 76 | - 'core.display_forums_modify_category_template_vars' => 'display_forums_modify_category_template_vars', |
|
| 77 | - 'core.generate_forum_nav' => 'generate_forum_nav', |
|
| 78 | - 'core.make_jumpbox_modify_tpl_ary' => 'make_jumpbox_modify_tpl_ary', // Not in phpBB |
|
| 79 | - 'core.pagination_generate_page_link' => 'pagination_generate_page_link', |
|
| 80 | - 'core.search_modify_tpl_ary' => 'search_modify_tpl_ary', |
|
| 81 | - 'core.viewforum_modify_topicrow' => 'viewforum_modify_topicrow', |
|
| 82 | - 'core.viewforum_get_topic_data' => 'viewforum_get_topic_data', |
|
| 83 | - 'core.viewtopic_assign_template_vars_before' => 'viewtopic_assign_template_vars_before', |
|
| 84 | - 'core.viewtopic_before_f_read_check' => 'viewtopic_before_f_read_check', |
|
| 85 | - 'core.viewtopic_modify_page_title' => 'viewtopic_modify_page_title', |
|
| 86 | - 'core.viewtopic_modify_post_row' => 'viewtopic_modify_post_row', |
|
| 87 | - 'core.viewtopic_get_post_data' => 'viewtopic_get_post_data', |
|
| 88 | - ); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * Correct the path of $viewtopic_url |
|
| 93 | - * |
|
| 94 | - * @param object $event The event object |
|
| 95 | - * @return null |
|
| 96 | - * @access public |
|
| 97 | - */ |
|
| 98 | - public function append_sid($event) |
|
| 99 | - { |
|
| 100 | - if ($this->in_viewtopic && preg_match('#./../viewtopic.' . $this->php_ext . '#', $event['url'])) |
|
| 101 | - { |
|
| 102 | - $url = '../viewtopic.' . $this->php_ext ; |
|
| 103 | - $event['url'] = $url; |
|
| 104 | - } |
|
| 105 | - if (isset($event['params']['redirect'])) |
|
| 106 | - { |
|
| 107 | - $params = $event['params']; |
|
| 108 | - $params['redirect'] = str_replace('..', '.', $event['params']['redirect']); |
|
| 109 | - $event['params'] = $params; |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * Get informations for the last post from Database |
|
| 115 | - * |
|
| 116 | - * @param object $event The event object |
|
| 117 | - * @return null |
|
| 118 | - * @access public |
|
| 119 | - */ |
|
| 120 | - public function display_forums_modify_sql($event) |
|
| 121 | - { |
|
| 122 | - $sql_array = $event['sql_ary']; |
|
| 123 | - $sql_array['LEFT_JOIN'][] = array( |
|
| 124 | - 'FROM' => array(TOPICS_TABLE => 't'), |
|
| 125 | - 'ON' => "f.forum_last_post_id = t.topic_last_post_id" |
|
| 126 | - ); |
|
| 127 | - $sql_array['SELECT'] .= ', t.topic_title, t.topic_id, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted'; |
|
| 128 | - $event['sql_ary'] = $sql_array; |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * Store informations for the last post in forum_rows array |
|
| 133 | - * |
|
| 134 | - * @param object $event The event object |
|
| 135 | - * @return null |
|
| 136 | - * @access public |
|
| 137 | - */ |
|
| 138 | - public function display_forums_modify_forum_rows($event) |
|
| 139 | - { |
|
| 140 | - $forum_rows = $event['forum_rows']; |
|
| 141 | - if ($event['row']['forum_last_post_time'] == $forum_rows[$event['parent_id']]['forum_last_post_time']) |
|
| 142 | - { |
|
| 143 | - $forum_rows[$event['parent_id']]['forum_name_last_post'] =$event['row']['forum_name']; |
|
| 144 | - $forum_rows[$event['parent_id']]['topic_id_last_post'] =$event['row']['topic_id']; |
|
| 145 | - $forum_rows[$event['parent_id']]['topic_title_last_post'] =$event['row']['topic_title']; |
|
| 146 | - $event['forum_rows'] = $forum_rows; |
|
| 147 | - } |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * Rewrite links to forums and subforums in forum index |
|
| 152 | - * also correct the path of the forum images if we are in a forum |
|
| 153 | - * |
|
| 154 | - * @param object $event The event object |
|
| 155 | - * @return null |
|
| 156 | - * @access public |
|
| 157 | - */ |
|
| 158 | - public function display_forums_modify_template_vars($event) |
|
| 159 | - { |
|
| 160 | - $subforums_row = $event['subforums_row']; |
|
| 161 | - $forum_row = $event['forum_row']; |
|
| 162 | - |
|
| 163 | - // Rewrite URLs of sub forums |
|
| 164 | - foreach ($subforums_row as $i => $subforum) |
|
| 165 | - { |
|
| 166 | - // A little bit a dirty way, but there is no better solution |
|
| 167 | - $query = str_replace('&', '&', parse_url($subforum['U_SUBFORUM'], PHP_URL_QUERY)); |
|
| 168 | - parse_str($query, $id); |
|
| 169 | - $subforums_row[$i]['U_SUBFORUM'] = append_sid($this->base->generate_forum_link($id['f'], $subforum['SUBFORUM_NAME'])); |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - // Update the image source in forums |
|
| 173 | - $img = $this->path_helper->update_web_root_path($forum_row['FORUM_IMAGE_SRC']); |
|
| 174 | - $forum_row['FORUM_IMAGE'] = preg_replace('#img src=\"(.*)\" alt#', 'img src="' . $img . '" alt', $forum_row['FORUM_IMAGE']); |
|
| 175 | - |
|
| 176 | - // Rewrite links to topics, posts and forums |
|
| 177 | - $replies = $this->base->get_count('topic_posts', $event['row'], $event['row']['forum_id']) - 1; |
|
| 178 | - $url = $this->base->generate_topic_link($event['row']['forum_id_last_post'], $event['row']['forum_name_last_post'], $event['row']['topic_id_last_post'], $event['row']['topic_title_last_post']); |
|
| 179 | - $forum_row['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($replies, $url) . '#p' . $event['row']['forum_last_post_id']); |
|
| 180 | - $forum_row['U_VIEWFORUM'] = append_sid($this->base->generate_forum_link($forum_row['FORUM_ID'], $forum_row['FORUM_NAME'])); |
|
| 181 | - $forum_row['U_NEWEST_POST'] = append_sid($this->base->generate_lastpost_link($replies, $url) . '#unread'); |
|
| 182 | - |
|
| 183 | - $event['subforums_row'] = $subforums_row; |
|
| 184 | - $event['forum_row'] = $forum_row; |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - /** |
|
| 188 | - * Rewrite the categorie links |
|
| 189 | - * |
|
| 190 | - * @param object $event The event object |
|
| 191 | - * @return null |
|
| 192 | - * @access public |
|
| 193 | - */ |
|
| 194 | - public function display_forums_modify_category_template_vars($event) |
|
| 195 | - { |
|
| 196 | - $cat_row = $event['cat_row']; |
|
| 197 | - $row = $event['row']; |
|
| 198 | - $cat_row['U_VIEWFORUM'] = append_sid($this->base->generate_forum_link($row['forum_id'], $row['forum_name'])); |
|
| 199 | - $event['cat_row'] = $cat_row; |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - /** |
|
| 203 | - * Rewrite links in breadcrumbs |
|
| 204 | - * |
|
| 205 | - * @param object $event The event object |
|
| 206 | - * @return null |
|
| 207 | - * @access public |
|
| 208 | - */ |
|
| 209 | - public function generate_forum_nav($event) |
|
| 210 | - { |
|
| 211 | - $forum_data = $event['forum_data']; |
|
| 212 | - $navlinks = $event['navlinks']; |
|
| 213 | - $navlinks_parents = $event['navlinks_parents']; |
|
| 214 | - |
|
| 215 | - foreach ($navlinks_parents as $id => $data) |
|
| 216 | - { |
|
| 217 | - $navlinks_parents[$id]['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($data['FORUM_ID'] , $data['FORUM_NAME'])); |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - $navlinks['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($forum_data['forum_id'], $forum_data['forum_name'])); |
|
| 221 | - $event['navlinks'] = $navlinks; |
|
| 222 | - $event['navlinks_parents'] = $navlinks_parents; |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - // Not in phpBB |
|
| 226 | - public function make_jumpbox_modify_tpl_ary($event) |
|
| 227 | - { |
|
| 228 | - $tpl_ary = $event['tpl_ary']; |
|
| 229 | - $row = $event['row']; |
|
| 230 | - foreach ($tpl_ary as $id => $data) |
|
| 231 | - { |
|
| 232 | - $tpl_ary[$id]['LINK'] = append_sid($this->base->generate_forum_link($row['forum_id'], $row['forum_name'])); |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - $event['tpl_ary'] = $tpl_ary; |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - /** |
|
| 239 | - * Rewrite pagination links |
|
| 240 | - * |
|
| 241 | - * @param object $event The event object |
|
| 242 | - * @return null |
|
| 243 | - * @access public |
|
| 244 | - */ |
|
| 245 | - public function pagination_generate_page_link($event) |
|
| 246 | - { |
|
| 247 | - // If we have a sort key we do not rewrite the URL |
|
| 248 | - $query = str_replace('&', '&', parse_url($event['base_url'], PHP_URL_QUERY)); |
|
| 249 | - parse_str($query, $param); |
|
| 250 | - if (isset($param['sd']) || isset($param['sk']) || isset($param['st'])) |
|
| 251 | - { |
|
| 252 | - return; |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - $start = (($event['on_page'] - 1) * $event['per_page']); |
|
| 256 | - if (!empty($this->topic_title)) |
|
| 257 | - { |
|
| 258 | - $event['generate_page_link_override'] = append_sid($this->base->generate_topic_link($this->forum_id, $this->forum_title, $this->topic_id, $this->topic_title, $start)); |
|
| 259 | - } |
|
| 260 | - else if (!empty($this->forum_title)) |
|
| 261 | - { |
|
| 262 | - $event['generate_page_link_override'] = append_sid($this->base->generate_forum_link($this->forum_id, $this->forum_title, $start)); |
|
| 263 | - } |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - /** |
|
| 267 | - * Rewrite links in the search result |
|
| 268 | - * |
|
| 269 | - * @param object $event The event object |
|
| 270 | - * @return null |
|
| 271 | - * @access public |
|
| 272 | - */ |
|
| 273 | - public function search_modify_tpl_ary($event) |
|
| 274 | - { |
|
| 275 | - $replies = $this->base->get_count('topic_posts', $event['row'], $event['row']['forum_id']) - 1; |
|
| 276 | - $u_view_topic = $this->base->generate_topic_link($event['row']['forum_id'], $event['row']['forum_name'], $event['row']['topic_id'], $event['row']['topic_title']); |
|
| 277 | - |
|
| 278 | - $tpl_ary = $event['tpl_ary']; |
|
| 279 | - $tpl_ary['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($replies, $u_view_topic) . '#p' . $event['row']['topic_last_post_id']); |
|
| 280 | - $tpl_ary['U_VIEW_TOPIC'] = append_sid($u_view_topic); |
|
| 281 | - $tpl_ary['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($event['row']['forum_id'], $event['row']['forum_name'])); |
|
| 282 | - $tpl_ary['U_NEWEST_POST'] = append_sid($this->base->generate_lastpost_link($replies, $u_view_topic) . '#unread'); |
|
| 283 | - |
|
| 284 | - $event['tpl_ary'] = $tpl_ary; |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - /** |
|
| 288 | - * Rewrite links to topics in forum view |
|
| 289 | - * |
|
| 290 | - * @param object $event The event object |
|
| 291 | - * @return null |
|
| 292 | - * @access public |
|
| 293 | - */ |
|
| 294 | - public function viewforum_modify_topicrow($event) |
|
| 295 | - { |
|
| 296 | - $topic_row = $event['topic_row']; |
|
| 297 | - $this->forum_title = $topic_row['FORUM_NAME']; |
|
| 298 | - $this->forum_id = $topic_row['FORUM_ID']; |
|
| 299 | - $this->topic_title = $topic_row['TOPIC_TITLE']; |
|
| 300 | - $this->topic_id = $topic_row['TOPIC_ID']; |
|
| 301 | - |
|
| 302 | - $u_view_topic = $this->base->generate_topic_link($this->forum_id, $this->forum_title, $this->topic_id, $this->topic_title); |
|
| 303 | - $topic_row['U_VIEW_TOPIC'] = append_sid($u_view_topic); |
|
| 304 | - $topic_row['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($this->forum_id, $this->forum_title)); |
|
| 305 | - $topic_row['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($event['topic_row']['REPLIES'], $u_view_topic) . '#p' . $event['row']['topic_last_post_id']); |
|
| 306 | - $topic_row['U_NEWEST_POST'] = append_sid($this->base->generate_lastpost_link($event['topic_row']['REPLIES'], $u_view_topic) . '#unread'); |
|
| 307 | - |
|
| 308 | - $event['topic_row'] = $topic_row; |
|
| 309 | - } |
|
| 310 | - |
|
| 311 | - /** |
|
| 312 | - * Rewrite the canonical URL on viewforum.php |
|
| 313 | - * |
|
| 314 | - * @param object $event The event object |
|
| 315 | - * @return null |
|
| 316 | - * @access public |
|
| 317 | - */ |
|
| 318 | - public function viewforum_get_topic_data($event) |
|
| 319 | - { |
|
| 320 | - $start = $this->request->variable('start', 0); |
|
| 321 | - $this->template->assign_vars(array( |
|
| 322 | - 'U_VIEW_FORUM' => append_sid($this->base->generate_forum_link($event['forum_data']['forum_id'], $event['forum_data']['forum_name'], $start)), |
|
| 323 | - 'U_CANONICAL' => $this->base->generate_forum_link($event['forum_data']['forum_id'], $event['forum_data']['forum_name'], $start, true), |
|
| 324 | - )); |
|
| 325 | - } |
|
| 326 | - |
|
| 327 | - /** |
|
| 328 | - * Rewrite the topic URL for the headline of the topic page and the link back to forum |
|
| 329 | - * |
|
| 330 | - * @param object $event The event object |
|
| 331 | - * @return null |
|
| 332 | - * @access public |
|
| 333 | - */ |
|
| 334 | - public function viewtopic_get_post_data($event) |
|
| 335 | - { |
|
| 336 | - $data = $event['topic_data']; |
|
| 337 | - $this->template->assign_vars(array( |
|
| 338 | - 'U_VIEW_TOPIC' => append_sid($this->base->generate_topic_link($event['forum_id'] , $data['forum_name'], $event['topic_id'], $data['topic_title'], $event['start'])), |
|
| 339 | - 'U_VIEW_FORUM' => append_sid($this->base->generate_forum_link($event['forum_id'] , $data['forum_name'])), |
|
| 340 | - 'S_POLL_ACTION' => append_sid($this->base->generate_topic_link($event['forum_id'] , $data['forum_name'], $event['topic_id'], $data['topic_title'], $event['start'])), |
|
| 341 | - )); |
|
| 342 | - } |
|
| 343 | - |
|
| 344 | - /** |
|
| 345 | - * Assign topic data to global variables for pagination |
|
| 346 | - * |
|
| 347 | - * @param object $event The event object |
|
| 348 | - * @return null |
|
| 349 | - * @access public |
|
| 350 | - */ |
|
| 351 | - public function viewtopic_assign_template_vars_before($event) |
|
| 352 | - { |
|
| 353 | - $this->forum_title = $event['topic_data']['forum_name']; |
|
| 354 | - $this->forum_id = $event['topic_data']['forum_id']; |
|
| 355 | - $this->topic_title = $event['topic_data']['topic_title']; |
|
| 356 | - $this->topic_id = $event['topic_data']['topic_id']; |
|
| 357 | - } |
|
| 358 | - |
|
| 359 | - public function viewtopic_before_f_read_check() |
|
| 360 | - { |
|
| 361 | - $this->in_viewtopic = true; |
|
| 362 | - } |
|
| 363 | - |
|
| 364 | - /** |
|
| 365 | - * Rewrite the canonical URL on viewtopic.php |
|
| 366 | - * |
|
| 367 | - * @param object $event The event object |
|
| 368 | - * @return null |
|
| 369 | - * @access public |
|
| 370 | - */ |
|
| 371 | - public function viewtopic_modify_page_title($event) |
|
| 372 | - { |
|
| 373 | - $start = $this->request->variable('start', 0); |
|
| 374 | - $data = $event['topic_data']; |
|
| 375 | - $this->template->assign_vars(array( |
|
| 376 | - 'U_CANONICAL' => $this->base->generate_topic_link($data['forum_id'], $data['forum_name'], $data['topic_id'], $data['topic_title'], $start, true), |
|
| 377 | - )); |
|
| 378 | - } |
|
| 379 | - |
|
| 380 | - /** |
|
| 381 | - * Rewrite mini post img link |
|
| 382 | - * |
|
| 383 | - * @param object $event The event object |
|
| 384 | - * @return null |
|
| 385 | - * @access public |
|
| 386 | - */ |
|
| 387 | - public function viewtopic_modify_post_row($event) |
|
| 388 | - { |
|
| 389 | - $row = $event['post_row']; |
|
| 390 | - $start = $this->request->variable('start', 0); |
|
| 391 | - $data = $event['topic_data']; |
|
| 392 | - $row['U_MINI_POST'] = append_sid($this->base->generate_topic_link($data['forum_id'], $data['forum_name'], $data['topic_id'], $data['topic_title'], $start) . '#p' . $event['row']['post_id']); |
|
| 393 | - $event['post_row'] = $row; |
|
| 394 | - } |
|
| 19 | + /** @var \tas2580\seourls\event\base */ |
|
| 20 | + protected $base; |
|
| 21 | + |
|
| 22 | + /** @var \phpbb\template\template */ |
|
| 23 | + protected $template; |
|
| 24 | + |
|
| 25 | + /** @var \phpbb\request\request */ |
|
| 26 | + protected $request; |
|
| 27 | + |
|
| 28 | + /** @var \phpbb\path_helper */ |
|
| 29 | + protected $path_helper; |
|
| 30 | + |
|
| 31 | + /** @var string phpbb_root_path */ |
|
| 32 | + protected $phpbb_root_path; |
|
| 33 | + |
|
| 34 | + /** @var string php_ext */ |
|
| 35 | + protected $php_ext; |
|
| 36 | + |
|
| 37 | + private $in_viewforum; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * Constructor |
|
| 41 | + * |
|
| 42 | + * @param \tas2580\seourls\event\base $base |
|
| 43 | + * @param \phpbb\template\template $template Template object |
|
| 44 | + * @param \phpbb\request\request $request Request object |
|
| 45 | + * @param \phpbb\path_helper $path_helper Controller helper object |
|
| 46 | + * @param string $phpbb_root_path phpbb_root_path |
|
| 47 | + * @param string $php_ext php_ext |
|
| 48 | + * @access public |
|
| 49 | + */ |
|
| 50 | + public function __construct(\tas2580\seourls\event\base $base, \phpbb\template\template $template, \phpbb\request\request $request, \phpbb\path_helper $path_helper, $phpbb_root_path, $php_ext) |
|
| 51 | + { |
|
| 52 | + $this->base = $base; |
|
| 53 | + $this->template = $template; |
|
| 54 | + $this->request = $request; |
|
| 55 | + $this->path_helper = $path_helper; |
|
| 56 | + $this->phpbb_root_path = $phpbb_root_path; |
|
| 57 | + $this->php_ext = $php_ext; |
|
| 58 | + |
|
| 59 | + $this->in_viewtopic = false; |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * Assign functions defined in this class to event listeners in the core |
|
| 64 | + * |
|
| 65 | + * @return array |
|
| 66 | + * @static |
|
| 67 | + * @access public |
|
| 68 | + */ |
|
| 69 | + public static function getSubscribedEvents() |
|
| 70 | + { |
|
| 71 | + return array( |
|
| 72 | + 'core.append_sid' => 'append_sid', |
|
| 73 | + 'core.display_forums_modify_sql' => 'display_forums_modify_sql', |
|
| 74 | + 'core.display_forums_modify_template_vars' => 'display_forums_modify_template_vars', |
|
| 75 | + 'core.display_forums_modify_forum_rows' => 'display_forums_modify_forum_rows', |
|
| 76 | + 'core.display_forums_modify_category_template_vars' => 'display_forums_modify_category_template_vars', |
|
| 77 | + 'core.generate_forum_nav' => 'generate_forum_nav', |
|
| 78 | + 'core.make_jumpbox_modify_tpl_ary' => 'make_jumpbox_modify_tpl_ary', // Not in phpBB |
|
| 79 | + 'core.pagination_generate_page_link' => 'pagination_generate_page_link', |
|
| 80 | + 'core.search_modify_tpl_ary' => 'search_modify_tpl_ary', |
|
| 81 | + 'core.viewforum_modify_topicrow' => 'viewforum_modify_topicrow', |
|
| 82 | + 'core.viewforum_get_topic_data' => 'viewforum_get_topic_data', |
|
| 83 | + 'core.viewtopic_assign_template_vars_before' => 'viewtopic_assign_template_vars_before', |
|
| 84 | + 'core.viewtopic_before_f_read_check' => 'viewtopic_before_f_read_check', |
|
| 85 | + 'core.viewtopic_modify_page_title' => 'viewtopic_modify_page_title', |
|
| 86 | + 'core.viewtopic_modify_post_row' => 'viewtopic_modify_post_row', |
|
| 87 | + 'core.viewtopic_get_post_data' => 'viewtopic_get_post_data', |
|
| 88 | + ); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * Correct the path of $viewtopic_url |
|
| 93 | + * |
|
| 94 | + * @param object $event The event object |
|
| 95 | + * @return null |
|
| 96 | + * @access public |
|
| 97 | + */ |
|
| 98 | + public function append_sid($event) |
|
| 99 | + { |
|
| 100 | + if ($this->in_viewtopic && preg_match('#./../viewtopic.' . $this->php_ext . '#', $event['url'])) |
|
| 101 | + { |
|
| 102 | + $url = '../viewtopic.' . $this->php_ext ; |
|
| 103 | + $event['url'] = $url; |
|
| 104 | + } |
|
| 105 | + if (isset($event['params']['redirect'])) |
|
| 106 | + { |
|
| 107 | + $params = $event['params']; |
|
| 108 | + $params['redirect'] = str_replace('..', '.', $event['params']['redirect']); |
|
| 109 | + $event['params'] = $params; |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * Get informations for the last post from Database |
|
| 115 | + * |
|
| 116 | + * @param object $event The event object |
|
| 117 | + * @return null |
|
| 118 | + * @access public |
|
| 119 | + */ |
|
| 120 | + public function display_forums_modify_sql($event) |
|
| 121 | + { |
|
| 122 | + $sql_array = $event['sql_ary']; |
|
| 123 | + $sql_array['LEFT_JOIN'][] = array( |
|
| 124 | + 'FROM' => array(TOPICS_TABLE => 't'), |
|
| 125 | + 'ON' => "f.forum_last_post_id = t.topic_last_post_id" |
|
| 126 | + ); |
|
| 127 | + $sql_array['SELECT'] .= ', t.topic_title, t.topic_id, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted'; |
|
| 128 | + $event['sql_ary'] = $sql_array; |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * Store informations for the last post in forum_rows array |
|
| 133 | + * |
|
| 134 | + * @param object $event The event object |
|
| 135 | + * @return null |
|
| 136 | + * @access public |
|
| 137 | + */ |
|
| 138 | + public function display_forums_modify_forum_rows($event) |
|
| 139 | + { |
|
| 140 | + $forum_rows = $event['forum_rows']; |
|
| 141 | + if ($event['row']['forum_last_post_time'] == $forum_rows[$event['parent_id']]['forum_last_post_time']) |
|
| 142 | + { |
|
| 143 | + $forum_rows[$event['parent_id']]['forum_name_last_post'] =$event['row']['forum_name']; |
|
| 144 | + $forum_rows[$event['parent_id']]['topic_id_last_post'] =$event['row']['topic_id']; |
|
| 145 | + $forum_rows[$event['parent_id']]['topic_title_last_post'] =$event['row']['topic_title']; |
|
| 146 | + $event['forum_rows'] = $forum_rows; |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * Rewrite links to forums and subforums in forum index |
|
| 152 | + * also correct the path of the forum images if we are in a forum |
|
| 153 | + * |
|
| 154 | + * @param object $event The event object |
|
| 155 | + * @return null |
|
| 156 | + * @access public |
|
| 157 | + */ |
|
| 158 | + public function display_forums_modify_template_vars($event) |
|
| 159 | + { |
|
| 160 | + $subforums_row = $event['subforums_row']; |
|
| 161 | + $forum_row = $event['forum_row']; |
|
| 162 | + |
|
| 163 | + // Rewrite URLs of sub forums |
|
| 164 | + foreach ($subforums_row as $i => $subforum) |
|
| 165 | + { |
|
| 166 | + // A little bit a dirty way, but there is no better solution |
|
| 167 | + $query = str_replace('&', '&', parse_url($subforum['U_SUBFORUM'], PHP_URL_QUERY)); |
|
| 168 | + parse_str($query, $id); |
|
| 169 | + $subforums_row[$i]['U_SUBFORUM'] = append_sid($this->base->generate_forum_link($id['f'], $subforum['SUBFORUM_NAME'])); |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + // Update the image source in forums |
|
| 173 | + $img = $this->path_helper->update_web_root_path($forum_row['FORUM_IMAGE_SRC']); |
|
| 174 | + $forum_row['FORUM_IMAGE'] = preg_replace('#img src=\"(.*)\" alt#', 'img src="' . $img . '" alt', $forum_row['FORUM_IMAGE']); |
|
| 175 | + |
|
| 176 | + // Rewrite links to topics, posts and forums |
|
| 177 | + $replies = $this->base->get_count('topic_posts', $event['row'], $event['row']['forum_id']) - 1; |
|
| 178 | + $url = $this->base->generate_topic_link($event['row']['forum_id_last_post'], $event['row']['forum_name_last_post'], $event['row']['topic_id_last_post'], $event['row']['topic_title_last_post']); |
|
| 179 | + $forum_row['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($replies, $url) . '#p' . $event['row']['forum_last_post_id']); |
|
| 180 | + $forum_row['U_VIEWFORUM'] = append_sid($this->base->generate_forum_link($forum_row['FORUM_ID'], $forum_row['FORUM_NAME'])); |
|
| 181 | + $forum_row['U_NEWEST_POST'] = append_sid($this->base->generate_lastpost_link($replies, $url) . '#unread'); |
|
| 182 | + |
|
| 183 | + $event['subforums_row'] = $subforums_row; |
|
| 184 | + $event['forum_row'] = $forum_row; |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + /** |
|
| 188 | + * Rewrite the categorie links |
|
| 189 | + * |
|
| 190 | + * @param object $event The event object |
|
| 191 | + * @return null |
|
| 192 | + * @access public |
|
| 193 | + */ |
|
| 194 | + public function display_forums_modify_category_template_vars($event) |
|
| 195 | + { |
|
| 196 | + $cat_row = $event['cat_row']; |
|
| 197 | + $row = $event['row']; |
|
| 198 | + $cat_row['U_VIEWFORUM'] = append_sid($this->base->generate_forum_link($row['forum_id'], $row['forum_name'])); |
|
| 199 | + $event['cat_row'] = $cat_row; |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + /** |
|
| 203 | + * Rewrite links in breadcrumbs |
|
| 204 | + * |
|
| 205 | + * @param object $event The event object |
|
| 206 | + * @return null |
|
| 207 | + * @access public |
|
| 208 | + */ |
|
| 209 | + public function generate_forum_nav($event) |
|
| 210 | + { |
|
| 211 | + $forum_data = $event['forum_data']; |
|
| 212 | + $navlinks = $event['navlinks']; |
|
| 213 | + $navlinks_parents = $event['navlinks_parents']; |
|
| 214 | + |
|
| 215 | + foreach ($navlinks_parents as $id => $data) |
|
| 216 | + { |
|
| 217 | + $navlinks_parents[$id]['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($data['FORUM_ID'] , $data['FORUM_NAME'])); |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + $navlinks['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($forum_data['forum_id'], $forum_data['forum_name'])); |
|
| 221 | + $event['navlinks'] = $navlinks; |
|
| 222 | + $event['navlinks_parents'] = $navlinks_parents; |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + // Not in phpBB |
|
| 226 | + public function make_jumpbox_modify_tpl_ary($event) |
|
| 227 | + { |
|
| 228 | + $tpl_ary = $event['tpl_ary']; |
|
| 229 | + $row = $event['row']; |
|
| 230 | + foreach ($tpl_ary as $id => $data) |
|
| 231 | + { |
|
| 232 | + $tpl_ary[$id]['LINK'] = append_sid($this->base->generate_forum_link($row['forum_id'], $row['forum_name'])); |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + $event['tpl_ary'] = $tpl_ary; |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + /** |
|
| 239 | + * Rewrite pagination links |
|
| 240 | + * |
|
| 241 | + * @param object $event The event object |
|
| 242 | + * @return null |
|
| 243 | + * @access public |
|
| 244 | + */ |
|
| 245 | + public function pagination_generate_page_link($event) |
|
| 246 | + { |
|
| 247 | + // If we have a sort key we do not rewrite the URL |
|
| 248 | + $query = str_replace('&', '&', parse_url($event['base_url'], PHP_URL_QUERY)); |
|
| 249 | + parse_str($query, $param); |
|
| 250 | + if (isset($param['sd']) || isset($param['sk']) || isset($param['st'])) |
|
| 251 | + { |
|
| 252 | + return; |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + $start = (($event['on_page'] - 1) * $event['per_page']); |
|
| 256 | + if (!empty($this->topic_title)) |
|
| 257 | + { |
|
| 258 | + $event['generate_page_link_override'] = append_sid($this->base->generate_topic_link($this->forum_id, $this->forum_title, $this->topic_id, $this->topic_title, $start)); |
|
| 259 | + } |
|
| 260 | + else if (!empty($this->forum_title)) |
|
| 261 | + { |
|
| 262 | + $event['generate_page_link_override'] = append_sid($this->base->generate_forum_link($this->forum_id, $this->forum_title, $start)); |
|
| 263 | + } |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + /** |
|
| 267 | + * Rewrite links in the search result |
|
| 268 | + * |
|
| 269 | + * @param object $event The event object |
|
| 270 | + * @return null |
|
| 271 | + * @access public |
|
| 272 | + */ |
|
| 273 | + public function search_modify_tpl_ary($event) |
|
| 274 | + { |
|
| 275 | + $replies = $this->base->get_count('topic_posts', $event['row'], $event['row']['forum_id']) - 1; |
|
| 276 | + $u_view_topic = $this->base->generate_topic_link($event['row']['forum_id'], $event['row']['forum_name'], $event['row']['topic_id'], $event['row']['topic_title']); |
|
| 277 | + |
|
| 278 | + $tpl_ary = $event['tpl_ary']; |
|
| 279 | + $tpl_ary['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($replies, $u_view_topic) . '#p' . $event['row']['topic_last_post_id']); |
|
| 280 | + $tpl_ary['U_VIEW_TOPIC'] = append_sid($u_view_topic); |
|
| 281 | + $tpl_ary['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($event['row']['forum_id'], $event['row']['forum_name'])); |
|
| 282 | + $tpl_ary['U_NEWEST_POST'] = append_sid($this->base->generate_lastpost_link($replies, $u_view_topic) . '#unread'); |
|
| 283 | + |
|
| 284 | + $event['tpl_ary'] = $tpl_ary; |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + /** |
|
| 288 | + * Rewrite links to topics in forum view |
|
| 289 | + * |
|
| 290 | + * @param object $event The event object |
|
| 291 | + * @return null |
|
| 292 | + * @access public |
|
| 293 | + */ |
|
| 294 | + public function viewforum_modify_topicrow($event) |
|
| 295 | + { |
|
| 296 | + $topic_row = $event['topic_row']; |
|
| 297 | + $this->forum_title = $topic_row['FORUM_NAME']; |
|
| 298 | + $this->forum_id = $topic_row['FORUM_ID']; |
|
| 299 | + $this->topic_title = $topic_row['TOPIC_TITLE']; |
|
| 300 | + $this->topic_id = $topic_row['TOPIC_ID']; |
|
| 301 | + |
|
| 302 | + $u_view_topic = $this->base->generate_topic_link($this->forum_id, $this->forum_title, $this->topic_id, $this->topic_title); |
|
| 303 | + $topic_row['U_VIEW_TOPIC'] = append_sid($u_view_topic); |
|
| 304 | + $topic_row['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($this->forum_id, $this->forum_title)); |
|
| 305 | + $topic_row['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($event['topic_row']['REPLIES'], $u_view_topic) . '#p' . $event['row']['topic_last_post_id']); |
|
| 306 | + $topic_row['U_NEWEST_POST'] = append_sid($this->base->generate_lastpost_link($event['topic_row']['REPLIES'], $u_view_topic) . '#unread'); |
|
| 307 | + |
|
| 308 | + $event['topic_row'] = $topic_row; |
|
| 309 | + } |
|
| 310 | + |
|
| 311 | + /** |
|
| 312 | + * Rewrite the canonical URL on viewforum.php |
|
| 313 | + * |
|
| 314 | + * @param object $event The event object |
|
| 315 | + * @return null |
|
| 316 | + * @access public |
|
| 317 | + */ |
|
| 318 | + public function viewforum_get_topic_data($event) |
|
| 319 | + { |
|
| 320 | + $start = $this->request->variable('start', 0); |
|
| 321 | + $this->template->assign_vars(array( |
|
| 322 | + 'U_VIEW_FORUM' => append_sid($this->base->generate_forum_link($event['forum_data']['forum_id'], $event['forum_data']['forum_name'], $start)), |
|
| 323 | + 'U_CANONICAL' => $this->base->generate_forum_link($event['forum_data']['forum_id'], $event['forum_data']['forum_name'], $start, true), |
|
| 324 | + )); |
|
| 325 | + } |
|
| 326 | + |
|
| 327 | + /** |
|
| 328 | + * Rewrite the topic URL for the headline of the topic page and the link back to forum |
|
| 329 | + * |
|
| 330 | + * @param object $event The event object |
|
| 331 | + * @return null |
|
| 332 | + * @access public |
|
| 333 | + */ |
|
| 334 | + public function viewtopic_get_post_data($event) |
|
| 335 | + { |
|
| 336 | + $data = $event['topic_data']; |
|
| 337 | + $this->template->assign_vars(array( |
|
| 338 | + 'U_VIEW_TOPIC' => append_sid($this->base->generate_topic_link($event['forum_id'] , $data['forum_name'], $event['topic_id'], $data['topic_title'], $event['start'])), |
|
| 339 | + 'U_VIEW_FORUM' => append_sid($this->base->generate_forum_link($event['forum_id'] , $data['forum_name'])), |
|
| 340 | + 'S_POLL_ACTION' => append_sid($this->base->generate_topic_link($event['forum_id'] , $data['forum_name'], $event['topic_id'], $data['topic_title'], $event['start'])), |
|
| 341 | + )); |
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + /** |
|
| 345 | + * Assign topic data to global variables for pagination |
|
| 346 | + * |
|
| 347 | + * @param object $event The event object |
|
| 348 | + * @return null |
|
| 349 | + * @access public |
|
| 350 | + */ |
|
| 351 | + public function viewtopic_assign_template_vars_before($event) |
|
| 352 | + { |
|
| 353 | + $this->forum_title = $event['topic_data']['forum_name']; |
|
| 354 | + $this->forum_id = $event['topic_data']['forum_id']; |
|
| 355 | + $this->topic_title = $event['topic_data']['topic_title']; |
|
| 356 | + $this->topic_id = $event['topic_data']['topic_id']; |
|
| 357 | + } |
|
| 358 | + |
|
| 359 | + public function viewtopic_before_f_read_check() |
|
| 360 | + { |
|
| 361 | + $this->in_viewtopic = true; |
|
| 362 | + } |
|
| 363 | + |
|
| 364 | + /** |
|
| 365 | + * Rewrite the canonical URL on viewtopic.php |
|
| 366 | + * |
|
| 367 | + * @param object $event The event object |
|
| 368 | + * @return null |
|
| 369 | + * @access public |
|
| 370 | + */ |
|
| 371 | + public function viewtopic_modify_page_title($event) |
|
| 372 | + { |
|
| 373 | + $start = $this->request->variable('start', 0); |
|
| 374 | + $data = $event['topic_data']; |
|
| 375 | + $this->template->assign_vars(array( |
|
| 376 | + 'U_CANONICAL' => $this->base->generate_topic_link($data['forum_id'], $data['forum_name'], $data['topic_id'], $data['topic_title'], $start, true), |
|
| 377 | + )); |
|
| 378 | + } |
|
| 379 | + |
|
| 380 | + /** |
|
| 381 | + * Rewrite mini post img link |
|
| 382 | + * |
|
| 383 | + * @param object $event The event object |
|
| 384 | + * @return null |
|
| 385 | + * @access public |
|
| 386 | + */ |
|
| 387 | + public function viewtopic_modify_post_row($event) |
|
| 388 | + { |
|
| 389 | + $row = $event['post_row']; |
|
| 390 | + $start = $this->request->variable('start', 0); |
|
| 391 | + $data = $event['topic_data']; |
|
| 392 | + $row['U_MINI_POST'] = append_sid($this->base->generate_topic_link($data['forum_id'], $data['forum_name'], $data['topic_id'], $data['topic_title'], $start) . '#p' . $event['row']['post_id']); |
|
| 393 | + $event['post_row'] = $row; |
|
| 394 | + } |
|
| 395 | 395 | } |
@@ -16,133 +16,133 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class extensions implements EventSubscriberInterface |
| 18 | 18 | { |
| 19 | - /** @var \tas2580\seourls\event\base */ |
|
| 20 | - protected $base; |
|
| 19 | + /** @var \tas2580\seourls\event\base */ |
|
| 20 | + protected $base; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Constructor |
|
| 24 | - * |
|
| 25 | - * @param \tas2580\seourls\event\base $base |
|
| 26 | - * @access public |
|
| 27 | - */ |
|
| 28 | - public function __construct(\tas2580\seourls\event\base $base) |
|
| 29 | - { |
|
| 30 | - $this->base = $base; |
|
| 31 | - } |
|
| 22 | + /** |
|
| 23 | + * Constructor |
|
| 24 | + * |
|
| 25 | + * @param \tas2580\seourls\event\base $base |
|
| 26 | + * @access public |
|
| 27 | + */ |
|
| 28 | + public function __construct(\tas2580\seourls\event\base $base) |
|
| 29 | + { |
|
| 30 | + $this->base = $base; |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Assign functions defined in this class to event listeners in the core |
|
| 35 | - * |
|
| 36 | - * @return array |
|
| 37 | - * @static |
|
| 38 | - * @access public |
|
| 39 | - */ |
|
| 40 | - public static function getSubscribedEvents() |
|
| 41 | - { |
|
| 42 | - return array( |
|
| 43 | - 'rmcgirr83.topfive.sql_pull_topics_data' => 'topfive_sql_pull_topics_data', |
|
| 44 | - 'rmcgirr83.topfive.modify_tpl_ary' => 'topfive_modify_tpl_ary', |
|
| 45 | - 'tas2580.sitemap.modify_before_output' => 'sitemap_modify_before_output', |
|
| 46 | - 'vse.similartopics.modify_topicrow' => 'similartopics_modify_topicrow', |
|
| 47 | - 'paybas.recenttopics.modify_tpl_ary' => 'recenttopics_modify_tpl_ary' |
|
| 48 | - ); |
|
| 49 | - } |
|
| 33 | + /** |
|
| 34 | + * Assign functions defined in this class to event listeners in the core |
|
| 35 | + * |
|
| 36 | + * @return array |
|
| 37 | + * @static |
|
| 38 | + * @access public |
|
| 39 | + */ |
|
| 40 | + public static function getSubscribedEvents() |
|
| 41 | + { |
|
| 42 | + return array( |
|
| 43 | + 'rmcgirr83.topfive.sql_pull_topics_data' => 'topfive_sql_pull_topics_data', |
|
| 44 | + 'rmcgirr83.topfive.modify_tpl_ary' => 'topfive_modify_tpl_ary', |
|
| 45 | + 'tas2580.sitemap.modify_before_output' => 'sitemap_modify_before_output', |
|
| 46 | + 'vse.similartopics.modify_topicrow' => 'similartopics_modify_topicrow', |
|
| 47 | + 'paybas.recenttopics.modify_tpl_ary' => 'recenttopics_modify_tpl_ary' |
|
| 48 | + ); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - public function recenttopics_modify_tpl_ary($event) |
|
| 52 | - { |
|
| 53 | - $tpl_ary = $event['tpl_ary']; |
|
| 54 | - $u_view_topic = $this->base->generate_topic_link($event['row']['forum_id'], $event['row']['forum_name'], $event['row']['topic_id'], $event['row']['topic_title']); |
|
| 55 | - $tpl_ary['U_VIEW_TOPIC'] = append_sid($u_view_topic); |
|
| 56 | - $tpl_ary['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($tpl_ary['REPLIES'], $u_view_topic) . '#p' . $event['row']['topic_last_post_id']); |
|
| 57 | - $tpl_ary['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($event['row']['forum_id'], $event['row']['forum_name'])); |
|
| 58 | - $tpl_ary['U_NEWEST_POST'] = append_sid($this->base->generate_lastpost_link($tpl_ary['REPLIES'], $u_view_topic) . '#unread'); |
|
| 51 | + public function recenttopics_modify_tpl_ary($event) |
|
| 52 | + { |
|
| 53 | + $tpl_ary = $event['tpl_ary']; |
|
| 54 | + $u_view_topic = $this->base->generate_topic_link($event['row']['forum_id'], $event['row']['forum_name'], $event['row']['topic_id'], $event['row']['topic_title']); |
|
| 55 | + $tpl_ary['U_VIEW_TOPIC'] = append_sid($u_view_topic); |
|
| 56 | + $tpl_ary['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($tpl_ary['REPLIES'], $u_view_topic) . '#p' . $event['row']['topic_last_post_id']); |
|
| 57 | + $tpl_ary['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($event['row']['forum_id'], $event['row']['forum_name'])); |
|
| 58 | + $tpl_ary['U_NEWEST_POST'] = append_sid($this->base->generate_lastpost_link($tpl_ary['REPLIES'], $u_view_topic) . '#unread'); |
|
| 59 | 59 | |
| 60 | - $event['tpl_ary'] = $tpl_ary; |
|
| 61 | - } |
|
| 60 | + $event['tpl_ary'] = $tpl_ary; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Rewrite URLs in tas2580 Sitemap Extension |
|
| 65 | - * |
|
| 66 | - * @param object $event The event object |
|
| 67 | - * @return null |
|
| 68 | - * @access public |
|
| 69 | - */ |
|
| 70 | - public function sitemap_modify_before_output($event) |
|
| 71 | - { |
|
| 72 | - // Nothing to rewrite in the sitemap index |
|
| 73 | - if ($event['type'] == 'sitemapindex') |
|
| 74 | - { |
|
| 75 | - return; |
|
| 76 | - } |
|
| 63 | + /** |
|
| 64 | + * Rewrite URLs in tas2580 Sitemap Extension |
|
| 65 | + * |
|
| 66 | + * @param object $event The event object |
|
| 67 | + * @return null |
|
| 68 | + * @access public |
|
| 69 | + */ |
|
| 70 | + public function sitemap_modify_before_output($event) |
|
| 71 | + { |
|
| 72 | + // Nothing to rewrite in the sitemap index |
|
| 73 | + if ($event['type'] == 'sitemapindex') |
|
| 74 | + { |
|
| 75 | + return; |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - $url_data =$event['url_data'] ; |
|
| 78 | + $url_data =$event['url_data'] ; |
|
| 79 | 79 | |
| 80 | - foreach ($url_data as $id => $data) |
|
| 81 | - { |
|
| 82 | - $row = $data['row']; |
|
| 83 | - if (isset($row['topic_id'])) |
|
| 84 | - { |
|
| 85 | - $url_data[$id]['url'] = $this->base->generate_topic_link($row['forum_id'], $row['forum_name'], $row['topic_id'], $row['topic_title'], $data['start'], true); |
|
| 86 | - } |
|
| 87 | - else if (isset($row['forum_id'])) |
|
| 88 | - { |
|
| 89 | - $url_data[$id]['url'] = $this->base->generate_forum_link($row['forum_id'], $row['forum_name'], $data['start'], true); |
|
| 90 | - } |
|
| 91 | - } |
|
| 80 | + foreach ($url_data as $id => $data) |
|
| 81 | + { |
|
| 82 | + $row = $data['row']; |
|
| 83 | + if (isset($row['topic_id'])) |
|
| 84 | + { |
|
| 85 | + $url_data[$id]['url'] = $this->base->generate_topic_link($row['forum_id'], $row['forum_name'], $row['topic_id'], $row['topic_title'], $data['start'], true); |
|
| 86 | + } |
|
| 87 | + else if (isset($row['forum_id'])) |
|
| 88 | + { |
|
| 89 | + $url_data[$id]['url'] = $this->base->generate_forum_link($row['forum_id'], $row['forum_name'], $data['start'], true); |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - $event['url_data'] = $url_data; |
|
| 94 | - } |
|
| 93 | + $event['url_data'] = $url_data; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * Rewrite URLs in Similar Topics Extension |
|
| 98 | - * |
|
| 99 | - * @param object $event The event object |
|
| 100 | - * @return null |
|
| 101 | - * @access public |
|
| 102 | - */ |
|
| 103 | - public function similartopics_modify_topicrow($event) |
|
| 104 | - { |
|
| 105 | - $this->forum_title = $event['row']['forum_name']; |
|
| 106 | - $this->forum_id = $event['row']['forum_id']; |
|
| 107 | - $this->topic_title = $event['row']['topic_title']; |
|
| 108 | - $this->topic_id = $event['row']['topic_id']; |
|
| 96 | + /** |
|
| 97 | + * Rewrite URLs in Similar Topics Extension |
|
| 98 | + * |
|
| 99 | + * @param object $event The event object |
|
| 100 | + * @return null |
|
| 101 | + * @access public |
|
| 102 | + */ |
|
| 103 | + public function similartopics_modify_topicrow($event) |
|
| 104 | + { |
|
| 105 | + $this->forum_title = $event['row']['forum_name']; |
|
| 106 | + $this->forum_id = $event['row']['forum_id']; |
|
| 107 | + $this->topic_title = $event['row']['topic_title']; |
|
| 108 | + $this->topic_id = $event['row']['topic_id']; |
|
| 109 | 109 | |
| 110 | - $topic_row = $event['topic_row']; |
|
| 111 | - $u_view_topic= $this->base->generate_topic_link($this->forum_id, $this->forum_title, $this->topic_id, $this->topic_title); |
|
| 112 | - $topic_row['U_VIEW_TOPIC'] = append_sid($u_view_topic); |
|
| 113 | - $topic_row['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($this->forum_id, $this->forum_title)); |
|
| 114 | - $topic_row['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($topic_row['TOPIC_REPLIES'], $u_view_topic) . '#p' . $event['row']['topic_last_post_id']); |
|
| 115 | - $event['topic_row'] = $topic_row; |
|
| 116 | - } |
|
| 110 | + $topic_row = $event['topic_row']; |
|
| 111 | + $u_view_topic= $this->base->generate_topic_link($this->forum_id, $this->forum_title, $this->topic_id, $this->topic_title); |
|
| 112 | + $topic_row['U_VIEW_TOPIC'] = append_sid($u_view_topic); |
|
| 113 | + $topic_row['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($this->forum_id, $this->forum_title)); |
|
| 114 | + $topic_row['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($topic_row['TOPIC_REPLIES'], $u_view_topic) . '#p' . $event['row']['topic_last_post_id']); |
|
| 115 | + $event['topic_row'] = $topic_row; |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - /** |
|
| 119 | - * Rewrite URLs in Top 5 Extension |
|
| 120 | - * |
|
| 121 | - * @param object $event The event object |
|
| 122 | - * @return null |
|
| 123 | - * @access public |
|
| 124 | - */ |
|
| 125 | - public function topfive_sql_pull_topics_data($event) |
|
| 126 | - { |
|
| 127 | - $sql_array = $event['sql_array']; |
|
| 128 | - $sql_array['SELECT'] = array_merge($sql_array, array('SELECT' => 'f.forum_name')); |
|
| 129 | - $sql_array['LEFT_JOIN'] = array_merge($sql_array['LEFT_JOIN'], array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 'f.forum_id = t.forum_id')); |
|
| 130 | - $event['sql_array'] = $sql_array; |
|
| 131 | - } |
|
| 118 | + /** |
|
| 119 | + * Rewrite URLs in Top 5 Extension |
|
| 120 | + * |
|
| 121 | + * @param object $event The event object |
|
| 122 | + * @return null |
|
| 123 | + * @access public |
|
| 124 | + */ |
|
| 125 | + public function topfive_sql_pull_topics_data($event) |
|
| 126 | + { |
|
| 127 | + $sql_array = $event['sql_array']; |
|
| 128 | + $sql_array['SELECT'] = array_merge($sql_array, array('SELECT' => 'f.forum_name')); |
|
| 129 | + $sql_array['LEFT_JOIN'] = array_merge($sql_array['LEFT_JOIN'], array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 'f.forum_id = t.forum_id')); |
|
| 130 | + $event['sql_array'] = $sql_array; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - /** |
|
| 134 | - * Rewrite URLs in Top 5 Extension |
|
| 135 | - * |
|
| 136 | - * @param object $event The event object |
|
| 137 | - * @return null |
|
| 138 | - * @access public |
|
| 139 | - */ |
|
| 140 | - public function topfive_modify_tpl_ary($event) |
|
| 141 | - { |
|
| 142 | - $tpl_ary = $event['tpl_ary']; |
|
| 143 | - $replies = $this->base->get_count('topic_posts', $event['row'], $event['row']['forum_id']) - 1; |
|
| 144 | - $u_view_topic = $this->base->generate_topic_link($event['row']['forum_id'], $event['row']['forum_name'], $event['row']['topic_id'], $event['row']['topic_title']); |
|
| 145 | - $tpl_ary['U_TOPIC'] = append_sid($this->base->generate_lastpost_link($replies, $u_view_topic) . '#p' . $event['row']['topic_last_post_id']); |
|
| 146 | - $event['tpl_ary'] = $tpl_ary; |
|
| 147 | - } |
|
| 133 | + /** |
|
| 134 | + * Rewrite URLs in Top 5 Extension |
|
| 135 | + * |
|
| 136 | + * @param object $event The event object |
|
| 137 | + * @return null |
|
| 138 | + * @access public |
|
| 139 | + */ |
|
| 140 | + public function topfive_modify_tpl_ary($event) |
|
| 141 | + { |
|
| 142 | + $tpl_ary = $event['tpl_ary']; |
|
| 143 | + $replies = $this->base->get_count('topic_posts', $event['row'], $event['row']['forum_id']) - 1; |
|
| 144 | + $u_view_topic = $this->base->generate_topic_link($event['row']['forum_id'], $event['row']['forum_name'], $event['row']['topic_id'], $event['row']['topic_title']); |
|
| 145 | + $tpl_ary['U_TOPIC'] = append_sid($this->base->generate_lastpost_link($replies, $u_view_topic) . '#p' . $event['row']['topic_last_post_id']); |
|
| 146 | + $event['tpl_ary'] = $tpl_ary; |
|
| 147 | + } |
|
| 148 | 148 | } |