From f34d25caf21f87dd3af0fc6c57722b9e6a7d58b7 Mon Sep 17 00:00:00 2001 From: PupperWoff Date: Wed, 10 May 2017 00:48:40 +0200 Subject: [PATCH] Quick and dirty fix for - Last 50 post page links - Might not be 100% but some testing will determine that Also includes "Small fix to noko50" --- inc/display.php | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/inc/display.php b/inc/display.php index 58cb4805..2895e099 100644 --- a/inc/display.php +++ b/inc/display.php @@ -446,8 +446,33 @@ class Thread { $hasnoko50 = $this->postCount() >= $config['noko50_min']; + /* Fix >>## post cites for Last 50 Posts pages: + * - Get minimum post_no in thread, go through all post.body and use regex on links + * - if link is to a post within the thread and shown, alter it to CURRENT_URL#POST_NR + */ + if($isnoko50) + { + $thread_num = $this->posts[0]->id; + $min_post_num = $this->posts[1]->id; + for($i=1; $iposts); $i++) { + // Find all post links + preg_match_all('/(href="\/' . $board['uri'] . '\/res\/)([\d]*)(.html#)([\d]*)(")/', $this->posts[$i]->body, $results, PREG_PATTERN_ORDER); + // Build list of links to change + $patterns = array(); + $changes = array(); + foreach($results[4] as $key => $num) { + if(($num >= $min_post_num) || ($num == $thread_num)) { + $patterns[] = '/' . str_replace('/', '\/', preg_quote($results[0][$key])) . '/'; + $changes[] = $results[1][$key] . sprintf($config['file_page50'], $results[2][$key]) . "#" . $results[4][$key] . '"'; + } + } + // Update Links + $this->posts[$i]->body = preg_replace($patterns, $changes, $this->posts[$i]->body); + } + } + event('show-thread', $this); - + $file = ($index && $config['file_board']) ? 'post_thread_fileboard.html' : 'post_thread.html'; $built = Element($file, array('config' => $config, 'board' => $board, 'post' => &$this, 'index' => $index, 'hasnoko50' => $hasnoko50, 'isnoko50' => $isnoko50, 'mod' => $this->mod));