########################################################################################################################### ## MOD Title: Topic Preview ## MOD Version: 1.5.2 ## MOD Author: Logeen [www.kurshtml.edu.pl] ## MOD Description: Podczas przegladania listy tematow wyswietla w "dymku" narzedziowym poczatek pierwszego postu w temacie. ## Installation Level: Easy ## Installation Time: 5-10 Minutes ## ## Files To Edit: 5 ## includes/functions.php ## templates/subSilver/search_results_topics.tpl ## templates/subSilver/viewforum_body.tpl ## search.php ## viewforum.php ## ########################################################################################################################### # #-----[ OPEN ]-------------------------------- # includes/functions.php # #-----[ FIND ]-------------------------------- # ?> # #-----[ BEFORE, ADD ]-------------------------------- # ////////// TOPIC PREVIEW define('TOPIC_PREVIEW_LENGTH', 200); // Maximum number of characters to preview function topic_preview($post_text, $words=array(), $replacements=array()) { static $orig_word = null; static $replacement_word = null; if ($orig_word === null && $replacement_word === null) { if (count($words) && count($replacements)) { $orig_word = $words; $replacement_word = $replacements; } else obtain_word_list($orig_word, $replacement_word); } $post_text_strlen = strlen($post_text); $post_text = preg_replace('/\[\/?.{1,255}(\]|$)/U', ' ', $post_text); $post_text = preg_replace('/:[^ \t\r\n]+:/iU', ' ', $post_text); $post_text = preg_replace('/[ \t\r\n]+/', ' ', $post_text); if (count($orig_word)) $post_text = preg_replace($orig_word, $replacement_word, $post_text); if ($post_text_strlen == TOPIC_PREVIEW_LENGTH*1.5 || strlen($post_text) > TOPIC_PREVIEW_LENGTH) { if (strlen($post_text) > TOPIC_PREVIEW_LENGTH) $post_text = substr($post_text, 0, TOPIC_PREVIEW_LENGTH); if (false !== ($pos = strrpos($post_text, ' '))) $post_text = substr($post_text, 0, $pos); $post_text .= '...'; } $post_text = htmlspecialchars(trim($post_text)); return $post_text; } ////////// /TOPIC PREVIEW # #-----[ OPEN ]-------------------------------- # templates/subSilver/search_results_topics.tpl # #-----[ FIND ]-------------------------------- # >{searchresults.TOPIC_TITLE} # #-----[ BEFORE, ADD ]-------------------------------- # title="{searchresults.TOPIC_PREVIEW}" # #-----[ OPEN ]-------------------------------- # templates/subSilver/viewforum_body.tpl # #-----[ FIND ]-------------------------------- # >{topicrow.TOPIC_TITLE} # #-----[ BEFORE, ADD ]-------------------------------- # title="{topicrow.TOPIC_PREVIEW}" # #-----[ OPEN ]-------------------------------- # search.php # #-----[ FIND ]-------------------------------- # $sql = "SELECT t.*, f.forum_id, f.forum_name, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2 WHERE t.topic_id IN ($search_results) AND t.topic_poster = u.user_id AND f.forum_id = t.forum_id AND p.post_id = t.topic_first_post_id AND p2.post_id = t.topic_last_post_id AND u2.user_id = p2.poster_id"; # #-----[ REPLACE WITH ]-------------------------------- # $sql = "SELECT t.*, f.forum_id, f.forum_name, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time, LEFT(pt.post_text," . (TOPIC_PREVIEW_LENGTH*1.5) . ") AS post_text FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2, " . POSTS_TEXT_TABLE . " pt WHERE t.topic_id IN ($search_results) AND t.topic_poster = u.user_id AND f.forum_id = t.forum_id AND p.post_id = t.topic_first_post_id AND p.post_id = pt.post_id AND p2.post_id = t.topic_last_post_id AND u2.user_id = p2.poster_id"; # #-----[ FIND ]-------------------------------- # 'TOPIC_TYPE' => $topic_type, # #-----[ BEFORE, ADD ]-------------------------------- # ////////// TOPIC PREVIEW 'TOPIC_PREVIEW' => topic_preview($searchset[$i]['post_text'], $orig_word, $replacement_word), ////////// /TOPIC PREVIEW # #-----[ OPEN ]-------------------------------- # viewforum.php # #-----[ FIND ]-------------------------------- # $sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_time, p.post_username FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . USERS_TABLE . " u2 WHERE t.forum_id = $forum_id AND t.topic_poster = u.user_id AND p.post_id = t.topic_last_post_id AND p.poster_id = u2.user_id AND t.topic_type = " . POST_ANNOUNCE . " ORDER BY t.topic_last_post_id DESC "; # #-----[ REPLACE WITH ]-------------------------------- # $sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_time, p.post_username, LEFT(pt.post_text," . (TOPIC_PREVIEW_LENGTH*1.5) . ") AS post_text FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p0, " . POSTS_TEXT_TABLE . " pt, " . USERS_TABLE . " u2 WHERE t.forum_id = $forum_id AND t.topic_poster = u.user_id AND p.post_id = t.topic_last_post_id AND p.poster_id = u2.user_id AND p0.post_id = t.topic_first_post_id AND p0.post_id = pt.post_id AND t.topic_type = " . POST_ANNOUNCE . " ORDER BY t.topic_last_post_id DESC "; # #-----[ FIND ]-------------------------------- # $sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2 WHERE t.forum_id = $forum_id AND t.topic_poster = u.user_id AND p.post_id = t.topic_first_post_id AND p2.post_id = t.topic_last_post_id AND u2.user_id = p2.poster_id AND t.topic_type <> " . POST_ANNOUNCE . " $limit_topics_time ORDER BY t.topic_type DESC, t.topic_last_post_id DESC LIMIT $start, ".$board_config['topics_per_page']; # #-----[ REPLACE WITH ]-------------------------------- # $sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, LEFT(pt.post_text," . (TOPIC_PREVIEW_LENGTH*1.5) . ") AS post_text, p2.post_username AS post_username2, p2.post_time FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TEXT_TABLE . " pt, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2 WHERE t.forum_id = $forum_id AND t.topic_poster = u.user_id AND p.post_id = t.topic_first_post_id AND p.post_id = pt.post_id AND p2.post_id = t.topic_last_post_id AND u2.user_id = p2.poster_id AND t.topic_type <> " . POST_ANNOUNCE . " $limit_topics_time ORDER BY t.topic_type DESC, t.topic_last_post_id DESC LIMIT $start, ".$board_config['topics_per_page']; # #-----[ FIND ]-------------------------------- # 'TOPIC_TYPE' => $topic_type, # #-----[ BEFORE, ADD ]-------------------------------- # ////////// TOPIC PREVIEW 'TOPIC_PREVIEW' => topic_preview($topic_rowset[$i]['post_text'], $orig_word, $replacement_word), ////////// /TOPIC PREVIEW # #-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ # # EoM