allanhardy wrote: While I liek this mod I had to disable the tooltips functionality, it simpley added to much time to page builds, users with dialup connections complained and even those with broadband didn't like the overhead.
Code: Select all
## EasyMod 0.0.10a compliant
#################################################################
## MOD Title: Mouse hover topic preview
## MOD Author: Shannado <sven@shannado.nl> (Sven) http://www.shannado.nl/forumorg
## MOD Description: With this MOD an user can see preview, when he/she holds the mouse over the topic in viewforum
## It showes the first 200 characters of the LAST post.In the HOWTO is also described how to
## preview the FIRST post instead of the LAST Post.
## Also in the search result screen you can preview the post (only when viewing topics)
## MOD Version: 1.0.7
##
## Installation Level: Easy
## Installation Time: 5 Minutes
## Files To Edit: viewforum.php,
## viewforum_body.tpl,
## bbcode.php
## Included Files: N/A
##############################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered
## in our MOD-Database, located at: http://www.phpbb.com/mods/
##############################################################
## Author Notes:
## I have set a limit (200) on the number of characters show in the preview. You can adjust is yourself to anynumber.
## Replace the '200' with your number. In the following code lines:
## $topic_content = $topic_rowset[$i]['post_text'];
##
## if (strlen($topic_content) > 200)
## {
## $topic_content = substr($topic_content, 0, 200) . "...";
## }
## else
## {
## $topic_content = $topic_content;
## }
##
##
## If you want to preview the first post instead of the last. change the next lines in viewforum.php
## after you completed the HOW TO.
##
##
## [ _F I N D_ ]
##
## AND p.post_id = pt.post_id
##
## [ _R E P L A C E W I T H_ ]
##
## AND t.topic_first_post_id = pt.post_id
##
##
## [ _F I N D_ ]
## AND p2.post_id = t.topic_last_post_id
## AND p2.post_id = pt.post_id
##
## [ _R E P L A C E W I T H_ ]
## AND p2.post_id = t.topic_last_post_id
## AND p.post_id = pt.post_id
##
## Known Issues:
## - Smilies & HTML code visible in preview
##
##############################################################
## MOD History:
##
## ------------
## 01-01-2002 - 0.9.0 beta
## - Beta
##
## 01-01-2002 - 0.9.1 beta
## - BBCode was visible in the preview. BBCode will be stripped now
##
## 01-01-2002 - 0.9.2 beta
## - Forgot the adjust the SQL statements
##
## 01-01-2002 - 0.9.3 beta
## - Author notes extended with HOWTO preview always the first post
##
## 01-01-2002 - 1.0.0 FINAL
## - Final
##
## 01-01-2002 - 1.0.1 FINAL
## - Fixed preview FIRST post Announcement. The Annoucement disappear in the viewforum.
## The Authors Notes theerfor have been adjusted.
##
## 01-01-2002 - 1.0.2 FINAL
## - Fixed typo in the HOWTO of the preview of the FIRST post
##
## 01-01-2002 - 1.0.3 FINAL
## - Adjusted (make shorter) the strip_bbcode function in the bbcode.php file
##
## 01-01-2002 - 1.0.4 FINAL
## - Text with double quotes was not displayed correctly
##
## 01-01-2002 - 1.0.5 FINAL
## - Added to preview to the search result page (only when viewing topics)
##
## 01-01-2002 - 1.0.6 FINAL
## - Made phpBB v2.0.2 complaint and EasyMod 0.0.7 complaint
##
## 05-12-2003 - 1.0.7 FINAL
## - Made phpBB v2.0.6 complaint and EasyMod 0.0.10a complaint
## - Adjusted to the new Template
#################################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
#################################################################
#
#-----[ OPEN ]------------------------------------------
#
includes/bbcode.php
#
#-----[ FIND ]------------------------------------------
#
?>
#
#-----[ BEFORE, ADD ]------------------------------------------
#
//
// Mouse hover topic preview MOD - BEGIN
//
function bbencode_strip($message, $uid)
{
$message = strip_tags($message);
// url #2
$message = str_replace("[url]","", $message);
$message = str_replace("[/url]", "", $message);
// url /\[url=([a-z0-9\-\.,\?!%\*_\/:;~\\&$@\/=\+]+)\](.*?)\[/url\]/si
$message = preg_replace("/\[url=([a-z0-9\-\.,\?!%\*_\/:;~\\&$@\/=\+]+)\]/si", "", $message);
$message = str_replace("[/url:$uid]", "", $message);
$message = preg_replace("/\[.*?:$uid:?.*?\]/si", '', $message);
$message = preg_replace('/\[url\]|\[\/url\]/si', '', $message);
$message = str_replace('"', "'", $message);
return $message;
}
//
// Mouse hover topic preview MOD - END
//
#
#-----[ OPEN ]------------------------------------------
#
viewforum.php
#
#-----[ FIND ]------------------------------------------
#
include($phpbb_root_path . 'common.'.$phpEx);
#
#-----[ AFTER, ADD ]------------------------------------------ !!!!!!!!!!!!!!!!!!!
#
include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
#
#-----[ FIND ]------------------------------------------
#
//
// All announcement data, this keeps announcements
// on each viewforum page ...
//
$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 . "
#
#-----[ REPLACE WITH ]------------------------------------------
#
//
// All announcement data, this keeps announcements
// on each viewforum page ...
//
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_time, p.post_username, pt.post_text, pt.bbcode_uid
FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . USERS_TABLE . " u2, " . POSTS_TEXT_TABLE . " pt
WHERE t.forum_id = $forum_id
AND t.topic_poster = u.user_id
AND p.post_id = t.topic_last_post_id
AND p.post_id = pt.post_id
AND p.poster_id = u2.user_id
AND t.topic_type = " . POST_ANNOUNCE . "
#
#-----[ FIND ]------------------------------------------
#
//
// Grab all the basic data (all topics except announcements)
// for this forum
//
$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 . "
#
#-----[ REPLACE WITH ]------------------------------------------
#
//
// Grab all the basic data (all topics except announcements)
// for this forum
//
$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, pt.post_text, pt.bbcode_uid
FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2, " . POSTS_TEXT_TABLE . " pt
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 p2.post_id = pt.post_id
AND u2.user_id = p2.poster_id
AND t.topic_type <> " . POST_ANNOUNCE . "
#
#-----[ FIND ]------------------------------------------
#
$topic_title = ( count($orig_word) ) ? preg_replace($orig_word, $replacement_word, $topic_rowset[$i]['topic_title']) : $topic_rowset[$i]['topic_title'];
#
#-----[ AFTER, ADD ]------------------------------------------
#
//
// Mouse hover topic preview MOD - BEGIN
//
$topic_content = $topic_rowset[$i]['post_text'];
$bbcode_uid = $topic_rowset[$i]['bbcode_uid'];
$topic_content = bbencode_strip($topic_content, $bbcode_uid);
if (strlen($topic_content) > 200)
{
$topic_content = substr($topic_content, 0, 200) . "...";
}
else
{
$topic_content = $topic_content;
}
//
// Mouse hover topic preview MOD - END
//
#
#-----[ FIND ]------------------------------------------
#
'TOPIC_TITLE' => $topic_title,
#
#-----[ AFTER, ADD ]------------------------------------------
#
'TOPIC_CONTENT' => $topic_content,
#
#-----[ OPEN ]------------------------------------------
#
templates/SubSilver/viewforum_body.tpl
#
#-----[ FIND ]------------------------------------------
#
<td class="row1" width="100%">
#
#-----[ IN-LINE FIND ]------------------------------------------
#
>{topicrow.TOPIC_TITLE}
#
#-----[ IN-LINE BEFORE, ADD ]------------------------------------------
#
title="{topicrow.TOPIC_CONTENT}"
#
#-----[ 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 pt.post_text, 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, " . 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 pt.post_id = p.post_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";
#
#-----[ FIND ]------------------------------------------
#
$views = $searchset[$i]['topic_views'];
$replies = $searchset[$i]['topic_replies'];
#
#-----[ AFTER, ADD ]------------------------------------------
#
//
// Mouse hover topic preview MOD - BEGIN
//
$topic_content = $searchset[$i]['post_text'];
$bbcode_uid = $searchset[$i]['bbcode_uid'];
$topic_content = bbencode_strip($topic_content, $bbcode_uid);
if (strlen($topic_content) > 200)
{
$topic_content = substr($topic_content, 0, 200) . "...";
}
else
{
$topic_content = $topic_content;
}
//
// Mouse hover topic preview MOD - END
//
#
#-----[ FIND ]------------------------------------------
#
'TOPIC_TITLE' => $topic_title,
#
#-----[ AFTER, ADD ]------------------------------------------
#
'TOPIC_CONTENT' => $topic_content,
#
#-----[ OPEN ]------------------------------------------
#
templates/SubSilver/search_results_topics.tpl
#
#-----[ FIND ]------------------------------------------
#
<td class="row2"><span class="topictitle">{searchresults.NEWEST_POST_IMG}{searchresults.TOPIC_TYPE}<a href="{searchresults.U_VIEW_TOPIC}" class="topictitle">{searchresults.TOPIC_TITLE}</a></span><br /><span class="gensmall">{searchresults.GOTO_PAGE}</span></td>
#
#-----[ REPLACE WITH ]------------------------------------------
#
<td class="row2"><span class="topictitle">{searchresults.NEWEST_POST_IMG}{searchresults.TOPIC_TYPE}<a href="{searchresults.U_VIEW_TOPIC}" class="topictitle" title="{searchresults.TOPIC_CONTENT}">{searchresults.TOPIC_TITLE}</a></span><br /><span class="gensmall">{searchresults.GOTO_PAGE}</span></td>
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
Swizec wrote: The reason why tooltips are slow with this mod is the parsing.
Just switch off BBcode in them and half the problem should be removed.
If I find the time I'll tinker with this to get it working with AJAX, have made different tooltips get data from ajax before, should be possible to make it work with this.
If I have the time... will see.
Code: Select all
$lang['desc_bbcode_remove'] = 'Completely remove BBCode that is in the hatelist';
Swizec wrote: It will slow a bit because of the str_replace
But don't put bbcode into the hatelist, just set "Parse tooltips as normal posts" to No. That way the tooltips are just fetched and printed without any mumbo jumbo.
Another big resource hog is the permission checking... but doubt that could be made any faster than it is... (it doesn't add any queries unless you make it do groups if I remember correctly)
Makc666 wrote:Swizec wrote:Done some coding on the mod and it woudl seem that by not too complicated of trickage I've shaved 200 sql queries (for a 50 topic forum) down to 6.
AJAX might not even be needed after this...
When we will be able to download?
Code: Select all
admin_forumauth.php
'auth_announce' => $lang['Announce'],
'auth_vote' => $lang['Vote'],
'auth_pollcreate' => $lang['Pollcreate'],
// mod topic description mod add
'auth_desc' => $lang['desc'],
'auth_moddesc' => $lang['moddesc'],
'auth_tooltip' => $lang['tooltip']); <--------------- LINE 74
// mod topic description mod end
$forum_auth_levels = array('ALL', 'REG', 'PRIVATE', 'MOD', 'ADMIN');
$forum_auth_const = array(AUTH_ALL, AUTH_REG, AUTH_ACL, AUTH_MOD, AUTH_ADMIN);
Code: Select all
page_header_admin.php
'T_SPAN_CLASS3' => $theme['span_class3'])
);
// Work around for "current" Apache 2 + PHP module which seems to not
// cope with private cache control setting
if (!empty($HTTP_SERVER_VARS['SERVER_SOFTWARE']) && strstr($HTTP_SERVER_VARS['SERVER_SOFTWARE'], 'Apache/2'))
{
header ('Cache-Control: no-cache, pre-check=0, post-check=0'); <--------- LINE 139
}
else
{
header ('Cache-Control: private, pre-check=0, post-check=0, max-age=0');
}
header ('Expires: 0');
Code: Select all
page_header_admin.php
header ('Cache-Control: no-cache, pre-check=0, post-check=0');
}
else
{
header ('Cache-Control: private, pre-check=0, post-check=0, max-age=0');
}
header ('Expires: 0'); <--------------- LINE 145
header ('Pragma: no-cache');
$template->pparse('header');
?>
Code: Select all
page_header_admin.php
header ('Cache-Control: no-cache, pre-check=0, post-check=0');
}
else
{
header ('Cache-Control: private, pre-check=0, post-check=0, max-age=0');
}
header ('Expires: 0');
header ('Pragma: no-cache'); <--------------- LINE 146
$template->pparse('header');
?>
Swizec wrote: Sorry to break this to you, but I'm fairly certain all those have been fixed in the update (which isn't yet availbable in the MODDB) but if you could hold on for a few days an even never update will be released on my website and should be on it's way to the MODDB soon after.
Oh and welcome to phpbb ^^