@@ -18,555 +18,555 @@ |
||
| 18 | 18 | class listener implements EventSubscriberInterface |
| 19 | 19 | { |
| 20 | 20 | |
| 21 | - /** @var \phpbb\auth\auth */ |
|
| 22 | - protected $auth; |
|
| 23 | - |
|
| 24 | - /** @var \phpbb\config\config */ |
|
| 25 | - protected $config; |
|
| 26 | - |
|
| 27 | - /** @var \phpbb\template\template */ |
|
| 28 | - protected $template; |
|
| 29 | - |
|
| 30 | - /** @var \phpbb\request\request */ |
|
| 31 | - protected $request; |
|
| 32 | - |
|
| 33 | - /** @var \phpbb\user */ |
|
| 34 | - protected $user; |
|
| 35 | - |
|
| 36 | - /** @var \phpbb\path_helper */ |
|
| 37 | - protected $path_helper; |
|
| 38 | - |
|
| 39 | - /** @var string phpbb_root_path */ |
|
| 40 | - protected $phpbb_root_path; |
|
| 41 | - |
|
| 42 | - /** @var string php_ext */ |
|
| 43 | - protected $php_ext; |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * Constructor |
|
| 47 | - * |
|
| 48 | - * @param \phpbb\auth\auth auth Authentication object |
|
| 49 | - * @param \phpbb\config\config $config Config Object |
|
| 50 | - * @param \phpbb\template\template $template Template object |
|
| 51 | - * @param \phpbb\request\request $request Request object |
|
| 52 | - * @param \phpbb\user $user User Object |
|
| 53 | - * @param \phpbb\path_helper $path_helper Controller helper object |
|
| 54 | - * @param string $phpbb_root_path phpbb_root_path |
|
| 55 | - * @param string $php_ext php_ext |
|
| 56 | - * @access public |
|
| 57 | - */ |
|
| 58 | - public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\template\template $template, \phpbb\request\request $request, \phpbb\user $user, \phpbb\path_helper $path_helper, $phpbb_root_path, $php_ext) |
|
| 59 | - { |
|
| 60 | - $this->auth = $auth; |
|
| 61 | - $this->config = $config; |
|
| 62 | - $this->template = $template; |
|
| 63 | - $this->request = $request; |
|
| 64 | - $this->user = $user; |
|
| 65 | - $this->path_helper = $path_helper; |
|
| 66 | - $this->phpbb_root_path = $phpbb_root_path; |
|
| 67 | - $this->php_ext = $php_ext; |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * Assign functions defined in this class to event listeners in the core |
|
| 72 | - * |
|
| 73 | - * @return array |
|
| 74 | - * @static |
|
| 75 | - * @access public |
|
| 76 | - */ |
|
| 77 | - static public function getSubscribedEvents() |
|
| 78 | - { |
|
| 79 | - return array( |
|
| 80 | - 'core.append_sid' => 'append_sid', |
|
| 81 | - 'core.display_forums_modify_sql' => 'display_forums_modify_sql', |
|
| 82 | - 'core.display_forums_modify_template_vars' => 'display_forums_modify_template_vars', |
|
| 83 | - 'core.display_forums_modify_forum_rows' => 'display_forums_modify_forum_rows', |
|
| 84 | - 'core.display_forums_modify_sql' => 'display_forums_modify_sql', |
|
| 85 | - 'core.generate_forum_nav' => 'generate_forum_nav', |
|
| 86 | - 'core.make_jumpbox_modify_tpl_ary' => 'make_jumpbox_modify_tpl_ary', // Not in phpBB |
|
| 87 | - 'core.pagination_generate_page_link' => 'pagination_generate_page_link', |
|
| 88 | - 'core.search_modify_tpl_ary' => 'search_modify_tpl_ary', |
|
| 89 | - 'core.viewforum_modify_topicrow' => 'viewforum_modify_topicrow', |
|
| 90 | - 'core.viewforum_get_topic_data' => 'viewforum_get_topic_data', |
|
| 91 | - 'core.viewtopic_assign_template_vars_before' => 'viewtopic_assign_template_vars_before', |
|
| 92 | - 'core.viewtopic_modify_page_title' => 'viewtopic_modify_page_title', |
|
| 93 | - 'core.viewtopic_modify_post_row' => 'viewtopic_modify_post_row', |
|
| 94 | - 'core.viewtopic_get_post_data' => 'viewtopic_get_post_data', |
|
| 95 | - |
|
| 96 | - // Rewrite other Extensions |
|
| 97 | - 'rmcgirr83.topfive.sql_pull_topics_data' => 'topfive_sql_pull_topics_data', |
|
| 98 | - 'rmcgirr83.topfive.modify_tpl_ary' => 'topfive_modify_tpl_ary', |
|
| 99 | - 'tas2580.sitemap_modify_before_output' => 'sitemap_modify_before_output', |
|
| 100 | - 'vse.similartopics.modify_topicrow' => 'similartopics_modify_topicrow', |
|
| 101 | - ); |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * Correct the path of $viewtopic_url |
|
| 106 | - * |
|
| 107 | - * @param object $event The event object |
|
| 108 | - * @return null |
|
| 109 | - * @access public |
|
| 110 | - */ |
|
| 111 | - public function append_sid($event) |
|
| 112 | - { |
|
| 113 | - if (preg_match('#./../viewtopic.' . $this->php_ext . '#', $event['url'])) |
|
| 114 | - { |
|
| 115 | - $url = $this->phpbb_root_path . 'viewtopic.' . $this->php_ext ; |
|
| 116 | - $event['url'] = $url; |
|
| 117 | - } |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * Get informations for the last post from Database |
|
| 122 | - * |
|
| 123 | - * @param object $event The event object |
|
| 124 | - * @return null |
|
| 125 | - * @access public |
|
| 126 | - */ |
|
| 127 | - public function display_forums_modify_sql($event) |
|
| 128 | - { |
|
| 129 | - $sql_array = $event['sql_ary']; |
|
| 130 | - $sql_array['LEFT_JOIN'][] = array( |
|
| 131 | - 'FROM' => array(TOPICS_TABLE => 't'), |
|
| 132 | - 'ON' => "f.forum_last_post_id = t.topic_last_post_id" |
|
| 133 | - ); |
|
| 134 | - $sql_array['SELECT'] .= ', t.topic_title, t.topic_id, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted'; |
|
| 135 | - $event['sql_ary'] = $sql_array; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * Store informations for the last post in forum_rows array |
|
| 140 | - * |
|
| 141 | - * @param object $event The event object |
|
| 142 | - * @return null |
|
| 143 | - * @access public |
|
| 144 | - */ |
|
| 145 | - public function display_forums_modify_forum_rows($event) |
|
| 146 | - { |
|
| 147 | - $forum_rows = $event['forum_rows']; |
|
| 148 | - if ($event['row']['forum_last_post_time'] == $forum_rows[$event['parent_id']]['forum_last_post_time']) |
|
| 149 | - { |
|
| 150 | - $forum_rows[$event['parent_id']]['forum_name_last_post'] =$event['row']['forum_name']; |
|
| 151 | - $forum_rows[$event['parent_id']]['topic_id_last_post'] =$event['row']['topic_id']; |
|
| 152 | - $forum_rows[$event['parent_id']]['topic_title_last_post'] =$event['row']['topic_title']; |
|
| 153 | - $event['forum_rows'] = $forum_rows; |
|
| 154 | - } |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - /** |
|
| 158 | - * Rewrite links to forums and subforums in forum index |
|
| 159 | - * also correct the path of the forum images if we are in a forum |
|
| 160 | - * |
|
| 161 | - * @param object $event The event object |
|
| 162 | - * @return null |
|
| 163 | - * @access public |
|
| 164 | - */ |
|
| 165 | - public function display_forums_modify_template_vars($event) |
|
| 166 | - { |
|
| 167 | - // Rewrite URLs of sub forums |
|
| 168 | - $subforums_row = $event['subforums_row']; |
|
| 169 | - foreach ($subforums_row as $i => $subforum) |
|
| 170 | - { |
|
| 171 | - // A little bit a dirty way, but there is no better solution |
|
| 172 | - $query = str_replace('&', '&', parse_url($subforum['U_SUBFORUM'], PHP_URL_QUERY)); |
|
| 173 | - parse_str($query, $id); |
|
| 174 | - $subforums_row[$i]['U_SUBFORUM'] = append_sid($this->generate_forum_link($id['f'], $subforum['SUBFORUM_NAME'])); |
|
| 175 | - } |
|
| 176 | - $event['subforums_row'] = $subforums_row; |
|
| 177 | - |
|
| 178 | - $forum_row = $event['forum_row']; |
|
| 179 | - |
|
| 180 | - // Update the image source in forums |
|
| 181 | - $img = $this->path_helper->update_web_root_path($forum_row['FORUM_IMAGE_SRC']); |
|
| 182 | - $forum_row['FORUM_IMAGE'] = preg_replace('#img src=\"(.*)\" alt#', 'img src="' . $img . '" alt', $forum_row['FORUM_IMAGE']); |
|
| 183 | - |
|
| 184 | - // Rewrite links to topics, posts and forums |
|
| 185 | - $replies = $this->get_count('topic_posts', $event['row'], $event['row']['forum_id']) - 1; |
|
| 186 | - $url = $this->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']); |
|
| 187 | - $forum_row['U_LAST_POST'] = append_sid($this->generate_lastpost_link($replies, $url) . '#p' . $event['row']['forum_last_post_id']); |
|
| 188 | - $forum_row['U_VIEWFORUM'] = append_sid($this->generate_forum_link($forum_row['FORUM_ID'], $forum_row['FORUM_NAME'])); |
|
| 189 | - $event['forum_row'] = $forum_row; |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - /** |
|
| 193 | - * Rewrite links in breadcrumbs |
|
| 194 | - * |
|
| 195 | - * @param object $event The event object |
|
| 196 | - * @return null |
|
| 197 | - * @access public |
|
| 198 | - */ |
|
| 199 | - public function generate_forum_nav($event) |
|
| 200 | - { |
|
| 201 | - $forum_data = $event['forum_data']; |
|
| 202 | - $navlinks = $event['navlinks']; |
|
| 203 | - $navlinks_parents = $event['navlinks_parents']; |
|
| 204 | - |
|
| 205 | - foreach ($navlinks_parents as $id => $data) |
|
| 206 | - { |
|
| 207 | - $navlinks_parents[$id]['U_VIEW_FORUM'] = append_sid($this->generate_forum_link($data['FORUM_ID'] , $data['FORUM_NAME'])); |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - $navlinks['U_VIEW_FORUM'] = append_sid($this->generate_forum_link($forum_data['forum_id'], $forum_data['forum_name'])); |
|
| 211 | - $event['navlinks'] = $navlinks; |
|
| 212 | - $event['navlinks_parents'] = $navlinks_parents; |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - // Not in phpBB |
|
| 216 | - public function make_jumpbox_modify_tpl_ary($event) |
|
| 217 | - { |
|
| 218 | - $tpl_ary = $event['tpl_ary']; |
|
| 219 | - $row = $event['row']; |
|
| 220 | - foreach ($tpl_ary as $id => $data) |
|
| 221 | - { |
|
| 222 | - |
|
| 223 | - $tpl_ary[$id]['LINK'] = append_sid($this->generate_forum_link($row['forum_id'], $row['forum_name'])); |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - $event['tpl_ary'] = $tpl_ary; |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - /** |
|
| 230 | - * Rewrite pagination links |
|
| 231 | - * |
|
| 232 | - * @param object $event The event object |
|
| 233 | - * @return null |
|
| 234 | - * @access public |
|
| 235 | - */ |
|
| 236 | - public function pagination_generate_page_link($event) |
|
| 237 | - { |
|
| 238 | - // If we have a sort key we do not rewrite the URL |
|
| 239 | - $query = str_replace('&', '&', parse_url($event['base_url'], PHP_URL_QUERY)); |
|
| 240 | - parse_str($query, $param); |
|
| 241 | - if (isset($param['sd']) || isset($param['sk']) || isset($param['st'])) |
|
| 242 | - { |
|
| 243 | - return; |
|
| 244 | - } |
|
| 245 | - |
|
| 246 | - $start = (($event['on_page'] - 1) * $event['per_page']); |
|
| 247 | - if (!empty($this->topic_title)) |
|
| 248 | - { |
|
| 249 | - $event['generate_page_link_override'] = append_sid($this->generate_topic_link($this->forum_id, $this->forum_title, $this->topic_id, $this->topic_title, $start)); |
|
| 250 | - } |
|
| 251 | - else if (!empty($this->forum_title)) |
|
| 252 | - { |
|
| 253 | - $event['generate_page_link_override'] = append_sid($this->generate_forum_link($this->forum_id, $this->forum_title, $start)); |
|
| 254 | - } |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - /** |
|
| 258 | - * Rewrite links in the search result |
|
| 259 | - * |
|
| 260 | - * @param object $event The event object |
|
| 261 | - * @return null |
|
| 262 | - * @access public |
|
| 263 | - */ |
|
| 264 | - public function search_modify_tpl_ary($event) |
|
| 265 | - { |
|
| 266 | - $replies = $this->get_count('topic_posts', $event['row'], $event['row']['forum_id']) - 1; |
|
| 267 | - $u_view_topic = $this->generate_topic_link($event['row']['forum_id'], $event['row']['forum_name'], $event['row']['topic_id'], $event['row']['topic_title']); |
|
| 268 | - |
|
| 269 | - $tpl_ary = $event['tpl_ary']; |
|
| 270 | - $tpl_ary['U_LAST_POST'] = append_sid($this->generate_lastpost_link($replies, $u_view_topic) . '#p' . $event['row']['topic_last_post_id']); |
|
| 271 | - $tpl_ary['U_VIEW_TOPIC'] = append_sid($u_view_topic); |
|
| 272 | - $tpl_ary['U_VIEW_FORUM'] = append_sid($this->generate_forum_link($event['row']['forum_id'], $event['row']['forum_name'])); |
|
| 273 | - |
|
| 274 | - $event['tpl_ary'] = $tpl_ary; |
|
| 275 | - } |
|
| 276 | - |
|
| 277 | - /** |
|
| 278 | - * Rewrite links to topics in forum view |
|
| 279 | - * |
|
| 280 | - * @param object $event The event object |
|
| 281 | - * @return null |
|
| 282 | - * @access public |
|
| 283 | - */ |
|
| 284 | - public function viewforum_modify_topicrow($event) |
|
| 285 | - { |
|
| 286 | - $topic_row = $event['topic_row']; |
|
| 287 | - $this->forum_title = $topic_row['FORUM_NAME']; |
|
| 288 | - $this->forum_id = $topic_row['FORUM_ID']; |
|
| 289 | - $this->topic_title = $topic_row['TOPIC_TITLE']; |
|
| 290 | - $this->topic_id = $topic_row['TOPIC_ID']; |
|
| 291 | - |
|
| 292 | - $u_view_topic = $this->generate_topic_link($this->forum_id, $this->forum_title, $this->topic_id, $this->topic_title); |
|
| 293 | - $topic_row['U_VIEW_TOPIC'] = append_sid($u_view_topic); |
|
| 294 | - $topic_row['U_VIEW_FORUM'] = append_sid($this->generate_forum_link($this->forum_id, $this->forum_title)); |
|
| 295 | - $topic_row['U_LAST_POST'] = append_sid($this->generate_lastpost_link($event['topic_row']['REPLIES'], $u_view_topic) . '#p' . $event['row']['topic_last_post_id']); |
|
| 296 | - |
|
| 297 | - $event['topic_row'] = $topic_row; |
|
| 298 | - } |
|
| 299 | - |
|
| 300 | - /** |
|
| 301 | - * Rewrite the canonical URL on viewforum.php |
|
| 302 | - * |
|
| 303 | - * @param object $event The event object |
|
| 304 | - * @return null |
|
| 305 | - * @access public |
|
| 306 | - */ |
|
| 307 | - public function viewforum_get_topic_data($event) |
|
| 308 | - { |
|
| 309 | - $this->forum_title = $event['forum_data']['forum_name']; |
|
| 310 | - $this->forum_id = $event['forum_data']['forum_id']; |
|
| 311 | - $start = $this->request->variable('start', 0); |
|
| 312 | - $this->template->assign_vars(array( |
|
| 313 | - 'U_VIEW_FORUM' => append_sid($this->generate_forum_link($this->forum_id, $this->forum_title, $start)), |
|
| 314 | - 'U_CANONICAL' => $this->generate_forum_link($this->forum_id, $this->forum_title, $start, true), |
|
| 315 | - )); |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - /** |
|
| 319 | - * Rewrite the topic URL for the headline of the topic page and the link back to forum |
|
| 320 | - * |
|
| 321 | - * @param object $event The event object |
|
| 322 | - * @return null |
|
| 323 | - * @access public |
|
| 324 | - */ |
|
| 325 | - public function viewtopic_get_post_data($event) |
|
| 326 | - { |
|
| 327 | - $data = $event['topic_data']; |
|
| 328 | - $this->template->assign_vars(array( |
|
| 329 | - 'U_VIEW_TOPIC' => append_sid($this->generate_topic_link($event['forum_id'] , $data['forum_name'], $event['topic_id'], $data['topic_title'], $event['start'])), |
|
| 330 | - 'U_VIEW_FORUM' => append_sid($this->generate_forum_link($event['forum_id'] , $data['forum_name'])), |
|
| 331 | - )); |
|
| 332 | - } |
|
| 333 | - |
|
| 334 | - /** |
|
| 335 | - * Assign topic data to global variables for pagination |
|
| 336 | - * |
|
| 337 | - * @param object $event The event object |
|
| 338 | - * @return null |
|
| 339 | - * @access public |
|
| 340 | - */ |
|
| 341 | - public function viewtopic_assign_template_vars_before($event) |
|
| 342 | - { |
|
| 343 | - $this->forum_title = $event['topic_data']['forum_name']; |
|
| 344 | - $this->forum_id = $event['topic_data']['forum_id']; |
|
| 345 | - $this->topic_title = $event['topic_data']['topic_title']; |
|
| 346 | - $this->topic_id = $event['topic_data']['topic_id']; |
|
| 347 | - } |
|
| 348 | - |
|
| 349 | - /** |
|
| 350 | - * Rewrite the canonical URL on viewtopic.php |
|
| 351 | - * |
|
| 352 | - * @param object $event The event object |
|
| 353 | - * @return null |
|
| 354 | - * @access public |
|
| 355 | - */ |
|
| 356 | - public function viewtopic_modify_page_title($event) |
|
| 357 | - { |
|
| 358 | - $start = $this->request->variable('start', 0); |
|
| 359 | - $data = $event['topic_data']; |
|
| 360 | - $this->template->assign_vars(array( |
|
| 361 | - 'U_CANONICAL' => $this->generate_topic_link($data['forum_id'], $data['forum_name'], $data['topic_id'], $data['topic_title'], $start, true), |
|
| 362 | - )); |
|
| 363 | - } |
|
| 364 | - |
|
| 365 | - /** |
|
| 366 | - * Rewrite mini post img link |
|
| 367 | - * |
|
| 368 | - * @param object $event The event object |
|
| 369 | - * @return null |
|
| 370 | - * @access public |
|
| 371 | - */ |
|
| 372 | - public function viewtopic_modify_post_row($event) |
|
| 373 | - { |
|
| 374 | - $row = $event['post_row']; |
|
| 375 | - $start = $this->request->variable('start', 0); |
|
| 376 | - $data = $event['topic_data']; |
|
| 377 | - $row['U_MINI_POST'] = append_sid($this->generate_topic_link($data['forum_id'], $data['forum_name'], $data['topic_id'], $data['topic_title'], $start) . '#p' . $event['row']['post_id']); |
|
| 378 | - $event['post_row'] = $row; |
|
| 379 | - } |
|
| 380 | - |
|
| 381 | - /** |
|
| 382 | - * Rewrite URLs in tas2580 Sitemap Extension |
|
| 383 | - * |
|
| 384 | - * @param object $event The event object |
|
| 385 | - * @return null |
|
| 386 | - * @access public |
|
| 387 | - */ |
|
| 388 | - public function sitemap_modify_before_output($event) |
|
| 389 | - { |
|
| 390 | - // Nothing to rewrite in the sitemap index |
|
| 391 | - if ($event['type'] == 'sitemapindex') |
|
| 392 | - { |
|
| 393 | - return; |
|
| 394 | - } |
|
| 395 | - |
|
| 396 | - $url_data =$event['url_data'] ; |
|
| 397 | - |
|
| 398 | - foreach ($url_data as $id => $data) |
|
| 399 | - { |
|
| 400 | - $row = $data['row']; |
|
| 401 | - if (isset($row['topic_id'])) |
|
| 402 | - { |
|
| 403 | - $url_data[$id]['url'] = $this->generate_topic_link($row['forum_id'], $row['forum_name'], $row['topic_id'], $row['topic_title'], $data['start'], true); |
|
| 404 | - } |
|
| 405 | - else if (isset($row['forum_id'])) |
|
| 406 | - { |
|
| 407 | - $url_data[$id]['url'] = $this->generate_forum_link($row['forum_id'], $row['forum_name'], $data['start'], true); |
|
| 408 | - } |
|
| 409 | - } |
|
| 410 | - |
|
| 411 | - $event['url_data'] = $url_data; |
|
| 412 | - } |
|
| 413 | - |
|
| 414 | - /** |
|
| 415 | - * Rewrite URLs in Similar Topics Extension |
|
| 416 | - * |
|
| 417 | - * @param object $event The event object |
|
| 418 | - * @return null |
|
| 419 | - * @access public |
|
| 420 | - */ |
|
| 421 | - public function similartopics_modify_topicrow($event) |
|
| 422 | - { |
|
| 423 | - $this->forum_title = $event['row']['forum_name']; |
|
| 424 | - $this->forum_id = $event['row']['forum_id']; |
|
| 425 | - $this->topic_title = $event['row']['topic_title']; |
|
| 426 | - $this->topic_id = $event['row']['topic_id']; |
|
| 427 | - |
|
| 428 | - $topic_row = $event['topic_row']; |
|
| 429 | - $u_view_topic= $this->generate_topic_link($this->forum_id, $this->forum_title, $this->topic_id, $this->topic_title); |
|
| 430 | - $topic_row['U_VIEW_TOPIC'] = append_sid($u_view_topic); |
|
| 431 | - $topic_row['U_VIEW_FORUM'] = append_sid($this->generate_forum_link($this->forum_id, $this->forum_title)); |
|
| 432 | - $topic_row['U_LAST_POST'] = append_sid($this->generate_lastpost_link($topic_row['TOPIC_REPLIES'], $u_view_topic) . '#p' . $event['row']['topic_last_post_id']); |
|
| 433 | - $event['topic_row'] = $topic_row; |
|
| 434 | - } |
|
| 435 | - |
|
| 436 | - /** |
|
| 437 | - * Rewrite URLs in Top 5 Extension |
|
| 438 | - * |
|
| 439 | - * @param object $event The event object |
|
| 440 | - * @return null |
|
| 441 | - * @access public |
|
| 442 | - */ |
|
| 443 | - public function topfive_sql_pull_topics_data($event) |
|
| 444 | - { |
|
| 445 | - $sql_array = $event['sql_array']; |
|
| 446 | - $sql_array['SELECT'] = array_merge($sql_array, array('SELECT' => 'f.forum_name')); |
|
| 447 | - $sql_array['LEFT_JOIN'] = array_merge($sql_array['LEFT_JOIN'], array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 'f.forum_id = t.forum_id')); |
|
| 448 | - // $event['sql_array'] = $sql_array; |
|
| 449 | - } |
|
| 450 | - |
|
| 451 | - /** |
|
| 452 | - * Rewrite URLs in Top 5 Extension |
|
| 453 | - * |
|
| 454 | - * @param object $event The event object |
|
| 455 | - * @return null |
|
| 456 | - * @access public |
|
| 457 | - */ |
|
| 458 | - public function topfive_modify_tpl_ary($event) |
|
| 459 | - { |
|
| 460 | - $tpl_ary = $event['tpl_ary']; |
|
| 461 | - $replies = $this->get_count('topic_posts', $event['row'], $event['row']['forum_id']) - 1; |
|
| 462 | - $u_view_topic = $this->generate_topic_link($event['row']['forum_id'], $event['row']['forum_name'], $event['row']['topic_id'], $event['row']['topic_title']); |
|
| 463 | - $tpl_ary['U_TOPIC'] = append_sid($this->generate_lastpost_link($replies, $u_view_topic) . '#p' . $event['row']['topic_last_post_id']); |
|
| 464 | - $event['tpl_ary'] = $tpl_ary; |
|
| 465 | - } |
|
| 466 | - |
|
| 467 | - /** |
|
| 468 | - * Generate the SEO link for a topic |
|
| 469 | - * |
|
| 470 | - * @param int $forum_id The ID of the forum |
|
| 471 | - * @param string $forum_name The title of the forum |
|
| 472 | - * @param int $topic_id The ID if the topic |
|
| 473 | - * @param string $topic_title The title of the topic |
|
| 474 | - * @param int $start Optional start parameter |
|
| 475 | - * @param bool $full Return the full URL |
|
| 476 | - * @return string The SEO URL |
|
| 477 | - * @access private |
|
| 478 | - */ |
|
| 479 | - private function generate_topic_link($forum_id, $forum_name, $topic_id, $topic_title, $start = 0, $full = false) |
|
| 480 | - { |
|
| 481 | - if ($full) |
|
| 482 | - { |
|
| 483 | - return generate_board_url() . '/' . $this->title_to_url($forum_name) . '-f' . $forum_id . '/' . $this->title_to_url($topic_title) . '-t' . $topic_id . ($start ? '-s' . $start : '') . '.html'; |
|
| 484 | - } |
|
| 485 | - return $this->phpbb_root_path . $this->title_to_url($forum_name) . '-f' . $forum_id . '/' . $this->title_to_url($topic_title) . '-t' . $topic_id . ($start ? '-s' . $start : '') . '.html'; |
|
| 486 | - } |
|
| 487 | - |
|
| 488 | - /** |
|
| 489 | - * Generate the SEO link for a forum |
|
| 490 | - * |
|
| 491 | - * @param int $forum_id The ID of the forum |
|
| 492 | - * @param string $forum_name The title of the forum |
|
| 493 | - * @param int $start Optional start parameter |
|
| 494 | - * @param bool $full Return the full URL |
|
| 495 | - * @return string The SEO URL |
|
| 496 | - * @access private |
|
| 497 | - */ |
|
| 498 | - private function generate_forum_link($forum_id, $forum_name, $start = 0, $full = false) |
|
| 499 | - { |
|
| 500 | - if ($full) |
|
| 501 | - { |
|
| 502 | - return generate_board_url() . '/' . $this->title_to_url($forum_name) . '-f' . $forum_id . '/' . ($start ? 'index-s' . $start . '.html' : ''); |
|
| 503 | - } |
|
| 504 | - return $this->phpbb_root_path . $this->title_to_url($forum_name) . '-f' . $forum_id . '/' . ($start ? 'index-s' . $start . '.html' : ''); |
|
| 505 | - } |
|
| 506 | - |
|
| 507 | - /** |
|
| 508 | - * |
|
| 509 | - * @global type $_SID |
|
| 510 | - * @param int $replies Replays in the topic |
|
| 511 | - * @param string $url URL oft the topic |
|
| 512 | - * @return string The URL with start included |
|
| 513 | - */ |
|
| 514 | - private function generate_lastpost_link($replies, $url) |
|
| 515 | - { |
|
| 516 | - $url = str_replace('.html', '', $url); |
|
| 517 | - $per_page = ($this->config['posts_per_page'] <= 0) ? 1 : $this->config['posts_per_page']; |
|
| 518 | - if (($replies + 1) > $per_page) |
|
| 519 | - { |
|
| 520 | - for ($j = 0; $j < $replies + 1; $j += $per_page) |
|
| 521 | - { |
|
| 522 | - $last_post_link = $url . '-s' . $j . '.html'; |
|
| 523 | - } |
|
| 524 | - } |
|
| 525 | - else |
|
| 526 | - { |
|
| 527 | - $last_post_link = $url . '.html'; |
|
| 528 | - } |
|
| 529 | - return $last_post_link; |
|
| 530 | - } |
|
| 531 | - |
|
| 532 | - /** |
|
| 533 | - * Replace letters to use title in URL |
|
| 534 | - * |
|
| 535 | - * @param string $title The title to use in the URL |
|
| 536 | - * @return string Title to use in URLs |
|
| 537 | - */ |
|
| 538 | - public static function title_to_url($title) |
|
| 539 | - { |
|
| 540 | - $url = strtolower(censor_text(utf8_normalize_nfc(strip_tags($title)))); |
|
| 541 | - |
|
| 542 | - // Let's replace |
|
| 543 | - $url_search = array(' ', 'í', 'ý', 'ß', 'ö', 'ô', 'ó', 'ò', 'ä', 'â', 'à', 'á', 'é', 'è', 'ü', 'ú', 'ù', 'ñ', 'ß', '²', '³', '@', '€', '$'); |
|
| 544 | - $url_replace = array('-', 'i', 'y', 's', 'oe', 'o', 'o', 'o', 'ae', 'a', 'a', 'a', 'e', 'e', 'ue', 'u', 'u', 'n', 'ss', '2', '3', 'at', 'eur', 'usd'); |
|
| 545 | - $url = str_replace($url_search, $url_replace, $url); |
|
| 546 | - $url_search = array('&', '"', '&', '"', "'", '¸', '`', '(', ')', '[', ']', '<', '>', '{', '}', '.', ':', ',', ';', '!', '?', '+', '*', '/', '=', 'µ', '#', '~', '"', '§', '%', '|', '°', '^', '„', '“'); |
|
| 547 | - $url = str_replace($url_search, '-', $url); |
|
| 548 | - $url = str_replace(array('----', '---', '--'), '-', $url); |
|
| 549 | - |
|
| 550 | - $url = substr($url, 0, 50); // Max length for a title in URL |
|
| 551 | - return urlencode($url); |
|
| 552 | - } |
|
| 553 | - |
|
| 554 | - /** |
|
| 555 | - * Get the topics post count or the forums post/topic count based on permissions |
|
| 556 | - * |
|
| 557 | - * @param $mode string One of topic_posts, forum_posts or forum_topics |
|
| 558 | - * @param $data array Array with the topic/forum data to calculate from |
|
| 559 | - * @param $forum_id int The forum id is used for permission checks |
|
| 560 | - * @return int Number of posts/topics the user can see in the topic/forum |
|
| 561 | - */ |
|
| 562 | - private function get_count($mode, $data, $forum_id) |
|
| 563 | - { |
|
| 564 | - if (!$this->auth->acl_get('m_approve', $forum_id)) |
|
| 565 | - { |
|
| 566 | - return (int) $data[$mode . '_approved']; |
|
| 567 | - } |
|
| 568 | - |
|
| 569 | - return (int) $data[$mode . '_approved'] + (int) $data[$mode . '_unapproved'] + (int) $data[$mode . '_softdeleted']; |
|
| 570 | - } |
|
| 21 | + /** @var \phpbb\auth\auth */ |
|
| 22 | + protected $auth; |
|
| 23 | + |
|
| 24 | + /** @var \phpbb\config\config */ |
|
| 25 | + protected $config; |
|
| 26 | + |
|
| 27 | + /** @var \phpbb\template\template */ |
|
| 28 | + protected $template; |
|
| 29 | + |
|
| 30 | + /** @var \phpbb\request\request */ |
|
| 31 | + protected $request; |
|
| 32 | + |
|
| 33 | + /** @var \phpbb\user */ |
|
| 34 | + protected $user; |
|
| 35 | + |
|
| 36 | + /** @var \phpbb\path_helper */ |
|
| 37 | + protected $path_helper; |
|
| 38 | + |
|
| 39 | + /** @var string phpbb_root_path */ |
|
| 40 | + protected $phpbb_root_path; |
|
| 41 | + |
|
| 42 | + /** @var string php_ext */ |
|
| 43 | + protected $php_ext; |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * Constructor |
|
| 47 | + * |
|
| 48 | + * @param \phpbb\auth\auth auth Authentication object |
|
| 49 | + * @param \phpbb\config\config $config Config Object |
|
| 50 | + * @param \phpbb\template\template $template Template object |
|
| 51 | + * @param \phpbb\request\request $request Request object |
|
| 52 | + * @param \phpbb\user $user User Object |
|
| 53 | + * @param \phpbb\path_helper $path_helper Controller helper object |
|
| 54 | + * @param string $phpbb_root_path phpbb_root_path |
|
| 55 | + * @param string $php_ext php_ext |
|
| 56 | + * @access public |
|
| 57 | + */ |
|
| 58 | + public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\template\template $template, \phpbb\request\request $request, \phpbb\user $user, \phpbb\path_helper $path_helper, $phpbb_root_path, $php_ext) |
|
| 59 | + { |
|
| 60 | + $this->auth = $auth; |
|
| 61 | + $this->config = $config; |
|
| 62 | + $this->template = $template; |
|
| 63 | + $this->request = $request; |
|
| 64 | + $this->user = $user; |
|
| 65 | + $this->path_helper = $path_helper; |
|
| 66 | + $this->phpbb_root_path = $phpbb_root_path; |
|
| 67 | + $this->php_ext = $php_ext; |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * Assign functions defined in this class to event listeners in the core |
|
| 72 | + * |
|
| 73 | + * @return array |
|
| 74 | + * @static |
|
| 75 | + * @access public |
|
| 76 | + */ |
|
| 77 | + static public function getSubscribedEvents() |
|
| 78 | + { |
|
| 79 | + return array( |
|
| 80 | + 'core.append_sid' => 'append_sid', |
|
| 81 | + 'core.display_forums_modify_sql' => 'display_forums_modify_sql', |
|
| 82 | + 'core.display_forums_modify_template_vars' => 'display_forums_modify_template_vars', |
|
| 83 | + 'core.display_forums_modify_forum_rows' => 'display_forums_modify_forum_rows', |
|
| 84 | + 'core.display_forums_modify_sql' => 'display_forums_modify_sql', |
|
| 85 | + 'core.generate_forum_nav' => 'generate_forum_nav', |
|
| 86 | + 'core.make_jumpbox_modify_tpl_ary' => 'make_jumpbox_modify_tpl_ary', // Not in phpBB |
|
| 87 | + 'core.pagination_generate_page_link' => 'pagination_generate_page_link', |
|
| 88 | + 'core.search_modify_tpl_ary' => 'search_modify_tpl_ary', |
|
| 89 | + 'core.viewforum_modify_topicrow' => 'viewforum_modify_topicrow', |
|
| 90 | + 'core.viewforum_get_topic_data' => 'viewforum_get_topic_data', |
|
| 91 | + 'core.viewtopic_assign_template_vars_before' => 'viewtopic_assign_template_vars_before', |
|
| 92 | + 'core.viewtopic_modify_page_title' => 'viewtopic_modify_page_title', |
|
| 93 | + 'core.viewtopic_modify_post_row' => 'viewtopic_modify_post_row', |
|
| 94 | + 'core.viewtopic_get_post_data' => 'viewtopic_get_post_data', |
|
| 95 | + |
|
| 96 | + // Rewrite other Extensions |
|
| 97 | + 'rmcgirr83.topfive.sql_pull_topics_data' => 'topfive_sql_pull_topics_data', |
|
| 98 | + 'rmcgirr83.topfive.modify_tpl_ary' => 'topfive_modify_tpl_ary', |
|
| 99 | + 'tas2580.sitemap_modify_before_output' => 'sitemap_modify_before_output', |
|
| 100 | + 'vse.similartopics.modify_topicrow' => 'similartopics_modify_topicrow', |
|
| 101 | + ); |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * Correct the path of $viewtopic_url |
|
| 106 | + * |
|
| 107 | + * @param object $event The event object |
|
| 108 | + * @return null |
|
| 109 | + * @access public |
|
| 110 | + */ |
|
| 111 | + public function append_sid($event) |
|
| 112 | + { |
|
| 113 | + if (preg_match('#./../viewtopic.' . $this->php_ext . '#', $event['url'])) |
|
| 114 | + { |
|
| 115 | + $url = $this->phpbb_root_path . 'viewtopic.' . $this->php_ext ; |
|
| 116 | + $event['url'] = $url; |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * Get informations for the last post from Database |
|
| 122 | + * |
|
| 123 | + * @param object $event The event object |
|
| 124 | + * @return null |
|
| 125 | + * @access public |
|
| 126 | + */ |
|
| 127 | + public function display_forums_modify_sql($event) |
|
| 128 | + { |
|
| 129 | + $sql_array = $event['sql_ary']; |
|
| 130 | + $sql_array['LEFT_JOIN'][] = array( |
|
| 131 | + 'FROM' => array(TOPICS_TABLE => 't'), |
|
| 132 | + 'ON' => "f.forum_last_post_id = t.topic_last_post_id" |
|
| 133 | + ); |
|
| 134 | + $sql_array['SELECT'] .= ', t.topic_title, t.topic_id, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted'; |
|
| 135 | + $event['sql_ary'] = $sql_array; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * Store informations for the last post in forum_rows array |
|
| 140 | + * |
|
| 141 | + * @param object $event The event object |
|
| 142 | + * @return null |
|
| 143 | + * @access public |
|
| 144 | + */ |
|
| 145 | + public function display_forums_modify_forum_rows($event) |
|
| 146 | + { |
|
| 147 | + $forum_rows = $event['forum_rows']; |
|
| 148 | + if ($event['row']['forum_last_post_time'] == $forum_rows[$event['parent_id']]['forum_last_post_time']) |
|
| 149 | + { |
|
| 150 | + $forum_rows[$event['parent_id']]['forum_name_last_post'] =$event['row']['forum_name']; |
|
| 151 | + $forum_rows[$event['parent_id']]['topic_id_last_post'] =$event['row']['topic_id']; |
|
| 152 | + $forum_rows[$event['parent_id']]['topic_title_last_post'] =$event['row']['topic_title']; |
|
| 153 | + $event['forum_rows'] = $forum_rows; |
|
| 154 | + } |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + /** |
|
| 158 | + * Rewrite links to forums and subforums in forum index |
|
| 159 | + * also correct the path of the forum images if we are in a forum |
|
| 160 | + * |
|
| 161 | + * @param object $event The event object |
|
| 162 | + * @return null |
|
| 163 | + * @access public |
|
| 164 | + */ |
|
| 165 | + public function display_forums_modify_template_vars($event) |
|
| 166 | + { |
|
| 167 | + // Rewrite URLs of sub forums |
|
| 168 | + $subforums_row = $event['subforums_row']; |
|
| 169 | + foreach ($subforums_row as $i => $subforum) |
|
| 170 | + { |
|
| 171 | + // A little bit a dirty way, but there is no better solution |
|
| 172 | + $query = str_replace('&', '&', parse_url($subforum['U_SUBFORUM'], PHP_URL_QUERY)); |
|
| 173 | + parse_str($query, $id); |
|
| 174 | + $subforums_row[$i]['U_SUBFORUM'] = append_sid($this->generate_forum_link($id['f'], $subforum['SUBFORUM_NAME'])); |
|
| 175 | + } |
|
| 176 | + $event['subforums_row'] = $subforums_row; |
|
| 177 | + |
|
| 178 | + $forum_row = $event['forum_row']; |
|
| 179 | + |
|
| 180 | + // Update the image source in forums |
|
| 181 | + $img = $this->path_helper->update_web_root_path($forum_row['FORUM_IMAGE_SRC']); |
|
| 182 | + $forum_row['FORUM_IMAGE'] = preg_replace('#img src=\"(.*)\" alt#', 'img src="' . $img . '" alt', $forum_row['FORUM_IMAGE']); |
|
| 183 | + |
|
| 184 | + // Rewrite links to topics, posts and forums |
|
| 185 | + $replies = $this->get_count('topic_posts', $event['row'], $event['row']['forum_id']) - 1; |
|
| 186 | + $url = $this->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']); |
|
| 187 | + $forum_row['U_LAST_POST'] = append_sid($this->generate_lastpost_link($replies, $url) . '#p' . $event['row']['forum_last_post_id']); |
|
| 188 | + $forum_row['U_VIEWFORUM'] = append_sid($this->generate_forum_link($forum_row['FORUM_ID'], $forum_row['FORUM_NAME'])); |
|
| 189 | + $event['forum_row'] = $forum_row; |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + /** |
|
| 193 | + * Rewrite links in breadcrumbs |
|
| 194 | + * |
|
| 195 | + * @param object $event The event object |
|
| 196 | + * @return null |
|
| 197 | + * @access public |
|
| 198 | + */ |
|
| 199 | + public function generate_forum_nav($event) |
|
| 200 | + { |
|
| 201 | + $forum_data = $event['forum_data']; |
|
| 202 | + $navlinks = $event['navlinks']; |
|
| 203 | + $navlinks_parents = $event['navlinks_parents']; |
|
| 204 | + |
|
| 205 | + foreach ($navlinks_parents as $id => $data) |
|
| 206 | + { |
|
| 207 | + $navlinks_parents[$id]['U_VIEW_FORUM'] = append_sid($this->generate_forum_link($data['FORUM_ID'] , $data['FORUM_NAME'])); |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + $navlinks['U_VIEW_FORUM'] = append_sid($this->generate_forum_link($forum_data['forum_id'], $forum_data['forum_name'])); |
|
| 211 | + $event['navlinks'] = $navlinks; |
|
| 212 | + $event['navlinks_parents'] = $navlinks_parents; |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + // Not in phpBB |
|
| 216 | + public function make_jumpbox_modify_tpl_ary($event) |
|
| 217 | + { |
|
| 218 | + $tpl_ary = $event['tpl_ary']; |
|
| 219 | + $row = $event['row']; |
|
| 220 | + foreach ($tpl_ary as $id => $data) |
|
| 221 | + { |
|
| 222 | + |
|
| 223 | + $tpl_ary[$id]['LINK'] = append_sid($this->generate_forum_link($row['forum_id'], $row['forum_name'])); |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + $event['tpl_ary'] = $tpl_ary; |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + /** |
|
| 230 | + * Rewrite pagination links |
|
| 231 | + * |
|
| 232 | + * @param object $event The event object |
|
| 233 | + * @return null |
|
| 234 | + * @access public |
|
| 235 | + */ |
|
| 236 | + public function pagination_generate_page_link($event) |
|
| 237 | + { |
|
| 238 | + // If we have a sort key we do not rewrite the URL |
|
| 239 | + $query = str_replace('&', '&', parse_url($event['base_url'], PHP_URL_QUERY)); |
|
| 240 | + parse_str($query, $param); |
|
| 241 | + if (isset($param['sd']) || isset($param['sk']) || isset($param['st'])) |
|
| 242 | + { |
|
| 243 | + return; |
|
| 244 | + } |
|
| 245 | + |
|
| 246 | + $start = (($event['on_page'] - 1) * $event['per_page']); |
|
| 247 | + if (!empty($this->topic_title)) |
|
| 248 | + { |
|
| 249 | + $event['generate_page_link_override'] = append_sid($this->generate_topic_link($this->forum_id, $this->forum_title, $this->topic_id, $this->topic_title, $start)); |
|
| 250 | + } |
|
| 251 | + else if (!empty($this->forum_title)) |
|
| 252 | + { |
|
| 253 | + $event['generate_page_link_override'] = append_sid($this->generate_forum_link($this->forum_id, $this->forum_title, $start)); |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + /** |
|
| 258 | + * Rewrite links in the search result |
|
| 259 | + * |
|
| 260 | + * @param object $event The event object |
|
| 261 | + * @return null |
|
| 262 | + * @access public |
|
| 263 | + */ |
|
| 264 | + public function search_modify_tpl_ary($event) |
|
| 265 | + { |
|
| 266 | + $replies = $this->get_count('topic_posts', $event['row'], $event['row']['forum_id']) - 1; |
|
| 267 | + $u_view_topic = $this->generate_topic_link($event['row']['forum_id'], $event['row']['forum_name'], $event['row']['topic_id'], $event['row']['topic_title']); |
|
| 268 | + |
|
| 269 | + $tpl_ary = $event['tpl_ary']; |
|
| 270 | + $tpl_ary['U_LAST_POST'] = append_sid($this->generate_lastpost_link($replies, $u_view_topic) . '#p' . $event['row']['topic_last_post_id']); |
|
| 271 | + $tpl_ary['U_VIEW_TOPIC'] = append_sid($u_view_topic); |
|
| 272 | + $tpl_ary['U_VIEW_FORUM'] = append_sid($this->generate_forum_link($event['row']['forum_id'], $event['row']['forum_name'])); |
|
| 273 | + |
|
| 274 | + $event['tpl_ary'] = $tpl_ary; |
|
| 275 | + } |
|
| 276 | + |
|
| 277 | + /** |
|
| 278 | + * Rewrite links to topics in forum view |
|
| 279 | + * |
|
| 280 | + * @param object $event The event object |
|
| 281 | + * @return null |
|
| 282 | + * @access public |
|
| 283 | + */ |
|
| 284 | + public function viewforum_modify_topicrow($event) |
|
| 285 | + { |
|
| 286 | + $topic_row = $event['topic_row']; |
|
| 287 | + $this->forum_title = $topic_row['FORUM_NAME']; |
|
| 288 | + $this->forum_id = $topic_row['FORUM_ID']; |
|
| 289 | + $this->topic_title = $topic_row['TOPIC_TITLE']; |
|
| 290 | + $this->topic_id = $topic_row['TOPIC_ID']; |
|
| 291 | + |
|
| 292 | + $u_view_topic = $this->generate_topic_link($this->forum_id, $this->forum_title, $this->topic_id, $this->topic_title); |
|
| 293 | + $topic_row['U_VIEW_TOPIC'] = append_sid($u_view_topic); |
|
| 294 | + $topic_row['U_VIEW_FORUM'] = append_sid($this->generate_forum_link($this->forum_id, $this->forum_title)); |
|
| 295 | + $topic_row['U_LAST_POST'] = append_sid($this->generate_lastpost_link($event['topic_row']['REPLIES'], $u_view_topic) . '#p' . $event['row']['topic_last_post_id']); |
|
| 296 | + |
|
| 297 | + $event['topic_row'] = $topic_row; |
|
| 298 | + } |
|
| 299 | + |
|
| 300 | + /** |
|
| 301 | + * Rewrite the canonical URL on viewforum.php |
|
| 302 | + * |
|
| 303 | + * @param object $event The event object |
|
| 304 | + * @return null |
|
| 305 | + * @access public |
|
| 306 | + */ |
|
| 307 | + public function viewforum_get_topic_data($event) |
|
| 308 | + { |
|
| 309 | + $this->forum_title = $event['forum_data']['forum_name']; |
|
| 310 | + $this->forum_id = $event['forum_data']['forum_id']; |
|
| 311 | + $start = $this->request->variable('start', 0); |
|
| 312 | + $this->template->assign_vars(array( |
|
| 313 | + 'U_VIEW_FORUM' => append_sid($this->generate_forum_link($this->forum_id, $this->forum_title, $start)), |
|
| 314 | + 'U_CANONICAL' => $this->generate_forum_link($this->forum_id, $this->forum_title, $start, true), |
|
| 315 | + )); |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + /** |
|
| 319 | + * Rewrite the topic URL for the headline of the topic page and the link back to forum |
|
| 320 | + * |
|
| 321 | + * @param object $event The event object |
|
| 322 | + * @return null |
|
| 323 | + * @access public |
|
| 324 | + */ |
|
| 325 | + public function viewtopic_get_post_data($event) |
|
| 326 | + { |
|
| 327 | + $data = $event['topic_data']; |
|
| 328 | + $this->template->assign_vars(array( |
|
| 329 | + 'U_VIEW_TOPIC' => append_sid($this->generate_topic_link($event['forum_id'] , $data['forum_name'], $event['topic_id'], $data['topic_title'], $event['start'])), |
|
| 330 | + 'U_VIEW_FORUM' => append_sid($this->generate_forum_link($event['forum_id'] , $data['forum_name'])), |
|
| 331 | + )); |
|
| 332 | + } |
|
| 333 | + |
|
| 334 | + /** |
|
| 335 | + * Assign topic data to global variables for pagination |
|
| 336 | + * |
|
| 337 | + * @param object $event The event object |
|
| 338 | + * @return null |
|
| 339 | + * @access public |
|
| 340 | + */ |
|
| 341 | + public function viewtopic_assign_template_vars_before($event) |
|
| 342 | + { |
|
| 343 | + $this->forum_title = $event['topic_data']['forum_name']; |
|
| 344 | + $this->forum_id = $event['topic_data']['forum_id']; |
|
| 345 | + $this->topic_title = $event['topic_data']['topic_title']; |
|
| 346 | + $this->topic_id = $event['topic_data']['topic_id']; |
|
| 347 | + } |
|
| 348 | + |
|
| 349 | + /** |
|
| 350 | + * Rewrite the canonical URL on viewtopic.php |
|
| 351 | + * |
|
| 352 | + * @param object $event The event object |
|
| 353 | + * @return null |
|
| 354 | + * @access public |
|
| 355 | + */ |
|
| 356 | + public function viewtopic_modify_page_title($event) |
|
| 357 | + { |
|
| 358 | + $start = $this->request->variable('start', 0); |
|
| 359 | + $data = $event['topic_data']; |
|
| 360 | + $this->template->assign_vars(array( |
|
| 361 | + 'U_CANONICAL' => $this->generate_topic_link($data['forum_id'], $data['forum_name'], $data['topic_id'], $data['topic_title'], $start, true), |
|
| 362 | + )); |
|
| 363 | + } |
|
| 364 | + |
|
| 365 | + /** |
|
| 366 | + * Rewrite mini post img link |
|
| 367 | + * |
|
| 368 | + * @param object $event The event object |
|
| 369 | + * @return null |
|
| 370 | + * @access public |
|
| 371 | + */ |
|
| 372 | + public function viewtopic_modify_post_row($event) |
|
| 373 | + { |
|
| 374 | + $row = $event['post_row']; |
|
| 375 | + $start = $this->request->variable('start', 0); |
|
| 376 | + $data = $event['topic_data']; |
|
| 377 | + $row['U_MINI_POST'] = append_sid($this->generate_topic_link($data['forum_id'], $data['forum_name'], $data['topic_id'], $data['topic_title'], $start) . '#p' . $event['row']['post_id']); |
|
| 378 | + $event['post_row'] = $row; |
|
| 379 | + } |
|
| 380 | + |
|
| 381 | + /** |
|
| 382 | + * Rewrite URLs in tas2580 Sitemap Extension |
|
| 383 | + * |
|
| 384 | + * @param object $event The event object |
|
| 385 | + * @return null |
|
| 386 | + * @access public |
|
| 387 | + */ |
|
| 388 | + public function sitemap_modify_before_output($event) |
|
| 389 | + { |
|
| 390 | + // Nothing to rewrite in the sitemap index |
|
| 391 | + if ($event['type'] == 'sitemapindex') |
|
| 392 | + { |
|
| 393 | + return; |
|
| 394 | + } |
|
| 395 | + |
|
| 396 | + $url_data =$event['url_data'] ; |
|
| 397 | + |
|
| 398 | + foreach ($url_data as $id => $data) |
|
| 399 | + { |
|
| 400 | + $row = $data['row']; |
|
| 401 | + if (isset($row['topic_id'])) |
|
| 402 | + { |
|
| 403 | + $url_data[$id]['url'] = $this->generate_topic_link($row['forum_id'], $row['forum_name'], $row['topic_id'], $row['topic_title'], $data['start'], true); |
|
| 404 | + } |
|
| 405 | + else if (isset($row['forum_id'])) |
|
| 406 | + { |
|
| 407 | + $url_data[$id]['url'] = $this->generate_forum_link($row['forum_id'], $row['forum_name'], $data['start'], true); |
|
| 408 | + } |
|
| 409 | + } |
|
| 410 | + |
|
| 411 | + $event['url_data'] = $url_data; |
|
| 412 | + } |
|
| 413 | + |
|
| 414 | + /** |
|
| 415 | + * Rewrite URLs in Similar Topics Extension |
|
| 416 | + * |
|
| 417 | + * @param object $event The event object |
|
| 418 | + * @return null |
|
| 419 | + * @access public |
|
| 420 | + */ |
|
| 421 | + public function similartopics_modify_topicrow($event) |
|
| 422 | + { |
|
| 423 | + $this->forum_title = $event['row']['forum_name']; |
|
| 424 | + $this->forum_id = $event['row']['forum_id']; |
|
| 425 | + $this->topic_title = $event['row']['topic_title']; |
|
| 426 | + $this->topic_id = $event['row']['topic_id']; |
|
| 427 | + |
|
| 428 | + $topic_row = $event['topic_row']; |
|
| 429 | + $u_view_topic= $this->generate_topic_link($this->forum_id, $this->forum_title, $this->topic_id, $this->topic_title); |
|
| 430 | + $topic_row['U_VIEW_TOPIC'] = append_sid($u_view_topic); |
|
| 431 | + $topic_row['U_VIEW_FORUM'] = append_sid($this->generate_forum_link($this->forum_id, $this->forum_title)); |
|
| 432 | + $topic_row['U_LAST_POST'] = append_sid($this->generate_lastpost_link($topic_row['TOPIC_REPLIES'], $u_view_topic) . '#p' . $event['row']['topic_last_post_id']); |
|
| 433 | + $event['topic_row'] = $topic_row; |
|
| 434 | + } |
|
| 435 | + |
|
| 436 | + /** |
|
| 437 | + * Rewrite URLs in Top 5 Extension |
|
| 438 | + * |
|
| 439 | + * @param object $event The event object |
|
| 440 | + * @return null |
|
| 441 | + * @access public |
|
| 442 | + */ |
|
| 443 | + public function topfive_sql_pull_topics_data($event) |
|
| 444 | + { |
|
| 445 | + $sql_array = $event['sql_array']; |
|
| 446 | + $sql_array['SELECT'] = array_merge($sql_array, array('SELECT' => 'f.forum_name')); |
|
| 447 | + $sql_array['LEFT_JOIN'] = array_merge($sql_array['LEFT_JOIN'], array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 'f.forum_id = t.forum_id')); |
|
| 448 | + // $event['sql_array'] = $sql_array; |
|
| 449 | + } |
|
| 450 | + |
|
| 451 | + /** |
|
| 452 | + * Rewrite URLs in Top 5 Extension |
|
| 453 | + * |
|
| 454 | + * @param object $event The event object |
|
| 455 | + * @return null |
|
| 456 | + * @access public |
|
| 457 | + */ |
|
| 458 | + public function topfive_modify_tpl_ary($event) |
|
| 459 | + { |
|
| 460 | + $tpl_ary = $event['tpl_ary']; |
|
| 461 | + $replies = $this->get_count('topic_posts', $event['row'], $event['row']['forum_id']) - 1; |
|
| 462 | + $u_view_topic = $this->generate_topic_link($event['row']['forum_id'], $event['row']['forum_name'], $event['row']['topic_id'], $event['row']['topic_title']); |
|
| 463 | + $tpl_ary['U_TOPIC'] = append_sid($this->generate_lastpost_link($replies, $u_view_topic) . '#p' . $event['row']['topic_last_post_id']); |
|
| 464 | + $event['tpl_ary'] = $tpl_ary; |
|
| 465 | + } |
|
| 466 | + |
|
| 467 | + /** |
|
| 468 | + * Generate the SEO link for a topic |
|
| 469 | + * |
|
| 470 | + * @param int $forum_id The ID of the forum |
|
| 471 | + * @param string $forum_name The title of the forum |
|
| 472 | + * @param int $topic_id The ID if the topic |
|
| 473 | + * @param string $topic_title The title of the topic |
|
| 474 | + * @param int $start Optional start parameter |
|
| 475 | + * @param bool $full Return the full URL |
|
| 476 | + * @return string The SEO URL |
|
| 477 | + * @access private |
|
| 478 | + */ |
|
| 479 | + private function generate_topic_link($forum_id, $forum_name, $topic_id, $topic_title, $start = 0, $full = false) |
|
| 480 | + { |
|
| 481 | + if ($full) |
|
| 482 | + { |
|
| 483 | + return generate_board_url() . '/' . $this->title_to_url($forum_name) . '-f' . $forum_id . '/' . $this->title_to_url($topic_title) . '-t' . $topic_id . ($start ? '-s' . $start : '') . '.html'; |
|
| 484 | + } |
|
| 485 | + return $this->phpbb_root_path . $this->title_to_url($forum_name) . '-f' . $forum_id . '/' . $this->title_to_url($topic_title) . '-t' . $topic_id . ($start ? '-s' . $start : '') . '.html'; |
|
| 486 | + } |
|
| 487 | + |
|
| 488 | + /** |
|
| 489 | + * Generate the SEO link for a forum |
|
| 490 | + * |
|
| 491 | + * @param int $forum_id The ID of the forum |
|
| 492 | + * @param string $forum_name The title of the forum |
|
| 493 | + * @param int $start Optional start parameter |
|
| 494 | + * @param bool $full Return the full URL |
|
| 495 | + * @return string The SEO URL |
|
| 496 | + * @access private |
|
| 497 | + */ |
|
| 498 | + private function generate_forum_link($forum_id, $forum_name, $start = 0, $full = false) |
|
| 499 | + { |
|
| 500 | + if ($full) |
|
| 501 | + { |
|
| 502 | + return generate_board_url() . '/' . $this->title_to_url($forum_name) . '-f' . $forum_id . '/' . ($start ? 'index-s' . $start . '.html' : ''); |
|
| 503 | + } |
|
| 504 | + return $this->phpbb_root_path . $this->title_to_url($forum_name) . '-f' . $forum_id . '/' . ($start ? 'index-s' . $start . '.html' : ''); |
|
| 505 | + } |
|
| 506 | + |
|
| 507 | + /** |
|
| 508 | + * |
|
| 509 | + * @global type $_SID |
|
| 510 | + * @param int $replies Replays in the topic |
|
| 511 | + * @param string $url URL oft the topic |
|
| 512 | + * @return string The URL with start included |
|
| 513 | + */ |
|
| 514 | + private function generate_lastpost_link($replies, $url) |
|
| 515 | + { |
|
| 516 | + $url = str_replace('.html', '', $url); |
|
| 517 | + $per_page = ($this->config['posts_per_page'] <= 0) ? 1 : $this->config['posts_per_page']; |
|
| 518 | + if (($replies + 1) > $per_page) |
|
| 519 | + { |
|
| 520 | + for ($j = 0; $j < $replies + 1; $j += $per_page) |
|
| 521 | + { |
|
| 522 | + $last_post_link = $url . '-s' . $j . '.html'; |
|
| 523 | + } |
|
| 524 | + } |
|
| 525 | + else |
|
| 526 | + { |
|
| 527 | + $last_post_link = $url . '.html'; |
|
| 528 | + } |
|
| 529 | + return $last_post_link; |
|
| 530 | + } |
|
| 531 | + |
|
| 532 | + /** |
|
| 533 | + * Replace letters to use title in URL |
|
| 534 | + * |
|
| 535 | + * @param string $title The title to use in the URL |
|
| 536 | + * @return string Title to use in URLs |
|
| 537 | + */ |
|
| 538 | + public static function title_to_url($title) |
|
| 539 | + { |
|
| 540 | + $url = strtolower(censor_text(utf8_normalize_nfc(strip_tags($title)))); |
|
| 541 | + |
|
| 542 | + // Let's replace |
|
| 543 | + $url_search = array(' ', 'í', 'ý', 'ß', 'ö', 'ô', 'ó', 'ò', 'ä', 'â', 'à', 'á', 'é', 'è', 'ü', 'ú', 'ù', 'ñ', 'ß', '²', '³', '@', '€', '$'); |
|
| 544 | + $url_replace = array('-', 'i', 'y', 's', 'oe', 'o', 'o', 'o', 'ae', 'a', 'a', 'a', 'e', 'e', 'ue', 'u', 'u', 'n', 'ss', '2', '3', 'at', 'eur', 'usd'); |
|
| 545 | + $url = str_replace($url_search, $url_replace, $url); |
|
| 546 | + $url_search = array('&', '"', '&', '"', "'", '¸', '`', '(', ')', '[', ']', '<', '>', '{', '}', '.', ':', ',', ';', '!', '?', '+', '*', '/', '=', 'µ', '#', '~', '"', '§', '%', '|', '°', '^', '„', '“'); |
|
| 547 | + $url = str_replace($url_search, '-', $url); |
|
| 548 | + $url = str_replace(array('----', '---', '--'), '-', $url); |
|
| 549 | + |
|
| 550 | + $url = substr($url, 0, 50); // Max length for a title in URL |
|
| 551 | + return urlencode($url); |
|
| 552 | + } |
|
| 553 | + |
|
| 554 | + /** |
|
| 555 | + * Get the topics post count or the forums post/topic count based on permissions |
|
| 556 | + * |
|
| 557 | + * @param $mode string One of topic_posts, forum_posts or forum_topics |
|
| 558 | + * @param $data array Array with the topic/forum data to calculate from |
|
| 559 | + * @param $forum_id int The forum id is used for permission checks |
|
| 560 | + * @return int Number of posts/topics the user can see in the topic/forum |
|
| 561 | + */ |
|
| 562 | + private function get_count($mode, $data, $forum_id) |
|
| 563 | + { |
|
| 564 | + if (!$this->auth->acl_get('m_approve', $forum_id)) |
|
| 565 | + { |
|
| 566 | + return (int) $data[$mode . '_approved']; |
|
| 567 | + } |
|
| 568 | + |
|
| 569 | + return (int) $data[$mode . '_approved'] + (int) $data[$mode . '_unapproved'] + (int) $data[$mode . '_softdeleted']; |
|
| 570 | + } |
|
| 571 | 571 | |
| 572 | 572 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | 'core.display_forums_modify_forum_rows' => 'display_forums_modify_forum_rows', |
| 84 | 84 | 'core.display_forums_modify_sql' => 'display_forums_modify_sql', |
| 85 | 85 | 'core.generate_forum_nav' => 'generate_forum_nav', |
| 86 | - 'core.make_jumpbox_modify_tpl_ary' => 'make_jumpbox_modify_tpl_ary', // Not in phpBB |
|
| 86 | + 'core.make_jumpbox_modify_tpl_ary' => 'make_jumpbox_modify_tpl_ary', // Not in phpBB |
|
| 87 | 87 | 'core.pagination_generate_page_link' => 'pagination_generate_page_link', |
| 88 | 88 | 'core.search_modify_tpl_ary' => 'search_modify_tpl_ary', |
| 89 | 89 | 'core.viewforum_modify_topicrow' => 'viewforum_modify_topicrow', |
@@ -110,9 +110,9 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | public function append_sid($event) |
| 112 | 112 | { |
| 113 | - if (preg_match('#./../viewtopic.' . $this->php_ext . '#', $event['url'])) |
|
| 113 | + if (preg_match('#./../viewtopic.'.$this->php_ext.'#', $event['url'])) |
|
| 114 | 114 | { |
| 115 | - $url = $this->phpbb_root_path . 'viewtopic.' . $this->php_ext ; |
|
| 115 | + $url = $this->phpbb_root_path.'viewtopic.'.$this->php_ext; |
|
| 116 | 116 | $event['url'] = $url; |
| 117 | 117 | } |
| 118 | 118 | } |
@@ -147,9 +147,9 @@ discard block |
||
| 147 | 147 | $forum_rows = $event['forum_rows']; |
| 148 | 148 | if ($event['row']['forum_last_post_time'] == $forum_rows[$event['parent_id']]['forum_last_post_time']) |
| 149 | 149 | { |
| 150 | - $forum_rows[$event['parent_id']]['forum_name_last_post'] =$event['row']['forum_name']; |
|
| 151 | - $forum_rows[$event['parent_id']]['topic_id_last_post'] =$event['row']['topic_id']; |
|
| 152 | - $forum_rows[$event['parent_id']]['topic_title_last_post'] =$event['row']['topic_title']; |
|
| 150 | + $forum_rows[$event['parent_id']]['forum_name_last_post'] = $event['row']['forum_name']; |
|
| 151 | + $forum_rows[$event['parent_id']]['topic_id_last_post'] = $event['row']['topic_id']; |
|
| 152 | + $forum_rows[$event['parent_id']]['topic_title_last_post'] = $event['row']['topic_title']; |
|
| 153 | 153 | $event['forum_rows'] = $forum_rows; |
| 154 | 154 | } |
| 155 | 155 | } |
@@ -179,12 +179,12 @@ discard block |
||
| 179 | 179 | |
| 180 | 180 | // Update the image source in forums |
| 181 | 181 | $img = $this->path_helper->update_web_root_path($forum_row['FORUM_IMAGE_SRC']); |
| 182 | - $forum_row['FORUM_IMAGE'] = preg_replace('#img src=\"(.*)\" alt#', 'img src="' . $img . '" alt', $forum_row['FORUM_IMAGE']); |
|
| 182 | + $forum_row['FORUM_IMAGE'] = preg_replace('#img src=\"(.*)\" alt#', 'img src="'.$img.'" alt', $forum_row['FORUM_IMAGE']); |
|
| 183 | 183 | |
| 184 | 184 | // Rewrite links to topics, posts and forums |
| 185 | 185 | $replies = $this->get_count('topic_posts', $event['row'], $event['row']['forum_id']) - 1; |
| 186 | 186 | $url = $this->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']); |
| 187 | - $forum_row['U_LAST_POST'] = append_sid($this->generate_lastpost_link($replies, $url) . '#p' . $event['row']['forum_last_post_id']); |
|
| 187 | + $forum_row['U_LAST_POST'] = append_sid($this->generate_lastpost_link($replies, $url).'#p'.$event['row']['forum_last_post_id']); |
|
| 188 | 188 | $forum_row['U_VIEWFORUM'] = append_sid($this->generate_forum_link($forum_row['FORUM_ID'], $forum_row['FORUM_NAME'])); |
| 189 | 189 | $event['forum_row'] = $forum_row; |
| 190 | 190 | } |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | |
| 205 | 205 | foreach ($navlinks_parents as $id => $data) |
| 206 | 206 | { |
| 207 | - $navlinks_parents[$id]['U_VIEW_FORUM'] = append_sid($this->generate_forum_link($data['FORUM_ID'] , $data['FORUM_NAME'])); |
|
| 207 | + $navlinks_parents[$id]['U_VIEW_FORUM'] = append_sid($this->generate_forum_link($data['FORUM_ID'], $data['FORUM_NAME'])); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | $navlinks['U_VIEW_FORUM'] = append_sid($this->generate_forum_link($forum_data['forum_id'], $forum_data['forum_name'])); |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | foreach ($tpl_ary as $id => $data) |
| 221 | 221 | { |
| 222 | 222 | |
| 223 | - $tpl_ary[$id]['LINK'] = append_sid($this->generate_forum_link($row['forum_id'], $row['forum_name'])); |
|
| 223 | + $tpl_ary[$id]['LINK'] = append_sid($this->generate_forum_link($row['forum_id'], $row['forum_name'])); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | $event['tpl_ary'] = $tpl_ary; |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | $u_view_topic = $this->generate_topic_link($event['row']['forum_id'], $event['row']['forum_name'], $event['row']['topic_id'], $event['row']['topic_title']); |
| 268 | 268 | |
| 269 | 269 | $tpl_ary = $event['tpl_ary']; |
| 270 | - $tpl_ary['U_LAST_POST'] = append_sid($this->generate_lastpost_link($replies, $u_view_topic) . '#p' . $event['row']['topic_last_post_id']); |
|
| 270 | + $tpl_ary['U_LAST_POST'] = append_sid($this->generate_lastpost_link($replies, $u_view_topic).'#p'.$event['row']['topic_last_post_id']); |
|
| 271 | 271 | $tpl_ary['U_VIEW_TOPIC'] = append_sid($u_view_topic); |
| 272 | 272 | $tpl_ary['U_VIEW_FORUM'] = append_sid($this->generate_forum_link($event['row']['forum_id'], $event['row']['forum_name'])); |
| 273 | 273 | |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | $u_view_topic = $this->generate_topic_link($this->forum_id, $this->forum_title, $this->topic_id, $this->topic_title); |
| 293 | 293 | $topic_row['U_VIEW_TOPIC'] = append_sid($u_view_topic); |
| 294 | 294 | $topic_row['U_VIEW_FORUM'] = append_sid($this->generate_forum_link($this->forum_id, $this->forum_title)); |
| 295 | - $topic_row['U_LAST_POST'] = append_sid($this->generate_lastpost_link($event['topic_row']['REPLIES'], $u_view_topic) . '#p' . $event['row']['topic_last_post_id']); |
|
| 295 | + $topic_row['U_LAST_POST'] = append_sid($this->generate_lastpost_link($event['topic_row']['REPLIES'], $u_view_topic).'#p'.$event['row']['topic_last_post_id']); |
|
| 296 | 296 | |
| 297 | 297 | $event['topic_row'] = $topic_row; |
| 298 | 298 | } |
@@ -326,8 +326,8 @@ discard block |
||
| 326 | 326 | { |
| 327 | 327 | $data = $event['topic_data']; |
| 328 | 328 | $this->template->assign_vars(array( |
| 329 | - 'U_VIEW_TOPIC' => append_sid($this->generate_topic_link($event['forum_id'] , $data['forum_name'], $event['topic_id'], $data['topic_title'], $event['start'])), |
|
| 330 | - 'U_VIEW_FORUM' => append_sid($this->generate_forum_link($event['forum_id'] , $data['forum_name'])), |
|
| 329 | + 'U_VIEW_TOPIC' => append_sid($this->generate_topic_link($event['forum_id'], $data['forum_name'], $event['topic_id'], $data['topic_title'], $event['start'])), |
|
| 330 | + 'U_VIEW_FORUM' => append_sid($this->generate_forum_link($event['forum_id'], $data['forum_name'])), |
|
| 331 | 331 | )); |
| 332 | 332 | } |
| 333 | 333 | |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | $row = $event['post_row']; |
| 375 | 375 | $start = $this->request->variable('start', 0); |
| 376 | 376 | $data = $event['topic_data']; |
| 377 | - $row['U_MINI_POST'] = append_sid($this->generate_topic_link($data['forum_id'], $data['forum_name'], $data['topic_id'], $data['topic_title'], $start) . '#p' . $event['row']['post_id']); |
|
| 377 | + $row['U_MINI_POST'] = append_sid($this->generate_topic_link($data['forum_id'], $data['forum_name'], $data['topic_id'], $data['topic_title'], $start).'#p'.$event['row']['post_id']); |
|
| 378 | 378 | $event['post_row'] = $row; |
| 379 | 379 | } |
| 380 | 380 | |
@@ -393,14 +393,14 @@ discard block |
||
| 393 | 393 | return; |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | - $url_data =$event['url_data'] ; |
|
| 396 | + $url_data = $event['url_data']; |
|
| 397 | 397 | |
| 398 | 398 | foreach ($url_data as $id => $data) |
| 399 | 399 | { |
| 400 | 400 | $row = $data['row']; |
| 401 | 401 | if (isset($row['topic_id'])) |
| 402 | 402 | { |
| 403 | - $url_data[$id]['url'] = $this->generate_topic_link($row['forum_id'], $row['forum_name'], $row['topic_id'], $row['topic_title'], $data['start'], true); |
|
| 403 | + $url_data[$id]['url'] = $this->generate_topic_link($row['forum_id'], $row['forum_name'], $row['topic_id'], $row['topic_title'], $data['start'], true); |
|
| 404 | 404 | } |
| 405 | 405 | else if (isset($row['forum_id'])) |
| 406 | 406 | { |
@@ -426,10 +426,10 @@ discard block |
||
| 426 | 426 | $this->topic_id = $event['row']['topic_id']; |
| 427 | 427 | |
| 428 | 428 | $topic_row = $event['topic_row']; |
| 429 | - $u_view_topic= $this->generate_topic_link($this->forum_id, $this->forum_title, $this->topic_id, $this->topic_title); |
|
| 429 | + $u_view_topic = $this->generate_topic_link($this->forum_id, $this->forum_title, $this->topic_id, $this->topic_title); |
|
| 430 | 430 | $topic_row['U_VIEW_TOPIC'] = append_sid($u_view_topic); |
| 431 | 431 | $topic_row['U_VIEW_FORUM'] = append_sid($this->generate_forum_link($this->forum_id, $this->forum_title)); |
| 432 | - $topic_row['U_LAST_POST'] = append_sid($this->generate_lastpost_link($topic_row['TOPIC_REPLIES'], $u_view_topic) . '#p' . $event['row']['topic_last_post_id']); |
|
| 432 | + $topic_row['U_LAST_POST'] = append_sid($this->generate_lastpost_link($topic_row['TOPIC_REPLIES'], $u_view_topic).'#p'.$event['row']['topic_last_post_id']); |
|
| 433 | 433 | $event['topic_row'] = $topic_row; |
| 434 | 434 | } |
| 435 | 435 | |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | $tpl_ary = $event['tpl_ary']; |
| 461 | 461 | $replies = $this->get_count('topic_posts', $event['row'], $event['row']['forum_id']) - 1; |
| 462 | 462 | $u_view_topic = $this->generate_topic_link($event['row']['forum_id'], $event['row']['forum_name'], $event['row']['topic_id'], $event['row']['topic_title']); |
| 463 | - $tpl_ary['U_TOPIC'] = append_sid($this->generate_lastpost_link($replies, $u_view_topic) . '#p' . $event['row']['topic_last_post_id']); |
|
| 463 | + $tpl_ary['U_TOPIC'] = append_sid($this->generate_lastpost_link($replies, $u_view_topic).'#p'.$event['row']['topic_last_post_id']); |
|
| 464 | 464 | $event['tpl_ary'] = $tpl_ary; |
| 465 | 465 | } |
| 466 | 466 | |
@@ -480,9 +480,9 @@ discard block |
||
| 480 | 480 | { |
| 481 | 481 | if ($full) |
| 482 | 482 | { |
| 483 | - return generate_board_url() . '/' . $this->title_to_url($forum_name) . '-f' . $forum_id . '/' . $this->title_to_url($topic_title) . '-t' . $topic_id . ($start ? '-s' . $start : '') . '.html'; |
|
| 483 | + return generate_board_url().'/'.$this->title_to_url($forum_name).'-f'.$forum_id.'/'.$this->title_to_url($topic_title).'-t'.$topic_id.($start ? '-s'.$start : '').'.html'; |
|
| 484 | 484 | } |
| 485 | - return $this->phpbb_root_path . $this->title_to_url($forum_name) . '-f' . $forum_id . '/' . $this->title_to_url($topic_title) . '-t' . $topic_id . ($start ? '-s' . $start : '') . '.html'; |
|
| 485 | + return $this->phpbb_root_path.$this->title_to_url($forum_name).'-f'.$forum_id.'/'.$this->title_to_url($topic_title).'-t'.$topic_id.($start ? '-s'.$start : '').'.html'; |
|
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | /** |
@@ -499,9 +499,9 @@ discard block |
||
| 499 | 499 | { |
| 500 | 500 | if ($full) |
| 501 | 501 | { |
| 502 | - return generate_board_url() . '/' . $this->title_to_url($forum_name) . '-f' . $forum_id . '/' . ($start ? 'index-s' . $start . '.html' : ''); |
|
| 502 | + return generate_board_url().'/'.$this->title_to_url($forum_name).'-f'.$forum_id.'/'.($start ? 'index-s'.$start.'.html' : ''); |
|
| 503 | 503 | } |
| 504 | - return $this->phpbb_root_path . $this->title_to_url($forum_name) . '-f' . $forum_id . '/' . ($start ? 'index-s' . $start . '.html' : ''); |
|
| 504 | + return $this->phpbb_root_path.$this->title_to_url($forum_name).'-f'.$forum_id.'/'.($start ? 'index-s'.$start.'.html' : ''); |
|
| 505 | 505 | } |
| 506 | 506 | |
| 507 | 507 | /** |
@@ -519,12 +519,12 @@ discard block |
||
| 519 | 519 | { |
| 520 | 520 | for ($j = 0; $j < $replies + 1; $j += $per_page) |
| 521 | 521 | { |
| 522 | - $last_post_link = $url . '-s' . $j . '.html'; |
|
| 522 | + $last_post_link = $url.'-s'.$j.'.html'; |
|
| 523 | 523 | } |
| 524 | 524 | } |
| 525 | 525 | else |
| 526 | 526 | { |
| 527 | - $last_post_link = $url . '.html'; |
|
| 527 | + $last_post_link = $url.'.html'; |
|
| 528 | 528 | } |
| 529 | 529 | return $last_post_link; |
| 530 | 530 | } |
@@ -563,10 +563,10 @@ discard block |
||
| 563 | 563 | { |
| 564 | 564 | if (!$this->auth->acl_get('m_approve', $forum_id)) |
| 565 | 565 | { |
| 566 | - return (int) $data[$mode . '_approved']; |
|
| 566 | + return (int) $data[$mode.'_approved']; |
|
| 567 | 567 | } |
| 568 | 568 | |
| 569 | - return (int) $data[$mode . '_approved'] + (int) $data[$mode . '_unapproved'] + (int) $data[$mode . '_softdeleted']; |
|
| 569 | + return (int) $data[$mode.'_approved'] + (int) $data[$mode.'_unapproved'] + (int) $data[$mode.'_softdeleted']; |
|
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | } |