Installation Level: Easy
Installation Time: ~5 Minutes
Hi, this is my first MOD. I've tested it a bit, and seems to work.
Code: Select all
##############################################################
## MOD Title: Topic preview
## MOD Author: Emanuele < manu75@libero.it > (Emanuele Iannone) n/a
## MOD Description: This mod adds a pop-up window that shows the first 255 characters
## of a topic message when user moves the cursor over the title on the forum view
## MOD Version: 1.0.1
##
## Installation Level: Easy
## Installation Time: ~5 Minutes
## Files To Edit:
## /includes/functions_post.php,
## /viewforum.php,
## /templates/subSilver/viewforum_body.tpl,
##
## 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:
## NOTE: The preview will appear only for topics posted/edited AFTER the mod installation
##############################################################
## MOD History:
## 2004-09-27 - Version 1.0.1
## - Corrected the \' bug
## 2004-06-06 - Version 1.0.0
## - First release
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ SQL ]-------------------------------------------------
#
ALTER TABLE phpbb_topics ADD summary VARCHAR(255);
#
#-----[ OPEN ]------------------------------------------------
#
includes/functions_post.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : topic preview ---------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$poll_id, &$topic_type, &$bbcode_on, &$html_on, &$smilies_on, &$attach_sig, &$bbcode_uid, &$post_username, &$post_subject, &$post_message, &$poll_title, &$poll_options, &$poll_length)
{
global $board_config, $lang, $db, $phpbb_root_path, $phpEx;
global $userdata, $user_ip;
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : topic preview ---------------------------------------------------------------------------
//-- add
global $bbcode_tpl;
//-- end mod : topic preview -----------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
if ($mode == 'newtopic' || ($mode == 'editpost' && $post_data['first_post']))
{
$topic_vote = (!empty($poll_title) && count($poll_options) >= 2) ? 1 : 0;
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : topic preview ---------------------------------------------------------------------------
//-- add
//
// Generate summary from message
//
$summary=substr(str_replace("''", "'", $post_message),0,1024);
// Remove last incomplete word
if (strlen($summary) == 1024) $summary = preg_replace("/[\s][\S]+$/"," ",$summary);
// If the board has HTML off but the post has HTML on then we process it, else leave it alone
if ( !$board_config['allow_html'] && $html_on )
{
$summary = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $summary);
}
// Parse message and/or sig for BBCode if reqd
if ( $board_config['allow_bbcode'] && $bbcode_uid != '' )
{
$summary = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($summary, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $summary);
}
// Parse smilies
if ( $board_config['allow_smilies'] && $smilies_on )
{
$summary = smilies_pass($summary);
}
// Replace naughty words
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);
if (count($orig_word))
{
$summary = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $summary . '<'), 1, -1));
}
// Replace newlines (we use this rather than nl2br because till recently it wasn't XHTML compliant)
$summary = str_replace("\n", "\n<br />\n", $summary);
// Remove newlines and quotes (for javascript)
$cerca=array("/(\r|\n)/","/\"/","/[`‘’´]/"); $sost=array("",""","'");
$summary=preg_replace($cerca,$sost,$summary);
$summary=addslashes(addslashes($summary));
if (strlen($summary) > 252) {
$summary=substr($summary,0,252);
$tronca = true;
}
// Remove last word if incomplete
if (strlen($summary)==252) {
$summary=preg_replace("/[\s][\S]+$/","",$summary);
while (preg_match("/<[^>]+$/",$summary)) $summary=preg_replace("/[\s]*<[^>]+$/","",$summary);
}
if (strlen($post_message) > 1024 || $tronca) $summary.="...";
//-- end mod : topic preview -----------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
$sql = ($mode != "editpost") ? "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_vote) VALUES ('$post_subject', " . $userdata['user_id'] . ", $current_time, $forum_id, " . TOPIC_UNLOCKED . ", $topic_type, $topic_vote)" : "UPDATE " . TOPICS_TABLE . " SET topic_title = '$post_subject', topic_type = $topic_type " . (($post_data['edit_vote'] || !empty($poll_title)) ? ", topic_vote = " . $topic_vote : "") . " WHERE topic_id = $topic_id";
#
#-----[ REPLACE WITH ]----------------------------------------
#
//-- mod : topic preview ---------------------------------------------------------------------------
//-- del
// $sql = ($mode != "editpost") ? "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_vote) VALUES ('$post_subject', " . $userdata['user_id'] . ", $current_time, $forum_id, " . TOPIC_UNLOCKED . ", $topic_type, $topic_vote)" : "UPDATE " . TOPICS_TABLE . " SET topic_title = '$post_subject', topic_type = $topic_type " . (($post_data['edit_vote'] || !empty($poll_title)) ? ", topic_vote = " . $topic_vote : "") . " WHERE topic_id = $topic_id";
//-- add:
$sql = ($mode != "editpost") ? "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_vote, summary) VALUES ('$post_subject', " . $userdata['user_id'] . ", $current_time, $forum_id, " . TOPIC_UNLOCKED . ", $topic_type, $topic_vote, '".str_replace("\'", "''", $summary)."')" : "UPDATE " . TOPICS_TABLE . " SET topic_title = '$post_subject', topic_type = $topic_type " . (($post_data['edit_vote'] || !empty($poll_title)) ? ", topic_vote = " . $topic_vote : "") . ", summary = '".str_replace("\'", "''", $summary)."' WHERE topic_id = $topic_id";
//-- end mod : topic preview -----------------------------------------------------------------------
#-----[ OPEN ]------------------------------------------------
#
viewforum.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : topic preview ---------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
'TOPIC_TITLE' => $topic_title,
'TOPIC_TYPE' => $topic_type,
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : topic preview ---------------------------------------------------------------------------
//-- add
'TOPIC_SUMMARY' => $topic_rowset[$i]['summary'],
//-- end mod : topic preview -----------------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
templates/subSilver/viewforum_body.tpl
#
#-----[ FIND ]------------------------------------------------
#
# at top of the file
#
<form method="post" action="{S_POST_DAYS_ACTION}">
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
<!-- mod : topic preview -->
<DIV ID=dek style="position: absolute; visibility: hidden; Z-INDEX:200; top: 0px; left: 0px"></DIV>
<SCRIPT TYPE="text/javascript"><!--
var old,yyy=-1000,Xoffset=-60,Yoffset= 20;
if (!document.getElementById) old=true;
else {
var skn=document.getElementById('dek');
if(!document.all) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove=get_mouse;
}
function popup(msg,bak){
var content="<TABLE WIDTH=350 BORDER=1 BORDERCOLOR=#664500 CELLPADDING=2 CELLSPACING=0 "+"BGCOLOR="+bak+"><tr><TD><FONT COLOR=black SIZE=2 face=verdana>"+msg+"</FONT></TD></tr></TABLE>";
if(!old){ yyy=Yoffset; skn.innerHTML=content; skn.style.visibility="visible"}
}
function get_mouse(e){
var x=(document.all)?event.x+document.body.scrollLeft:e.pageX;
var y=(document.all)?event.y+document.body.scrollTop:e.pageY;
skn.style.left=x+Xoffset; skn.style.top=y+yyy;
}
function kill(){ if(!old){yyy=-1000;skn.style.visibility="hidden";} }
//--></SCRIPT>
#
#-----[ FIND ]------------------------------------------------
#
<td class="row1" width="100%"><span class="topictitle">{topicrow.NEWEST_POST_IMG}{topicrow.TOPIC_TYPE}<a href="{topicrow.U_VIEW_TOPIC}" class="topictitle">{topicrow.TOPIC_TITLE}</a></span><span class="gensmall"><br />
#
#-----[ IN-LINE FIND ]----------------------------------------
#
<a href="{topicrow.U_VIEW_TOPIC}" class="topictitle"
#
#-----[ IN-LINE AFTER, ADD ]--------------------------------
#
ONMOUSEOVER="popup('{topicrow.TOPIC_SUMMARY}','#FFCC66')" ONMOUSEOUT="kill()"
#
#-----[ SAVE/CLOSE ALL FILES ]--------------------------------
#
# EoM