Archives FluxBB.fr

Les archives de FluxBB.fr

Vous n'êtes pas identifié(e).

#1 23-12-2011 01:16:40

Muz1k4l
Membre

Demande d'adaptation à fluxbb 1.4.7 (Topic Images)

Bonjour , Bonsoir ,

Je ouvre ce topic pour demander un adaptation d'un ancien mod punbb 1.2.x "Topic Image" pour qu'il marche en 1.4.7.
J'ai essayer de l'adapter moi même mais je n'ai guère réussit , je suis rester bloquer à l'étape "8" ...

##
##
##        Mod title:  Topic Image
##
##      Mod version:  1.0
##   Works on PunBB:  1.2.x
##     Release date:  2008-10-24
##           Author:  downliner ( willvilliers.com/forum.php )
##
##      Description:  Display an image on viewforum.php with each topic.
##			    Similiar to Topic Icons only this allows any image URL to be entered and displayed.
##
##   Affected files:  post.php
##			    lang/English/common.php
##			    edit.php
##			    viewforum.php
##
##       Affects DB:  Yes. Adds one column to 'topics'.
##
##            Notes:  PLEASE BACKUP THE ABOVE 4 LISTED FILES BEFORE INSTALLING THIS MOD!
##			    IF YOU'RE UNCOMFORTABLE INSTALLING MODS/EDITING CODE DROP ME AN EMAIL :)
##
##       DISCLAIMER:  Please note that "mods" are not officially supported by
##                    PunBB. Installation of this modification is done at your
##                    own risk. Backup your forum database and any and all
##                    applicable files before proceeding.
##
##


#
#---------[x. UPLOAD ]----------------------------------------------
#

install_mod.php


#
#---------[x. RUN ]----------------------------------------------
#

install_mod.php


#
#---------[x. DELETE ]----------------------------------------------
#

install_mod.php


#
#---------[ 1. OPEN ]----------------------------------------------------------
#

post.php

#
#---------[ 2. FIND (line:41) ]----------------------------------------------------------
#

if ($tid)
	$result = $db->query('SELECT f.id, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics, t.subject, t.closed FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$tid) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());
else

#
#---------[ 3. REPLACE WITH ]----------------------------------------------------------
#

if ($tid)
	$result = $db->query('SELECT f.id, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics, t.subject, t.topicimage, t.closed FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$tid) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());
else

#
#---------[ 4. FIND (line:93) ]----------------------------------------------------------
#

		else if ($pun_config['p_subject_all_caps'] == '0' && strtoupper($subject) == $subject && $pun_user['g_id'] > PUN_MOD)
			$subject = ucwords(strtolower($subject));

#
#---------[ 5. ADD AFTER !!! ]----------------------------------------------------------
#

			$topicimage = $_POST['topicimage'];

#
#---------[ 6. FIND (line:287) ]----------------------------------------------------------
#

			// Create the topic
			$db->query('INSERT INTO '.$db->prefix.'topics (poster, subject, posted, last_post, last_poster, forum_id) VALUES(\''.$db->escape($username).'\', \''.$db->escape($subject).'\', '.$now.', '.$now.', \''.$db->escape($username).'\', '.$fid.')') or error('Unable to create topic', __FILE__, __LINE__, $db->error());

#
#---------[ 7. REPLACE WITH ]----------------------------------------------------------
#

			// Create the topic
			$db->query('INSERT INTO '.$db->prefix.'topics (poster, subject, posted, last_post, last_poster, forum_id, topicimage) VALUES(\''.$db->escape($username).'\', \''.$db->escape($subject).'\', '.$now.', '.$now.', \''.$db->escape($username).'\', '.$fid.', \''.$db->escape($topicimage).'\')') or error('Unable to create topic', __FILE__, __LINE__, $db->error());

#
#---------[ 8. FIND (line:491) ]----------------------------------------------------------
#

if ($fid): ?>
						<label><strong><?php echo $lang_common['Subject'] ?></strong><br /><input class="longinput" type="text" name="req_subject" value="<?php if (isset($_POST['req_subject'])) echo pun_htmlspecialchars($subject); ?>" size="80" maxlength="70" tabindex="<?php echo $cur_index++ ?>" /><br /></label>
<?php endif; ?>						<label><strong><?php echo $lang_common['Message'] ?></strong><br />


#
#---------[ 9. REPLACE WITH !!! ]----------------------------------------------------------
#

if ($fid): ?>
						<label><strong><?php echo $lang_common['Subject'] ?></strong><br /><input class="longinput" type="text" name="req_subject" value="<?php if (isset($_POST['req_subject'])) echo pun_htmlspecialchars($subject); ?>" size="80" maxlength="70" tabindex="<?php echo $cur_index++ ?>" /><br /></label>
<?php endif; ?>

<?php 
if ($fid AND $pun_user['g_id'] == 1): ?>
						<label><strong><?php echo $lang_common['TopicImage'] ?></strong><br /><input class="longinput" type="text" name="topicimage" value="<?php if (isset($_POST['topicimage'])) echo pun_htmlspecialchars($topicimage); ?>" size="80" /><br /></label>
<?php endif; ?>						<label><strong><?php echo $lang_common['Message'] ?></strong><br />


#
#---------[ 10. OPEN ]----------------------------------------------------------
#

lang/English/common.php

#
#---------[ 11. FIND (line: 78) ]----------------------------------------------------------
#

'Subject'				=>	'Subject',

#
#---------[ 12. ADD AFTER !!! ]----------------------------------------------------------
#

'TopicImage'				=>	'Topic Image URL',

#
#---------[ 13. OPEN ]----------------------------------------------------------
#

edit.php

#
#---------[ 14. FIND (line:39) ]----------------------------------------------------------
#

// Fetch some info about the post, the topic and the forum
$result = $db->query('SELECT f.id AS fid, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics, t.id AS tid, t.subject, t.posted, t.closed, p.poster, p.poster_id, p.message, p.hide_smilies FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND p.id='.$id) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());

#
#---------[ 15. REPLACE WITH ]----------------------------------------------------------
#

// Fetch some info about the post, the topic and the forum
$result = $db->query('SELECT f.id AS fid, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics, t.id AS tid, t.subject, t.topicimage, t.posted, t.closed, p.poster, p.poster_id, p.message, p.hide_smilies FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND p.id='.$id) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());

#
#---------[ 16. FIND (line:84) ]----------------------------------------------------------
#

		else if ($pun_config['p_subject_all_caps'] == '0' && strtoupper($subject) == $subject && $pun_user['g_id'] > PUN_MOD)
			$subject = ucwords(strtolower($subject));

#
#---------[ 17. ADD AFTER !!! ]----------------------------------------------------------
#

			$topicimage = $_POST['topicimage'];

#
#---------[ 18. FIND (line:117) ]----------------------------------------------------------
#

			// Update the topic and any redirect topics
			$db->query('UPDATE '.$db->prefix.'topics SET subject=\''.$db->escape($subject).'\' WHERE id='.$cur_post['tid'].' OR moved_to='.$cur_post['tid']) or error('Unable to update topic', __FILE__, __LINE__, $db->error());

#
#---------[ 19. ADD AFTER !!! ]----------------------------------------------------------
#

			// Update the topic image?
			$db->query('UPDATE '.$db->prefix.'topics SET topicimage=\''.$db->escape($topicimage).'\' WHERE id='.$cur_post['tid']) or error('Unable to update topic image', __FILE__, __LINE__, $db->error());

#
#---------[ 20. FIND (line:209) ]----------------------------------------------------------
#

<?php if ($can_edit_subject): ?>						<label><?php echo $lang_common['Subject'] ?><br />
						<input class="longinput" type="text" name="req_subject" size="80" maxlength="70" tabindex="<?php echo $cur_index++ ?>" value="<?php echo pun_htmlspecialchars(isset($_POST['req_subject']) ? $_POST['req_subject'] : $cur_post['subject']) ?>" /><br /></label>
<?php endif; ?>						<label><?php echo $lang_common['Message'] ?><br />

#
#---------[ 21. REPLACE WITH ]----------------------------------------------------------
#

<?php if ($can_edit_subject): ?>						<label><?php echo $lang_common['Subject'] ?><br />
						<input class="longinput" type="text" name="req_subject" size="80" maxlength="70" tabindex="<?php echo $cur_index++ ?>" value="<?php echo pun_htmlspecialchars(isset($_POST['req_subject']) ? $_POST['req_subject'] : $cur_post['subject']) ?>" /><br /></label>
<?php endif; ?>
<?php 

if ($pun_user['g_id'] == 1): ?>
						<label><strong><?php echo $lang_common['TopicImage'] ?></strong><br />
						<input class="longinput" type="text" name="topicimage" size="80" maxlength="70" tabindex="<?php echo $cur_index++ ?>" value="<?php echo pun_htmlspecialchars(isset($_POST['topicimage']) ? $_POST['topicimage'] : $cur_post['topicimage']) ?>" /><br /></label>
<?php endif; ?>						<label><?php echo $lang_common['Message'] ?><br />


#
#---------[ 22. OPEN ]----------------------------------------------------------
#

viewforum.php


#
#---------[ 23. FIND (line:112) ]----------------------------------------------------------
#

	// Without "the dot"
	$sql = 'SELECT id, poster, subject, posted, last_post, last_post_id, last_poster, num_views, num_replies, closed, sticky, moved_to FROM '.$db->prefix.'topics WHERE forum_id='.$id.' ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];


#
#---------[ 24. REPLACE WITH ]----------------------------------------------------------
#

	// Without "the dot"
	$sql = 'SELECT id, poster, subject, posted, last_post, last_post_id, last_poster, num_views, num_replies, closed, sticky, moved_to, topicimage FROM '.$db->prefix.'topics WHERE forum_id='.$id.' ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];

#
#---------[ 25. FIND (line:122) ]----------------------------------------------------------
#

		case 'mysqli':
			$sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.forum_id='.$id.' GROUP BY t.id ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
			break;

#
#---------[ 26. REPLACE WITH ]----------------------------------------------------------
#

		case 'mysqli':
			$sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, t.topicimage FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.forum_id='.$id.' GROUP BY t.id ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
			break;

#
#---------[ 27. FIND (line:126) ]----------------------------------------------------------
#

		case 'sqlite':
			$sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.id IN(SELECT id FROM '.$db->prefix.'topics WHERE forum_id='.$id.' ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'].') GROUP BY t.id ORDER BY t.sticky DESC, t.last_post DESC';
			break;

#
#---------[ 28. REPLACE WITH ]----------------------------------------------------------
#

		case 'sqlite':
			$sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, t.topicimage FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.id IN(SELECT id FROM '.$db->prefix.'topics WHERE forum_id='.$id.' ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'].') GROUP BY t.id ORDER BY t.sticky DESC, t.last_post DESC';
			break;

#
#---------[ 29. FIND (line:130) ]----------------------------------------------------------
#

		default:
			$sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.forum_id='.$id.' GROUP BY t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, p.poster_id ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
			break;

#
#---------[ 30. REPLACE WITH ]----------------------------------------------------------
#

		default:
			$sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, t.topicimage FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.forum_id='.$id.' GROUP BY t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, t.topicimage, p.poster_id ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
			break;

#
#---------[ 31. FIND (line:206) ]----------------------------------------------------------
#

?>
				<tr<?php if ($item_status != '') echo ' class="'.trim($item_status).'"'; ?>>

#
#---------[ 32. ADD BEFORE !!! ]----------------------------------------------------------
#

		if ($topicimage != '')
			$topicimage = '<a href="viewtopic.php?id='.$cur_topic['id'].'" title="'.pun_htmlspecialchars($cur_topic['subject']).'"><img src="'.pun_htmlspecialchars($cur_topic['topicimage']).'" alt="'.pun_htmlspecialchars($cur_topic['subject']).'" class="topicimage" /></a>';
		else
		{
			$topicimage = '&nbsp;';
		}




#
#---------[ 33. FIND (line:213) ]----------------------------------------------------------
#

								<?php echo $subject."\n" ?>


#
#---------[ 34. ADD BEFORE !!! ]----------------------------------------------------------
#

								<?php echo $topicimage ?>

#
#---------[ 35. OPEN ]----------------------------------------------------------
#

style/YOUR_STYLE.css


#
#---------[ 36. ADD TO THE VERY BOTTOM OF FILE ]-------------------------------------------------
#

.topicimage {	float: right;
			width:75px;
			height: 50px;
			padding: 1px;
			border: 1px solid! important;
			margin-left: 10px ! important;}


#--------------[ NOTE ]-------------------------------------------------------------------------------------#
#																		#
# You must repeat steps 33 and 34 for each stylesheet your site offers (i.e Oxygen, Sulfur, etc)		#
#																		#
# During step 34 please ensure that the preceeding style declaration contains its closing curly bracket.	#
# If using a default style (i.e Oxygen) then you should be adding the code in step 34 directly below :	#
# 																		#
#                    TD DIV.tclcon {MARGIN-LEFT: 2.3em}									#
#																		#
#-----------------------------------------------------------------------------------------------------------#


#
#---------[ 37. SAVE & UPLOAD ]-------------------------------------------------
#

Lien de téléchargement

Si j'ai ouvert ce topic dans la mauvaise section je m'excuse d'avance pour l'éventuelle erreur faites.
Si part hasard les demandes d'adaptation son internet je m'en excuse aussi.

Je remercie les développer , et je remercie d'avance pour quelconque aide pour cette adaptation.

Merci d'avance, Amicalement.

Hors ligne

#2 23-12-2011 19:28:39

Wan
Membre

Re : Demande d'adaptation à fluxbb 1.4.7 (Topic Images)

Bonjour !

Le fichier install_mod.php :

<?php
/***********************************************************************/

// Some info about your mod.
$mod_title      = 'Topic Image';
$mod_version    = '1.1';
$release_date   = '2011-12-23';
$author         = 'Wan';
$author_email   = 'Wan@cara-vintage.com';

// Versions of FluxBB this mod was created for. A warning will be displayed, if versions do not match
$fluxbb_versions= array('1.4.7');

// Set this to false if you haven't implemented the restore function (see below)
$mod_restore	= true;


// This following function will be called when the user presses the "Install" button
function install()
{
	global $db, $db_type, $pun_config, $mod_version;
	
	$db->add_field('topics', 'topicimage', 'VARCHAR(255)', FALSE, "", 'subject', NULL);

	// and now, update the cache...
	require_once PUN_ROOT.'include/cache.php';
	generate_config_cache();
}

// This following function will be called when the user presses the "Restore" button (only if $mod_restore is true (see above))
function restore()
{
	global $db, $db_type, $pun_config;
	
	$db->drop_field('topics', 'topicimage');

	// and now, update the cache...
	require_once PUN_ROOT.'include/cache.php';
	generate_config_cache();
}

/***********************************************************************/

// DO NOT EDIT ANYTHING BELOW THIS LINE!


// Circumvent maintenance mode
define('PUN_TURN_OFF_MAINT', 1);
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';

// We want the complete error message if the script fails
if (!defined('PUN_DEBUG'))
	define('PUN_DEBUG', 1);

// Make sure we are running a FluxBB version that this mod works with
$version_warning = !in_array($pun_config['o_cur_version'], $fluxbb_versions);

$style = (isset($pun_user)) ? $pun_user['style'] : $pun_config['o_default_style'];

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo pun_htmlspecialchars($mod_title) ?> installation</title>
<link rel="stylesheet" type="text/css" href="style/<?php echo $style.'.css' ?>" />
</head>
<body>

<div id="punwrap">
<div id="puninstall" class="pun" style="margin: 10% 20% auto 20%">

<?php

if (isset($_POST['form_sent']))
{
	if (isset($_POST['install']))
	{
		// Run the install function (defined above)
		install();

?>
<div class="block">
	<h2><span>Installation successful</span></h2>
	<div class="box">
		<div class="inbox">
			<p>Your database has been successfully prepared for <?php echo pun_htmlspecialchars($mod_title) ?>. See readme.txt for further instructions.</p>
		</div>
	</div>
</div>
<?php

	}
	else
	{
		// Run the restore function (defined above)
		restore();

?>
<div class="block">
	<h2><span>Restore successful</span></h2>
	<div class="box">
		<div class="inbox">
			<p>Your database has been successfully restored.</p>
		</div>
	</div>
</div>
<?php

	}
}
else
{

?>
<div class="blockform">
	<h2><span>Mod installation</span></h2>
	<div class="box">
		<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>?foo=bar">
			<div><input type="hidden" name="form_sent" value="1" /></div>
			<div class="inform">
				<p>This script will update your database to work with the following modification:</p>
				<p><strong>Mod title:</strong> <?php echo pun_htmlspecialchars($mod_title.' '.$mod_version) ?></p>
				<p><strong>Author:</strong> <?php echo pun_htmlspecialchars($author) ?> (<a href="mailto:<?php echo pun_htmlspecialchars($author_email) ?>"><?php echo pun_htmlspecialchars($author_email) ?></a>)</p>
				<p><strong>Disclaimer:</strong> Mods are not officially supported by FluxBB. Mods generally can't be uninstalled without running SQL queries manually against the database. Make backups of all data you deem necessary before installing.</p>
<?php if ($mod_restore): ?>
				<p>If you've previously installed this mod and would like to uninstall it, you can click the Restore button below to restore the database.</p>
<?php endif; ?>
<?php if ($version_warning): ?>
				<p style="color: #a00"><strong>Warning:</strong> The mod you are about to install was not made specifically to support your current version of FluxBB (<?php echo $pun_config['o_cur_version']; ?>). This mod supports FluxBB versions: <?php echo pun_htmlspecialchars(implode(', ', $fluxbb_versions)); ?>. If you are uncertain about installing the mod due to this potential version conflict, contact the mod author.</p>
<?php endif; ?>
			</div>
			<p class="buttons"><input type="submit" name="install" value="Install" /><?php if ($mod_restore): ?><input type="submit" name="restore" value="Restore" /><?php endif; ?></p>
		</form>
	</div>
</div>
<?php

}

?>

</div>
</div>

</body>
</html>

Le fichier /lang/English/topicimage.php :

<?php

// Language definitions for frequently used strings
$lang_topicimage = array(

'TopicImage'				=>	'Topic Image URL',

);

Le fichier lang/French/topicimage.php :

<?php

// Language definitions for frequently used strings
$lang_attach = array(

'TopicImage'				=>	'URL de l\'image (Topic Image)',

);

Et enfin le readme.txt :

##
##
##        Mod title:  Topic Image
##
##      Mod version:  1.1
##  Works on FluxBB:  1.4.7
##     Release date:  2011-12-23
##           Author:  Wan (Wan@cara-vintage.com) based on a work by downliner (willvilliers.com/forum.php) for 1.0 version for punBB 1.2
##
##      Description:  Display an image on viewforum.php with each topic.
##			    	  Allows any image URL to be entered by an admin for being displayed on the viewforum page.
##
##   Affected files:  post.php
##			    	  edit.php
##				      viewforum.php
##					  style/YOUR_STYLE.css
##
##       Affects DB:  Yes. Adds one column to 'topics'.
##
##            Notes:  PLEASE BACKUP THE ABOVE 4 LISTED FILES BEFORE INSTALLING THIS MOD!
##
##       DISCLAIMER:  Please note that "mods" are not officially supported by
##                    FluxBB. Installation of this modification is done at your
##                    own risk. Backup your forum database and all
##                    applicable files before proceeding.
##
##


#
#---------[x. UPLOAD ]----------------------------------------------
#

files/install_mod.php to /
files/lang/English/topicimage.php to lang/English/
files/lang/French/topicimage.php to lang/French/


#
#---------[x. RUN ]----------------------------------------------
#

install_mod.php


#
#---------[x. DELETE ]----------------------------------------------
#

install_mod.php


#
#---------[ 1. OPEN ]----------------------------------------------------------
#

post.php

#
#---------[ 2. FIND (line:24) ]----------------------------------------------------------
#

	$result = $db->query('SELECT f.id, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics, t.subject, t.closed, s.user_id AS is_subscribed FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') LEFT JOIN '.$db->prefix.'topic_subscriptions AS s ON (t.id=s.topic_id AND s.user_id='.$pun_user['id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$tid) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());

#
#---------[ 3. REPLACE WITH ]----------------------------------------------------------
#

	$result = $db->query('SELECT f.id, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics, t.subject, t.topicimage, t.closed, s.user_id AS is_subscribed FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') LEFT JOIN '.$db->prefix.'topic_subscriptions AS s ON (t.id=s.topic_id AND s.user_id='.$pun_user['id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$tid) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());

#
#---------[ 4. FIND (line:69) ]----------------------------------------------------------
#

		$subject = pun_trim($_POST['req_subject']);

#
#---------[ 5. ADD AFTER !!! ]----------------------------------------------------------
#

		$topicimage = pun_trim($_POST['topicimage']);

#
#---------[ 6. FIND (line:287) ]----------------------------------------------------------
#

			$db->query('INSERT INTO '.$db->prefix.'topics (poster, subject, posted, last_post, last_poster, sticky, forum_id) VALUES(\''.$db->escape($username).'\', \''.$db->escape($subject).'\', '.$now.', '.$now.', \''.$db->escape($username).'\', '.$stick_topic.', '.$fid.')') or error('Unable to create topic', __FILE__, __LINE__, $db->error());

#
#---------[ 7. REPLACE WITH ]----------------------------------------------------------
#

			$db->query('INSERT INTO '.$db->prefix.'topics (poster, subject, topicimage, posted, last_post, last_poster, sticky, forum_id) VALUES(\''.$db->escape($username).'\', \''.$db->escape($subject).'\', \''.$db->escape($topicimage).'\', '.$now.', '.$now.', \''.$db->escape($username).'\', '.$stick_topic.', '.$fid.')') or error('Unable to create topic', __FILE__, __LINE__, $db->error());

#
#---------[ 8. FIND (line:632) ]----------------------------------------------------------
#

						<label class="required"><strong><?php echo $lang_common['Subject'] ?> <span><?php echo $lang_common['Required'] ?></span></strong><br /><input class="longinput" type="text" name="req_subject" value="<?php if (isset($_POST['req_subject'])) echo pun_htmlspecialchars($subject); ?>" size="80" maxlength="70" tabindex="<?php echo $cur_index++ ?>" /><br /></label>					<label><strong><?php echo $lang_common['Message'] ?></strong><br />

#
#---------[ 9. ADD AFTER !!! ]----------------------------------------------------------
#

<?php endif; ?>
<?php if ($fid && $pun_user['g_id'] == PUN_ADMIN): ?>
						<label><strong><?php echo $lang_topicimage['TopicImage'] ?></strong><br /><input type="text" name="topicimage" value="<?php if (isset($_POST['topicimage'])) echo pun_htmlspecialchars($topicimage); ?>" size="80" maxlength="255" tabindex="<?php echo $cur_index++ ?>" /><br /></label>


#
#---------[ 10. OPEN ]----------------------------------------------------------
#

edit.php

#
#---------[ 11. FIND (line:22) ]----------------------------------------------------------
#

$result = $db->query('SELECT f.id AS fid, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics, t.id AS tid, t.subject, t.posted, t.first_post_id, t.sticky, t.closed, p.poster, p.poster_id, p.message, p.hide_smilies FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND p.id='.$id) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());

#
#---------[ 12. REPLACE WITH ]----------------------------------------------------------
#

$result = $db->query('SELECT f.id AS fid, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics, t.id AS tid, t.subject, t.topicimage, t.posted, t.first_post_id, t.sticky, t.closed, p.poster, p.poster_id, p.message, p.hide_smilies FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND p.id='.$id) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());

#
#---------[ 13. FIND (line:62) ]----------------------------------------------------------
#

		$subject = pun_trim($_POST['req_subject']);

#
#---------[ 14. ADD AFTER !!! ]----------------------------------------------------------
#

		$topicimage = pun_trim($_POST['topicimage']);

#
#---------[ 15. FIND (line:122) ]----------------------------------------------------------
#

			$db->query('UPDATE '.$db->prefix.'topics SET subject=\''.$db->escape($subject).'\', sticky='.$stick_topic.' WHERE id='.$cur_post['tid'].' OR moved_to='.$cur_post['tid']) or error('Unable to update topic', __FILE__, __LINE__, $db->error());

#
#---------[ 16. ADD AFTER !!! ]----------------------------------------------------------
#

			// Update the topic image ?
			$db->query('UPDATE '.$db->prefix.'topics SET topicimage=\''.$db->escape($topicimage).'\' WHERE id='.$cur_post['tid']) or error('Unable to update topic image', __FILE__, __LINE__, $db->error());

#
#---------[ 17. FIND (line:221) ]----------------------------------------------------------
#

						<input class="longinput" type="text" name="req_subject" size="80" maxlength="70" tabindex="<?php echo $cur_index++ ?>" value="<?php echo pun_htmlspecialchars(isset($_POST['req_subject']) ? $_POST['req_subject'] : $cur_post['subject']) ?>" /><br /></label>

#
#---------[ 18. ADD AFTER !!! ]----------------------------------------------------------
#

<?php endif; ?>
<?php if ($pun_user['g_id'] == PUN_ADMIN): ?>
						<label><strong><?php echo $lang_topicimage['TopicImage'] ?></strong><br />
						<input type="text" name="topicimage" size="80" maxlength="255" tabindex="<?php echo $cur_index++ ?>" value="<?php echo pun_htmlspecialchars(isset($_POST['topicimage']) ? $_POST['topicimage'] : $cur_post['topicimage']) ?>" /><br /></label>

#
#---------[ 19. OPEN ]----------------------------------------------------------
#

viewforum.php


#
#---------[ 20. FIND (line:153) ]----------------------------------------------------------
#

		// Without "the dot"
		$sql = 'SELECT id, poster, subject, posted, last_post, last_post_id, last_poster, num_views, num_replies, closed, sticky, moved_to FROM '.$db->prefix.'topics WHERE id IN('.implode(',', $topic_ids).') ORDER BY sticky DESC, '.$sort_by.', id DESC';
	}
	else
	{
		// With "the dot"
		$sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.id IN('.implode(',', $topic_ids).') GROUP BY t.id'.($db_type == 'pgsql' ? ', t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, p.poster_id' : '').' ORDER BY t.sticky DESC, t.'.$sort_by.', t.id DESC';
	}


#
#---------[ 21. REPLACE WITH ]----------------------------------------------------------
#

		// Without "the dot"
		$sql = 'SELECT id, poster, subject, topicimage, posted, last_post, last_post_id, last_poster, num_views, num_replies, closed, sticky, moved_to FROM '.$db->prefix.'topics WHERE id IN('.implode(',', $topic_ids).') ORDER BY sticky DESC, '.$sort_by.', id DESC';
	}
	else
	{
		// With "the dot"
		$sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.topicimage, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.id IN('.implode(',', $topic_ids).') GROUP BY t.id'.($db_type == 'pgsql' ? ', t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, p.poster_id' : '').' ORDER BY t.sticky DESC, t.'.$sort_by.', t.id DESC';
	}

#
#---------[ 22. FIND (line:238) ]----------------------------------------------------------
#

?>
				<tr class="<?php echo $item_status ?>">

#
#---------[ 23. ADD BEFORE !!! ]----------------------------------------------------------
#

		if ($cur_topic['topicimage'] != "")
			$topicimage = '<a href="viewtopic.php?id='.$cur_topic['id'].'" title="'.pun_htmlspecialchars($cur_topic['subject']).'"><img src="'.pun_htmlspecialchars($cur_topic['topicimage']).'" alt="'.pun_htmlspecialchars($cur_topic['subject']).'" class="topicimage" /></a>';
		else
		{
			$topicimage = '&nbsp;';
		}




#
#---------[ 24. FIND (line:244) ]----------------------------------------------------------
#

								<?php echo $subject."\n" ?>


#
#---------[ 25. ADD BEFORE !!! ]----------------------------------------------------------
#

								<?php echo $topicimage ?>

#
#---------[ 26. OPEN ]----------------------------------------------------------
#

style/YOUR_STYLE.css


#
#---------[ 27. ADD TO THE VERY BOTTOM OF FILE ]-------------------------------------------------
#

/* Topic Image */
.topicimage {	float: right;
			height: 50px;
			padding: 1px;
			border: 1px solid! important;
			margin-left: 10px ! important;}


#--------------[ NOTE ]-------------------------------------------------------------------------------------#
#																		#
# You must repeat steps 26 and 27 for each stylesheet your site offers (i.e Air, Mercury, Oxygen, etc.)		#
#																		#
# During step 26 please ensure that the preceeding style declaration contains its closing curly bracket.	#
# If using a default style (i.e Oxygen) then you should be adding the code in step 34 directly below :	#
# 																		#
#                    TD DIV.tclcon {MARGIN-LEFT: 2.3em}									#
#																		#
#-----------------------------------------------------------------------------------------------------------#


#
#---------[ 37. SAVE & UPLOAD ]-------------------------------------------------
#

smile smile smile

Hors ligne

#3 26-12-2011 01:25:41

Muz1k4l
Membre

Re : Demande d'adaptation à fluxbb 1.4.7 (Topic Images)

Merci beaucoup Wan pour l'adaptation pour fluxbb 1.4.7 très rapide en plus smile

Hors ligne

#4 26-12-2011 04:09:16

Muz1k4l
Membre

Re : Demande d'adaptation à fluxbb 1.4.7 (Topic Images)

Je voulais demander aussi si il y avait une possibilité de ne pas afficher l'image sur viewforum.php mais que sur viewtopic.php ?

Dernière modification par Muz1k4l (26-12-2011 04:09:37)

Hors ligne

#5 26-12-2011 11:13:27

Wan
Membre

Re : Demande d'adaptation à fluxbb 1.4.7 (Topic Images)

Bonjour.
Où voudrais-tu la mettre sur le viewtopic exactement ?

Hors ligne

#6 26-12-2011 17:49:31

Muz1k4l
Membre

Re : Demande d'adaptation à fluxbb 1.4.7 (Topic Images)

Wan a écrit :

Bonjour.
Où voudrais-tu la mettre sur le viewtopic exactement ?

Bonjour , j'aimerais la mettre juste en dessous de la pagination en haut de chaque topic (entre la pagination et le pseudonyme du poster).
Merci.

Hors ligne

#7 01-01-2012 02:29:03

Muz1k4l
Membre

Re : Demande d'adaptation à fluxbb 1.4.7 (Topic Images)

Wan a écrit :

Bonjour.
Où voudrais-tu la mettre sur le viewtopic exactement ?

Désolé de remonter le topic pour un simple up.

Serait-tu où pas comment faire pour le mettre dans viewtopic ?

Merci d'avance

Hors ligne

#8 01-01-2012 16:17:17

Wan
Membre

Re : Demande d'adaptation à fluxbb 1.4.7 (Topic Images)

Muz1k4l a écrit :
Wan a écrit :

Bonjour.
Où voudrais-tu la mettre sur le viewtopic exactement ?

Désolé de remonter le topic pour un simple up.

Serait-tu où pas comment faire pour le mettre dans viewtopic ?

Merci d'avance

Je ne sais pas si je "serais" mais peut-être "saurais-je"...
Je me pencherai sur le cas en temps et en heure... wink
(N.B. : ne pas oublier que tout ça c'est du temps complètement bénévole... smile)

Hors ligne

Pied de page des forums